无效的JPEG数据(对诗人的tensorflow重新训练inceptionv3)!

时间:2017-06-20 16:46:37

标签: python tensorflow

当我想重新训练初始模块时,我收到以下错误(我使用https://codelabs.developers.google.com/codelabs/tensorflow-for-poets/#0中的方法)

root@00aa0e1cd75b:/tf_files# python retrain.py \
--bottleneck_dir=bottlenecks 
--how_many_training_steps=500 
--model_dir=inception 
--summaries_dir=training_summaries/basic 
--output_graph=retrained_graph.pb 
--output_labels=retrained_labels.txt 
--image_dir=MRII
2017-06-20 15:04:15.616625: W 
tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library 
wasn't compiled to use SSE4.1 instructions, but these are available on your 
machine and could speed up CPU computations.
Looking for images in 'Bold'
Looking for images in 'ASL'
Creating bottleneck at bottlenecks/Bold/1011_221_MR.MR.CCIR-00600_CCIR-
00675_Benzinger_AV45.13.49.20150915.142526.1kyq4ky.dcm.jpeg.txt
2017-06-20 15:04:22.501680: W tensorflow/core/framework/op_def_util.cc:332] 
Op BatchNormWithGlobalNormalization is deprecated. It will cease to work in 
GraphDef version 9. Use tf.nn.batch_normalization().
Not a JPEG file: starts with 0x50 0x35
Traceback (most recent call last):
File "retrain.py", line 1062, in 
tf.app.run(main=main, argv=[sys.argv[0]] + unparsed)
File "/usr/local/lib/python2.7/dist-
packages/tensorflow/python/platform/app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "retrain.py", line 808, in main
jpeg_data_tensor, bottleneck_tensor)
File "retrain.py", line 440, in cache_bottlenecks
jpeg_data_tensor, bottleneck_tensor)
File "retrain.py", line 392, in get_or_create_bottleneck
create_bottleneck_file(bottleneck_path, image_lists, label_name, index, 
image_dir, category, sess, jpeg_data_tensor, bottleneck_tensor)
File "retrain.py", line 356, in create_bottleneck_file
bottleneck_values = run_bottleneck_on_image(sess, image_data, 
jpeg_data_tensor, bottleneck_tensor)
File "retrain.py", line 275, in run_bottleneck_on_image
{image_data_tensor: image_data})
File "/usr/local/lib/python2.7/dist-
packages/tensorflow/python/client/session.py", line 778, in run
run_metadata_ptr)
File "/usr/local/lib/python2.7/dist-
packages/tensorflow/python/client/session.py", line 982, in _run
feed_dict_string, options, run_metadata)
File "/usr/local/lib/python2.7/dist-
packages/tensorflow/python/client/session.py", line 1032, in _do_run
target_list, options, run_metadata)
File "/usr/local/lib/python2.7/dist-
packages/tensorflow/python/client/session.py", line 1052, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Invalid JPEG 
data, size 147471
[[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"]]
Caused by op u'DecodeJpeg', defined at:
File "retrain.py", line 1062, in 
tf.app.run(main=main, argv=[sys.argv[0]] + unparsed)
File "/usr/local/lib/python2.7/dist-
packages/tensorflow/python/platform/app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "retrain.py", line 779, in main
create_inception_graph())
File "retrain.py", line 256, in create_inception_graph
RESIZED_INPUT_TENSOR_NAME]))
File "/usr/local/lib/python2.7/dist-
packages/tensorflow/python/framework/importer.py", line 308, in 
import_graph_def
op_def=op_def)
File "/usr/local/lib/python2.7/dist-
packages/tensorflow/python/framework/ops.py", line 2336, in create_op
original_op=self._default_original_op, op_def=op_def)
File "/usr/local/lib/python2.7/dist-
packages/tensorflow/python/framework/ops.py", line 1228, in init
self._traceback = _extract_stack()

InvalidArgumentError (see above for traceback): Invalid JPEG data, size 
147471
[[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"]]

请告诉我如何处理此错误。谢谢!

1 个答案:

答案 0 :(得分:1)

您正在使用的图像似乎不是jpeg图像。

错误说Not a JPEG file: starts with 0x50 0x35.检查here后,我发现这可能是.PGM文件。

您可以使用以下命令验证文件格式。

file /path_to_file/file_name.jpeg
vi -b /path_to_file/file_name.jpeg

确保首先尝试使用一个或两个图像运行它。

相关问题