Git Product home page Git Product logo

Comments (19)

SirPhemmiey avatar SirPhemmiey commented on June 29, 2024 24

The solution is a simple one.

You just need to change the else statement so it returns 0 instead of "None".

def class_text_to_int(row_label): if row_label == '<YOUR LABEL NAME>': return 1 else: return 0

You can find def class_text_to_int in the generate_tfrecord.py file.

Most forums talk about return equal None. It should be zero.

Ref: here

I hope it works for you!

from raccoon_dataset.

jtara1 avatar jtara1 commented on June 29, 2024 22

'iron ore' is the label I assigned. It describes what I'm training the model to detect, that is, iron ore, an object from an online game.

Whatever your label is, it should match what's located in https://github.com/datitran/raccoon_dataset/blob/master/training/object-detection.pbtxt

(raw text):

item {
  id: 1
  name: 'raccoon'
}

my previous comment points to the wrong line number; at that time I needed to replace the string 'raccoon' in the func below of the same file with 'iron ore' b/c that was my label

# TO-DO replace this with label map
def class_text_to_int(row_label):
    if row_label == 'raccoon':
        return 1
    else:
        None

It's been a while since I touched this stuff, mb if I misstated something.

from raccoon_dataset.

pranavjadhav001 avatar pranavjadhav001 commented on June 29, 2024 14

This happens because labels in your xml are wrong in someplaces, check your csv and change those mistakes. Like instead of racoon label , you have labelled it as car.

from raccoon_dataset.

Iamhomkar avatar Iamhomkar commented on June 29, 2024 6

My Stack Trace before making the change
Traceback (most recent call last):
File "generate_tfrecord.py", line 107, in
tf.app.run()
File "/home/shadeslayer/anaconda/envs/MYML/lib/python3.5/site-packages/tensorflow/python/platform/app.py", line 125, in run
_sys.exit(main(argv))
File "generate_tfrecord.py", line 98, in main
tf_example = create_tf_example(group, path)
File "generate_tfrecord.py", line 87, in create_tf_example
'image/object/class/label': dataset_util.int64_list_feature(classes),
File "/home/shadeslayer/Documents/Tensorflow_Object_detection/models/research/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

TO-DO replace this with label map

def class_text_to_int(row_label):
if row_label == 'raccoon':
return 1
else:
None

This should return an integer in the else case,since line number 87 "'image/object/class/label': dataset_util.int64_list_feature(classes)," expects it to be an integer, returning an integer like 0 worked for me.

from raccoon_dataset.

jtara1 avatar jtara1 commented on June 29, 2024 4

Changing the string in https://github.com/datitran/raccoon-dataset/blob/master/generate_tfrecord.py#L25 to the label I'm using ('iron ore') for my data seems to have fixed this. No errors now and I got the train.record file. I'll probably close this issue later after I make sure this file is legit.

from raccoon_dataset.

bahshat avatar bahshat commented on June 29, 2024 3

You need this piece

def class_text_to_int(row_label):
    if row_label == '<YOUR LABEL NAME>': 
         return 1 
    else: 
         return 0

You can find def class_text_to_int in the generate_tfrecord.py file.
find the else shown in the above code
there you'd see

else: 
         None

make as above code which needs to be replaced with

  else: 
         return 0

from raccoon_dataset.

adarsh666 avatar adarsh666 commented on June 29, 2024 2

This usually happens when "label name" specified to create the tf record mismatches with the "label name" in the annotation files.
For example if u annotated an image by the name "cars" , and u incorrectly named label as "car" while creating tf record.

from raccoon_dataset.

Zumbalamambo avatar Zumbalamambo commented on June 29, 2024

@jtara1 what do you mean by iron ore?

from raccoon_dataset.

shauviks avatar shauviks commented on June 29, 2024

Can some one help me on this. Even i changed return value to 0 but i still get the same error

from raccoon_dataset.

prameshbajra avatar prameshbajra commented on June 29, 2024

@shauviks can you post your error trace? or did you solve it?

from raccoon_dataset.

jayasuryar97 avatar jayasuryar97 commented on June 29, 2024

