Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AssertionError: labels.txt and cfg/yolov2.cfg indicate inconsistent class numbers #790

Open
zef1611 opened this issue Jun 5, 2018 · 9 comments

Comments

@zef1611
Copy link

zef1611 commented Jun 5, 2018

so i try to use the code from https://github.com/markjay4k/YOLO-series/blob/master/part2%20-%20Processing%20Images%20with%20YOLO%20and%20openCV.ipynb
and i try to change yolo.cfg to yolov2.cfg and then this error appears can someone please help me

@keides2
Copy link

keides2 commented Jun 21, 2018

I have the same issue.
Did you create weights file using darknet?
I did it.

@ss199302
Copy link

ss199302 commented Dec 6, 2018

@keides2 hello, I create weights file using darknet,then AssertionError: labels.txt and cfg/yolov2.cfg indicate inconsistent class numbers,can i solve this question?

@keides2
Copy link

keides2 commented Dec 6, 2018

@ss199302 Hi, Does the number of classes of objects described in labes.txt match with the number of classes described on line 244 of cfg / yolov2.cfg?

@abecus
Copy link

abecus commented Dec 19, 2018

if you are using dark flow then,
copy this:-

person
bicycle
car
motorbike
aeroplane
bus
train
truck
boat
traffic light
fire hydrant
stop sign
parking meter
bench
bird
cat
dog
horse
sheep
cow
elephant
bear
zebra
giraffe
backpack
umbrella
handbag
tie
suitcase
frisbee
skis
snowboard
sports ball
kite
baseball bat
baseball glove
skateboard
surfboard
tennis racket
bottle
wine glass
cup
fork
knife
spoon
bowl
banana
apple
sandwich
orange
broccoli
carrot
hot dog
pizza
donut
cake
chair
sofa
pottedplant
bed
diningtable
toilet
tvmonitor
laptop
mouse
remote
keyboard
cell phone
microwave
oven
toaster
sink
refrigerator
book
clock
vase
scissors
teddy bear
hair drier
toothbrush

--
till toothbrush.
copied from coco.names from cfg folder
and it worked for me.

@carlchandev
Copy link

if you are using dark flow then,

copy this:-
person
bicycle
car
motorbike
aeroplane
bus
train
truck
boat
traffic light
fire hydrant
stop sign
parking meter
bench
bird
cat
dog
horse
sheep
cow
elephant
bear
zebra
giraffe
backpack
umbrella
handbag
tie
suitcase
frisbee
skis
snowboard
sports ball
kite
baseball bat
baseball glove
skateboard
surfboard
tennis racket
bottle
wine glass
cup
fork
knife
spoon
bowl
banana
apple
sandwich
orange
broccoli
carrot
hot dog
pizza
donut
cake
chair
sofa
pottedplant
bed
diningtable
toilet
tvmonitor
laptop
mouse
remote
keyboard
cell phone
microwave
oven
toaster
sink
refrigerator
book
clock
vase
scissors
teddy bear
hair drier
toothbrush

--
till toothbrush.
copied from coco.names from cfg folder
and it worked for me.

THANKS MAN!! This works for me. I spent like 2 hours to find this.

@Narayanprasai
Copy link

I used my own dataset to train model in darkflow which contains 7 classes and i have mentioned those classes in labels.txt as well. I've changed the no. of filters to 60 and classes to 7 in .cfg file as well but even though I'm having an error. Which reads:

Parsing ./cfg/yolo.cfg
Parsing cfg/yolo-7c.cfg
Loading bin/yolo.weights ...
Successfully identified 203934260 bytes
Finished in 0.006638526916503906s
Traceback (most recent call last):
File "/home/mirait/anaconda3/envs/test/bin/flow", line 6, in
exec(compile(open(file).read(), file, 'exec'))
File "/home/mirait/Desktop/cvyolo/darkflow/flow", line 6, in
cliHandler(sys.argv)
File "/home/mirait/Desktop/cvyolo/darkflow/darkflow/cli.py", line 26, in cliHandler
tfnet = TFNet(FLAGS)
File "/home/mirait/Desktop/cvyolo/darkflow/darkflow/net/build.py", line 64, in init
self.framework = create_framework(*args)
File "/home/mirait/Desktop/cvyolo/darkflow/darkflow/net/framework.py", line 59, in create_framework
return this(meta, FLAGS)
File "/home/mirait/Desktop/cvyolo/darkflow/darkflow/net/framework.py", line 15, in init
self.constructor(meta, FLAGS)
File "/home/mirait/Desktop/cvyolo/darkflow/darkflow/net/yolo/init.py", line 24, in constructor
).format(meta['model'])
AssertionError: labels.txt and cfg/yolo-7c.cfg indicate inconsistent class numbers

