mmdetection2.3.0训练报错:RuntimeError: The size of tensor a (8) must match the size of tensor b (81)

欢迎大家关注笔者,你的关注是我持续更博的最大动力


原创文章,转载告知,盗版必究


mmdetection2.3.0训练报错:RuntimeError: The size of tensor a (8) must match the size of tensor b (81) at non-singleton dimension 1

文章目录:

  • 1 错误原因分析
  • 2 解决方式


1 错误原因分析

1、使用SAC-Cascade模型训练,模型位置:

./configs/detectors/cascade_rcnn_r50_sac_1x_coco.py

2、修改类别数num_classes,在如下的配置文件中修改

./configs/base/models/cascade_rcnn_r50_fpn.py

3、使用多GPU训练命令

./tools/dist_train.sh ./configs/detectors/cascade_rcnn_r50_sac_1x_coco.py 3 --work-dir 23_work_dirs_sac_cascade_hat_hair_beard

然后运行包如下错误,即使使用单GPU依然会报如下错误:
mmdetection2.3.0训练报错:RuntimeError: The size of tensor a (8) must match the size of tensor b (81)_第1张图片

这个错误原因是由于num_classes没有完全修改导致,

2 解决方式

修改如下配置文件中:num_classes的类别为自己的类别

./configs/base/models/cascade_rcnn_r50_fpn.py

注意:

这个文件中一共有三处 num_classes=80,把这个num_classes全部修改为自己的类别即可





在这里插入图片描述
♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠

你可能感兴趣的:(16_各种错误和bug(你的痛,我的痛,痛痛痛))