Closed venkateshbabusekar closed 5 years ago
found the solution
If you're getting error "TypeError: None has type NoneType, but expected one of: int, long" .
To fix, go to generate_tfrecord.py and under def class_text_to_int, the last else statement should be a return 0, not None. This makes sense, since we are expecting an int but are getting back a none.
Closing as this is resolved
found the solution
If you're getting error "TypeError: None has type NoneType, but expected one of: int, long" .
To fix, go to generate_tfrecord.py and under def class_text_to_int, the last else statement should be a return 0, not None. This makes sense, since we are expecting an int but are getting back a none.
I tried this, I still got the same error.
found the solution If you're getting error "TypeError: None has type NoneType, but expected one of: int, long" . To fix, go to generate_tfrecord.py and under def class_text_to_int, the last else statement should be a return 0, not None. This makes sense, since we are expecting an int but are getting back a none.
I tried this, I still got the same error.
You should not get it, check it once again. If you are still getting the same error, then share the code here someone will help you.
found the solution
If you're getting error "TypeError: None has type NoneType, but expected one of: int, long" .
To fix, go to generate_tfrecord.py and under def class_text_to_int, the last else statement should be a return 0, not None. This makes sense, since we are expecting an int but are getting back a none.
This solution solves this issue for me too.... Just change the 'None' to return 0. and that's all
Yes this solution works. Just change your label to desired label name.
Working Function:
def class_text_to_int(row_label):
if row_label == 'racoon':
return 1
else:
return 0
解决了,return None 改成 return 0,但是之前return None一直是没问题的,不知道有时候就会出错。。
found the solution
If you're getting error "TypeError: None has type NoneType, but expected one of: int, long" .
To fix, go to generate_tfrecord.py and under def class_text_to_int, the last else statement should be a return 0, not None. This makes sense, since we are expecting an int but are getting back a none.
Awesome Thank very much
found the solution
If you're getting error "TypeError: None has type NoneType, but expected one of: int, long" .
To fix, go to generate_tfrecord.py and under def class_text_to_int, the last else statement should be a return 0, not None. This makes sense, since we are expecting an int but are getting back a none.
thanks, you're right. I fix this issue as soon as I change 'None' to '0'.
Just change the label name whatever you labeling them during crop the image by labelImg tool.
def class_text_to_int(row_label):
if row_label == 'raccon':
return 1
else:
None
Instead of 'raccon' put label name for ex:- 'car'.
To solve typeerror on genrate TFrecord file: def class_text_to_int(row_label): if row_label == 'x': return 1 elif row_label == 'y': return 2 elif row_label == 'Z': return 3 else: return None Solution: else: return 0
I got this error but what resolved it for me was making sure the labels matched what I needed. This means I had 14 objects I was trying to detect, but I had only 4 in my def class_text_to_int. After adding the other 10 object it worked as intended.
If you only change the else to return 0, then you will probably will not get the correct output.
Something that could help is adding a print in def class_text_to_int(row_label): if row_label == 'name': return 1 else: print(row_label) None
This way you will learn which label is not being read properly and can add a new int for this new class.
Yes this solution works. Just change your label to desired label name.
Working Function:
def class_text_to_int(row_label): if row_label == 'racoon': return 1 else: return 0
this helps a lot. I am using tensorflow 2.6 version, I had compatible issue. Then use this to update the generate TFRecord py file, it works. Thanks
(tensorflow2) C:\tensorflow2\models\research\object_detection>python generate_tfrecord.py --csv_input=images\train_labels.csv --image_dir=images\train --output_path=train.record Traceback (most recent call last): File "generate_tfrecord.py", line 100, in
tf.app.run()
File "C:\Users\babus\Anaconda3\envs\tensorflow2\lib\site-packages\tensorflow\python\platform\app.py", line 125, in run
_sys.exit(main(argv))
File "generate_tfrecord.py", line 91, in main
tf_example = create_tf_example(group, path)
File "generate_tfrecord.py", line 80, in create_tf_example
'image/object/class/label': dataset_util.int64_list_feature(classes),
File "C:\Users\babus\Anaconda3\envs\tensorflow2\lib\site-packages\object_detection-0.1-py3.5.egg\object_detection\utils\dataset_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