我已经使用Tensorflow和Keras通过IAM数据集创建了一个机器学习模型。如何将此模型作为API加载以预测图像?当我试图整合时,它显示出错误
return self.function(inputs, **arguments)
File "test2.py", line 136, in resize_image
return tf.image.resize_images(image,[56,56])
NameError: name 'tf' is not defined
我使用从keras.型号导入load\u model并尝试预测图像笔迹。low_loss.hdf5
是我试图集成的模型。你知道吗
def testmodel(image_path):
global model
# load the pre-trained Keras model
model = load_model('low_loss.hdf5')
model.summary()
img = Image.open(image_path).convert("L")
img = np.resize(image_path, (28,28,1))
im2arr = np.array(img)
im2arr = im2arr.reshape(1,28,28,1)
y_pred = model.predict_classes(im2arr)
return y_pred
我希望预测图像手写数据。你知道吗
出现错误的原因是您没有在代码中导入TensorFlow,或者如果导入了TensorFlow,则没有提供别名。你知道吗
你的错误是关于tf的,它没有加载。你知道吗
尝试:
相关问题 更多 >
编程相关推荐