Я работаю с sjango и пытаюсь предсказать изображение, используя Keras с бэкэндом тензорного потока, но у меня есть эта ошибка:
line 3669, in _as_graph_element_locked
raise ValueError("Tensor %s is not an element of this graph." % obj)
ValueError: Tensor Tensor("dense_6/Softmax:0", shape=(?, 50), dtype=float32) is not an element of this graph.
[28/Apr/2019 16:54:53] "POST /facture/upload/ HTTP/1.1" 500 133945
Вот мой код:
#Loading the model
pwd = os.path.dirname(__file__)
with open(pwd+'/ModelML/model_architecture19.json', 'r') as f:
model = model_from_json(f.read())
# Load weights into the new model
model.load_weights(pwd+'/ModelML/model_weights19.h5')
roi = cv2.cvtColor(roi,cv2.COLOR_BGR2GRAY)
ret2, roi = cv2.threshold(roi, 127, 255, cv2.THRESH_BINARY_INV)
roi = cv2.resize(roi, (IMG_SIZE, IMG_SIZE)) # Resize the image
roi = roi.reshape(1,IMG_SIZE, IMG_SIZE,1)
#normalize image
roi = roi /255
graph = tf.get_default_graph()
with graph.as_default():
pred =model.predict(roi)
ошибка в последней строке "модель предсказания"
Заранее спасибо за помощь