TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10 icon indicating copy to clipboard operation
TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10 copied to clipboard

Couldn't run generate_tfrecord.py

Open AniTho opened this issue 6 years ago • 7 comments
trafficstars

While executing python generate_tfrecord.py, encountering this error. Screenshot (14) while executing python generate_tfrecord.py --csv_input=images\train_labels.csv --output_path=train.record --image_dir=images\train , encountering this error. Screenshot (15)

AniTho avatar Oct 31 '19 17:10 AniTho

In your generate_tfrecord.py file make sure the last else statement is return 0 instead of None

def class_text_to_int(row_label): if row_label == 'basketball': return 1 elif row_label == 'shirt': return 2 elif row_label == 'shoe': return 3 else: None

Nightrain avatar Oct 31 '19 19:10 Nightrain

I tried to use the markup for adding code, sorry it did not stay formatted. but you should figure it out.

Nightrain avatar Oct 31 '19 19:10 Nightrain

did you figured out how to solve the problem? because i have the same error

nika9774 avatar Dec 08 '19 12:12 nika9774

@nika9774 Yes I did. It is like in the post above. In the generate_tfrecord.py look for the function you modified to match your lablemap.pbtxt file. At the end of the IF statement is the else:None to wrap it up. You have to change that else:None to else:0. (else:zero) That function (class_text_to_int) needs to return all ints, it is the None being returned that is causing the problem downstream.

Nightrain avatar Dec 09 '19 13:12 Nightrain

thank you. it worked!

nika9774 avatar Dec 09 '19 16:12 nika9774

Good to hear it have fun

Nightrain avatar Dec 09 '19 17:12 Nightrain

image i have problem when i run file generate_tfrecord.py.

hoanglvdev avatar Apr 04 '21 09:04 hoanglvdev