如何使用图像作为TFLite模型的输入?

时间:2019-03-28 17:10:54

标签: java android tensorflow keras deep-learning

我在Keras中训练了一个模型,然后将其保存并转换为TFLite文件。为了测试我的Keras模型,我使用以下代码将图像转换为numpy数组:

img_path = r'path'
img = image.load_img(img_path, color_mode="grayscale", target_size=(img_height, img_width))
img = image.img_to_array(img)
img = numpy.expand_dims(img, axis=0)
img = img.reshape(1, img_width, img_height, 1)

将其放入形状为(1、224、224、1)的4d数组中。我的问题是如何为Android上的TFLite模型以相同的方式准备数据? TFLite文件是否要求数据格式相同?

0 个答案:

没有答案
相关问题