sicara / tf2-yolov4

A TensorFlow 2.0 implementation of YOLOv4: Optimal Speed and Accuracy of Object Detection

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Loading weight file containing 217 layers into a model with 3 layers

flixmk opened this issue · comments

Hello Guys! I have trained a Yolov4 model and I got the .weights file back. I am trying to convert the file into .h5 but there is my first Problem.
This is the error message that I get back when trying to convert to .h5. Does anybody know why this might occur?
"ValueError: cannot reshape array of size 4554552 into shape (1024,512,3,3)"

Anyways I found another way to get my file into the .h5 format. But is there the possibility that the 2 different converters are returning different results since I now get this error when trying to create a YOLOv4 Model:
"ValueError: You are trying to load a weight file containing 217 layers into a model with 3 layers."

This is the code that threw the error:

model = YOLOv4( input_shape=(HEIGHT, WIDTH, 3), anchors=YOLOV4_ANCHORS, num_classes=1, training=False, yolo_max_boxes=50, yolo_iou_threshold=0.5, yolo_score_threshold=0.5, )

As you can see I have changed the number of classes but nothing else.

Might the other used converter be the reason for this problem or is there something that I am missing?
Please help me out :D

have you been able to solve this issue? if not...
I had the same problem... turns out that for some reason, yolov4 wieghts have to be placed in home directory, also you need to flag explicitly how many classes are there as shown in image, I have only one class so "-n 1" at the end...

i converted them using gpu on colab and also a vmware virtual machine with ubuntu 18/python 3.6.

edit: I used colab without gpu
image