首页 > 解决方案 > 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 的执行。为什么是这样?

标签: tensorflowaws-lambda

解决方案


检测是异步的,所以你必须await detect(....)

或然后使用

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

推荐阅读