SSD-PyTorch训练自己的数据集问题汇总

代码链接:https://github.com/amdegroot/ssd.pytorch

运行train.py :

(1)ModuleNotFoundError: No module named 'cv2'

         安装opencv-python :pip install opencv-python

(2)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/")

(3)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())

(4)KeyError: 'Traceback (most recent call last):\n

         train.py第165行处内容改为如下

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

(5)RuntimeError: The shape of the mask [13, 8732] at index 0 does not match the shape of the indexed tensor [113516, 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()

(6)RuntimeError: merge_sort: failed to synchronize: an illegal memory access was encountered

        调整学习率和bach_size,比如我把学习率改为0.001,bach_size设置为4,问题即可解决。

(7)完成训练

运行eval.py:

(注意:以下两个问题新版源码已修正)

(1)ValueError: not enough values to unpack (expected 2, got 0)

         layers/functions/detection.py 第49行改为

 if scores.size(0) == 0:

(2)IndexError: too many indices for tensor of dimension 1

         eval.py 第393行改为

if dets.size(0) == 0:

 

  • 4
    点赞
  • 38
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值