hhk7734 / tensorflow-yolov4

YOLOv4 Implemented in Tensorflow 2.
MIT License
136 stars 75 forks source link

ValueError: Model and weights file do not match. #37

Closed lidorshimoni closed 3 years ago

lidorshimoni commented 3 years ago

I'm suddenly getting this error... but it worked for me before with the same weights file. using yolov4-tiny

ValueError: Model and weights file do not match.

lidorshimoni commented 3 years ago

even with new and unchanged yolov4.weights and coco.names files, it raises the same exception.

hhk7734 commented 3 years ago

Can you share your script?

Gabrielopesantos commented 3 years ago

I'm getting the same error with yolov4 and yolov4-tiny. I'm using the "tutorial" script present on the documentation page.

hhk7734 commented 3 years ago
from yolov4.tf import YOLOv4

yolo = YOLOv4()
# yolo = YOLOv4(tiny=True)

yolo.classes = "coco.names"
yolo.input_size = (640, 480)

yolo.make_model()
yolo.load_weights("yolov4.weights", weights_type="yolo")
# yolo.load_weights("yolov4-tiny.weights", weights_type="yolo")

yolo.inference(media_path="kite.jpg")

yolo.inference(media_path="road.mp4", is_image=False)

is it?

Gabrielopesantos commented 3 years ago

Yes. I did a little investigation and at some point the length of the data read from the weights file is different from the count (darknet shape product).

hhk7734 commented 3 years ago

Check version.

python3 -m pip show yolov4

Name: yolov4
Version: 2.0.0
...

And try this.

from yolov4.tf import YOLOv4

yolo = YOLOv4(tiny=True)
yolo.classes = "coco.names"
assert(len(yolo.classes) == 80)
yolo.input_size = (640, 480)

yolo.make_model()
yolo.load_weights("yolov4-tiny.weights", weights_type="yolo")
yolo.inference("kite.jpg")
Gabrielopesantos commented 3 years ago

Problem solved, thanks. The error was in my coco.names file.

hhk7734 commented 3 years ago

@lidorshimoni Closed because there is no answer for a long time.