hunglc007 / tensorflow-yolov4-tflite

YOLOv4, YOLOv4-tiny, YOLOv3, YOLOv3-tiny Implemented in Tensorflow 2.0, Android. Convert YOLO v4 .weights tensorflow, tensorrt and tflite
https://github.com/hunglc007/tensorflow-yolov4-tflite
MIT License
2.24k stars 1.24k forks source link

ValueError: cannot reshape array of size 30868 into shape (256,256,3,3) #115

Open rahuladiga opened 4 years ago

rahuladiga commented 4 years ago

Im getting this error while converting yolov4-tiny model to tflite Im using tensorflow 2.1 if any other information is required ill provide

Traceback (most recent call last): File "convert_tflite.py", line 111, in app.run(main) File "C:\Users\PC\AppData\Local\Programs\Python\Python36\lib\site-packages\absl\app.py", line 299, in run _run_main(main, args) File "C:\Users\PC\AppData\Local\Programs\Python\Python36\lib\site-packages\absl\app.py", line 250, in _run_main sys.exit(main(argv)) File "convert_tflite.py", line 106, in main save_tflite() File "convert_tflite.py", line 59, in save_tflite utils.load_weights(model, FLAGS.weights) File "C:\Users\PC\Desktop\tensorflow-yolov4-tflite-master\core\utils.py", line 121, in load_weights conv_weights = conv_weights.reshape(conv_shape).transpose([2, 3, 1, 0]) ValueError: cannot reshape array of size 30868 into shape (256,256,3,3)

hunglc007 commented 4 years ago

This issue are fixed in newest code

feizhouxiaozhu commented 4 years ago

This problem still exists

Ashwin-Ramesh2607 commented 4 years ago

@feizhouxiaozhu If you have trained a custom dataset (that has a different number of classes). Then you have to change the class names at data/classes/coco.names. This should fix the re-shape issues

jenapss commented 4 years ago

@Ashwin-Ramesh2607 Yeap, It works. You just delete all the class names in coco.names and then write your own classes. Thank you!

Lorenzo-azar commented 4 years ago

When I changed the classes it skipped the error but i got another error (yolo4 to tf):

Traceback (most recent call last): File "save_model.py", line 61, in app.run(main) File "/home/anaconda3/envs/yolov4-gpu/lib/python3.7/site-packages/absl/app.py", line 299, in run _run_main(main, args) File "/home/anaconda3/envs/yolov4-gpu/lib/python3.7/site-packages/absl/app.py", line 250, in _run_main sys.exit(main(argv)) File "save_model.py", line 57, in main save_tf() File "save_model.py", line 50, in save_tf utils.load_weights(model, FLAGS.weights, FLAGS.model, FLAGS.tiny) File "/home/tensorflow-yolov4-tflite/core/utils.py", line 65, in load_weights conv_weights = conv_weights.reshape(conv_shape).transpose([2, 3, 1, 0]) ValueError: cannot reshape array of size 16119 into shape (21,1024,1,1)

pengKiina commented 4 years ago

When I changed the classes it skipped the error but i got another error (yolo4 to tf):

Traceback (most recent call last): File "save_model.py", line 61, in app.run(main) File "/home/anaconda3/envs/yolov4-gpu/lib/python3.7/site-packages/absl/app.py", line 299, in run _run_main(main, args) File "/home/anaconda3/envs/yolov4-gpu/lib/python3.7/site-packages/absl/app.py", line 250, in _run_main sys.exit(main(argv)) File "save_model.py", line 57, in main save_tf() File "save_model.py", line 50, in save_tf utils.load_weights(model, FLAGS.weights, FLAGS.model, FLAGS.tiny) File "/home/tensorflow-yolov4-tflite/core/utils.py", line 65, in load_weights conv_weights = conv_weights.reshape(conv_shape).transpose([2, 3, 1, 0]) ValueError: cannot reshape array of size 16119 into shape (21,1024,1,1)

change in config.py C.YOLO.ANCHOR_PER_SCALE = 1.2 C.YOLO.IOU_LOSS_THRESH = 0.213