My object-detection.pbtxt
item { id: 1 name: 'PAN' } item { id: 2 name: 'Cheque' } item { id: 3 name: 'Unknown' }
It has multiple classes.
How do i modify my class_text_to_int function for multi class

from raccoon_dataset.

nuttheguitar avatar nuttheguitar commented on June 29, 2024

python generate_tfrecord.py --label=person --csv_input=../../annotations/train_labels.csv --output_path=../../annotations/train_labels.record --img_path=../../images/train

This is my run script. I just change '--label' to match with a class that you assigned in label_map.txt

from raccoon_dataset.

Daring-Deekshith avatar Daring-Deekshith commented on June 29, 2024

The solution is a simple one.

You just need to change the else statement so it returns 0 instead of "None".

def class_text_to_int(row_label): if row_label == '<YOUR LABEL NAME>': return 1 else: return 0

You can find def class_text_to_int in the generate_tfrecord.py file.

Most forums talk about return equal None. It should be zero.

Ref: here

I hope it works for you!

It is working great.
Thank you.
Simply do the thing in the image.
solved_return

from raccoon_dataset.

yashmukaty avatar yashmukaty commented on June 29, 2024

The solution is a simple one.

You just need to change the else statement so it returns 0 instead of "None".

def class_text_to_int(row_label): if row_label == '<YOUR LABEL NAME>': return 1 else: return 0

You can find def class_text_to_int in the generate_tfrecord.py file.

Most forums talk about return equal None. It should be zero.

Ref: here

I hope it works for you!

It still doesn't work!

from raccoon_dataset.

IndiskPrasad avatar IndiskPrasad commented on June 29, 2024

@yashmukaty , it worked for me by simply adding 0 instead of None. thanks

from raccoon_dataset.

dhanpalrajpurohit avatar dhanpalrajpurohit commented on June 29, 2024

if row_label == 'raccon': return 1 else: None
convert to
if row_label == 'raccon': return 1 else: return 0

from raccoon_dataset.

gilmotta avatar gilmotta commented on June 29, 2024

My Stack Trace before making the change
Traceback (most recent call last):
File "generate_tfrecord.py", line 107, in
tf.app.run()
File "/home/shadeslayer/anaconda/envs/MYML/lib/python3.5/site-packages/tensorflow/python/platform/app.py", line 125, in run
_sys.exit(main(argv))
File "generate_tfrecord.py", line 98, in main
tf_example = create_tf_example(group, path)
File "generate_tfrecord.py", line 87, in create_tf_example
'image/object/class/label': dataset_util.int64_list_feature(classes),
File "/home/shadeslayer/Documents/Tensorflow_Object_detection/models/research/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

TO-DO replace this with label map

def class_text_to_int(row_label):
if row_label == 'raccoon':
return 1
else:
None

This should return an integer in the else case,since line number 87 "'image/object/class/label': dataset_util.int64_list_feature(classes)," expects it to be an integer, returning an integer like 0 worked for me.

This function only makes sense if you want to filter your label in csv with many labels but the code isn't checking for None so it doesn't have purpose.
Just comment out the whole thing and return 1 always

Below is what I did and it works for all labels I have in my csv:

TO-DO replace this with label map

def class_text_to_int(row_label):
# print(row_label + " ")
# if row_label == 'car' or row_label == 'plate'
# or row_label == 'motorcycle' or row_label == 'bus'
# or row_label == 'volkwagen' or row_label == 'chevrolet'
# or row_label == 'truck' or row_label == 'van' or row_label == 'suv':
# return 1
# else:
# None
return 1

from raccoon_dataset.

mahmudsaral avatar mahmudsaral commented on June 29, 2024

The solution is a simple one.

You just need to change the else statement so it returns 0 instead of "None".

def class_text_to_int(row_label): if row_label == '<YOUR LABEL NAME>': return 1 else: return 0

You can find def class_text_to_int in the generate_tfrecord.py file.

Most forums talk about return equal None. It should be zero.

Ref: here

I hope it works for you!

Thanks for the help :)

from raccoon_dataset.

shubhamnagalwade avatar shubhamnagalwade commented on June 29, 2024

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

NOTE:- for windows just change the forward-slash like:-
python3 generate_tfrecord.py --csv_input=data\test_labels.csv --output_path=data\test.record

from raccoon_dataset.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.