使用zappa的AWS Lambda部署问题

时间:2019-09-07 05:26:33

标签: python-3.x amazon-web-services flask aws-lambda zappa

我在我的python代码中使用了tensorflow和ImageAI,但是当尝试将其上传到Lambda时收到以下警告:

Error: Warning! Status check on the deployed lambda failed. A GET request to '/' yielded a 502 response code.

当我从代码中删除此行时,它成功并且可以正常工作: 从imageai.Prediction.Custom导入CustomImagePrediction

我已经创建了虚拟环境,并使用zappa在lambda上上传了软件包,但没有成功

from flask import Flask, jsonify

app = Flask(__name__)

@app.route('/')
def hello_world():

    from imageai.Prediction.Custom import CustomImagePrediction
    import os
    filename = 'Image path'
    prediction = CustomImagePrediction()
    prediction.setModelTypeAsResNet()
    prediction.setModelPath("Model path")
    prediction.setJsonPath("Model json path")
    prediction.loadModel(num_objects=7)
    predictions, probabilities = prediction.predictImage(filename, result_count=3)
    data = {}
    for eachPrediction, eachProbability in zip(predictions, probabilities):
        data[eachPrediction] = eachProbability
    return jsonify({"status":"200","message": "Ok"})
if __name__ == '__main__':
    app.run(threaded=False)
  

预期结果:您更新的Zappa部署已上线!:   https://i8ppr4snid.execute-api.us-east-1.amazonaws.com/

Actual Result: Error: Warning! Status check on the deployed lambda failed. A GET request to '/' yielded a 502 response code.

0 个答案:

没有答案