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.25k stars 1.24k forks source link

Error converting gray-scale (1 channel) yolo4 model #293

Open PatrikPatrik2 opened 3 years ago

PatrikPatrik2 commented 3 years ago

I have trained a 1 channel yolo4 model and verified that it is working. However, when I run python save_model.py --weights ./data/yolov4_1Chanell.weights --output ./checkpoints/yolov4-416 --input_size 416 --model yolov4

I get this error File "save_model.py", line 58, in <module> app.run(main) File "C:\Users\patri\miniconda3\envs\yolov4-gpu-deepsort\lib\site-packages\absl\app.py", line 300, in run _run_main(main, args) File "C:\Users\patri\miniconda3\envs\yolov4-gpu-deepsort\lib\site-packages\absl\app.py", line 251, 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 "C:\Users\patri\yolov4-Orginal\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 4591671 into shape (1024,512,3,3)

what is causing the error?

chairiq commented 3 years ago

is there any solution? I have similar problem.

ThurgaShri commented 3 years ago

In save_model.py, you will have to change your input_layer channel from 3 to 1. This works for me. input_layer = tf.keras.layers.Input([FLAGS.input_size, FLAGS.input_size, 1])