自己使用load_weights函数加载预测时正常,但利用用flask使用model.load_weights函数加载keras模型进行预测时,出现的ValueError: Tensor Tensor(“loss/mul:0”, shape=(), dtype=float32) is not an element of this graph.的错误。
采用gevent启动服务:
from gevent.pywsgi import WSGIServer
## flask server
# app.debug=True
# app.run(host='0.0.0.0')
## Serve the app with gevent
http_server = WSGIServer(('',5000),app)
http_server.serve_forever()
即可解决!
本文介绍了解决在使用Flask部署Keras模型时遇到的ValueError问题的方法,该问题出现在尝试加载模型权重时。通过使用gevent启动服务可以有效避免此错误。
6652





