models icon indicating copy to clipboard operation
models copied to clipboard

Train.py in object_detection crash. AttributeError: module 'tensorflow.contrib.slim.python.slim.data.tfexample_decoder' has no attribute 'BackupHandler'

Open radzfoto opened this issue 9 years ago • 38 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 custom code, and using a neural network supplied in the object_detection folders. The dataset for retraining is my own.

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux Ubuntu 16.04

  • TensorFlow installed from (source or binary): binary

  • TensorFlow version (use command below): v1.3.0-rc2-20-g0787eee 1.3.0

  • Bazel version (if compiling from source):

  • Python version 3.6.3, using GCC 5.4.0 20160609

  • CUDA/cuDNN version: CUDA 8.0, cudnn 6.0, nVidia driver: 384.90

  • GPU: nVidia TitanXp 12GB memory

  • CPU: Intel x86-64 Intel Core i7-7700K @ 4.20GHz x 8, 32GB memory

  • Exact command to reproduce: python train.py --logtostderr --train_dir=/media/raul/RD750G/highwai/tfrecords/checkpoint --pipeline_config_path=/media/raul/RD750G/highwai/tfrecords/models/model/highwai_data.config

Describe the problem

I run the object_detection train.py script, which I have done many times successfully. However, after a git pull today, I get the error below. I have not changed any code in object_detection at all.

Source code / logs

python train.py --logtostderr --train_dir=/media/raul/RD750G/highwai/tfrecords/checkpoint --pipeline_config_path=/media/raul/RD750G/highwai/tfrecords/models/model/highwai_data.config INFO:tensorflow:Scale of 0 disables regularizer. INFO:tensorflow:Scale of 0 disables regularizer. Traceback (most recent call last): File "train.py", line 163, in tf.app.run() File "/home/raul/tensorflow/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 48, in run _sys.exit(main(_sys.argv[:1] + flags_passthrough)) File "train.py", line 159, in main worker_job_name, is_chief, FLAGS.train_dir) File "/home/raul/tensorflow/models/research/object_detection/trainer.py", line 217, in train train_config.prefetch_queue_capacity, data_augmentation_options) File "/home/raul/tensorflow/models/research/object_detection/trainer.py", line 59, in create_input_queue tensor_dict = create_tensor_dict_fn() File "/home/raul/tensorflow/models/research/object_detection/builders/input_reader_builder.py", line 72, in build label_map_proto_file=label_map_proto_file) File "/home/raul/tensorflow/models/research/object_detection/data_decoders/tf_example_decoder.py", line 128, in init label_handler = slim_example_decoder.BackupHandler( AttributeError: module 'tensorflow.contrib.slim.python.slim.data.tfexample_decoder' has no attribute 'BackupHandler'

radzfoto avatar Oct 31 '17 00:10 radzfoto

I have the same error. I search

BackupHandler

in tensorflow sourcecode from r1.0 - r1.4. I can not find it. I aslo run the unittest at research directory:

python object_detection/data_decoders/tf_example_decoder_test.py there are 12 errors, all the error message is similar, here is the first error message:

====================================================================== ERROR: testDecodeBoundingBox (main.TfExampleDecoderTest)

Traceback (most recent call last): File "object_detection/data_decoders/tf_example_decoder_test.py", line 128, in testDecodeBoundingBox 'image/format': self._BytesFeature('jpeg'), File "object_detection/data_decoders/tf_example_decoder_test.py", line 57, in _BytesFeature return tf.train.Feature(bytes_list=tf.train.BytesList(value=[value])) TypeError: 'jpeg' has type str, but expected one of: bytes

scotthuang1989 avatar Oct 31 '17 01:10 scotthuang1989

I hava the same error too I run object_detection/train.py today, the error info is follows:

Traceback (most recent call last): File "object_detection/train.py", line 163, in tf.app.run() File "/home/caffe/.local/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 48, in run _sys.exit(main(_sys.argv[:1] + flags_passthrough)) File "object_detection/train.py", line 159, in main worker_job_name, is_chief, FLAGS.train_dir) File "/home/caffe/models/research/object_detection/trainer.py", line 217, in train train_config.prefetch_queue_capacity, data_augmentation_options) File "/home/caffe/models/research/object_detection/trainer.py", line 59, in create_input_queue tensor_dict = create_tensor_dict_fn() File "/home/caffe/models/research/object_detection/builders/input_reader_builder.py", line 72, in build label_map_proto_file=label_map_proto_file) File "/home/caffe/models/research/object_detection/data_decoders/tf_example_decoder.py", line 128, in init label_handler = slim_example_decoder.BackupHandler( AttributeError: 'module' object has no attribute 'BackupHandler'

