Closed seek-ing closed 4 years ago
你用的训练指令是什么?
@SpursLipu
谢谢回复
python3 train.py --data data/obj.data -pt --batch-size 16 --weights weights/yolov3.pt --cfg cfg/yolov3.cfg
我在训练的过程中没有遇到过这个问题,你可以检查一下你是用数据集的分类数是否与yolov3.cfg中的分类数相等(80类),-pt是使用在coco上进行预训练的.weights文件时使用的命令,不知道是不是和你的指令有冲突。
另外这个仓库中的detect.py程序是使用原图的分辨率进行检测的,你可以测试一下效果。
@SpursLipu 谢谢~ 我的是7分类,我把 -pt去除也遇到了同样的问题 你师兄是缩放成256x416的?
你用multi-scale训练暂时就没问题了,我在排查你说的问题。
缩放都是使用原分辨率除以输入图片长边算出的缩放倍数进行缩放的,检测时的缩放是没有填充。
应该是解决了,你可以再试一下
@SpursLipu 非常感谢~
When i try to prune the model, I also encounter this error " YOLOLayer object has no attribute 'grid'". My comand is: python train.py --data --batch-size --weights big_model/best.pt --cfg --sr --s 0.001 --prune 0 --single_cls Can you give some suggestions? @SpursLipu
I have already solve this problem, you can download new version of this repository.
您好,我之前是使用你师兄的代码去训练工程,但是加载训练完成后保存的best.pt去预测视频时候图像被缩放为256x416的:
video 1/1 (1452/67673) /home/yhy/YOLOv3_pruning/ch03.mp4: 256x416 Done.
检测图片的时候也是会被重置为256x416,检测的效果非常差,但是看训练时的mAP倒是挺好,70%左右。 你师兄的工程貌似已经没有在维护了,不知道你有没有在你师兄的工程中遇到图像被缩放为256x416的情况? 找不到原因,所以用你的工程,但是训练的时候报错:
Traceback (most recent call last): File "train.py", line 497, in
train(hyp) # train normally
File "train.py", line 387, in train
dataloader=testloader)
File "/home/yhy/pruning/test.py", line 74, in test
_ = model(torch.zeros((1, 3, img_size, img_size), device=device)) if device.type != 'cpu' else None # run once
File "/home/yhy/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 532, in call
result = self.forward(*input, kwargs)
File "/home/yhy/.local/lib/python3.6/site-packages/torch/nn/parallel/distributed.py", line 449, in forward
outputs = self.parallel_apply(self._module_copies[:len(inputs)], inputs, kwargs)
File "/home/yhy/.local/lib/python3.6/site-packages/torch/nn/parallel/distributed.py", line 474, in parallel_apply
return parallel_apply(replicas, inputs, kwargs, self.device_ids[:len(replicas)])
File "/home/yhy/.local/lib/python3.6/site-packages/torch/nn/parallel/parallel_apply.py", line 85, in parallel_apply
output.reraise()
File "/home/yhy/.local/lib/python3.6/site-packages/torch/_utils.py", line 394, in reraise
raise self.exc_type(msg)
AttributeError: Caught AttributeError in replica 0 on device 0.
Original Traceback (most recent call last):
File "/home/yhy/.local/lib/python3.6/site-packages/torch/nn/parallel/parallel_apply.py", line 60, in _worker
output = module(*input, *kwargs)
File "/home/yhy/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 532, in call
result = self.forward(input, kwargs)
File "/home/yhy/pruning/models.py", line 306, in forward
return self.forward_once(x)
File "/home/yhy/pruning/models.py", line 358, in forward_once
yolo_out.append(module(x, out))
File "/home/yhy/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 532, in call
result = self.forward(*input, **kwargs)
File "/home/yhy/pruning/models.py", line 279, in forward
io[..., :2] = torch.sigmoid(io[..., :2]) + self.grid # xy
File "/home/yhy/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 576, in getattr
type(self).name, name))
AttributeError: 'YOLOLayer' object has no attribute 'grid'
这个错误在你师兄或者ultralytics/yolov3的工程里都没有出现。