Hvass-Labs / TensorFlow-Tutorials

TensorFlow Tutorials with YouTube Videos
MIT License
9.27k stars 4.19k forks source link

09_Video_Data Tutorials failed to calculate transfer-values #31

Closed alwynmathew closed 7 years ago

alwynmathew commented 7 years ago

09_Video_Data Tutorials failed to calculate transfer-values

Tutorials failed to calculate transfer-values when I used more number of dataset. It was perfectly working when my dataset size was 3000+ images but after increasing my dataset size to 6000+ transfer_values_cache() throws an error at exactly when calculating transfer value for 5317th image in dataset.

Running on

Ubuntu 14.04 LTS Jupyter 4.3.1 Python 2.7.13 |Anaconda custom (64-bit) [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] Kernal Python 3.6 Tensorflow 1.0.1 Prettytensor 0.7.4

Error Message

Processing Inception transfer-values for training-images ...
- Processing image:   5317 / 6325

---------------------------------------------------------------------------
InvalidArgumentError                      Traceback (most recent call last)
/home/alwynpcs16/anaconda2/envs/py3k/lib/python3.6/site-packages/tensorflow/python/client/session.py in _do_call(self, fn, *args)
   1021     try:
-> 1022       return fn(*args)
   1023     except errors.OpError as e:

/home/alwynpcs16/anaconda2/envs/py3k/lib/python3.6/site-packages/tensorflow/python/client/session.py in _run_fn(session, feed_dict, fetch_list, target_list, options, run_metadata)
   1003                                  feed_dict, fetch_list, target_list,
-> 1004                                  status, run_metadata)
   1005 

/home/alwynpcs16/anaconda2/envs/py3k/lib/python3.6/contextlib.py in __exit__(self, type, value, traceback)
     88             try:
---> 89                 next(self.gen)
     90             except StopIteration:

/home/alwynpcs16/anaconda2/envs/py3k/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py in raise_exception_on_not_ok_status()
    465           compat.as_text(pywrap_tensorflow.TF_Message(status)),
--> 466           pywrap_tensorflow.TF_GetCode(status))
    467   finally:

InvalidArgumentError: Invalid JPEG data, size 1310720
     [[Node: DecodeJpeg = DecodeJpeg[acceptable_fraction=1, channels=3, dct_method="", fancy_upscaling=true, ratio=1, try_recover_truncated=false, _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_DecodeJpeg/contents_0)]]

During handling of the above exception, another exception occurred:

InvalidArgumentError                      Traceback (most recent call last)
<ipython-input-165-472ae91bad08> in <module>()
      5 transfer_values_train = transfer_values_cache(cache_path=file_path_cache_train,
      6                                               image_paths=image_paths_train,
----> 7                                               model=model)

/home/alwynpcs16/tutorial/inception.py in transfer_values_cache(cache_path, model, images, image_paths)
    592 
    593     # Read the transfer-values from a cache-file, or calculate them if the file does not exist.
--> 594     transfer_values = cache(cache_path=cache_path, fn=fn)
    595 
    596     return transfer_values

/home/alwynpcs16/tutorial/cache.py in cache(cache_path, fn, *args, **kwargs)
     63 
     64         # Call the function / class-init with the supplied arguments.
---> 65         obj = fn(*args, **kwargs)
     66 
     67         # Save the data to a cache-file.

/home/alwynpcs16/tutorial/inception.py in fn()
    589     # and fn=model.transfer_values to the cache()-function.
    590     def fn():
--> 591         return process_images(fn=model.transfer_values, images=images, image_paths=image_paths)
    592 
    593     # Read the transfer-values from a cache-file, or calculate them if the file does not exist.

/home/alwynpcs16/tutorial/inception.py in process_images(fn, images, image_paths)
    543             result[i] = fn(image=images[i])
    544         else:
--> 545             result[i] = fn(image_path=image_paths[i])
    546 
    547     # Print newline.

/home/alwynpcs16/tutorial/inception.py in transfer_values(self, image_path, image)
    487         # This calculates the values for the last layer of the Inception model
    488         # prior to the softmax-classification, which we call transfer-values.
--> 489         transfer_values = self.session.run(self.transfer_layer, feed_dict=feed_dict)
    490 
    491         # Reduce to a 1-dim array.

/home/alwynpcs16/anaconda2/envs/py3k/lib/python3.6/site-packages/tensorflow/python/client/session.py in run(self, fetches, feed_dict, options, run_metadata)
    765     try:
    766       result = self._run(None, fetches, feed_dict, options_ptr,
--> 767                          run_metadata_ptr)
    768       if run_metadata:
    769         proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)

/home/alwynpcs16/anaconda2/envs/py3k/lib/python3.6/site-packages/tensorflow/python/client/session.py in _run(self, handle, fetches, feed_dict, options, run_metadata)
    963     if final_fetches or final_targets:
    964       results = self._do_run(handle, final_targets, final_fetches,
--> 965                              feed_dict_string, options, run_metadata)
    966     else:
    967       results = []

