Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

csd = ckpt['model'].float().state_dict() #5

Closed
gav1n-cheung opened this issue Apr 11, 2022 · 2 comments
Closed

csd = ckpt['model'].float().state_dict() #5

gav1n-cheung opened this issue Apr 11, 2022 · 2 comments

Comments

@gav1n-cheung
Copy link

gav1n-cheung commented Apr 11, 2022

hey,dude.I find you are the only one to train imagenet in yolov5.
I wanna to use your pretrained model in yolov5 for object detecting.
But it cann't take it in raw yolov5?

python train.py --data tinyObject.yaml --cfg ./models/yolov5m.yaml  --weights darknet_yolov5m-a1eb31bd.pt

error:  File "train.py", line 123, in train
    csd = ckpt['model'].float().state_dict()  # checkpoint state_dict as FP32
KeyError: 'model'

So what can I do to edit backbone net?

@gau-nernst
Copy link
Owner

You need to rename the weights appropriately since the PyTorch model definition is different. You may need to add some extra wrapper to conform to what YOLOv5 train script expects. For example, it seems like the train script expects a checkpoint file, with a key model.

If you want to train a YOLOv5 object detector, I recommend you to use their pre-trained weights on COCO. Unless you have specific needs, using their COCO pre-trained weights will be better.

@gav1n-cheung
Copy link
Author

You need to rename the weights appropriately since the PyTorch model definition is different. You may need to add some extra wrapper to conform to what YOLOv5 train script expects. For example, it seems like the train script expects a checkpoint file, with a key model.

If you want to train a YOLOv5 object detector, I recommend you to use their pre-trained weights on COCO. Unless you have specific needs, using their COCO pre-trained weights will be better.

Thanks a lot, I have to get the dectecter without COCO pretrained.Maybe yolo don't suit currnet apply.
But thanks your comment!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants