-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
ValueError: cannot reshape array of size 2048 into shape (18,1024,1,1) #147
Comments
Me as well, but with yolov4-tiny! |
@vladimirhorvat I am able to successfully do the conversion but using below repository- |
Thank you. It's a good lead, although it doesn't work for tiny. |
Any resolutions to this. My change from the default instructions at https://github.com/AlexeyAB/darknet#how-to-train-to-detect-your-custom-objects is to also include the changes recommended in "for training for small objects" which is part of https://github.com/AlexeyAB/darknet#how-to-improve-object-detection |
@tobymcclean I recommend you to use following repo- The author of above repo is more active and replies asap. With this repo, I am able to convert my custom YOLOv4 into keras model. |
I've just got exactly the same issue trying to convert tiny weights file trained with custom dataset following the instructions at https://github.com/AlexeyAB/darknet#how-to-train-to-detect-your-custom-objects and to convert weights to checkpoint I defined class list in the file data/classes/custom.names (one class per line) and pointed the code to use this classes here: https://github.com/hunglc007/tensorflow-yolov4-tflite/blob/master/core/config.py#L14 |
I can confirm this is the solution - @hunglc007 please add command line argument support inorder to provide classnames to avoid future issues |
Getting the same issue but not still resolved by me. Any suggestions? |
me to #193 |
Thanks, this work for me! |
Please could you detail a bit more this? Is just to change the default coco.names with your own one? |
Maybe it because of the absolute path makes things work. |
Thank you. Conversion and inference worked for me after correcting this. |
Supposing you're using Colab this command modifies the file name |
When train darknet,did you edit your custom *.cfg based on yolov4-custom.cfg instead of yolov4.cfg? There are some different in these two cfg data. You can edit your custom cfg based on yolov4.cfg and train again,that is how I solve the issue. |
try to check class names defines properly |
More updated code hosted by theAIGuysCode https://github.com/theAIGuysCode/tensorflow-yolov4-tflite. Has the instructions with images on what to change for the names when custom training. |
I still don't understand how to solve this problem, can anyone explain it to me? Thanks |
I had the same question like this,I tried all the suggestion above this coment,but still not got solved.... |
I used black and white images to train, which means that I had to change the channel number to 1 in input_layer, line 19 in save_model.py:
|
Simple solution __C = edict() Consumers can get config by: from config import cfgcfg = __C YOLO options__C.YOLO = edict() __C.YOLO.CLASSES = "./data/classes/coco.names" Train options__C.TRAIN = edict() __C.TRAIN.ANNOT_PATH = "./data/dataset/val2017.txt" __C.TRAIN.INPUT_SIZE = [320, 352, 384, 416, 448, 480, 512, 544, 576, 608]__C.TRAIN.INPUT_SIZE = 416 TEST options__C.TEST = edict() __C.TEST.ANNOT_PATH = "./data/dataset/val2017.txt" |
Thanks a lot!
Joel Jacob ***@***.***> 於 2022年3月30日 週三 15:46 寫道:
… Hi,
I am trying to convert my custom YOLOv4 weights to TF using below command- python
save_model.py --weights ./data/yolo-obj_best.weights --output
./checkpoints/yolov4-704 --input_size 704 --model yolov4
But getting below error- File "save_model.py", line 58, in <module>
app.run(main) File "/usr/local/lib/python3.6/dist-packages/absl/app.py",
line 299, in run _run_main(main, args) File
"/usr/local/lib/python3.6/dist-packages/absl/app.py", line 250, in
_run_main sys.exit(main(argv)) File "save_model.py", line 54, in main
save_tf() File "save_model.py", line 49, in save_tf
utils.load_weights(model, FLAGS.weights, FLAGS.model, FLAGS.tiny) File
"/content/drive/My Drive/kaggle/tensorflow-yolov4-tflite/core/utils.py",
line 63, in load_weights conv_weights =
conv_weights.reshape(conv_shape).transpose([2, 3, 1, 0]) ValueError: cannot
reshape array of size 2048 into shape (18,1024,1,1)
I have only one class in my data/classes/obj.names file- obj.txt
<https://github.com/hunglc007/tensorflow-yolov4-tflite/files/4924125/obj.txt>
Please suggest how to solve this error.
I was facing the same error, I checked my config file where mistakenly
changed the default number of filters, the default was 32 and I changed it
to 21, when I corrected that, I was able to convert the model into
tensorflow. Hope this helps.
—
Reply to this email directly, view it on GitHub
<#147 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ATUJXHYAG27RPRVUS66YJMTVCQBDTANCNFSM4O2KWYCA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Hi, thanks for the solution purposed. |
Hi, thanks for the solution purposed. |
In |
Hi,
I am trying to convert my custom YOLOv4 weights to TF using below command-
python save_model.py --weights ./data/yolo-obj_best.weights --output ./checkpoints/yolov4-704 --input_size 704 --model yolov4
But getting below error-
File "save_model.py", line 58, in <module> app.run(main) File "/usr/local/lib/python3.6/dist-packages/absl/app.py", line 299, in run _run_main(main, args) File "/usr/local/lib/python3.6/dist-packages/absl/app.py", line 250, in _run_main sys.exit(main(argv)) File "save_model.py", line 54, in main save_tf() File "save_model.py", line 49, in save_tf utils.load_weights(model, FLAGS.weights, FLAGS.model, FLAGS.tiny) File "/content/drive/My Drive/kaggle/tensorflow-yolov4-tflite/core/utils.py", line 63, in load_weights conv_weights = conv_weights.reshape(conv_shape).transpose([2, 3, 1, 0]) ValueError: cannot reshape array of size 2048 into shape (18,1024,1,1)
I have only one class in my data/classes/obj.names file-
obj.txt
Please suggest how to solve this error.
The text was updated successfully, but these errors were encountered: