Skip to main content
 首页 » 编程设计

python之Tensorflow inception v3 图像重新训练无法在新的 .jpg 图像上进行测试

2024年10月17日33TianFang

我已经在 ubuntu 16.04 中成功地为我自己的图像分类重新训练了 tensorflows image_retrain inception v3 模型。性能结果很好,所以我尝试使用 label_image.py 脚本来预测新图像 (.jpg)。但是我在

处遇到错误

predictions = sess.run(softmax_tensor, {'DecodeJpeg/contents:0': image_data})

错误日志

InvalidArgumentError (see above for traceback): NodeDef mentions attr 'dct_method' not in Op image:uint8; attr=channels:int,default=0; attr=ratio:int,default=1; attr=fancy_upscaling:bool,default=true; attr=try_recover_truncated:bool,default=false; attr=acceptable_fraction:float,default=1>; NodeDef: DecodeJpeg = DecodeJpegacceptable_fraction=1, channels=3, dct_method="", fancy_upscaling=true, ratio=1, try_recover_truncated=false, _device="/job:localhost/replica:0/task:0/cpu:0" [[Node: DecodeJpeg = DecodeJpegacceptable_fraction=1, channels=3, dct_method="", fancy_upscaling=true, ratio=1, try_recover_truncated=false, _device="/job:localhost/replica:0/task:0/cpu:0"]]

请帮我解决

谢谢

请您参考如下方法:

我自己也遇到了这个问题。

据我所知,您用于生成输出图的 tensorflow 版本与您现在用于运行 label_image.py 脚本的版本不匹配。

我花了很多时间试图追踪变化并弄清楚如何在与我之前用于生成图形的版本相同的版本中运行 tensorflow。

最后,我找到了解决我问题的 hacky 解决方案:

从您的文件加载图表后

graph_def.ParseFromString(f.read()) 

添加

del(graph_def.node[1].attr["dct_method"]) 

这不是一个好方法,如果可能,您应该尝试重新训练图形并确保 tensorflow 版本相同。