YOLOv6 icon indicating copy to clipboard operation
YOLOv6 copied to clipboard

Resume command Doesn't Work

Open yuvrajhembade opened this issue 2 years ago • 8 comments

I have even tried several solutions suggested earlier but that doesn't help, Error is as below.....

Traceback (most recent call last): File "tools/train.py", line 114, in main(args) File "tools/train.py", line 103, in main trainer = Trainer(args, cfg, device) File "/content/drive/MyDrive/Projects/YOLOv6/yolov6/core/engine.py", line 63, in init self.optimizer.load_state_dict(self.ckpt['optimizer']) File "/usr/local/lib/python3.7/dist-packages/torch/optim/optimizer.py", line 159, in load_state_dict saved_groups = state_dict['param_groups'] **

TypeError: 'NoneType' object is not subscriptable

**

yuvrajhembade avatar Aug 01 '22 07:08 yuvrajhembade

Thanks for your attentions! What is your resume command?

khwengXU avatar Aug 01 '22 07:08 khwengXU

Thanks for your attention! What is your resume command?

!python tools/train.py --resume runs/train/exp2/weights/best_ckpt.pt

yuvrajhembade avatar Aug 01 '22 08:08 yuvrajhembade

Are you resuming from the last checkpoint? Since last checkpoint does not contain optimizer parameters, we cannot resume from the last checkpoint. If you want finetuning, you can add the model path here https://github.com/meituan/YOLOv6/blob/5f00d8bf374d9f2cd01cc8ab9a4204ce37d66186/configs/yolov6s.py#L4

mtjhl avatar Aug 02 '22 02:08 mtjhl

Are you resuming from the last checkpoint? Since last checkpoint does not contain optimizer parameters, we cannot resume from the last checkpoint. If you want finetuning, you can add the model path here

https://github.com/meituan/YOLOv6/blob/5f00d8bf374d9f2cd01cc8ab9a4204ce37d66186/configs/yolov6s.py#L4

If we cant resume from the last ckpt then it means we have to retrain & past learning is completely lost? So isn't it like we can't resume?

yuvrajhembade avatar Aug 02 '22 04:08 yuvrajhembade

This. It should be fixed

sarmientoj24 avatar Aug 04 '22 07:08 sarmientoj24

This. It should be fixed

But Exactly How, I have tried several ways to do that, If we modify weights in finetune.py with best ckpt of our training results then further training goes vegue. So it's like not able to resume in true sense. Error that blows is about not finding optimizer in ckpts generated by the model, if that would be resolved then probably we could resume training.

yuvrajhembade avatar Aug 04 '22 07:08 yuvrajhembade

strip_optimizer()函数有问题 : for k in ['optimizer', 'ema', 'updates']: # keys ckpt[k] = None 注释一下 问题解决。

adduu345 avatar Aug 18 '22 01:08 adduu345

This method worked for me In yolov6s_finetune.py you should edit pretrained = '/path/to/the/last_ckpt.pt' example pretrained='./runs/train/exp/weights/last_ckpt.pt', then run command

!python tools/train.py --conf configs/yolov6s_finetune.py #--params_u_need_put here it will create new folder (./runs/train/exp1) and every time you want to train, should replace new last_ckpt.pt path in yolov6s_finetune.py example pretrained='./runs/train/exp1/weights/last_ckpt.pt', pretrained='./runs/train/exp2/weights/last_ckpt.pt', pretrained='./runs/train/exp3/weights/last_ckpt.pt' and so on Hope it will help u

ken2190 avatar Aug 20 '22 09:08 ken2190

@ken2190 , fixed it replacing pretrained='weights/yolov6s.pt' by pretrained='./runs/train/exp/weights/last_ckpt.pt'`, Thanks!

np-n avatar Dec 13 '22 05:12 np-n