1

I'm trying to convert a custom dataset to tfrecord for DeepLab v3+, following this tutorial. My directory setup is as follows:

+ datasets
  + pascal_voc_seg/custom_dataset
    + VOCdevkit
      + VOC2012
        + JPEGImages
        + SegmentationClassRaw
        + ImageSets
           +Segmentation
    + tfrecord

I also have downloaded the Pascal VOC dataset and the two directory structures are now identical. When I run the build_voc2012_data.py script on the PascalVOC dataset as follows:

#from models/research/deeplab/dataset/pascal_voc_seg

python build_voc2012_data.py \
--image_folder="./VOCdevkit/VOC2012/JPEGImages" \
--semantic_segmentation_folder="./VOCdevkit/VOC2012/SegmentationClassRaw" \
--list_folder="./VOCdevkit/VOC2012/ImageSets/Segmentation" \
--image_format="jpg" \
--output_dir="./tfrecord"

...everything works fine, the dataset gets converted to tfrecord files with a progress bar displayed. However when I run the same script from my custom dataset directory, the following error occurs:

>> Converting image 1/164 shard 0Traceback (most recent call last):
  File "build_voc2012_data.py", line 146, in <module>
    tf.compat.v1.app.run()
  File "/home/delanyn/.local/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 40, in run
    _run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
  File "/home/delanyn/.local/lib/python2.7/site-packages/absl/app.py", line 299, in run
    _run_main(main, args)
  File "/home/delanyn/.local/lib/python2.7/site-packages/absl/app.py", line 250, in _run_main
    sys.exit(main(argv))
  File "build_voc2012_data.py", line 142, in main
    _convert_dataset(dataset_split)
  File "build_voc2012_data.py", line 121, in _convert_dataset
    image_data = tf.io.gfile.GFile(image_filename, 'rb').read()
  File "/home/delanyn/.local/lib/python2.7/site-packages/tensorflow/python/lib/io/file_io.py", line 122, in read
    self._preread_check()
  File "/home/delanyn/.local/lib/python2.7/site-packages/tensorflow/python/lib/io/file_io.py", line 84, in _preread_check
    compat.as_bytes(self.__name), 1024 * 512)
.jpg; No such file or directoryors_impl.NotFoundError: ./VOCdevkit/VOC2012/JPEGImages/2020_0

What could I be missing here? My images are JPEG with the same dimensions as the Pascal VOC images. The segmentation masks have the same colormap as well, and I use remove colormap script on them in advance.

NiallD
  • 23
  • 3

1 Answers1

0

As per the error message, I could only say that an entry in the train.txt or val.txt file in the folder: pascal_voc_dataset/VOCdevkit/VOC2012/ImageSets/Segmentation does not match with anything (image) in the JPEG folder: pascal_voc_dataset/VOCdevkit/VOC2012/JPEGImages.

Manas
  • 888
  • 10
  • 20