TNTWEN / OpenVINO-YOLOV4

This is implementation of YOLOv4,YOLOv4-relu,YOLOv4-tiny,YOLOv4-tiny-3l,Scaled-YOLOv4 and INT8 Quantization in OpenVINO2021.3
MIT License
238 stars 66 forks source link

cannot reshape array #9

Closed devipramita closed 4 years ago

devipramita commented 4 years ago

Hi,

I'm trying to convert darknet weights into pb model, but I got this error on reshaping array.

I tried yolov4-tiny.weights and coco.names

Traceback (most recent call last): File "convert_weights_pb.py", line 52, in
tf.app.run()
File "C:\Users\Asus\Anaconda3\envs\env-openvino\lib\site-packages\tensorflow\python\platform\app.py", line 40, in run _run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
File "C:\Users\Asus\Anaconda3\envs\env-openvino\lib\site-packages\absl\app.py", line 300, in run _run_main(main, args)
File "C:\Users\Asus\Anaconda3\envs\env-openvino\lib\site-packages\absl\app.py", line 251, in _run_main sys.exit(main(argv))
File "convert_weights_pb.py", line 42, in main
load_ops = load_weights(tf.global_variables(scope='detector'), FLAGS.weights_file)
File "D:\ds\prosa\OpenVINO-YOLOV4\utils.py", line 117, in load_weights
(shape[3], shape[2], shape[0], shape[1]))
ValueError: cannot reshape array of size 554878 into shape (256,256,3,3)

I also got same error on reshaping array, when converting 1 class darknet weights model into pb model.

Would you help me what's going wrong? Thanks

TNTWEN commented 4 years ago

Hello! @devipramita which command did you use? python convert_weights_pb.py --class_names cfg/coco.names --weights_file yolov4-tiny.weights --data_format NHWC --tiny I think you may miss “--tiny"

lijunnankman commented 4 years ago

Hello! @TNTWEN I also meet same situation. I have trained a yolov4-tiny by myself dataset(image size is 608*608).But when I use the "convert_weights_pb.py" to convert. I got this error on reshaping array. Traceback (most recent call last): File "D:/summer/code_article/code/OpenVINO-YOLOV4/convert_weights_pb.py", line 52, in tf.app.run() File "C:\Users\jji\AppData\Roaming\Python\Python36\site-packages\tensorflow_core\python\platform\app.py", line 40, in run _run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef) File "C:\Users\jji\AppData\Roaming\Python\Python36\site-packages\absl\app.py", line 299, in run _run_main(main, args) File "C:\Users\jji\AppData\Roaming\Python\Python36\site-packages\absl\app.py", line 250, in _run_main sys.exit(main(argv)) File "D:/summer/code_article/code/OpenVINO-YOLOV4/convert_weights_pb.py", line 42, in main load_ops = load_weights(tf.global_variables(scope='detector'), FLAGS.weights_file) File "D:\summer\code_article\code\OpenVINO-YOLOV4\utils.py", line 115, in load_weights (shape[3], shape[2], shape[0], shape[1])) ValueError: cannot reshape array of size 446994 into shape (256,384,3,3)

I have write " tf.app.flags.DEFINE_bool('tiny', True, 'Use tiny version of YOLOv4')" in convert_weights_pb.py

TNTWEN commented 4 years ago

Hello!@lijunnankman https://github.com/TNTWEN/OpenVINO-YOLOV4/blob/534cca38d1e3bf95dce98daa216a57f62a2f83ce/convert_weights_pb.py#L24-L25 You also need to set --size 608

lijunnankman commented 4 years ago

yes, I also set.Can we keep touch in mail?My mail is :894855066@qq.com.Thanks a lot.

AlanHN commented 4 years ago

I meet this error too, but after I change the file cfg/coco.names, it works for me