Search code examples
pythontensorflowobject-detectiontraining-data

ValueError when training TensorFlow object detection: "all elements of boxlists should be BoxList objects"


I have a dataset of just 10 images of sodacans. This is because I want to get the process of setting up the TFRecords and Training Pipeline tested, before I spend hours labeling a bunch of photos.

I labeled the images using RectLabel on macOS. Here is an example of an annotation

<annotation>
<folder>training</folder>
<filename>image1.jpg</filename>
<path>/Users/{my_username}/Desktop/models-master/object_detection/training/image1.jpg</path>
<size>
    <width>225</width>
    <height>225</height>
</size>
<segmented>0</segmented>
<object>
    <name>sodacan</name>
    <pose>Unspecified</pose>
    <truncated>0</truncated>
    <difficult>0</difficult>
    <bndbox>
        <xmin>61</xmin>
        <ymin>20</ymin>
        <xmax>155</xmax>
        <ymax>207</ymax>
    </bndbox>
</object>

I added the path attribute myself. I don't know if I need that, I just saw it in an example of an annotation.

Here is what my label map looks like:

item {
  id: 1
  name: 'sodacan'
}

I used two scripts by Dat Tran to create the TFRecords. They can be found in this repo. First I use 'xml_to_csv.py' and then I use 'generate_tfrecord.py'.

I used a config file written by eshirima which can be found here, of course configured to match my data structure.

I run the training script from the models folder using:

python object_detection/train.py \
--logtostderr \
--pipeline_config_path=object_detection/ts_configuration.config \
--train_dir=Users/{my_username}/Desktop/empty_folder

After about 20-30 seconds this error is throw:

ValueError: all elements of boxlists should be BoxList objects

I have tried using the tutorial on the Object Detection repo to create the records, I have tried using one of the sample configs, but I still get that error. However if I use the 'faster_rcnn_inception_resnet_v2_atrous_pets' config from the samples folder in the object_detection folder, I get this error:

ValueError: boxlist must be a BoxList

I have no idea what to do from here. Any help will be appreciated!


Solution

  • So I figured out the issue.

    I had totally forgot about modifications I made to the visualization_utils.py script, to extract more information. This apparently seemed to also break the training.

    I downloaded the models repo again, started the entire process over, and now the training is running!