Tensorflow Invalid JPEG data or crop window, data size 之一

在使用Tensorflow学习图片的时候会遇到:
《OpenCV将JPEG中的progressive类型转换成baseline类型》

Traceback (most recent call last):
  File "/home/king/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1327, in _do_call
    return fn(*args)
  File "/home/king/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1312, in _run_fn
    options, feed_dict, fetch_list, target_list, run_metadata)
  File "/home/king/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1420, in _call_tf_sessionrun
    status, run_metadata)
  File "/home/king/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/framework/errors_impl.py", line 516, in __exit__
    c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: Invalid JPEG data or crop window, data size 32768
	 [[Node: DecodeJpeg_1 = DecodeJpeg[acceptable_fraction=1, channels=3, dct_method="", fancy_upscaling=true, ratio=1, try_recover_truncated=false, _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_DecodeJPGInput_0_0)]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "retrain.py", line 382, in create_bottleneck_file
    resized_input_tensor, bottleneck_tensor)
  File "retrain.py", line 314, in run_bottleneck_on_image
    {image_data_tensor: image_data})
  File "/home/king/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 905, in run
    run_metadata_ptr)
  File "/home/king/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1140, in _run
    feed_dict_tensor, options, run_metadata)
  File "/home/king/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1321, in _do_run
    run_metadata)
  File "/home/king/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1340, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Invalid JPEG data or crop window, data size 32768
	 [[Node: DecodeJpeg_1 = DecodeJpeg[acceptable_fraction=1, channels=3, dct_method="", fancy_upscaling=true, ratio=1, try_recover_truncated=false, _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_DecodeJPGInput_0_0)]]

Caused by op 'DecodeJpeg_1', defined at:
  File "retrain.py", line 1366, in 
    tf.app.run(main=main, argv=[sys.argv[0]] + unparsed)
  File "/home/king/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/platform/app.py", line 126, in run
    _sys.exit(main(argv))
  File "retrain.py", line 1049, in main
    model_info['input_std'])
  File "retrain.py", line 995, in add_jpeg_decoding
    decoded_image = tf.image.decode_jpeg(jpeg_data, channels=input_depth)
  File "/home/king/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/ops/gen_image_ops.py", line 944, in decode_jpeg
    name=name)
  File "/home/king/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
    op_def=op_def)
  File "/home/king/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 3290, in create_op
    op_def=op_def)
  File "/home/king/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 1654, in __init__
    self._traceback = self._graph._extract_stack()  # pylint: disable=protected-access

InvalidArgumentError (see above for traceback): Invalid JPEG data or crop window, data size 32768
	 [[Node: DecodeJpeg_1 = DecodeJpeg[acceptable_fraction=1, channels=3, dct_method="", fancy_upscaling=true, ratio=1, try_recover_truncated=false, _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_DecodeJPGInput_0_0)]]


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "retrain.py", line 1366, in 
    tf.app.run(main=main, argv=[sys.argv[0]] + unparsed)
  File "/home/king/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/platform/app.py", line 126, in run
    _sys.exit(main(argv))
  File "retrain.py", line 1180, in main
    f.write('\n'.join(image_lists.keys()) + '\n')
  File "/home/king/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1545, in __exit__
    self._default_graph_context_manager.__exit__(exec_type, exec_value, exec_tb)
  File "/home/king/anaconda3/envs/tensorflow/lib/python3.5/contextlib.py", line 77, in __exit__
    self.gen.throw(type, value, traceback)
  File "/home/king/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 5086, in get_controller
    yield g
  File "/home/king/anaconda3/envs/tensorflow/lib/python3.5/contextlib.py", line 77, in __exit__
    self.gen.throw(type, value, traceback)
  File "/home/king/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 4896, in get_controller
    yield default
  File "/home/king/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 5086, in get_controller
    yield g
  File "retrain.py", line 1065, in main
    bottleneck_tensor, FLAGS.architecture)
  File "retrain.py", line 488, in cache_bottlenecks
    resized_input_tensor, bottleneck_tensor, architecture)
  File "retrain.py", line 430, in get_or_create_bottleneck
    bottleneck_tensor)
  File "retrain.py", line 385, in create_bottleneck_file
    str(e)))
RuntimeError: Error during processing file train/hentai/a2407693-2cb4-4254-8b0d-28daa00be68c.jpg (Invalid JPEG data or crop window, data size 32768
	 [[Node: DecodeJpeg_1 = DecodeJpeg[acceptable_fraction=1, channels=3, dct_method="", fancy_upscaling=true, ratio=1, try_recover_truncated=false, _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_DecodeJPGInput_0_0)]]

Caused by op 'DecodeJpeg_1', defined at:
  File "retrain.py", line 1366, in 
    tf.app.run(main=main, argv=[sys.argv[0]] + unparsed)
  File "/home/king/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/platform/app.py", line 126, in run
    _sys.exit(main(argv))
  File "retrain.py", line 1049, in main
    model_info['input_std'])
  File "retrain.py", line 995, in add_jpeg_decoding
    decoded_image = tf.image.decode_jpeg(jpeg_data, channels=input_depth)
  File "/home/king/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/ops/gen_image_ops.py", line 944, in decode_jpeg
    name=name)
  File "/home/king/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
    op_def=op_def)
  File "/home/king/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 3290, in create_op
    op_def=op_def)
  File "/home/king/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 1654, in __init__
    self._traceback = self._graph._extract_stack()  # pylint: disable=protected-access

InvalidArgumentError (see above for traceback): Invalid JPEG data or crop window, data size 32768
	 [[Node: DecodeJpeg_1 = DecodeJpeg[acceptable_fraction=1, channels=3, dct_method="", fancy_upscaling=true, ratio=1, try_recover_truncated=false, _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_DecodeJPGInput_0_0)]]

这个是什么原因呢?

 file OCR-eng.jpg  QR4.jpeg 
OCR-eng.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, progressive , precision 8, 2639x1169, frames 3
QR4.jpeg:  JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, baseline , precision 8, 640x480, frames 3

Tensorflow 不认识progressive的图片,需要转化成baseline格式的图片。转换方式就是抬头写的那篇文章。

你可能感兴趣的:(Tensorflow)