Hi when I write
python train.py --img 640 --batch 2 --epochs 300 --data ./data/coco128.yaml --cfg ./models/yolov5s.yaml
I have no problem and can train model bu when I add weights to initialize it like buttom I have an error
python train.py --img 640 --batch 2 --epochs 300 --data ./data/coco128.yaml --cfg ./models/yolov5s.yaml --weights yolov5s.pt --noautoanchor
this is my error
train(hyp, tb_writer, opt, device)
File "train.py", line 127, in train
ckpt['model'] = {k: v for k, v in ckpt['model'].float().state_dict().items()
File "/home/mojtaba/virtualenvironment/project_1/lib/python3.6/site-packages/torch/nn/modules/module.py", line 900, in state_dict
module.state_dict(destination, prefix + name + '.', keep_vars=keep_vars)
File "/home/mojtaba/virtualenvironment/project_1/lib/python3.6/site-packages/torch/nn/modules/module.py", line 900, in state_dict
module.state_dict(destination, prefix + name + '.', keep_vars=keep_vars)
File "/home/mojtaba/virtualenvironment/project_1/lib/python3.6/site-packages/torch/nn/modules/module.py", line 900, in state_dict
module.state_dict(destination, prefix + name + '.', keep_vars=keep_vars)
[Previous line repeated 1 more time]
File "/home/mojtaba/virtualenvironment/project_1/lib/python3.6/site-packages/torch/nn/modules/module.py", line 897, in state_dict
self._save_to_state_dict(destination, prefix, keep_vars)
File "/home/mojtaba/virtualenvironment/project_1/lib/python3.6/site-packages/torch/nn/modules/module.py", line 860, in _save_to_state_dict
if buf is not None and name not in self._non_persistent_buffers_set:
File "/home/mojtaba/virtualenvironment/project_1/lib/python3.6/site-packages/torch/nn/modules/module.py", line 772, in __getattr__
type(self).__name__, name))
torch.nn.modules.module.ModuleAttributeError: 'BatchNorm2d' object has no attribute '_non_persistent_buffers_set'
what should I do?I have this problem in uubntu18 . in windows no problem.
@123456789mojtaba _non_persistent_buffers_set is a new module attribute that pytorch 1.6 requires. If you are seeing this message this means that you are attempting to load a model trained with an earlier version of pytorch. You should start with a blank slate: delete your older models and reclone a fresh copy of yolov5, and everything will work correctly.
NOTE: The YOLOv5 autodownload functionality will only download new models if it does not find a local copy. It does not check versions, so even if your models are out of date it will not automatically replace them.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Most helpful comment
@123456789mojtaba
_non_persistent_buffers_setis a new module attribute that pytorch 1.6 requires. If you are seeing this message this means that you are attempting to load a model trained with an earlier version of pytorch. You should start with a blank slate: delete your older models and reclone a fresh copy of yolov5, and everything will work correctly.NOTE: The YOLOv5 autodownload functionality will only download new models if it does not find a local copy. It
does not check versions, so even if your models are out of date it will not automatically replace them.