目前,我正在为Inception v3提供以下测试:
image_data = tf.gfile.FastGFile(image_path, 'rb').read()
softmax_tensor = sess.graph.get_tensor_by_name('final_result:0')
predictions = sess.run(softmax_tensor, \
{'DecodeJpeg/contents:0': image_data})
但是,相反,我需要先裁剪图像,然后再将其提供给CNN,因此我使用的是读取和裁剪矩阵。但是,如果我这样做,则无法将其用作image_data,因为它期望使用jpeg二进制文件。
通过使用PIL代替OpenCV解决。可以直接输入它,并且绘图功能似乎比我在OpenCV中使用的要好。
img = Image.open(tstImg)
image = img.resize((1936, 1296), Image.ANTIALIAS)
crop_img = image.crop((x, y, x+x_adds, y+y_adds))
predictions = sess.run(softmax_tensor, {'DecodeJpeg:0': crop_img})
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句