一、mmdetection断点训练
由于mmdetection是用终端运行的,如果不小心把终端关掉了,用以下方式继续上次训练.
可以看到train.py里面是有一个resume参数的
在命令行输入以下语句进行训练,将resume的参数变成 work_dirs/yyy/latest.pth 即可以完全相同的模型配置继续上次的训练啦:
python tools/train.py configs/tridentnet/tridentnet_r50-caffe_1x_my.py --work-dir work_dirs/trident --resume work_dirs/trident/epoch_6.pth
二、出现的问题:
AttributeError: ‘SSDHead‘ object has no attribute ‘loss_cls‘1.
进入mmdetection/mmdet/models/dense_heads/base_dense_head.py,将if getattr(self.loss_cls, 'custom_cls_channels', False)改成if False:
# if getattr(self.loss_cls, 'custom_cls_channels', False): # Change made here
if False:
scores = self.loss_cls.get_activation(cls_score)
elif self.use_sigmoid_cls:
scores = cls_score.sigmoid()
else:
# remind that we set FG labels to [0, num_class-1]
# since mmdet v2.0
# BG cat_id: num_class
scores = cls_score.softmax(-1)[:, :-1]
进入mmdetection-main目录里面之后再次重新编译
pip install -v -e .
或者
python setup.py install