Tianxiaomo / pytorch-YOLOv4

PyTorch ,ONNX and TensorRT implementation of YOLOv4
Apache License 2.0
4.46k stars 1.49k forks source link

Use models.py to inference failed! #519

Open d5423197 opened 2 years ago

d5423197 commented 2 years ago

Hello Author:

Thanks for your contribution.

I have downloaded the pth file mentioned in README.md. I used it in models.py script but got below errors. image

Any help will be appreciated!

Shiny-ZhangXiXin commented 2 years ago

I have solved this problem, it seems to be an overlooked spelling problem. The main cause of the problem is the mismatch between the loaded pre-training model and the constructed network model. image Careful debugging of the code. In line 474, there is a network layer called neck in the model, but the layer in the pre-trained loaded model is called neek, so the inconsistency between the two causes the error message in the figure. So I replaced all self.neck with self.neek in the code: class Yolov4(nn.module): balabala (there should be three changes: line 422, line 425, line 446) Hope this can solve your problem ~