theAIGuysCode / Object-Detection-API

Yolov3 Object Detection implemented as APIs, using TensorFlow and Flask
Apache License 2.0
339 stars 179 forks source link

Unable to convert weights file into tf #7

Open cat768 opened 4 years ago

cat768 commented 4 years ago

my custom weights file is junglecamp0.6.weights, based on yolov3 (not yolov3-tiny) 31 classes

When I run the command " python load_weights.py --weights ./weights/junglecamp0.6.weights --output ./weights/junglecamp0.6.tf " it gives me the following error message:

ValueError: cannot reshape array of size 76070 into shape (256,128,3,3)

cat768 commented 4 years ago

image

cat768 commented 4 years ago

Here is my cfg file:

junglecamp0.5.txt

(saved it to a txt file instead of cfg because github won't allow me to upload cfg)

safayildirim commented 4 years ago

You should provide number of custom classes you have as parameters.

cat768 commented 4 years ago

You should provide number of custom classes you have as parameters.

How do I do that? (I have 31 classes)

ejri commented 4 years ago
Screen Shot 2020-06-22 at 1 59 21 AM

in the load_weights.py file, change the number of classes from 80 to 31 in your case.

Also make sure to make the changes in app.py and detect.py

Screen Shot 2020-06-22 at 2 19 29 AM Screen Shot 2020-06-22 at 2 19 14 AM
Shreyas0812 commented 4 years ago

I did this, but got the same error...

Object-Detection-API/yolov3_tf2/utils.py", line 68, in load_darknet_weights conv_shape).transpose([2, 3, 1, 0]) ValueError: cannot reshape array of size 209204 into shape (512,256,3,3)

Zwj321123 commented 3 years ago
Screen Shot 2020-06-22 at 1 59 21 AM

in the load_weights.py file, change the number of classes from 80 to 31 in your case.

Also make sure to make the changes in app.py and detect.py

Screen Shot 2020-06-22 at 2 19 29 AM Screen Shot 2020-06-22 at 2 19 14 AM

This works for me! Thank you!