Search code examples
tensorflowobject-detectiontfrecord

Tensorflow Object Detection, error while generating tfrecord [TypeError: None has type NoneType, but expected one of: int, long]


When checking across different solutions available on the net, most people (including datitran) pointed out that it might be a missing class or a misspell of a class in the train csv file. Am not able to figure that out since the labelling is done using labelImg, it saves these classes as xml, the xml_to_csv.py converts this to a csv. Am not sure under what circumstance I could have had the opportunity to miss out or misspel any class incorrectly.

Here's the error am dealing with:

(OT) 
nisxxxxx@xxxxxxxx:~/Desktop/OD/models/research/object_detection$ 
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 192, in <module>
    tf.app.run()
  File "/home/nisxxxxx/Desktop/test_OD/OT/lib/python2.7/site-
packages/tensorflow/python/platform/app.py", line 48, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "generate_tfrecord.py", line 184, in main
tf_example = create_tf_example(group, path)
  File "generate_tfrecord.py", line 173, in create_tf_example
    'image/object/class/label': 
dataset_util.int64_list_feature(classes),
File"/home/nishanth/Desktop/test_OD/models/research/object_detection/utils/dat
aset_util.py", line 26, in int64_list_feature
    return 
tf.train.Feature(int64_list=tf.train.Int64List(value=value))
TypeError: None has type NoneType, but expected one of: int, long

Has anyone been able to solve this problem?


Solution

  • I am not sure how many classes you have used... after the final else try with "return 0 instead of none"... example

    if row_label == 'red':
        return 1
    elif row_label == 'orange':
        return 2
    elif row_label == 'blue':
        return 3
    else:
        return 0