Comments (19)
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.
'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.
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.
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.
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.
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.
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.
@jtara1 what do you mean by iron ore?
from raccoon_dataset.
Can some one help me on this. Even i changed return value to 0 but i still get the same error
from raccoon_dataset.
@shauviks can you post your error trace? or did you solve it?
from raccoon_dataset.
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.
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.
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 thegenerate_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.
from raccoon_dataset.
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 thegenerate_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.
@yashmukaty , it worked for me by simply adding 0 instead of None. thanks
from raccoon_dataset.
if row_label == 'raccon': return 1 else: None
convert to
if row_label == 'raccon': return 1 else: return 0
from raccoon_dataset.
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, longTO-DO replace this with label map
def class_text_to_int(row_label):
if row_label == 'raccoon':
return 1
else:
NoneThis 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.
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 thegenerate_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.
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)
- UNKNOWN ERROR. PLEASE HELP! HOT 1
- TFRecord load HOT 1
- How do you evaluate an image while training the model as you did in your article
- UnicodeDecodeError HOT 4
- ERROR in generate_tfrecord.py ( AttributeError: output_path ) HOT 1
- train_dir is missing while training object detection using tensorflow lite HOT 1
- python: can't open file 'generate_tfrecord.py': [Errno 2] No such file or directory HOT 1
- run 'generate_tfrecord.py' error HOT 3
- Unable to generate TFRrecord: getting error : TypeError: None has type NoneType, but expected one of: int, long
- Getting Blank record file on Tfrecod generation
- @chuasonglin I followed your revisions and keep getting this error:
- issue while generating tf.record
- in <module> flags = tf.app.flags AttributeError: module 'tensorflow' has no attribute 'app' HOT 4
- MacOS: ModuleNotFoundError: No module named 'object_detection'
- appeared xml_to_csv.py file
- xml_to_csv: format in the csv file
- generate_tfrecord.py not workingn correctlyt with png images
- Traceback (most recent call last):
- Can the new dataset (raccoon) be combined with the old dataset of the pre-trained model?
- xml_to_csv.py error index is out of range HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from raccoon_dataset.