之前直接写,可能会出现 is not an element of this graph的问题,解决方法如下:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19import tensorflow as tf
...
g = tf.Graph()
with g.as_default():
print("Loading model")
model = load_model(os.path.join(MODEL_DIR, 'classifier_model.hdf5'))
...
def index():
...
with g.as_default():
round_predict = model.predict_classes(scaled_predict_data,verbose=0)
...
参考: