models icon indicating copy to clipboard operation
models copied to clipboard

slim_example_decoder.BackupHandler( AttributeError: 'module' object has no attribute 'BackupHandler

Open josh-a-dcosta opened this issue 8 years ago • 9 comments

System information

  • What is the top-level directory of the model you are using: /tensorflow/models/research/object_detection/
  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): No
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): MacOS
  • TensorFlow installed from (source or binary): binary
  • TensorFlow version (use command below): 'v1.5.0-0-g37aa430d84', '1.5.0'
  • Bazel version (if compiling from source):
  • CUDA/cuDNN version:
  • GPU model and memory: No GPU
  • Exact command to reproduce: gcloud ml-engine jobs submit training object_detection_date +%s
    --runtime-version 1.2
    --job-dir=gs://agitensorflow1/models/model/train
    --packages /Users/agi/downloads/tensorflow/models/research/dist/object_detection-0.1.tar.gz,/Users/agi/downloads/tensorflow/models/research/slim/dist/slim-0.1.tar.gz
    --module-name object_detection.train
    --region us-central1
    --config /Users/agi/downloads/tensorflow/poc/config/cloud.yml
    --
    --train_dir=gs://agitensorflow1/models/model/train
    --pipeline_config_path=gs://agitensorflow1/models/model/ssd_mobilenet_v1_poc.config

You can collect some of this information using our environment capture script:

== cat /etc/issue =============================================== Darwin MacBookAir-I.RJJADOMAIN 17.4.0 Darwin Kernel Version 17.4.0: Sun Dec 17 09:19:54 PST 2017; root:xnu-4570.41.2~1/RELEASE_X86_64 x86_64 Mac OS X 10.13.3

== are we in docker ============================================= No

== compiler ===================================================== Apple LLVM version 9.0.0 (clang-900.0.39.2) Target: x86_64-apple-darwin17.4.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

== uname -a ===================================================== Darwin MacBookAir-I.RJJADOMAIN 17.4.0 Darwin Kernel Version 17.4.0: Sun Dec 17 09:19:54 PST 2017; root:xnu-4570.41.2~1/RELEASE_X86_64 x86_64

== check pips =================================================== numpy (1.14.1) protobuf (3.5.1) tensorflow (1.5.0) tensorflow-tensorboard (1.5.1)

== check for virtualenv ========================================= True

== tensorflow import ============================================

Describe the problem

When I run the training model in the cloud i receive the following error.

Source code / logs

The replica master 0 exited with a non-zero status of 1. Termination reason: Error. Traceback (most recent call last): File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main "main", fname, loader, pkg_name) File "/usr/lib/python2.7/runpy.py", line 72, in _run_code exec code in run_globals File "/root/.local/lib/python2.7/site-packages/object_detection/train.py", line 169, in tf.app.run() 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 "/root/.local/lib/python2.7/site-packages/object_detection/train.py", line 165, in main worker_job_name, is_chief, FLAGS.train_dir) File "/root/.local/lib/python2.7/site-packages/object_detection/trainer.py", line 235, in train train_config.prefetch_queue_capacity, data_augmentation_options) File "/root/.local/lib/python2.7/site-packages/object_detection/trainer.py", line 59, in create_input_queue tensor_dict = create_tensor_dict_fn() File "/root/.local/lib/python2.7/site-packages/object_detection/train.py", line 122, in get_next worker_index=FLAGS.task)).get_next() File "/root/.local/lib/python2.7/site-packages/object_detection/builders/dataset_builder.py", line 140, in build label_map_proto_file=label_map_proto_file) File "/root/.local/lib/python2.7/site-packages/object_detection/data_decoders/tf_example_decoder.py", line 153, in init label_handler = slim_example_decoder.BackupHandler( AttributeError: 'module' object has no attribute 'BackupHandler' The replica worker 0 exited with a non-zero status of 1. Termination reason: Error. Traceback (most recent call last): File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main "main", fname, loader, pkg_name) File "/usr/lib/python2.7/runpy.py", line 72, in _run_code exec code in run_globals File "/root/.local/lib/python2.7/site-packages/object_detection/train.py", line 169, in tf.app.run() 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 "/root/.local/lib/python2.7/site-packages/object_detection/train.py", line 165, in main worker_job_name, is_chief, FLAGS.train_dir) File "/root/.local/lib/python2.7/site-packages/object_detection/trainer.py", line 235, in train train_config.prefetch_queue_capacity, data_augmentation_options) File "/root/.local/lib/python2.7/site-packages/object_detection/trainer.py", line 59, in create_input_queue tensor_dict = create_tensor_dict_fn() File "/root/.local/lib/python2.7/site-packages/object_detection/train.py", line 122, in get_next worker_index=FLAGS.task)).get_next() File "/root/.local/lib/python2.7/site-packages/object_detection/builders/dataset_builder.py", line 140, in build label_map_proto_file=label_map_proto_file) File "/root/.local/lib/python2.7/site-packages/object_detection/data_decoders/tf_example_decoder.py", line 153, in init label_handler = slim_example_decoder.BackupHandler( AttributeError: 'module' object has no attribute 'BackupHandler' The replica worker 1 exited with a non-zero status of 1. Termination reason: Error. Traceback (most recent call last): File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main "main", fname, loader, pkg_name) File "/usr/lib/python2.7/runpy.py", line 72, in _run_code exec code in run_globals File "/root/.local/lib/python2.7/site-packages/object_detection/train.py", line 169, in tf.app.run() 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 "/root/.local/lib/python2.7/site-packages/object_detection/train.py", line 165, in main worker_job_name, is_chief, FLAGS.train_dir) File "/root/.local/lib/python2.7/site-packages/object_detection/trainer.py", line 235, in train train_config.prefetch_queue_capacity, data_augmentation_options) File "/root/.local/lib/python2.7/site-packages/object_detection/trainer.py", line 59, in create_input_queue tensor_dict = create_tensor_dict_fn() File "/root/.local/lib/python2.7/site-packages/object_detection/train.py", line 122, in get_next worker_index=FLAGS.task)).get_next() File "/root/.local/lib/python2.7/site-packages/object_detection/builders/dataset_builder.py", line 140, in build label_map_proto_file=label_map_proto_file) File "/root/.local/lib/python2.7/site-packages/object_detection/data_decoders/tf_example_decoder.py", line 153, in init label_handler = slim_example_decoder.BackupHandler( AttributeError: 'module' object has no attribute 'BackupHandler' The replica worker 2 exited with a non-zero status of 1. Termination reason: Error. Traceback (most recent call last): File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main "main", fname, loader, pkg_name) File "/usr/lib/python2.7/runpy.py", line 72, in _run_code exec code in run_globals File "/root/.local/lib/python2.7/site-packages/object_detection/train.py", line 169, in tf.app.run() 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 "/root/.local/lib/python2.7/site-packages/object_detection/train.py", line 165, in main worker_job_name, is_chief, FLAGS.train_dir) File "/root/.local/lib/python2.7/site-packages/object_detection/trainer.py", line 235, in train train_config.prefetch_queue_capacity, data_augmentation_options) File "/root/.local/lib/python2.7/site-packages/object_detection/trainer.py", line 59, in create_input_queue tensor_dict = create_tensor_dict_fn() File "/root/.local/lib/python2.7/site-packages/object_detection/train.py", line 122, in get_next worker_index=FLAGS.task)).get_next() File "/root/.local/lib/python2.7/site-packages/object_detection/builders/dataset_builder.py", line 140, in build label_map_proto_file=label_map_proto_file) File "/root/.local/lib/python2.7/site-packages/object_detection/data_decoders/tf_example_decoder.py", line 153, in init label_handler = slim_example_decoder.BackupHandler( AttributeError: 'module' object has no attribute 'BackupHandler' The replica worker 3 exited with a non-zero status of 1. Termination reason: Error. Traceback (most recent call last): File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main "main", fname, loader, pkg_name) File "/usr/lib/python2.7/runpy.py", line 72, in _run_code exec code in run_globals File "/root/.local/lib/python2.7/site-packages/object_detection/train.py", line 169, in tf.app.run() 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 "/root/.local/lib/python2.7/site-packages/object_detection/train.py", line 165, in main worker_job_name, is_chief, FLAGS.train_dir) File "/root/.local/lib/python2.7/site-packages/object_detection/trainer.py", line 235, in train train_config.prefetch_queue_capacity, data_augmentation_options) File "/root/.local/lib/python2.7/site-packages/object_detection/trainer.py", line 59, in create_input_queue tensor_dict = create_tensor_dict_fn() File "/root/.local/lib/python2.7/site-packages/object_detection/train.py", line 122, in get_next worker_index=FLAGS.task)).get_next() File "/root/.local/lib/python2.7/site-packages/object_detection/builders/dataset_builder.py", line 140, in build label_map_proto_file=label_map_proto_file) File "/root/.local/lib/python2.7/site-packages/object_detection/data_decoders/tf_example_decoder.py", line 153, in init label_handler = slim_example_decoder.BackupHandler( AttributeError: 'module' object has no attribute 'BackupHandler' The replica worker 4 exited with a non-zero status of 1. Termination reason: Error. Traceback (most recent call last): File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main "main", fname, loader, pkg_name) File "/usr/lib/python2.7/runpy.py", line 72, in _run_code exec code in run_globals File "/root/.local/lib/python2.7/site-packages/object_detection/train.py", line 169, in tf.app.run() 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 "/root/.local/lib/python2.7/site-packages/object_detection/train.py", line 165, in main worker_job_name, is_chief, FLAGS.train_dir) File "/root/.local/lib/python2.7/site-packages/object_detection/trainer.py", line 235, in train train_config.prefetch_queue_capacity, data_augmentation_options) File "/root/.local/lib/python2.7/site-packages/object_detection/trainer.py", line 59, in create_input_queue tensor_dict = create_tensor_dict_fn() File "/root/.local/lib/python2.7/site-packages/object_detection/train.py", line 122, in get_next worker_index=FLAGS.task)).get_next() File "/root/.local/lib/python2.7/site-packages/object_detection/builders/dataset_builder.py", line 140, in build label_map_proto_file=label_map_proto_file) File "/root/.local/lib/python2.7/site-packages/object_detection/data_decoders/tf_example_decoder.py", line 153, in init label_handler = slim_example_decoder.BackupHandler( AttributeError: 'module' object has no attribute 'BackupHandler' To find out more about why your job exited please check the logs: https://console.cloud.google.com/logs/viewer?project=466506725782&resource=ml_job%2Fjob_id%2Fobject_detection_1519330761&advancedFilter=resource.type%3D%22ml_job%22%0Aresource.labels.job_id%3D%22object_detection_1519330761%22

josh-a-dcosta avatar Feb 22 '18 20:02 josh-a-dcosta

@tombstone can you please take a look?

bignamehyp avatar Feb 22 '18 23:02 bignamehyp

@tombstone - Any update on this? appreciate your help. I am trying to create/train a model for identifying "guns", "weapons" for a school project, using object detection.

josh-a-dcosta avatar Feb 23 '18 15:02 josh-a-dcosta

In my experience, pip3 install tensorflow doesn't necessarily install the latest version, so be sure to check your version and upgrade if necessary. You can check it with python3 --> import tensorflow as tf --> print(tf.__version__) but you could also just run pip3 install --upgrade tensorflow and it'll ignore it if not needed.

Also, be sure to set the PYTHONPATH environmental variables at the beginning of every time you try to go to perform these actions. You can check with env to see if it's right.

I was also experiencing this today, but performing these two actions solved this problem for me. There are other problems as well, but at least that's one down. This has been a common issue recently: #2653 and here.

npeirson avatar Feb 23 '18 22:02 npeirson

@npeirson Thanks. I was able to train export the graph locally. However, when I use the jupyter notebook for object_detection_tutorial, I receive the following error,


ValueError Traceback (most recent call last) in () 7 image_np_expanded = np.expand_dims(image_np, axis=0) 8 # Actual detection. ----> 9 output_dict = run_inference_for_single_image(image_np, detection_graph) 10 # Visualization of the results of a detection. 11 vis_util.visualize_boxes_and_labels_on_image_array(

in run_inference_for_single_image(image, graph) 33 # Run inference 34 output_dict = sess.run(tensor_dict, ---> 35 feed_dict={image_tensor: np.expand_dims(image, 0)}) 36 37 # all outputs are float32 numpy arrays, so convert types as appropriate

/Users/agi/Downloads/tensorflow/lib/python2.7/site-packages/tensorflow/python/client/session.pyc in run(self, fetches, feed_dict, options, run_metadata) 893 try: 894 result = self._run(None, fetches, feed_dict, options_ptr, --> 895 run_metadata_ptr) 896 if run_metadata: 897 proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)

/Users/agi/Downloads/tensorflow/lib/python2.7/site-packages/tensorflow/python/client/session.pyc in _run(self, handle, fetches, feed_dict, options, run_metadata) 1102 'Cannot feed value of shape %r for Tensor %r, ' 1103 'which has shape %r' -> 1104 % (np_val.shape, subfeed_t.name, str(subfeed_t.get_shape()))) 1105 if not self.graph.is_feedable(subfeed_t): 1106 raise ValueError('Tensor %s may not be fed.' % subfeed_t)

ValueError: Cannot feed value of shape (1, 199, 254, 3) for Tensor u'encoded_image_string_tensor:0', which has shape '(?,)'

josh-a-dcosta avatar Feb 24 '18 20:02 josh-a-dcosta

I'm reproing this problem as well with the same error message, following the pet detector tutorial

maxwang7 avatar Feb 27 '18 03:02 maxwang7

@tombstone @derekjchow Can one of you please direct us to the solution of this ValueError issue

josh-a-dcosta avatar Feb 27 '18 19:02 josh-a-dcosta

Same error as @agnellodcosta. Any solution so far?

mhasnat avatar Mar 02 '18 19:03 mhasnat

@mhasnat @maxwang7 Pls check #3517, the shape error was resolved, after exporting the graph using the command given by @derekjchow. My issue was caused because I was using the wrong input_type. This command resolved my issues with the shape dimension error.

python object_detection/export_inference_graph.py
--# input_type image_tensor
--pipeline_config_path=/Users/agi/downloads/tensorflow/poc/models/model/ssd_mobilenet_v1_poc_local.config
--trained_checkpoint_prefix=/Users/agi/downloads/tensorflow/poc/models/model/train/model.ckpt-400
--output_directory=/Users/agi/downloads/tensorflow/poc/models/model/output

josh-a-dcosta avatar Mar 06 '18 03:03 josh-a-dcosta

Following up on this...I was able to submit the training of my model in the cloud by doing the following steps

  1. Upgraded tensorflow -- pip install --upgrade tensorflow
  2. Upgraded glcoud sdk -- gcloud components update
  3. Removed the archived packages from /tensorflow/models/research/dist and /tensorflow/models/research/slim/dist
  4. Copy pycocotools folder in tensorflow/models/research/slim
  5. Modify setup.py in tensorflow/models/research/slim to include the Pycocotools package REQUIRED_PACKAGES = ['pycocotools>=1.0']
  6. Modify the setup.py in tensorflow/models/research to include tensorflow 1.5 REQUIRED_PACKAGES = ['tensorflow>=1.5','Pillow>=1.0','matplotlib>=1.0'] 6.1 Repackage the depenendcies using... --Run in cd /Users/xxx/Downloads/tensorflow/models/research python setup.py sdist (cd slim && python setup.py sdist)
  7. Use the runtime version 1.5 in GCloud training command
  8. Copy the checkpoint model.ckpt-data-... file to the cloud bucket
  9. Start the training (using the fine_tune_checkpoint: "gs://.../models/model/ckpt/model.ckpt" from_detection_checkpoint: false )

My Glcoud command looks like this...

gcloud ml-engine jobs submit training object_detection_1
--runtime-version 1.5
--job-dir=gs://xxx/models/model/train
--packages /Users/xxx/downloads/tensorflow/models/research/dist/object_detection-0.1.tar.gz,/Users/xxx/downloads/tensorflow/models/research/slim/dist/slim-0.1.tar.gz
--module-name object_detection.train
--region us-central1
--config /Users/xxx/downloads/tensorflow/poc/config/cloud.yml
--
--train_dir=gs://xxx/models/model/train
--pipeline_config_path=gs://xxx/models/model/ssd_mobilenet_v1_poc.config

josh-a-dcosta avatar Mar 18 '18 21:03 josh-a-dcosta