自己使用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()
即可解决!