'generate_tfrecord.py: error: unrecognized arguments - error while trying to create TF Record files for test and train data

While using the generate_tfrecord.py, I'm always getting this error of "generate_tfrecord.py: error: unrecognized arguments".

But, I haven't changed anything, and I've used the same command from the custom object detection tutorial, from the TFOD website. Link: https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/training.html

Tried both on Google Collab and also on local python environment, still same issue.

Anyone has experienced this error before, if so, how did you solve it? Please help. Thanks!

python generate_tfrecord.py -x [PATH_TO_IMAGES_FOLDER]/train -l [PATH_TO_ANNOTATIONS_FOLDER]/label_map.pbtxt -o [PATH_TO_ANNOTATIONS_FOLDER]/train.record

Changes I made:

python generate_tfrecord.py -x C:/Users/prana/Desktop/cnn_system/images/train -l C:/Users/prana/Desktop/cnn_system/annotations/label_map.pbtxt -o C:/Users/prana/Desktop/cnn_system/annotations/train.record

On Collab, I tried this:

!python generate_tfrecord.py -i /content/trainingdemo/images/train -l /content/trainingdemo/annotations/label_map.pbtxt -o /content/trainingdemo/annotations/train.record

All the files have been double checked, they all exist in the right path.



Solution 1:[1]

this worked for me, it may work for someone else.

Try not to leave any spaces in the line of code, replace spaces with _

BEFORE:

python generate_tfrecord.py -x D:/Semestre/graduation project/files/TensorFlow/workspace/training/images/train -l D:/Semestre/graduation project/files/TensorFlow/workspace/training/annotations/labelmap.pbtxt -o D:/Semestre/graduation project/files/TensorFlow/workspace/training/annotations/train.record

AFTER:

python generate_tfrecord.py -x D:/Semestre/graduation_project/files/TensorFlow/workspace/training/images/train -l D:/Semestre/graduation_project/files/TensorFlow/workspace/training/annotations/labelmap.pbtxt -o D:/Semestre/graduation_project/files/TensorFlow/workspace/training/annotations/train.record

I had a space between graduation project

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1