I run this before many times and it runs well. But today I start from a new virtual machine with same cuda8.0, cudnn6.0 and other dependencies, the tensorflow is installed using command "pip install tensorflow-gpu" with version of 1.3.0 under python2.7.12

Since error happened in object_detection/data_decoders/tf_example_decoder.py, line 128: slim_example_decoder = tf.contrib.slim.tfexample_decoder, label_handler = slim_example_decoder.BackupHandler( .......... I check the tensorflow 1.3.0 sorcecode, https://github.com/tensorflow/tensorflow/blob/r1.3/tensorflow/contrib/slim/python/slim/data/tfexample_decoder.py This file "tfexample_decoder.py" actually does not have attribute 'BackupHandler', I don't know why object_detection/data_decoders/tf_example_decoder.py has the code 'label_handler = slim_example_decoder.BackupHandler'

I checked all versions of tensorflow from r0.7-r1.4, all of them don't have attribute 'BackupHandler' in tensorflow/contrib/slim/python/slim/data/tfexample_decoder.py. Only in master branch has this attribute.

tuobay avatar Oct 31 '17 04:10 tuobay

me too :

root@fc086fe4f615:/notebooks/models/research# python object_detection/train.py --logtostderr /notebooks/katakana --pipeline_config_path=/noteboo ks/katakana/data/ssd_mobilenet_v1_katakana.config --train_dir=/notebooks/katakana/ Traceback (most recent call last): File "object_detection/train.py", line 163, 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 "object_detection/train.py", line 159, in main worker_job_name, is_chief, FLAGS.train_dir) File "/notebooks/models/research/object_detection/trainer.py", line 217, in train train_config.prefetch_queue_capacity, data_augmentation_options) File "/notebooks/models/research/object_detection/trainer.py", line 59, in create_input_queue tensor_dict = create_tensor_dict_fn() File "/notebooks/models/research/object_detection/builders/input_reader_builder.py", line 72, in build label_map_proto_file=label_map_proto_file) File "/notebooks/models/research/object_detection/data_decoders/tf_example_decoder.py", line 128, in init label_handler = slim_example_decoder.BackupHandler( AttributeError: 'module' object has no attribute 'BackupHandler'

hoangtocdo90 avatar Oct 31 '17 05:10 hoangtocdo90

I am facing the same issue today. Yesterday I was able to run on the personal machine. But today I am trying on AWS.

My command is

python object_detection/train.py --logtostderr --pipeline_config_path=/home/ubuntu/od/models/model/ssd_mobilenet_v1_pets.config --train_dir=/home/ubuntu/od/models/model/train

I get this error.

Traceback (most recent call last): File "object_detection/train.py", line 163, in <module> 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 "object_detection/train.py", line 159, in main worker_job_name, is_chief, FLAGS.train_dir) File "/home/ubuntu/models/research/object_detection/trainer.py", line 217, in train train_config.prefetch_queue_capacity, data_augmentation_options) File "/home/ubuntu/models/research/object_detection/trainer.py", line 59, in create_input_queue tensor_dict = create_tensor_dict_fn() File "/home/ubuntu/models/research/object_detection/builders/input_reader_builder.py", line 72, in build label_map_proto_file=label_map_proto_file) File "/home/ubuntu/models/research/object_detection/data_decoders/tf_example_decoder.py", line 128, in __init__ label_handler = slim_example_decoder.BackupHandler( AttributeError: 'module' object has no attribute 'BackupHandler'

harshkn avatar Oct 31 '17 07:10 harshkn

BUT tfexample_decoder.py has the class BackupHandler. https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/slim/python/slim/data/tfexample_decoder.py

chihyuwang avatar Oct 31 '17 07:10 chihyuwang

@chihyuwang When do pip install tensorflow-gpu, in the installed tensorflow code 'BackupHandler' class is itself not their. May be we need build tensorflow from source i guess. I'm trying that now and will here accordingly.

Sharathnasa avatar Oct 31 '17 12:10 Sharathnasa

I changed to the previous commit code, now it works.

tuobay avatar Oct 31 '17 12:10 tuobay

Temporary solution (at ubuntu 16.04 @ TensorFlow r1.4 ):

1:download new tfexample_decoder.py: $ cd $home $ wget https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/slim/python/slim/data/tfexample_decoder.py

2:replace $ cd /usr/local/lib/python3.5/dist-packages/tensorflow/contrib/slim/python/slim/data $ sudo cp ./tfexample_decoder.py tfexample_decoder-backup.py $ sudo rm ./tfexample_decoder.py $ sudo cp /home/wpq/tfexample_decoder.py ./tfexample_decoder.py

ok!

wpq3142 avatar Oct 31 '17 13:10 wpq3142

File "/home/wpq/models-master/research/object_detection/utils/variables_helper.py", line 122, in get_variables_available_in_checkpoint ckpt_reader = tf.train.NewCheckpointReader(checkpoint_path) File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 150, in NewCheckpointReader return CheckpointReader(compat.as_bytes(filepattern), status) File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/errors_impl.py", line 473, in exit c_api.TF_GetCode(self.status.status))

Error: tensorflow.python.framework.errors_impl.DataLossError: Unable to open table file /home/wpq/data/potato/data/model.ckpt.data-00000-of-00001: Data loss: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?

Process finished with exit code 1

help me: What is the reason,How to solve?

wpq3142 avatar Oct 31 '17 13:10 wpq3142

The Class in the tfexample_decoder.py TFExampleDecoder , while the constructor calling it has a name TfExampleDecoder

Nilavro avatar Oct 31 '17 15:10 Nilavro

Hi all, I have the same problem. I installed Tensor Flow using pip install tensorflow-gpu. Does installing from source or a previous commit solve the problem? If so how do I do that?

Thanks

alberto139 avatar Oct 31 '17 16:10 alberto139

The new ones have models/research/object_detection . They are still being updated . I am at least able to train with this repo .

https://github.com/tensorflow/models/tree/0375c800c767db2ef070cee1529d8a50f42d1042

The older version seems to work.

Nilavro avatar Oct 31 '17 17:10 Nilavro

loss @tombstone I was able to run the latest repo. I installed the tensorflow from the source code of master branch. But the loss looks really bad.. Loss is in 10 digits long. I will attach the screenshot.

Sharathnasa avatar Oct 31 '17 18:10 Sharathnasa

wow, BackupHandler only exists in master, not even in Tensorflow-1.4. I know this is research code, but it would be great if we can stick with an official TF release, given that the latest supported TF version on Google Cloud is only 1.2.

mrfortynine avatar Oct 31 '17 19:10 mrfortynine

To resolve this issue you'll have to update your TensorFlow version. You can install a nightly build here for GPU, or here for CPU.

Any TensorFlow version after October 24th 2017 should work (which is when this method was added).

Adrrei avatar Oct 31 '17 19:10 Adrrei

Hello AlgorithmR: it works! The nightly build works with object_detection/train.py. HOWEVER, I installed this in a clean ubuntu linux env, and now tensorboard is missing. Is there something different in the nightly builds that requires a separate installation for tensorboard? And if so, do I need to build tensorboard from source? Thank you!

radzfoto avatar Oct 31 '17 21:10 radzfoto

@radzfoto I use this nightly build and this error is gone, but I get another one, from the message, I can know tensorflow can't restore the variable from checkpoint, I use ssd mobile v1 model which I download from model zoom, which one do you use?

tensorflow.python.framework.errors_impl.DataLossError: Unable to open table file /home/scott/github/models/research/object_detection/ssd_mobilenet_v1_coco_11_06_2017/model.ckpt.data-00000-of-00001: Data loss: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?

scotthuang1989 avatar Oct 31 '17 23:10 scotthuang1989

hi @scotthuang1989: I use faster_rcnn_inception_resnet_v2_atrous_coco_11_06_2017. I re-downloaded it just in case, but it looks to be the same as before. I did not have problems with this frozen proto.

radzfoto avatar Oct 31 '17 23:10 radzfoto

@radzfoto Tensorboard is not included in the nightly builds of TensorFlow. You can install it manually with pip like so: pip install tensorflow-tensorboard.

Adrrei avatar Nov 01 '17 07:11 Adrrei

@radzfoto your TensorFlow version is?
Can you give the contents of the pipeline_config file ?

my faster_rcnn_inception_resnet_v2_atrous_pets.config:

model { faster_rcnn { num_classes: 37 image_resizer { keep_aspect_ratio_resizer { min_dimension: 600 max_dimension: 1024 } } feature_extractor { type: 'faster_rcnn_inception_resnet_v2' first_stage_features_stride: 8 }

wpq3142 avatar Nov 01 '17 07:11 wpq3142