bourdakos1 / Custom-Object-Detection

Custom Object Detection with TensorFlow

Home Page:https://medium.freecodecamp.org/tracking-the-millenium-falcon-with-tensorflow-c8c86419225e

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

train.py fails ... don't know what's wrong. I suspect image path in XML annotations file ...

jetzzze opened this issue · comments

When running train.py with the parameters given in the tutorial I get also a lot of the relative path warnings as documented in my other issue but train.py completely fails with the following last error messages (I did not post all the warnings before):

...
dyld: warning, LC_RPATH $ORIGIN/../../../../../_solib_darwin_x86_64/_U_S_Stensorflow_Scontrib_Stensor_Uforest_Cpython_Sops_S_Ustats_Uops.so___Utensorflow in /Users/jreich/Library/Python/2.7/lib/python/site-packages/tensorflow/contrib/tensor_forest/python/ops/_stats_ops.so being ignored in restricted program because it is a relative path
INFO:tensorflow:Scale of 0 disables regularizer.
INFO:tensorflow:Scale of 0 disables regularizer.
WARNING:tensorflow:From /Users/jreich/Downloads/Watson/Custom-Object-Detection-master/object_detection/trainer.py:176: create_global_step (from tensorflow.contrib.framework.python.ops.variables) is deprecated and will be removed in a future version.
Instructions for updating:
Please switch to tf.train.get_or_create_global_step
INFO:tensorflow:Summary name Learning Rate is illegal; using Learning_Rate instead.
Traceback (most recent call last):
  File "object_detection/train.py", line 198, in <module>
    tf.app.run()
  File "/Users/jre/Library/Python/2.7/lib/python/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 194, in main
    worker_job_name, is_chief, FLAGS.train_dir)
  File "/Users/jre/Downloads/Watson/Custom-Object-Detection-master/object_detection/trainer.py", line 218, in train
    var_map, train_config.fine_tune_checkpoint))
  File "/Users/jre/Downloads/Watson/Custom-Object-Detection-master/object_detection/utils/variables_helper.py", line 122, in get_variables_available_in_checkpoint
    ckpt_reader = tf.train.NewCheckpointReader(checkpoint_path)
  File "/Users/jre/Library/Python/2.7/lib/python/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 150, in NewCheckpointReader
    return CheckpointReader(compat.as_bytes(filepattern), status)
  File "/Users/jre/Library/Python/2.7/lib/python/site-packages/tensorflow/python/framework/errors_impl.py", line 473, in __exit__
    c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.NotFoundError: Unsuccessful TensorSliceReader constructor: Failed to find any matching files for model.ckpt
[ /Users/jre/Downloads/Watson/Custom-Object-Detection-master ]
jre@ibm-jre-mbp  ==_-+- 

I interpret the error message that train.py is not able to find the files for the model. I checked the annotation files in "annotations/xmls" and found that there is different folder name given in all of them:

<folder>less_selected</folder>

But the "videoplayback####" JPGs are stored in the "images" folder ... Maybe this also causes trouble with "create_tf_record.py". But probably I am completely on the wrong track ;-)

jre@ibm-jre-mbp  ==_-+- cat videoplayback0051.xml 
<annotation>
    <folder>less_selected</folder>
    <filename>videoplayback0051.jpg</filename>
    <size>
        <width>1000</width>
        <height>563</height>
    </size>
    <segmented>0</segmented>
    <object>
        <name>Tie Fighter</name>
        <pose>Unspecified</pose>
        <truncated>0</truncated>
        <difficult>0</difficult>
        <bndbox>
            <xmin>157</xmin>
            <ymin>165</ymin>
            <xmax>166</xmax>
            <ymax>176</ymax>
        </bndbox>
    </object>
    <object>
        <name>Tie Fighter</name>
        <pose>Unspecified</pose>
        <truncated>0</truncated>
        <difficult>0</difficult>
        <bndbox>
            <xmin>136</xmin>
            <ymin>151</ymin>
            <xmax>145</xmax>
            <ymax>160</ymax>
        </bndbox>
    </object>
</annotation>[ /Users/jre/Downloads/Watson/Custom-Object-Detection-master/annotations/xmls ]
jre@ibm-jre-mbp  ==_-+- 

I am using for python 2.7.10 which is the default version of my mac os sierra and the pip version is 9.0.1. I hope it is not a big deal to solve :-)

Did you download a base model? and if so where is it located?

Stupid me ... missed to copy the model.ckpt files to the root of the repo. Sorry for this newbie mistake but I am a newbie ;-) ... works now:

...
INFO:tensorflow:Restoring parameters from model.ckpt
INFO:tensorflow:Starting Session.
INFO:tensorflow:Saving checkpoint to path train/model.ckpt
INFO:tensorflow:Starting Queues.
INFO:tensorflow:global_step/sec: 0
INFO:tensorflow:Recording summary at step 0.
INFO:tensorflow:global step 1: loss = 1.6799 (37.102 sec/step)
INFO:tensorflow:global step 2: loss = 1.9270 (19.976 sec/step)
INFO:tensorflow:global step 3: loss = 1.3862 (15.996 sec/step)
INFO:tensorflow:global step 4: loss = 1.4605 (14.378 sec/step)
INFO:tensorflow:global step 5: loss = 1.2063 (14.626 sec/step)
INFO:tensorflow:global step 6: loss = 1.3154 (14.493 sec/step)
INFO:tensorflow:global_step/sec: 0.0506604
INFO:tensorflow:Recording summary at step 6.
INFO:tensorflow:global step 7: loss = 1.2904 (20.829 sec/step)
...

No problem!

I'm always glad to help :)

What about the folder entry in the xml files? Does this needs to be corrected as all images lie in folder "images" and there is no folder "less_selected"?

And another newbie question: I used Rectlabel for annotating and also used polygons and not only no boxes. Will that work too?

the folder tag has no meaning when being parsed so It can be anything and you might be able to just remove it.

The important tags are:

<filename>myfile.jpg</filename>
<size>
    <width>1000</width>
    <height>563</height>
</size>
<object>
    <name>Object Name</name>
    <bndbox>
        <xmin>157</xmin>
        <ymin>165</ymin>
        <xmax>166</xmax>
        <ymax>176</ymax>
    </bndbox>
</object>

The object detection isn't built to support polygons.