tensorflow-ValueError: Input 0 is in compatible with layer functional_1: expected shape=(None, 112, 112, 3), found shape=(None, 224, 224, 3)
发布时间:2022-06-01 09:53:25 288
相关标签:
我正在尝试将经过训练的模型放入 Flask 应用程序中。问题是,应用程序的两个输入图像都以与训练模型相同的方式进行预处理。我仍然收到此错误:
ValueError: Input 0 is in compatible with layer functional_1: expected shape=(None, 112, 112, 3), found shape=(None, 224, 224, 3)
模型训练:''' train_data.element_spec >>(TensorSpec(shape=(None, 224, 224, 3), dtype=tf.float32, name=None), TensorSpec(shape=(None, 400), dtype=tf .bool, name=None)) '''
烧瓶应用程序:''' IMG_SIZE=224 BATCH_SIZE=32
def preprocess_image(image_path, img_size = 224):
image=tf.io.read_file(image_path)
image=tf.image.decode_jpeg(image,channels=3)
image=tf.image.convert_image_dtype(image,tf.float32)
image = tf.image.resize(image,size=[IMG_SIZE,IMG_SIZE])
return image
def create_data_batches(x,batch_size=32):
print('Creating test data branches....')
x=[x]
data=tf.data.Dataset.from_tensor_slices((tf.constant(x)))
data_batch=data.map(preprocess_image).batch(BATCH_SIZE)
return data_batch
'''
那么这个预期的 shape=(None, 112, 112, 3) 是从哪里来的呢?代码中没有一个“112”,那我做错了什么?
我将非常感谢任何帮助。PS 我正在尝试使用的模型是 inception_v2。PPS 保存的训练模型格式 id .h5
特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报