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

ValueError: cannot reshape array of size 4571650 into shape (1024,512,3,3) #28

Closed stoneWeb closed 3 years ago

stoneWeb commented 3 years ago

python convert_weights_pb.py --class_names models/self_make.names --weights_file models/self_make-yolov4_last.weights --data_format NHWC --size 608

My model cannot be converted and has been subject to this error:

File "/xxx/OpenVINO-YOLOV4/utils.py", line 115, in load_weights (shape[3], shape[2], shape[0], shape[1]))
ValueError: cannot reshape array of size 4571650 into shape (1024,512,3,3)
TNTWEN commented 3 years ago

Have you modified the yolov4‘s model structure?

stoneWeb commented 3 years ago

I only modified:

max_batches
steps
[convolutional]
filter=81
[yolo]
classes=22

I didn't change much. Why?

TNTWEN commented 3 years ago

Training parameters at the beginning of .cfg file, [yolo] and [convolutional] before every [yolo] layer could be modified. If you changed other parts, ValueError will occur

Someone had a similar situation before. He mistakenly modified the filter of one more convolution layer.

You could check .cfg file ,make sure .names , .weights , .cfg are all correct.

Or you could try https://github.com/TNTWEN/OpenVINO-YOLO-Automatic-Generation

stoneWeb commented 3 years ago

I tried to download the new yolov4.cfg file and modify it. I passed the training again.

stoneWeb commented 3 years ago

I successfully converted the IR model with convert_weights_pb.py and got the xml and bin file. but I tried to run object_detection_demo_yolov3_async.py and got the following error:

out_blob = out_blob.buffer.reshape(output_shape)
ValueError: cannot reshape array of size 689520 into shape (1,93,52,52)
TNTWEN commented 3 years ago

Have you modified https://github.com/TNTWEN/OpenVINO-YOLOV4/blob/18e908e4e5e50ae43e2d8cc25a0450f3030b9f25/yolov4.json#L6

stoneWeb commented 3 years ago

Thank you so much. My problem is solved. but why does the bounding box get bigger when I convert it to IR?

TNTWEN commented 3 years ago

Different frameworks have different inference methods, and it is normal to have slightly different output results. It may also have something to do with the dataset and the training process. I'm sorry that I didn't encounter the situation you encountered in my test