AWS Lambda函数不正确退出执行



我有Lambda函数试图从TensorflowJS运行PoseNet。程序正确执行,直到到达

const net = await posenet.load({
architecture: 'MobileNetV1',
inputResolution: { width: 183, height: 275 },
scale: 0.8,
})

在这一行之后,我有一个函数detect(net, image),它在内部获取输入图像并执行const pose = await net.estimateSinglePose(image),它应该只返回一个包含模型结果的JSON对象。但是,程序跳过了这个detect()函数,并成功地完成了Lambda的执行。为什么会这样?

detect是异步的,因此您必须使用await detect(....)

或者使用

detect(img).then(predictions => {
console.log('Predictions: ', predictions);
});

最新更新