yjh0410 / RT-ODLab

YOLO Tutorial
MIT License
136 stars 29 forks source link

the yolo v1 backbone pretrained param load error #12

Closed sixone-Jiang closed 8 months ago

sixone-Jiang commented 8 months ago

When load the pretrain resnet18, like: Capture how can I fix it?

sixone-Jiang commented 8 months ago

I don`t know if I use 'strict=False' when load checkpoint is OK? or may be I should compare the param dict structure difference ?

yjh0410 commented 8 months ago

@sixone-Jiang These error won't happen in my models/detectors/yolov1/yolov1_backbone.py. You can refer to my code to check if there are bugs in your code. Maybe stride=False can work as I used it in my code.

sixone-Jiang commented 8 months ago

Thanks for your reply, I just try to refer your code, but these bugs still occurs; In my view, may be I use torch version ''2.0.1+cu117'' have some deference with your default version '1.9.1'?

yjh0410 commented 8 months ago

@sixone-Jiang The version of torch is fine. I suggest you to check the class ResNet() and def build_resnet18() in my models/detectors/yolov1/yolov1_backbone.py file. In my code file, I have remove the self.avgpool and self.fc which are defined in the official ResNet(torchvision), so I have to set strict=False in my def build_resnet18(). I think this difference might be essential for your problem.

sixone-Jiang commented 8 months ago

@yjh0410 Thanks!