Search code examples
pythonmachine-learningtensorflowobject-detection

how to create tfrecord for custom labels in Tensorflow object detection?


I am trying to use tensorflow object detection API for custom image classification. After collecting images and creating csv from labelimg I tried generating the TfRecord. But everytime I run the program it returns error

    C:\>python generate_tfrecord.py --csv_input=data/train
_labels.csv  --output_path=data/train.record
Traceback (most recent call last):
  File "generate_tfrecord.py", line 101, in <module>
    tf.app.run()
  File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\platform\ap
p.py", line 48, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "generate_tfrecord.py", line 92, in main
    tf_example = create_tf_example(group, path)
  File "generate_tfrecord.py", line 47, in create_tf_example
    encoded_jpg = fid.read()
  File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\lib\io\file
_io.py", line 118, in read
    self._preread_check()
  File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\lib\io\file
_io.py", line 78, in _preread_check
    compat.as_bytes(self.__name), 1024 * 512, status)
  File "C:\ProgramData\Anaconda3\lib\contextlib.py", line 89, in __exit__
    next(self.gen)
  File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\framework\e
rrors_impl.py", line 466, in raise_exception_on_not_ok_status
    pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.NotFoundError: NewRandomAccessFile faile
d to Create/Open: C:\image.jpg : The system cannot find the file specified.

I have all the images in jpg format and the images are available in the specified folders.


Solution

  • C:\image.jpg : The system cannot find the file specified.

    The path in the file has to be a full path.