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

训练报错,请问如何解决? #21

Open
ouxiand opened this issue Aug 18, 2022 · 7 comments
Open

训练报错,请问如何解决? #21

ouxiand opened this issue Aug 18, 2022 · 7 comments

Comments

@ouxiand
Copy link

ouxiand commented Aug 18, 2022

报错信息:训练完成一次后出错,没生产pt文件,请问如何解决?
100%|█████████▉| 14.1M/14.1M [32:20<00:01, 10.3kB/s]
100%|██████████| 14.1M/14.1M [32:20<00:00, 13.4kB/s]
100%|██████████| 14.1M/14.1M [32:20<00:00, 7.63kB/s]

Traceback (most recent call last):
File "/detect/yolov5-car-plate/train.py", line 552, in
train(hyp, opt, device, tb_writer)
File "/detect/yolov5-car-plate/train.py", line 90, in train
ckpt = torch.load(weights, map_location=device) # load checkpoint
File "/root/anaconda3/lib/python3.9/site-packages/torch/serialization.py", line 607, in load
return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
File "/root/anaconda3/lib/python3.9/site-packages/torch/serialization.py", line 882, in _load
result = unpickler.load()
File "/root/anaconda3/lib/python3.9/site-packages/torch/serialization.py", line 875, in find_class
return super().find_class(mod_name, name)
AttributeError: Can't get attribute 'SPPF' on <module 'models.common' from '/detect/yolov5-car-plate/models/common.py'>

数据集是这样的:
0 0.5059158805031446 0.5967854647099929 0.2672955974842768 0.2585604472396925 0.4793828616352201 0.6509433962264151 0.5422759433962264 0.6491963661774982 0.5422759433962264 0.6823899371069182 0.47741745283018866 0.6771488469601677

@leatherking
Copy link

版本不对,作者使用的是yolov5-4.0版本,解决方案:
1、用last.pt作预训练模型
2、代码会自动下载最新版yolov5s.pt,在yolo5官方代码asset里面下载yolov5-4.0版本的yolov5s.pt

@ouxiand
Copy link
Author

ouxiand commented Aug 22, 2022

就是用last.pt作预训练模型的,不知道为啥错误很多,改完一个有一个,改到后面糊涂了

@ouxiand
Copy link
Author

ouxiand commented Aug 22, 2022

这是用last.pt训练的
Traceback (most recent call last):
File "/detect/yolov5-car-plate/train.py", line 552, in
train(hyp, opt, device, tb_writer)
File "/detect/yolov5-car-plate/train.py", line 285, in train
for i, (imgs, targets, paths, _) in pbar: # batch -------------------------------------------------------------
File "/root/anaconda3/lib/python3.9/site-packages/tqdm/std.py", line 1195, in iter
for obj in iterable:
File "/detect/yolov5-car-plate/utils/plate_datasets.py", line 104, in iter
yield next(self.iterator)
File "/root/anaconda3/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 521, in next
data = self._next_data()
File "/root/anaconda3/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 1183, in _next_data
return self._process_data(data)
File "/root/anaconda3/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 1229, in _process_data
data.reraise()
File "/root/anaconda3/lib/python3.9/site-packages/torch/_utils.py", line 434, in reraise
raise exception
TypeError: Caught TypeError in DataLoader worker process 1.
Original Traceback (most recent call last):
File "/root/anaconda3/lib/python3.9/site-packages/torch/utils/data/_utils/worker.py", line 287, in _worker_loop
data = fetcher.fetch(index)
File "/root/anaconda3/lib/python3.9/site-packages/torch/utils/data/_utils/fetch.py", line 49, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/root/anaconda3/lib/python3.9/site-packages/torch/utils/data/_utils/fetch.py", line 49, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/detect/yolov5-car-plate/utils/plate_datasets.py", line 530, in getitem
img, labels = load_mosaic(self, index)
File "/detect/yolov5-car-plate/utils/plate_datasets.py", line 758, in load_mosaic
x,y = point
TypeError: cannot unpack non-iterable numpy.float32 object

@leatherking
Copy link

就是用last.pt作预训练模型的,不知道为啥错误很多,改完一个有一个,改到后面糊涂了

至少没报SPPF的错了,看样子是你数据有点问题

@ouxiand
Copy link
Author

ouxiand commented Aug 23, 2022

@leatherking 能否看看你的数据集,我的数据集发出来了,估计是后面4个点的问题
x1,y1,x2,y2,x3,y3,x4,y4,后面四个点用以下计算:
x1直接除以width出来的数值
y1直接除以height出来的数值

@leatherking
Copy link

@leatherking 能否看看你的数据集,我的数据集发出来了,估计是后面4个点的问题 x1,y1,x2,y2,x3,y3,x4,y4,后面四个点用以下计算: x1直接除以width出来的数值 y1直接除以height出来的数值

是的
class, center x, center y, w, h, 左上x, 左上y, 右上x, 右上y, 右下x, 右下y, 左下x, 左下y
x / w
y / h

@ouxiand
Copy link
Author

ouxiand commented Aug 24, 2022

@leatherking 能否发一些你的数据集给验证下 感谢 , (如果可以,[email protected]

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