SSD.Pytorch运行问题汇总

SSD运行问题汇总

  • 地址
  • 环境配置
  • train.py
    • 1.FileNotFoundError: [Errno 2] No such file or directory
    • 2.RuntimeError: randperm is only implemented for CPU
    • 3.images, targets = next(batch_iterator)
    • 4.RuntimeError: The shape of the mask [32, 8732] at index 0 does not match the shape of the indexed tensor [279424, 1] at index 0
    • 5.RuntimeError: DataLoader worker is killed by signal: Killed
  • eval.py
  • 参考

地址

https://github.com/amdegroot/ssd.pytorch

环境配置

传了anaconda配置,主要是自己用。(直接去上面地址中的github地址配置就行)
https://download.csdn.net/download/Doraemon_Zzn/12614296

conda env create -f xxx.yaml

train.py

1.FileNotFoundError: [Errno 2] No such file or directory

修改路径指向自己的数据集:
针对coco数据集,修改data/coco.py第11行
COCO_ROOT = osp.join(HOME, ‘data/coco/’)

针对voc数据集,修改data/voc0712.py第28行
VOC_ROOT = osp.join(HOME, “data/VOCdevkit/”)

我改成绝对路径才成功

用的是VOC数据集,形式如下:

  • VOCdevkit
    • VOC2007
    • VOC2012

2.RuntimeError: randperm is only implemented for CPU

torch/utils/data/sampler.py 第51行处内容如下

def _iter_(self)
    cpu = torch.device('cpu')
    return iter(torch.randperm(len(self.data_source),device = cpu).tolist())

3.images, targets = next(batch_iterator)

SSD.Pytorch运行问题汇总_第1张图片

try:
    images, targets = next(batch_iterator)
except StopIteration:
    bath_iterator = iter(data_loader)
    images, targets = next(bath_iterator)

4.RuntimeError: The shape of the mask [32, 8732] at index 0 does not match the shape of the indexed tensor [279424, 1] at index 0

layers/modules/multibox_loss.py 第97、98行调换

loss_c = loss_c.view(num, -1)
loss_c[pos] = 0  # filter out pos boxes for now

第114行将 N = num_pos.data.sum() 改为

N = num_pos.data.sum().double()
loss_l = loss_l.double()
loss_c = loss_c.double()

5.RuntimeError: DataLoader worker is killed by signal: Killed

num_workers=0

SSD.Pytorch运行问题汇总_第2张图片

eval.py

SSD.Pytorch运行问题汇总_第3张图片
自己训练15000iter的结果。
SSD.Pytorch运行问题汇总_第4张图片

参考

https://blog.csdn.net/lianggyu/article/details/100076153
https://github.com/pytorch/pytorch/issues/8976
https://zhuanlan.zhihu.com/p/92154612

你可能感兴趣的:(目标检测)