Models: Unable to generate TFRrecord: getting error : TypeError: None has type NoneType, but expected one of: int, long :

Created on 1 Oct 2018  ·  9Comments  ·  Source: tensorflow/models

(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

Most helpful comment

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.

All 9 comments

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'.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wrkgm picture wrkgm  ·  78Comments

NilsLattek picture NilsLattek  ·  61Comments

edwardHujber picture edwardHujber  ·  82Comments

Hemanth2396 picture Hemanth2396  ·  60Comments

yuanzhuohao picture yuanzhuohao  ·  81Comments