thtrieu / darkflow

Translate darknet to tensorflow. Load trained weights, retrain/fine-tune using tensorflow, export constant graph def to mobile devices
GNU General Public License v3.0
6.13k stars 2.08k forks source link

AssertionError: labels.txt and yolov2-tiny.cfg indicate inconsistent class numbers #1166

Open mustansarsaeed opened 4 years ago

mustansarsaeed commented 4 years ago

Hi,

I am trying to converts yolov2 weights to tensorflow buffers using following command:

./flow --model yolov2-tiny.cfg^C-load yolov2-tiny.weights --savepb

yolov2-tiny.cfg

[net]
# Testing
batch=1
subdivisions=1
# Training
# batch=64
# subdivisions=2
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
burn_in=1000
max_batches = 500200
policy=steps
steps=400000,450000
scales=.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=512
activation=leaky

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

[region]
anchors =  0.57273, 0.677385, 1.87446, 2.06253, 3.33843, 5.47434, 7.88282, 3.52778, 9.77052, 9.16828
bias_match=1
classes=80
coords=4
num=5
softmax=1
jitter=.2
rescore=0

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

absolute=1
thresh = .6
random=1

labels

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

But I am getting following error:

Traceback (most recent call last):
  File "./flow", line 6, in <module>
    cliHandler(sys.argv)
  File "/home/mustansar/Softwares/darkflow/darkflow/cli.py", line 26, in cliHandler
    tfnet = TFNet(FLAGS)
  File "/home/mustansar/Softwares/darkflow/darkflow/net/build.py", line 64, in __init__
    self.framework = create_framework(*args)
  File "/home/mustansar/Softwares/darkflow/darkflow/net/framework.py", line 59, in create_framework
    return this(meta, FLAGS)
  File "/home/mustansar/Softwares/darkflow/darkflow/net/framework.py", line 15, in __init__
    self.constructor(meta, FLAGS)
  File "/home/mustansar/Softwares/darkflow/darkflow/net/yolo/__init__.py", line 24, in constructor
    ).format(meta['model'])
AssertionError: labels.txt and yolov2-tiny.cfg indicate inconsistent class numbers

What can be the issue?

Regards

utsav003 commented 4 years ago

Please do copy the whole cfg file to new file and rename file name and will solve the issue. As currently it is taking default labels for the cfg file you have added and the mentioned label as well

WesleyFrancis commented 10 months ago

how did you all get darkflow to complie? what os and packages are you all using to compile. I keep getting errors concerning cython

darkflow/cython_utils/cy_yolo2_findboxes.pyx:97:11: 'NMS' is not a constant, variable or function identifier Traceback (most recent call last): File "/content/darkflow/setup.py", line 73, in ext_modules = cythonize(ext_modules) File "/usr/local/lib/python3.10/dist-packages/Cython/Build/Dependencies.py", line 1154, in cythonize cythonize_one(*args) File "/usr/local/lib/python3.10/dist-packages/Cython/Build/Dependencies.py", line 1321, in cythonize_one raise CompileError(None, pyx_file) Cython.Compiler.Errors.CompileError: darkflow/cython_utils/cy_yolo2_findboxes.pyx

ferozkhanabbasi commented 10 months ago

getting same error

darkflow\cython_utils\cy_yolo2_findboxes.pyx:97:11: 'NMS' is not a constant, variable or function identifier Traceback (most recent call last): File "setup.py", line 73, in ext_modules = cythonize(ext_modules) File "C:\Users\feroz\anaconda3\envs\darkflow_env\lib\site-packages\Cython\Build\Dependencies.py", line 1154, in cythonize cythonize_one(*args) File "C:\Users\feroz\anaconda3\envs\darkflow_env\lib\site-packages\Cython\Build\Dependencies.py", line 1321, in cythonize_one raise CompileError(None, pyx_file) Cython.Compiler.Errors.CompileError: darkflow/cython_utils/cy_yolo2_findboxes.pyx