Keras - Python Deep Learning Neural Network API 课程实现及遇到的坑填满

课程:https://www.youtube.com/watch?v=eCz_DTtUBfo&list=PLZbbT5o_s2xrwRnXk_yCPtnqqo4_u2YGL&index=27

使用flask搭建前后端平台主要问题:

1.跨域访问异常:

添加:

from flask_cors import CORS

app = Flask(__name__)
CORS(app, supports_credentials=True)

2.存储的模型VGG15.h5提示you are trying to load a weight file containing 1 layers into a model with 0 layers

解决:把keras版本回到2.0.8。https://github.com/keras-team/keras/issues/10417

3.Tensor("dense_2/Softmax:0", shape=(?, 2), dtype=float32) is not an element o

解决:https://blog.csdn.net/gqixf/article/details/85071949

添加:global graph

graph = tf.get_default_graph()

with graph.as_default():

前两句放在global model后面。最后的放在模型调用前

4.windows下加载flask文件使用set

set FLASK_APP=hello_app.py
flask run --host=0.0.0.0
http://localhost:5000/static/hello.html

 

Keras - Python Deep Learning Neural Network API 课程实现及遇到的坑填满