/home/alwynpcs16/anaconda2/envs/py3k/lib/python3.6/site-packages/tensorflow/python/client/session.py in _do_run(self, handle, target_list, fetch_list, feed_dict, options, run_metadata)
   1013     if handle is None:
   1014       return self._do_call(_run_fn, self._session, feed_dict, fetch_list,
-> 1015                            target_list, options, run_metadata)
   1016     else:
   1017       return self._do_call(_prun_fn, self._session, handle, feed_dict,

/home/alwynpcs16/anaconda2/envs/py3k/lib/python3.6/site-packages/tensorflow/python/client/session.py in _do_call(self, fn, *args)
   1033         except KeyError:
   1034           pass
-> 1035       raise type(e)(node_def, op, message)
   1036 
   1037   def _extend_graph(self):

InvalidArgumentError: Invalid JPEG data, size 1310720
     [[Node: DecodeJpeg = DecodeJpeg[acceptable_fraction=1, channels=3, dct_method="", fancy_upscaling=true, ratio=1, try_recover_truncated=false, _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_DecodeJpeg/contents_0)]]

Caused by op 'DecodeJpeg', defined at:
  File "/home/alwynpcs16/anaconda2/envs/py3k/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/alwynpcs16/anaconda2/envs/py3k/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/alwynpcs16/anaconda2/envs/py3k/lib/python3.6/site-packages/ipykernel/__main__.py", line 3, in <module>
    app.launch_new_instance()
  File "/home/alwynpcs16/anaconda2/envs/py3k/lib/python3.6/site-packages/traitlets/config/application.py", line 658, in launch_instance
    app.start()
  File "/home/alwynpcs16/anaconda2/envs/py3k/lib/python3.6/site-packages/ipykernel/kernelapp.py", line 474, in start
    ioloop.IOLoop.instance().start()
  File "/home/alwynpcs16/anaconda2/envs/py3k/lib/python3.6/site-packages/zmq/eventloop/ioloop.py", line 177, in start
    super(ZMQIOLoop, self).start()
  File "/home/alwynpcs16/anaconda2/envs/py3k/lib/python3.6/site-packages/tornado/ioloop.py", line 887, in start
    handler_func(fd_obj, events)
  File "/home/alwynpcs16/anaconda2/envs/py3k/lib/python3.6/site-packages/tornado/stack_context.py", line 275, in null_wrapper
    return fn(*args, **kwargs)
  File "/home/alwynpcs16/anaconda2/envs/py3k/lib/python3.6/site-packages/zmq/eventloop/zmqstream.py", line 440, in _handle_events
    self._handle_recv()
  File "/home/alwynpcs16/anaconda2/envs/py3k/lib/python3.6/site-packages/zmq/eventloop/zmqstream.py", line 472, in _handle_recv
    self._run_callback(callback, msg)
  File "/home/alwynpcs16/anaconda2/envs/py3k/lib/python3.6/site-packages/zmq/eventloop/zmqstream.py", line 414, in _run_callback
    callback(*args, **kwargs)
  File "/home/alwynpcs16/anaconda2/envs/py3k/lib/python3.6/site-packages/tornado/stack_context.py", line 275, in null_wrapper
    return fn(*args, **kwargs)
  File "/home/alwynpcs16/anaconda2/envs/py3k/lib/python3.6/site-packages/ipykernel/kernelbase.py", line 276, in dispatcher
    return self.dispatch_shell(stream, msg)
  File "/home/alwynpcs16/anaconda2/envs/py3k/lib/python3.6/site-packages/ipykernel/kernelbase.py", line 228, in dispatch_shell
    handler(stream, idents, msg)
  File "/home/alwynpcs16/anaconda2/envs/py3k/lib/python3.6/site-packages/ipykernel/kernelbase.py", line 390, in execute_request
    user_expressions, allow_stdin)
  File "/home/alwynpcs16/anaconda2/envs/py3k/lib/python3.6/site-packages/ipykernel/ipkernel.py", line 196, in do_execute
    res = shell.run_cell(code, store_history=store_history, silent=silent)
  File "/home/alwynpcs16/anaconda2/envs/py3k/lib/python3.6/site-packages/ipykernel/zmqshell.py", line 501, in run_cell
    return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
  File "/home/alwynpcs16/anaconda2/envs/py3k/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2717, in run_cell
    interactivity=interactivity, compiler=compiler, result=result)
  File "/home/alwynpcs16/anaconda2/envs/py3k/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2821, in run_ast_nodes
    if self.run_code(code, result):
  File "/home/alwynpcs16/anaconda2/envs/py3k/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2881, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-162-45804e0be4f2>", line 1, in <module>
    model = inception.Inception()
  File "/home/alwynpcs16/tutorial/inception.py", line 285, in __init__
    tf.import_graph_def(graph_def, name='')
  File "/home/alwynpcs16/anaconda2/envs/py3k/lib/python3.6/site-packages/tensorflow/python/framework/importer.py", line 288, in import_graph_def
    op_def=op_def)
  File "/home/alwynpcs16/anaconda2/envs/py3k/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2327, in create_op
    original_op=self._default_original_op, op_def=op_def)
  File "/home/alwynpcs16/anaconda2/envs/py3k/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1226, in __init__
    self._traceback = _extract_stack()

InvalidArgumentError (see above for traceback): Invalid JPEG data, size 1310720
     [[Node: DecodeJpeg = DecodeJpeg[acceptable_fraction=1, channels=3, dct_method="", fancy_upscaling=true, ratio=1, try_recover_truncated=false, _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_DecodeJpeg/contents_0)]]
Hvass-Labs commented 7 years ago

If I recall correctly, the cache for transfer values is held in memory. If you have large data-sets then you need to save the transfer values to disk, otherwise you will run out of RAM. This could be the problem you are having.