@Narayanprasai
Copy link

Narayanprasai commented Mar 9, 2020

my cfg file is:

[net]
batch=64
subdivisions=8
width=416
height=416
channels=3
momentum=0.9
decay=0.0005
angle=0
saturation = 1.5
exposure = 1.5
hue=.1

learning_rate=0.001
max_batches = 40100
policy=steps
steps=-1,100,20000,30000
scales=.1,10,.1,.1

[convolutional]
batch_normalize=1
filters=16
size=3
stride=1
pad=1
activation=leaky

[maxpool]
size=2
stride=2

[convolutional]
batch_normalize=1
filters=32
size=3
stride=1
pad=1
activation=leaky

[maxpool]
size=2
stride=2

[convolutional]
batch_normalize=1
filters=64
size=3
stride=1
pad=1
activation=leaky

[maxpool]
size=2
stride=2

[convolutional]
batch_normalize=1
filters=128
size=3
stride=1
pad=1
activation=leaky

[maxpool]
size=2
stride=2

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[maxpool]
size=2
stride=2

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[maxpool]
size=2
stride=1

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

###########

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=1024
activation=leaky

[convolutional]
size=1
stride=1
pad=1
filters=60
activation=linear

[region]
anchors = 1.08,1.19, 3.42,4.41, 6.63,11.38, 9.42,5.11, 16.62,10.52
bias_match=1
classes=7
coords=4
num=5
softmax=1
jitter=.2
rescore=1

object_scale=5
noobject_scale=1
class_scale=1
coord_scale=1

absolute=1
thresh = .5
random=1

my labels.txt file contains:
1.bear
2.boar
3.cat
4.crow
5.deer
6.dog
7.monkey

but i'm getting error which reads:

AssertionError: labels.txt and cfg/tiny-yolo-voc-7c.cfg indicate inconsistent class numbers

@ozanpkr
Copy link

ozanpkr commented Apr 11, 2020

my cfg file is:

[net]
batch=64
subdivisions=8
width=416
height=416
channels=3
momentum=0.9
decay=0.0005
angle=0
saturation = 1.5
exposure = 1.5
hue=.1

learning_rate=0.001
max_batches = 40100
policy=steps
steps=-1,100,20000,30000
scales=.1,10,.1,.1

[convolutional]
batch_normalize=1
filters=16
size=3
stride=1
pad=1
activation=leaky

[maxpool]
size=2
stride=2

[convolutional]
batch_normalize=1
filters=32
size=3
stride=1
pad=1
activation=leaky

[maxpool]
size=2
stride=2

[convolutional]
batch_normalize=1
filters=64
size=3
stride=1
pad=1
activation=leaky

[maxpool]
size=2
stride=2

[convolutional]
batch_normalize=1
filters=128
size=3
stride=1
pad=1
activation=leaky

[maxpool]
size=2
stride=2

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[maxpool]
size=2
stride=2

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[maxpool]
size=2
stride=1

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

###########

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=1024
activation=leaky

[convolutional]
size=1
stride=1
pad=1
filters=60
activation=linear

[region]
anchors = 1.08,1.19, 3.42,4.41, 6.63,11.38, 9.42,5.11, 16.62,10.52
bias_match=1
classes=7
coords=4
num=5
softmax=1
jitter=.2
rescore=1

object_scale=5
noobject_scale=1
class_scale=1
coord_scale=1

absolute=1
thresh = .5
random=1

my labels.txt file contains:
1.bear
2.boar
3.cat
4.crow
5.deer
6.dog
7.monkey

but i'm getting error which reads:

AssertionError: labels.txt and cfg/tiny-yolo-voc-7c.cfg indicate inconsistent class numbers

Hi brother,
I solved that.You can solve that with change coco.names .Because it used coco.names for get labels sometimes.Just open coc.names ,delete all and put your labels like label.txt structures

@rfernandezv
Copy link

I solved that.You can solve that with change coco.names .Because it used coco.names for get labels sometimes.Just open coc.names ,delete all and put your labels like label.txt structures

This works for me. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants