HRSC2016 数据集 L2 L3 task

网上没有HRSC2016 数据集 L2 L3 task 任务的开源项目,我的毕设跟老师吹的牛是把数据集用到L2、L3任务上,现在发现没有开源代码,心态没了。
接下来这段时间尝试手写代码,完成这个任务。

0. GPU

还是接着之前使用的autodl 的GPU,当时保存镜像了,现在拖过来可以直接使用。

1.修改网络模型中 num_class=33

configs\obb\oriented_rcnn\faster_rcnn_orpn_r50_fpn_3x_hrsc.py
num_classes=1,改成33

2.修改 hrsc.py中 classwise=True

configs\obb_base_\datasets\hrsc.py
classwise=False,改成True

3.疑惑

训练读取的标签从哪读取?
为什么都没改读取标签的位置就能行?
因为数据集里的annotation还是labelTxt,用的是哪个我不确定。先把testdataset里边的labelTxt文件夹删掉进行测试。能运行,表示Oriented R-CNN没用labelTxt里边的文件,那我直接修改上边两处试试。

(obbdetection) root@container-bd721182ac-1b86a0fe:~/OBBDetection# python tools/test.py configs/obb/oriented_rcnn/faster_rcnn_orpn_r101_fpn_3x_hrsc.py /root/OBBDetection/work_dirs/epoch_35.pth --eval mAP
Starting loading HRSC dataset information.
100%|███████████████████████████████████████████████████████████████████████████████████████| 444/444 [00:00<00:00, 4659.11it/s]
Finishing loading HRSC, get 444 images, using 0.214s.
load checkpoint from local path: /root/OBBDetection/work_dirs/epoch_35.pth
[                                                  ] 0/444, elapsed: 0s, ETA:/root/OBBDetection/mmdet/core/post_processing/obb/obb_nms.py:29: UserWarning: This overload of nonzero is deprecated:
        nonzero()
Consider using one of the following signatures instead:
        nonzero(*, bool as_tuple) (Triggered internally at  /opt/conda/conda-bld/pytorch_1595629403081/work/torch/csrc/utils/python_arg_parser.cpp:766.)
  labels = valid_mask.nonzero()[:, 1]
[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 444/444, 9.9 task/s, elapsed: 45s, ETA:     0s
+-------+------+------+--------+--------+
| class | gts  | dets | recall | ap     |
+-------+------+------+--------+--------+
| ship  | 1188 | 3160 | 0.9840 | 0.9049 |
+-------+------+------+--------+--------+
| mAP   |      |      |        | 0.9049 |
+-------+------+------+--------+--------+

不确定: 现在看他的Annotation里的东西我们没用到。当时转化成txt格式了,后边都是ship,0/1,看来还得再转换一边。

4. 修改前 完整性测试

先运行一下 Train.py,确保修改之前正确。

nohup python tools/train.py configs/obb/oriented_rcnn/faster_rcnn_orpn_r101_fpn_3x_hrsc.py --work-dir work_dirs >xcbTrain202205171509.log 2>&1 &

可以正常训练。

5.然后修改参数

configs\obb\oriented_rcnn\faster_rcnn_orpn_r50_fpn_3x_hrsc.py
num_classes=1,改成33
configs\obb_base_\datasets\hrsc.py
classwise=False,改成True

nohup python tools/train.py configs/obb/oriented_rcnn/faster_rcnn_orpn_r101_fpn_3x_hrsc.py --work-dir work_dirs >xcbTrain202205171520.log 2>&1 &

2022年5月17日15点22分
训练一下,2080Ti的GPU 预计使用一个半小时。打游戏了。

可以看GPU的使用情况,2s刷新一次。

watch -n 2 -d nvidia-smi

中途因为空间不够(他每次都生成xepoch.pth),中断了,所以重新恢复训练。
这里注意,从Jupyter notebook 选中后右键删除的文件并没从磁盘上消失,也就是你的磁盘空间还是不足,因为他放入了回收站、c。
用这个代码清空回收站

rm -rf ~/.local/share/Trash/*

可以用这个语句查询磁盘空间

df -h
或者
df /root/OBBDetection
其他等等。

然后我们恢复训练。注意,我们上次失败是存储到epoch24.pth了。但是数据不全,所以从epoch23.pth开始恢复

nohup python tools/train.py configs/obb/oriented_rcnn/faster_rcnn_orpn_r101_fpn_3x_hrsc.py --work-dir work_dirs --resume-from work_dirs/epoch_23.pth >xcbTrain202205171647.log 2>&1 &
 

训练完成了,让我们找个图片测试。

6.测试图片

python demo/image_demo.py demo/100001132.bmp configs/obb/oriented_rcnn/faster_rcnn_orpn_r101_fpn_3x_hrsc.py  work_dirs/epoch_36.pth  

贴上几张图片。
HRSC2016 数据集 L2 L3 task_第1张图片
注意:每个预测框上的第一个数字表示33个类型,比如09表示佩里级护卫舰 perry class frigate。这个文件在imageset里叫 sysdata.xml
HRSC2016 数据集 L2 L3 task_第2张图片
下面是sysdata.xml 部分标签的参考:
HRSC2016 数据集 L2 L3 task_第3张图片

7. 评价 mAP

先用VOC07评价:

(obbdetection) root@container-bd721182ac-1b86a0fe:~/OBBDetection# python tools/test.py configs/obb/oriented_rcnn/faster_rcnn_orpn_r101_fpn_3x_hrsc.py /root/OBBDetection/work_dirs/epoch_36.pth --eval mAP --options use_07_metric=True
Starting loading HRSC dataset information.
100%|█████████████████████████████████████████████████████████████████████████| 444/444 [00:00<00:00, 5789.69it/s]
Finishing loading HRSC, get 444 images, using 0.148s.
load checkpoint from local path: /root/OBBDetection/work_dirs/epoch_36.pth
[                                                  ] 0/444, elapsed: 0s, ETA:/root/OBBDetection/mmdet/core/post_processing/obb/obb_nms.py:29: UserWarning: This overload of nonzero is deprecated:
        nonzero()
Consider using one of the following signatures instead:
        nonzero(*, bool as_tuple) (Triggered internally at  /opt/conda/conda-bld/pytorch_1595629403081/work/torch/csrc/utils/python_arg_parser.cpp:766.)
  labels = valid_mask.nonzero()[:, 1]
[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 444/444, 10.0 task/s, elapsed: 44s, ETA:     0s
+-------+-----+------+--------+--------+
| class | gts | dets | recall | ap     |
+-------+-----+------+--------+--------+
| 01    | 230 | 547  | 0.8391 | 0.6287 |
| 02    | 0   | 0    | 0.0000 | 0.0000 |
| 03    | 22  | 284  | 0.9091 | 0.1458 |
| 04    | 2   | 0    | 0.0000 | 0.0000 |
| 05    | 35  | 70   | 1.0000 | 0.8107 |
| 06    | 12  | 76   | 0.9167 | 0.4671 |
| 07    | 158 | 293  | 0.9684 | 0.8945 |
| 08    | 40  | 111  | 0.9250 | 0.8055 |
| 09    | 128 | 268  | 0.9766 | 0.8960 |
| 10    | 22  | 103  | 1.0000 | 0.9716 |
| 11    | 103 | 212  | 0.9806 | 0.9072 |
| 12    | 1   | 0    | 0.0000 | 0.0000 |
| 13    | 2   | 68   | 1.0000 | 0.4000 |
| 14    | 0   | 0    | 0.0000 | 0.0000 |
| 15    | 35  | 93   | 1.0000 | 0.9225 |
| 16    | 50  | 84   | 1.0000 | 0.9917 |
| 17    | 1   | 0    | 0.0000 | 0.0000 |
| 18    | 18  | 49   | 0.8889 | 0.6243 |
| 19    | 39  | 112  | 0.9487 | 0.8279 |
| 20    | 16  | 32   | 1.0000 | 0.9192 |
| 21    | 0   | 0    | 0.0000 | 0.0000 |
| 22    | 50  | 73   | 0.9200 | 0.7254 |
| 23    | 0   | 0    | 0.0000 | 0.0000 |
| 24    | 1   | 34   | 1.0000 | 0.0303 |
| 25    | 119 | 214  | 0.9076 | 0.8259 |
| 26    | 4   | 69   | 1.0000 | 0.4387 |
| 27    | 60  | 82   | 0.9500 | 0.8959 |
| 28    | 4   | 7    | 0.7500 | 0.4870 |
| 29    | 10  | 79   | 1.0000 | 0.9587 |
| 30    | 16  | 57   | 0.9375 | 0.8745 |
| 31    | 0   | 0    | 0.0000 | 0.0000 |
| 32    | 10  | 67   | 1.0000 | 0.9504 |
| 33    | 0   | 0    | 0.0000 | 0.0000 |
+-------+-----+------+--------+--------+
| mAP   |     |      |        | 0.6444 |
+-------+-----+------+--------+--------+

用VOC12评价

python tools/test.py configs/obb/oriented_rcnn/faster_rcnn_orpn_r101_fpn_3x_hrsc.py /root/OBBDetection/work_dirs/epoch_36.pth --eval mAP --options use_07_metric=False
Starting loading HRSC dataset information.
100%|█████████████████████████████████████████████████████████████████████████| 444/444 [00:00<00:00, 6964.86it/s]
Finishing loading HRSC, get 444 images, using 0.139s.
load checkpoint from local path: /root/OBBDetection/work_dirs/epoch_36.pth
[                                                  ] 0/444, elapsed: 0s, ETA:/root/OBBDetection/mmdet/core/post_processing/obb/obb_nms.py:29: UserWarning: This overload of nonzero is deprecated:
        nonzero()
Consider using one of the following signatures instead:
        nonzero(*, bool as_tuple) (Triggered internally at  /opt/conda/conda-bld/pytorch_1595629403081/work/torch/csrc/utils/python_arg_parser.cpp:766.)
  labels = valid_mask.nonzero()[:, 1]
[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 444/444, 10.0 task/s, elapsed: 44s, ETA:     0s
+-------+-----+------+--------+--------+
| class | gts | dets | recall | ap     |
+-------+-----+------+--------+--------+
| 01    | 230 | 547  | 0.8391 | 0.6419 |
| 02    | 0   | 0    | 0.0000 | 0.0000 |
| 03    | 22  | 284  | 0.9091 | 0.1445 |
| 04    | 2   | 0    | 0.0000 | 0.0000 |
| 05    | 35  | 70   | 1.0000 | 0.8120 |
| 06    | 12  | 76   | 0.9167 | 0.4504 |
| 07    | 158 | 293  | 0.9684 | 0.9453 |
| 08    | 40  | 111  | 0.9250 | 0.8261 |
| 09    | 128 | 268  | 0.9766 | 0.9495 |
| 10    | 22  | 103  | 1.0000 | 0.9755 |
| 11    | 103 | 212  | 0.9806 | 0.9726 |
| 12    | 1   | 0    | 0.0000 | 0.0000 |
| 13    | 2   | 68   | 1.0000 | 0.4000 |
| 14    | 0   | 0    | 0.0000 | 0.0000 |
| 15    | 35  | 93   | 1.0000 | 0.9441 |
| 16    | 50  | 84   | 1.0000 | 0.9970 |
| 17    | 1   | 0    | 0.0000 | 0.0000 |
| 18    | 18  | 49   | 0.8889 | 0.6429 |
| 19    | 39  | 112  | 0.9487 | 0.8628 |
| 20    | 16  | 32   | 1.0000 | 0.9236 |
| 21    | 0   | 0    | 0.0000 | 0.0000 |
| 22    | 50  | 73   | 0.9200 | 0.7296 |
| 23    | 0   | 0    | 0.0000 | 0.0000 |
| 24    | 1   | 34   | 1.0000 | 0.0303 |
| 25    | 119 | 214  | 0.9076 | 0.8414 |
| 26    | 4   | 69   | 1.0000 | 0.4248 |
| 27    | 60  | 82   | 0.9500 | 0.9305 |
| 28    | 4   | 7    | 0.7500 | 0.4821 |
| 29    | 10  | 79   | 1.0000 | 0.9636 |
| 30    | 16  | 57   | 0.9375 | 0.9014 |
| 31    | 0   | 0    | 0.0000 | 0.0000 |
| 32    | 10  | 67   | 1.0000 | 0.9455 |
| 33    | 0   | 0    | 0.0000 | 0.0000 |
+-------+-----+------+--------+--------+
| mAP   |     |      |        | 0.6569 |
+-------+-----+------+--------+--------+

我找到了有两篇做了L3\L2 task的文章他们没开源
分别是:
Ship detection and classification from optical
remote sensing images: A survey
好像是民航和北航联合做的,删掉了不存在的类

HRSC2016 数据集 L2 L3 task_第4张图片
还有一篇西电的硕士毕业论文:
基于深度学习的卫星图像目标检测算法研究_李巍
HRSC2016 数据集 L2 L3 task_第5张图片
精度我也没看他们用的VOC几,因为目前类的数量不同。

本文参考的代码上直接使用了33类的,就是HRSC2016自带的所有标签,可以看出有些标签根本不存在,可能他们的文章为了美观没放上去,这个后续再说吧。
我下一步尝试进行L2 级别的task。

L2 task

说来很惭愧,我自己什么都没做,只是改了几处代码 :<
现在已知的信息是:
1.能做L1 task 分类,只有ship 1 class
2.能做L3 task 分类,有 33 classs

修改的地方只有 classwise 和 num_class
接下来把num_class 改成四试试。
然后在BboxToolkit\datasets\misc.py文件中加入

'HRSC_4cls': ('01', '02', '03', '04'),

还得在dataset_aliases
加入

'HRSC_cls': product(['hrsc', 'HRSC'], ['_4cls', '2016_4cls']),

在mmdet\datasets\obb\hrsc.py中
修改:

if classwise:
            HRSCDataset.CLASSES = bt.get_classes('hrsc_4cls')

然后进行测试。
忙着头做的,也不知道行不行,好紧张。一个小时后见分晓。
2022年5月17日19点25分
打游戏去。

nohup python tools/train.py configs/obb/oriented_rcnn/faster_rcnn_orpn_r101_fpn_3x_hrsc.py --work-dir work_dirs >xcbTrain202205171920.log 2>&1 &

8.完了

‘HRSC_4cls’: product([‘hrsc’, ‘HRSC’], [‘_4cls’, ‘2016_4cls’]),
这个地方训练之前HRSC_CLS
忘记加4了,先试试epoch5.pth 怎么样。
epoch5,7,10 都检测不出来,
log显示 坏了
HRSC2016 数据集 L2 L3 task_第6张图片
刚才粗心了,现在重新训练。

9.失败了

(obbdetection) root@container-bd721182ac-1b86a0fe:~/OBBDetection# python tools/test.py configs/obb/oriented_rcnn/faster_rcnn_orpn_r101_fpn_3x_hrsc.py /root/OBBDetection/work_dirs/epoch_36.pth --eval mAP
Starting loading HRSC dataset information.
100%|████████████████████████████████████████████████████████████████████████| 444/444 [00:00<00:00, 10876.42it/s]
Finishing loading HRSC, get 444 images, using 0.131s.
load checkpoint from local path: /root/OBBDetection/work_dirs/epoch_36.pth
[                                                  ] 0/444, elapsed: 0s, ETA:/root/OBBDetection/mmdet/core/post_processing/obb/obb_nms.py:29: UserWarning: This overload of nonzero is deprecated:
        nonzero()
Consider using one of the following signatures instead:
        nonzero(*, bool as_tuple) (Triggered internally at  /opt/conda/conda-bld/pytorch_1595629403081/work/torch/csrc/utils/python_arg_parser.cpp:766.)
  labels = valid_mask.nonzero()[:, 1]
[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 444/444, 10.2 task/s, elapsed: 44s, ETA:     0s
+-------+-----+------+--------+--------+
| class | gts | dets | recall | ap     |
+-------+-----+------+--------+--------+
| 01    | 230 | 1668 | 0.7913 | 0.5600 |
| 02    | 0   | 1158 | 0.0000 | 0.0000 |
| 03    | 22  | 1516 | 0.5000 | 0.1264 |
| 04    | 2   | 1147 | 0.0000 | 0.0000 |
+-------+-----+------+--------+--------+
| mAP   |     |      |        | 0.2288 |
+-------+-----+------+--------+--------+

肯定是读取的标签不对,相当于我把33个类减到四个类了c。
肯定得从读取标签的地方入手。

9.load annotation 修改

BboxToolkit\datasets\HRSCio.py文件中,
修改Class_ID为HRS_Class_ID

cls = obj.find('Class_ID').text
改为
cls = obj.find('HRS_Class_ID').text

报错了,这个是sysdata.xml的名称,应该改每张图片对应的annotation的

应该把他加载annotation的代码,Class_ID为HRS_Class_ID。明天再说,今天腰疼了。

2022年5月19日16点33分

HRSC2016 数据集 L2 L3 task_第7张图片
把注释掉的改为这几个判断。然后训练试试。

			if cls2lbl[cls] in [1,2,3,4,27]:
                labels.append(1)
            if cls2lbl[cls] in [5,6,12,13,16,31,32,33]:
                labels.append(2)
            if cls2lbl[cls] in [7,8,9,10,11,14,15,17,19,28,29]:
                labels.append(3)
            if cls2lbl[cls] in [18,20,22,24,25,26,30]:
                labels.append(4)
            # labels.append(cls2lbl[cls])

先保持 num_class = 33
训练12epoch试试结果。
改的乱七八糟,很多运行错误。重新清除一下,刷新一下镜像。
再次说明了跑程序之前验证一下完整性的重要。

重新恢复

33 类正常运行

nohup python tools/train.py configs/obb/oriented_rcnn/faster_rcnn_orpn_r101_fpn_3x_hrsc.py --work-dir work_dirs >xxxcbtrain202204051625.log 2>&1 &

只修改HRSCio.py 里边
if cls2lbl[cls] in [1,2,3,4,27]:
labels.append(1)
if cls2lbl[cls] in [5,6,12,13,16,31,32,33]:
labels.append(2)
if cls2lbl[cls] in [7,8,9,10,11,14,15,17,19,28,29]:
labels.append(3)
if cls2lbl[cls] in [18,20,22,24,25,26,30]:
labels.append(4)
报错:

IndexError: index 0 is out of bounds for dimension 0 with size 0

大概是有些范围超了。

然后修改了
BboxToolkit\datasets\misc.py
中:

 'HRSC_4cls': ('01', '02', '03', '04'),
 'HRSC_4cls': product(['hrsc', 'HRSC'], ['_4cls', '2016_4cls']),

修改:
mmdet\datasets\obb\hrsc.py

 HRSCDataset.CLASSES = bt.get_classes('hrsc_4cls')

运行试试
还是越界。
把config的num_class 改成4,还是越界。
吃饭了 17点22分

晚上奋战30mins

捋着错误找找,进一步有进一步的欢喜。

2022-05-19 21:12:32,653 - mmdet - INFO - Epoch [1][50/219]      lr: 4.945e-04, eta: 0:57:05, time: 0.437, data_time: 0.055, memory: 5327, loss_rpn_cls: 0.4885, loss_rpn_bbox: 0.0252, loss_cls: 0.3598, acc: 88.0039, loss_bbox: 0.0000, loss: 0.8735, grad_norm: 8.2542
谢昌贝
assigned_labels.shape= torch.Size([2000])
assigned_gt_inds= tensor([0, 0, 0,  ..., 0, 0, 0], device='cuda:0')
gt_labels= tensor([], device='cuda:0', dtype=torch.int64)
Traceback (most recent call last):
  File "tools/train.py", line 153, in <module>
    main()
  File "tools/train.py", line 149, in main
    meta=meta)
  File "/root/OBBDetection/mmdet/apis/train.py", line 133, in train_detector
    runner.run(data_loaders, cfg.workflow, cfg.total_epochs)
  File "/root/miniconda3/envs/obbdetection/lib/python3.7/site-packages/mmcv/runner/epoch_based_runner.py", line 127, in run
    epoch_runner(data_loaders[i], **kwargs)
  File "/root/miniconda3/envs/obbdetection/lib/python3.7/site-packages/mmcv/runner/epoch_based_runner.py", line 50, in train
    self.run_iter(data_batch, train_mode=True, **kwargs)
  File "/root/miniconda3/envs/obbdetection/lib/python3.7/site-packages/mmcv/runner/epoch_based_runner.py", line 30, in run_iter
    **kwargs)
  File "/root/miniconda3/envs/obbdetection/lib/python3.7/site-packages/mmcv/parallel/data_parallel.py", line 75, in train_step
    return self.module.train_step(*inputs[0], **kwargs[0])
  File "/root/OBBDetection/mmdet/models/detectors/base.py", line 237, in train_step
    losses = self(**data)
  File "/root/miniconda3/envs/obbdetection/lib/python3.7/site-packages/torch/nn/modules/module.py", line 722, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/root/OBBDetection/mmdet/core/fp16/decorators.py", line 51, in new_func
    return old_func(*args, **kwargs)
  File "/root/OBBDetection/mmdet/models/detectors/base.py", line 172, in forward
    return self.forward_train(img, img_metas, **kwargs)
  File "/root/OBBDetection/mmdet/models/detectors/obb/obb_two_stage.py", line 181, in forward_train
    **kwargs)
  File "/root/OBBDetection/mmdet/models/roi_heads/obb/obb_standard_roi_head.py", line 117, in forward_train
    target_bboxes_ignore[i], gt_labels[i])
  File "/root/OBBDetection/mmdet/core/bbox/assigners/max_iou_assigner.py", line 119, in assign
    assign_result = self.assign_wrt_overlaps(overlaps, gt_labels)
  File "/root/OBBDetection/mmdet/core/bbox/assigners/max_iou_assigner.py", line 211, in assign_wrt_overlaps
    assigned_gt_inds[pos_inds] - 1]
IndexError: index is out of bounds for dimension with size 0

最后一行倒着看,数组越界了,从下往上看了一遍代码,中间那几个地方没看,我估计是gt_labels没得到值,所以才出问题的。
可能是修改了几个标签后,反向传播的时候丢了,或者没搞进去。
现在gt_labels是空的
查看了很多遍之后,发现判断加1、2、3、4可能会出现空的情况

			if cls2lbl[cls]+1 in [1,2,3,4,27]:
                print("labels.append(1)")
                labels.append(1)
            if cls2lbl[cls]+1 in [5,6,12,13,16,31,32,33]:
                print("labels.append(1)")
                labels.append(2)
            if cls2lbl[cls]+1 in [7,8,9,10,11,14,15,17,19,28,29]:
                print("labels.append(1)")
                labels.append(3)
            if cls2lbl[cls]+1 in [18,20,22,24,25,26,30]:
                print("labels.append(1)")
                labels.append(4)

刚才输入的标签是1~4,可能识别的有问题:评价精度如下:

  labels = valid_mask.nonzero()[:, 1]
[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 444/444, 10.2 task/s, elapsed: 44s, ETA:     0s
+-------+-----+------+--------+--------+
| class | gts | dets | recall | ap     |
+-------+-----+------+--------+--------+
| 01    | 0   | 1502 | 0.0000 | 0.0000 |
| 02    | 254 | 2744 | 0.7480 | 0.3475 |
| 03    | 0   | 1514 | 0.0000 | 0.0000 |
| 04    | 0   | 1508 | 0.0000 | 0.0000 |
+-------+-----+------+--------+--------+
| mAP   |     |      |        | 0.3475 |
+-------+-----+------+--------+--------+

精度很低,现在改到了0~3,,尝试resume-from试试,因为从头训练成本高啊(也不知道行不行,)
2022年5月19日22点25分,还有半小时熄灯了。快点快点
可能跟开始的位置也有关系吧。
从epoch17 resume 到 22epoch。

[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 444/444, 10.7 task/s, elapsed: 42s, ETA:     0s
+-------+-----+------+--------+--------+
| class | gts | dets | recall | ap     |
+-------+-----+------+--------+--------+
| 01    | 254 | 3017 | 0.7520 | 0.4733 |
| 02    | 0   | 2023 | 0.0000 | 0.0000 |
| 03    | 0   | 2003 | 0.0000 | 0.0000 |
| 04    | 0   | 2009 | 0.0000 | 0.0000 |
+-------+-----+------+--------+--------+
| mAP   |     |      |        | 0.4733 |
+-------+-----+------+--------+--------+

明天接着搞。
找到一处没返回成4cls的字符串。
这次再试试。
mmdet/datasets/obb/hrsc.py
line52
def pre_pipeline(self, results):
results[‘4cls’] = self.CLASSES
还是不行,可能有的地方缺少乐。

直接把标签改成(1,2,3,4)

修改的地方如下:

booktool/dataset/hrsc.py中改
    'HRSC_cls': product(['hrsc', 'HRSC'], ['_4cls', '2016_4cls']),
    'HRSC_cls': ('01', '02', '03', '04'),
config/obb/orcnn/fasxxx.py中改
            num_classes=4,
HRSCio.py中改
			if cls2lbl[cls]+1 in [1,2,3,4,27]:
                print("labels.append(1)")
                labels.append(0)
            if cls2lbl[cls]+1 in [5,6,12,13,16,31,32,33]:
                print("labels.append(1)")
                labels.append(1)
            if cls2lbl[cls]+1 in [7,8,9,10,11,14,15,17,19,28,29]:
                print("labels.append(1)")
                labels.append(2)
            if cls2lbl[cls]+1 in [18,20,22,24,25,26,30]:
                print("labels.append(1)")
                labels.append(3)
            # labels.append(cls2lbl[cls])

终于能显示正常的4个了,泪目,
2022年5月20日11点13分
人家都在过情人节,俺也干饭去了。

load checkpoint from local path: /root/autodl-nas/epoch/epoch_3.pth
[                                                  ] 0/444, elapsed: 0s, ETA:/root/OBBDetection/mmdet/core/post_processing/obb/obb_nms.py:29: UserWarning: This overload of nonzero is deprecated:
        nonzero()
Consider using one of the following signatures instead:
        nonzero(*, bool as_tuple) (Triggered internally at  /opt/conda/conda-bld/pytorch_1595629403081/work/torch/csrc/utils/python_arg_parser.cpp:766.)
  labels = valid_mask.nonzero()[:, 1]
[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 444/444, 10.2 task/s, elapsed: 43s, ETA:     0s
+-------+-----+------+--------+--------+
| class | gts | dets | recall | ap     |
+-------+-----+------+--------+--------+
| 01    | 314 | 3604 | 0.2866 | 0.0499 |
| 02    | 110 | 3078 | 0.4000 | 0.1148 |
| 03    | 540 | 3489 | 0.5167 | 0.3083 |
| 04    | 224 | 3941 | 0.5089 | 0.0767 |
+-------+-----+------+--------+--------+
| mAP   |     |      |        | 0.1374 |
+-------+-----+------+--------+--------+
load checkpoint from local path: /root/autodl-nas/epoch/epoch_9.pth
[                                                  ] 0/444, elapsed: 0s, ETA:/root/OBBDetection/mmdet/core/post_processing/obb/obb_nms.py:29: UserWarning: This overload of nonzero is deprecated:
        nonzero()
Consider using one of the following signatures instead:
        nonzero(*, bool as_tuple) (Triggered internally at  /opt/conda/conda-bld/pytorch_1595629403081/work/torch/csrc/utils/python_arg_parser.cpp:766.)
  labels = valid_mask.nonzero()[:, 1]
[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 444/444, 10.1 task/s, elapsed: 44s, ETA:     0s
+-------+-----+------+--------+--------+
| class | gts | dets | recall | ap     |
+-------+-----+------+--------+--------+
| 01    | 314 | 2376 | 0.8153 | 0.4269 |
| 02    | 110 | 1018 | 0.7909 | 0.6111 |
| 03    | 540 | 2078 | 0.9574 | 0.8249 |
| 04    | 224 | 1618 | 0.8170 | 0.5311 |
+-------+-----+------+--------+--------+
| mAP   |     |      |        | 0.5985 |
+-------+-----+------+--------+--------+

最后的结果

结果应该是可以的吧,感动死了

[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 444/444, 10.7 task/s, elapsed: 42s, ETA:     0s
+-------+-----+------+--------+--------+
| class | gts | dets | recall | ap     |
+-------+-----+------+--------+--------+
| 01    | 314 | 5140 | 0.8917 | 0.6404 |
| 02    | 110 | 4529 | 1.0000 | 0.9828 |
| 03    | 540 | 5068 | 0.9907 | 0.8885 |
| 04    | 224 | 4765 | 0.9152 | 0.8066 |
+-------+-----+------+--------+--------+
| mAP   |     |      |        | 0.8296 |
+-------+-----+------+--------+--------+

show img
HRSC2016 数据集 L2 L3 task_第8张图片
HRSC2016 数据集 L2 L3 task_第9张图片
HRSC2016 数据集 L2 L3 task_第10张图片
睡觉 2022年5月20日14点37分

你可能感兴趣的:(复现论文,目标检测,深度学习,python)