python - tf.image.decode_png raise InvalidArgumentError -


my images this:

train:

-- 1.png

-- 2.png

-- 3.png

...

-- m.png

i created file_list contains paths these images.

my code:

  filename_queue = tf.train.string_input_producer(file_list)    reader = tf.wholefilereader()   key, value = reader.read(filename_queue)   image_png_grey = tf.image.decode_png(value, channels=1)   image_std = tf.image.per_image_standardization(image_png_grey)   img_resize = tf.image.resize_images(image_std,[28,28],method=tf.image.resizemethod.area)    init_op = tf.global_variables_initializer()   tf.session() sess:     sess.run(init_op)    # start populating filename queue.     coord = tf.train.coordinator()     threads = tf.train.start_queue_runners(coord=coord)      in range(len(file_list)):       image, i_key = sess.run([img_resize, key]) 

and console:

2017-09-14 11:34:37.434681: w tensorflow/core/platform/cpu_feature_guard.cc:45] tensorflow library wasn't compiled use sse4.2 instructions, these available on machine andcould speed cpu computations. 2017-09-14 11:34:37.434701: w tensorflow/core/platform/cpu_feature_guard.cc:45] tensorflow library wasn't compiled use avx instructions, these available on machine , speed cpu computations. 2017-09-14 11:34:37.434706: w tensorflow/core/platform/cpu_feature_guard.cc:45] tensorflow library wasn't compiled use avx2 instructions, these available on machine , speed cpu computations. 2017-09-14 11:34:37.434709: w tensorflow/core/platform/cpu_feature_guard.cc:45] tensorflow library wasn't compiled use fma instructions, these available on machine , speed cpu computations. 2017-09-14 11:40:43.080336: w tensorflow/core/kernels/queue_base.cc:295] _0_input_producer: skipping cancelled enqueue attempt queue not closed traceback (most recent call last):   file "/users/andrew/anaconda3/envs/tf3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1327, in _do_call     return fn(*args)   file "/users/andrew/anaconda3/envs/tf3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1306, in _run_fn     status, run_metadata)   file "/users/andrew/anaconda3/envs/tf3/lib/python3.6/contextlib.py", line 88, in __exit__     next(self.gen)   file "/users/andrew/anaconda3/envs/tf3/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py", line 466, in raise_exception_on_not_ok_status     pywrap_tensorflow.tf_getcode(status)) tensorflow.python.framework.errors_impl.invalidargumenterror: invalid png header, data size 33          [[node: decodepng = decodepng[channels=1, dtype=dt_uint8, _device="/job:localhost/replica:0/task:0/cpu:0"](readerreadv2:1)]]   during handling of above exception, exception occurred:   traceback (most recent call last):   file "convert_2_records.py", line 87, in <module>     main(sys.argv[1:])   file "convert_2_records.py", line 68, in main     image, i_key = sess.run([img_resize, key])   file "/users/andrew/anaconda3/envs/tf3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 895, in run     run_metadata_ptr)   file "/users/andrew/anaconda3/envs/tf3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1124, in _run     feed_dict_tensor, options, run_metadata)   file "/users/andrew/anaconda3/envs/tf3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1321, in _do_run     options, run_metadata)   file "/users/andrew/anaconda3/envs/tf3/lib/python3.6/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 png header, data size 33          [[node: decodepng = decodepng[channels=1, dtype=dt_uint8, _device="/job:localhost/replica:0/task:0/cpu:0"](readerreadv2:1)]]   caused op 'decodepng', defined at:   file "convert_2_records.py", line 87, in <module>     main(sys.argv[1:])   file "convert_2_records.py", line 55, in main     image_png_grey = tf.image.decode_png(value, channels=1)   file "/users/andrew/anaconda3/envs/tf3/lib/python3.6/site-packages/tensorflow/python/ops/gen_image_ops.py", line 393, in decode_png     channels=channels, dtype=dtype, name=name)   file "/users/andrew/anaconda3/envs/tf3/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 767, in apply_op     op_def=op_def)   file "/users/andrew/anaconda3/envs/tf3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2630, in create_op     original_op=self._default_original_op, op_def=op_def)   file "/users/andrew/anaconda3/envs/tf3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1204, in __init__     self._traceback = self._graph._extract_stack()  # pylint: disable=protected-access   invalidargumenterror (see above traceback): invalid png header, data size 33          [[node: decodepng = decodepng[channels=1, dtype=dt_uint8, _device="/job:localhost/replica:0/task:0/cpu:0"](readerreadv2:1)]] 

all images generated same process of keras imagedatagenerator. after few iteration, on 80% of data, error occurs. don't know what's wrong code. generator or code of tf_records.


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -