1、Batchsize和学习率问题
1、关于rotated_rtmdet_l-coco_pretrain-3x-dota_ms.py配置文件的batchsize和学习率设置
问题:
![](https://img-blog.csdnimg.cn/img_convert/df91b46d9f7fb75a52a0cadbbe85496b.png)
回答:
![](https://img-blog.csdnimg.cn/img_convert/25a362578fb5c72b41afa1374aa54e46.png)
2、不同batchsize下s2anet的mAP #59
问题:
![](https://img-blog.csdnimg.cn/img_convert/41138ec362beb72c6f63b613a96a44ba.png)
回答:
![](https://img-blog.csdnimg.cn/img_convert/05801421c8ba150f5691a1b0c3e4c6a8.png)
![](https://img-blog.csdnimg.cn/img_convert/6c1681bb63618baadda417f9a0f983c7.png)
![](https://img-blog.csdnimg.cn/img_convert/286493ef162648cf8bb0214d81b2bf94.png)
![](https://img-blog.csdnimg.cn/img_convert/a4c5c2384c8ff5f56b0584ebe7ce0da5.png)
3、关于lr和batchsize的问题 #645
![](https://img-blog.csdnimg.cn/img_convert/06b46600f42f2de2aa689bfc5bd6e039.png)
2、如何进行多尺度测试? #201
![](https://img-blog.csdnimg.cn/img_convert/c08ecc5730ee6a4a17b17c3dafc5932f.png)
![](https://img-blog.csdnimg.cn/img_convert/95695039f356d1c52b00cc7f20d6ff91.png)
3、为什么相同的物体分类分数相差很大? #455
问题:
![](https://img-blog.csdnimg.cn/img_convert/a57be9646298641d11613440c809e787.png)
![](https://img-blog.csdnimg.cn/img_convert/a0b887f78aff534397f61fa1317b44ad.png)
![](https://img-blog.csdnimg.cn/img_convert/58e9d75e16508d25456041b98aeb7155.png)
回答:
![](https://img-blog.csdnimg.cn/img_convert/b13c2605766837f84b33c66ff306ab73.png)
_base_ = ['./roi_trans_r50_fpn_1x_dota_le90.py']
data_root = 'datasets/split_ms_dotav1/'
angle_version = 'le90'
img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
train_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations', with_bbox=True),
dict(type='RResize', img_scale=(1024, 1024)),
dict(
type='RRandomFlip',
flip_ratio=[0.25, 0.25, 0.25],
direction=['horizontal', 'vertical', 'diagonal'],
version=angle_version),
dict(
type='PolyRandomRotate',
rotate_ratio=0.5,
angles_range=180,
auto_bound=False,
rect_classes=[9, 11],
version=angle_version),
dict(type='Normalize', **img_norm_cfg),
dict(type='Pad', size_divisor=32),
dict(type='DefaultFormatBundle'),
dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels'])
]
data = dict(
train=dict(
pipeline=train_pipeline,
ann_file=data_root + 'trainval/annfiles/',
img_prefix=data_root + 'trainval/images/'),
val=dict(
ann_file=data_root + 'trainval/annfiles/',
img_prefix=data_root + 'trainval/images/'),
test=dict(
ann_file=data_root + 'test/images/',
img_prefix=data_root + 'test/images/'))
model = dict(train_cfg=dict(rpn=dict(assigner=dict(gpu_assign_thr=200))))
4、检测细长物体的困难 #384
问题:
![](https://img-blog.csdnimg.cn/img_convert/b8ed7319c80ea6291a8abbf000dcbb3f.png)
![](https://img-blog.csdnimg.cn/img_convert/2d46b8589d4960c63e23c8ad3335e0db.png)
回答:
![](https://img-blog.csdnimg.cn/img_convert/7e68ee353525a2564df79bcdd8febde8.png)
def gen_single_level_base_anchors(self,
base_size,
scales,
ratios,
center=None):
"""Generate base anchors of a single level.
Args:
base_size (int | float): Basic size of an anchor.
scales (torch.Tensor): Scales of the anchor.
ratios (torch.Tensor): The ratio between between the height
and width of anchors in a single level.
center (tuple[float], optional): The center of the base anchor
related to a single feature grid. Defaults to None.
Returns:
torch.Tensor: Anchors in a single-level feature maps.
"""
w = base_size
h = base_size
if center is None:
x_center = self.center_offset * w
y_center = self.center_offset * h
else:
x_center, y_center = center
h_ratios = torch.sqrt(ratios)
w_ratios = 1 / h_ratios
if self.scale_major:
ws = (w * w_ratios[:, None] * scales[None, :]).view(-1)
hs = (h * h_ratios[:, None] * scales[None, :]).view(-1)
else:
ws = (w * scales[:, None] * w_ratios[None, :]).view(-1)
hs = (h * scales[:, None] * h_ratios[None, :]).view(-1)
# use float anchor and the anchor's center is aligned with the
# pixel center
base_anchors = [
x_center - 0.5 * ws, y_center - 0.5 * hs, x_center + 0.5 * ws,
y_center + 0.5 * hs
]
base_anchors = torch.stack(base_anchors, dim=-1)
return base_anchors
5、如何训练宽高比大的物体 #285
![](https://img-blog.csdnimg.cn/img_convert/93e6bc550517395c285056cc36b3b308.png)
![](https://img-blog.csdnimg.cn/img_convert/0f0ed5b6582745fa6d6df8502d45b8b3.png)
6、请问这个项目中通道的ms+rr和论文中常说的多维度测试和多维度训练有什么区别
问题:
![](https://img-blog.csdnimg.cn/img_convert/6e324beed615e658b6fcebb912a07426.png)
回答:
![](https://img-blog.csdnimg.cn/img_convert/628cedcb7bccdaa854c5c690996773fb.png)
7、如何在mmrotate中绘制特征图
问题:
![](https://img-blog.csdnimg.cn/img_convert/340aca12e3c0e489eca892d43f2712b7.png)
回答:
你好@AllieLan,您可以尝试使用https://github.com/open-mmlab/mmyolo/blob/main/demo/featmap_vis_demo.py
8、oriented reppoints 支持 filter_empty_gt=False 的训练
问题:
![](https://img-blog.csdnimg.cn/img_convert/9d9de65619473fa9ba399199df7b33d9.png)
回答:
![](https://img-blog.csdnimg.cn/img_convert/485c66294b791e0d126155c9d0f63d4a.png)
9、[1.x] RTMDet-R (tiny) 内存不足的 CUDA,具有 24GB VRAM 和 batch_size=1
问题:
![](https://img-blog.csdnimg.cn/img_convert/29f54fc61c3a0e07aa9d96d348ab5dde.png)
回答:
![](https://img-blog.csdnimg.cn/img_convert/d3078dc823d5a855bcfa33bd17c46378.png)
10、如何在自己的数据集上测试大场景图片?
问题:
![](https://img-blog.csdnimg.cn/img_convert/8c29b4fc1a1722aa10513c6f1ebddeb5.png)
回答:
你好@TheGreatTreatsby, 你可以试试https://github.com/CAPTAIN-WHU/DOTA_devkit
11、使用 DOTA V1.0 数据集时 CFA 重新分配过程中的张量不匹配错误
问题:
![](https://img-blog.csdnimg.cn/img_convert/10e4affc53839530db8781c76112b258.png)
回答:
![](https://img-blog.csdnimg.cn/img_convert/110e26b279f90e0d8d83a8ce50e233c9.png)
![](https://img-blog.csdnimg.cn/img_convert/710248523631df56dc529018ede5cbe9.png)
12、如何改变旋转框的定义范围(如何更改旋转框的定义范围)
问题:
![](https://img-blog.csdnimg.cn/img_convert/78108c5f3b9a65fcc5a4409701b7893c.png)
回答:
![](https://img-blog.csdnimg.cn/img_convert/5f575760eec51e6eb9ad335d41857176.png)
![](https://img-blog.csdnimg.cn/img_convert/47203d823936b54863cf5a4047d4cae6.png)
13、如何获得精度和F1分数
问题:
![](https://img-blog.csdnimg.cn/img_convert/df6f1d2dfa93b46175ec2bff95982e63.png)
回答:
在我的例子中,我修改了 eval_map.py 和我的 custumdataset.py
通过在 def eval_rbbox_map 中创建额外的变量来计算
cls_all_tp = np.sum(tp) cls_all_fp = np.sum(fp)
参考我项目的代码
![](https://img-blog.csdnimg.cn/img_convert/014ee9fb56df8e06fdf741619da36793.png)
14、关于 R3Det 中的随机种子 #464
问题:
![](https://img-blog.csdnimg.cn/img_convert/19207632e7c20e399087766d38a625c6.png)
![](https://img-blog.csdnimg.cn/img_convert/714c53222e10f32860e91c11c4a57735.png)
回答:
![](https://img-blog.csdnimg.cn/img_convert/580637a746e3b862e45807aff7540758.png)
![](https://img-blog.csdnimg.cn/img_convert/30500b048cfff3fdc412a2bfc2381020.png)
![](https://img-blog.csdnimg.cn/img_convert/790c193fefe4aba386b7a9d19d4de9b0.png)
15、Question about random seed. #291
![](https://img-blog.csdnimg.cn/img_convert/509f6b7b36b1e0a68c860b2149a04b6a.png)
![](https://img-blog.csdnimg.cn/img_convert/7b1203732bbf85b021557296d0566617.png)
16、HRSC2016 数据集性能重新实现 #202
问题:
![](https://img-blog.csdnimg.cn/img_convert/911979faf611ec7873d63ca5c849214a.png)
回答:
_base_ = [
'../_base_/datasets/hrsc.py', '../_base_/schedules/schedule_3x.py',
'../_base_/default_runtime.py'
]
angle_version = 'le90'
model = dict(
type='ReDet',
backbone=dict(
type='ReResNet',
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=1,
style='pytorch',
pretrained='./work_dirs/re_resnet50_c8_batch256-25b16846.pth'),
neck=dict(
type='ReFPN',
in_channels=[256, 512, 1024, 2048],
out_channels=256,
num_outs=5),
rpn_head=dict(
type='RotatedRPNHead',
in_channels=256,
feat_channels=256,
version=angle_version,
anchor_generator=dict(
type='AnchorGenerator',
scales=[8],
ratios=[0.5, 1.0, 2.0],
strides=[4, 8, 16, 32, 64]),
bbox_coder=dict(
type='DeltaXYWHBBoxCoder',
target_means=[.0, .0, .0, .0],
target_stds=[1.0, 1.0, 1.0, 1.0]),
loss_cls=dict(
type='CrossEntropyLoss', use_sigmoid=True, loss_weight=1.0),
loss_bbox=dict(type='SmoothL1Loss', beta=1.0 / 9.0, loss_weight=1.0)),
roi_head=dict(
type='RoITransRoIHead',
version=angle_version,
num_stages=2,
stage_loss_weights=[1, 1],
bbox_roi_extractor=[
dict(
type='SingleRoIExtractor',
roi_layer=dict(
type='RoIAlign', output_size=7, sampling_ratio=0),
out_channels=256,
featmap_strides=[4, 8, 16, 32]),
dict(
type='RotatedSingleRoIExtractor',
roi_layer=dict(
type='RiRoIAlignRotated',
out_size=7,
num_samples=2,
num_orientations=8,
clockwise=True),
out_channels=256,
featmap_strides=[4, 8, 16, 32]),
],
bbox_head=[
dict(
type='RotatedShared2FCBBoxHead',
in_channels=256,
fc_out_channels=1024,
roi_feat_size=7,
num_classes=1,
bbox_coder=dict(
type='DeltaXYWHAHBBoxCoder',
angle_range=angle_version,
norm_factor=2,
edge_swap=True,
target_means=[0., 0., 0., 0., 0.],
target_stds=[0.1, 0.1, 0.2, 0.2, 0.1]),
reg_class_agnostic=True,
loss_cls=dict(
type='CrossEntropyLoss',
use_sigmoid=False,
loss_weight=1.0),
loss_bbox=dict(type='SmoothL1Loss', beta=1.0,
loss_weight=1.0)),
dict(
type='RotatedShared2FCBBoxHead',
in_channels=256,
fc_out_channels=1024,
roi_feat_size=7,
num_classes=1,
bbox_coder=dict(
type='DeltaXYWHAOBBoxCoder',
angle_range=angle_version,
norm_factor=None,
edge_swap=True,
proj_xy=True,
target_means=[0., 0., 0., 0., 0.],
target_stds=[0.05, 0.05, 0.1, 0.1, 0.05]),
reg_class_agnostic=False,
loss_cls=dict(
type='CrossEntropyLoss',
use_sigmoid=False,
loss_weight=1.0),
loss_bbox=dict(type='SmoothL1Loss', beta=1.0, loss_weight=1.0))
]),
train_cfg=dict(
rpn=dict(
assigner=dict(
type='MaxIoUAssigner',
pos_iou_thr=0.7,
neg_iou_thr=0.3,
min_pos_iou=0.3,
match_low_quality=True,
ignore_iof_thr=-1),
sampler=dict(
type='RandomSampler',
num=256,
pos_fraction=0.5,
neg_pos_ub=-1,
add_gt_as_proposals=False),
allowed_border=0,
pos_weight=-1,
debug=False),
rpn_proposal=dict(
nms_pre=2000,
max_per_img=2000,
nms=dict(type='nms', iou_threshold=0.7),
min_bbox_size=0),
rcnn=[
dict(
assigner=dict(
type='MaxIoUAssigner',
pos_iou_thr=0.5,
neg_iou_thr=0.5,
min_pos_iou=0.5,
match_low_quality=False,
ignore_iof_thr=-1,
iou_calculator=dict(type='BboxOverlaps2D')),
sampler=dict(
type='RandomSampler',
num=512,
pos_fraction=0.25,
neg_pos_ub=-1,
add_gt_as_proposals=True),
pos_weight=-1,
debug=False),
dict(
assigner=dict(
type='MaxIoUAssigner',
pos_iou_thr=0.5,
neg_iou_thr=0.5,
min_pos_iou=0.5,
match_low_quality=False,
ignore_iof_thr=-1,
iou_calculator=dict(type='RBboxOverlaps2D')),
sampler=dict(
type='RRandomSampler',
num=512,
pos_fraction=0.25,
neg_pos_ub=-1,
add_gt_as_proposals=True),
pos_weight=-1,
debug=False)
]),
test_cfg=dict(
rpn=dict(
nms_pre=2000,
max_per_img=2000,
nms=dict(type='nms', iou_threshold=0.7),
min_bbox_size=0),
rcnn=dict(
nms_pre=2000,
min_bbox_size=0,
score_thr=0.05,
nms=dict(iou_thr=0.1),
max_per_img=2000)))
img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
train_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations', with_bbox=True),
dict(type='RResize', img_scale=(800, 512)),
dict(type='RRandomFlip', flip_ratio=0.5),
dict(type='Normalize', **img_norm_cfg),
dict(type='Pad', size_divisor=32),
dict(type='DefaultFormatBundle'),
dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels'])
]
test_pipeline = [
dict(type='LoadImageFromFile'),
dict(
type='MultiScaleFlipAug',
img_scale=(800, 512),
flip=False,
transforms=[
dict(type='RResize'),
dict(type='Normalize', **img_norm_cfg),
dict(type='Pad', size_divisor=32),
dict(type='DefaultFormatBundle'),
dict(type='Collect', keys=['img'])
])
]
dataset_type = 'HRSCDataset'
data_root = '/data/dataset_share/HRSC2016/HRSC2016/'
data = dict(
samples_per_gpu=2,
workers_per_gpu=2,
train=dict(
type=dataset_type,
classwise=False,
ann_file=data_root + 'ImageSets/trainval.txt',
ann_subdir=data_root + 'FullDataSet/Annotations/',
img_subdir=data_root + 'FullDataSet/AllImages/',
pipeline=train_pipeline),
val=dict(
type=dataset_type,
classwise=False,
ann_file=data_root + 'ImageSets/test.txt',
ann_subdir=data_root + 'FullDataSet/Annotations/',
img_subdir=data_root + 'FullDataSet/AllImages/',
pipeline=test_pipeline),
test=dict(
type=dataset_type,
classwise=False,
ann_file=data_root + 'ImageSets/test.txt',
ann_subdir=data_root + 'FullDataSet/Annotations/',
img_subdir=data_root + 'FullDataSet/AllImages/',
pipeline=test_pipeline))
evaluation = dict(interval=12, metric='mAP')
optimizer = dict(lr=0.01)
![](https://img-blog.csdnimg.cn/img_convert/8598d05a430c19db40b5d72841f02277.png)
![](https://img-blog.csdnimg.cn/img_convert/fb9d457f89d346d064545f858d922336.png)
![](https://img-blog.csdnimg.cn/img_convert/b31a5542144977813062e3c1de4353a4.png)
#原因是问题者的Target_stds和官方不一致,同时学习率也不一致导致的,官方也是使用单张GPU进行模型训练的。
![](https://img-blog.csdnimg.cn/img_convert/6474c63a63793b9ec3319a0d634948ae.png)
![](https://img-blog.csdnimg.cn/img_convert/01855a71903add3a585586887380c3c7.png)
问题:
![](https://img-blog.csdnimg.cn/img_convert/2ce711a0102510eba988e2c984f3e148.png)
回答:
![](https://img-blog.csdnimg.cn/img_convert/2610963d8182e81b62eb5bd2325970b3.png)
17、单个类别训练报错
问题:
![](https://img-blog.csdnimg.cn/img_convert/0c03ae2dfc3da04c526b141a92c7e58a.png)
![](https://img-blog.csdnimg.cn/img_convert/643b9d88f6d5cc9670daa0d72f3cb1c9.png)
回答:
![](https://img-blog.csdnimg.cn/img_convert/7f4bffd0d3a46ebd52ac4a150bf4a0ee.png)
18、HRSC2016 的 classwise 设置为 True 时,在评估时出现“IndexError: tuple index out of range”。 #182
![](https://img-blog.csdnimg.cn/img_convert/b8af7d2ddcccc71f557a1208aba06c65.png)
![](https://img-blog.csdnimg.cn/img_convert/878522ca562fda86bb012d654c3a5187.png)
19、尝试结合 swin-Transform 和 s2anet #217
问题:
![](https://img-blog.csdnimg.cn/img_convert/511cd02a0f52c3912f2d706982fa86c6.png)
_base_ = ['./s2anet_r50_fpn_1x_dota_le135.py']
pretrained = 'https://github.com/SwinTransformer/storage/releases/download/v1.0.0/swin_tiny_patch4_window7_224.pth' # noqa
model = dict(
backbone=dict(
_delete_=True,
type='SwinTransformer',
embed_dims=96,
depths=[2, 2, 6, 2],
num_heads=[3, 6, 12, 24],
window_size=7,
mlp_ratio=4,
qkv_bias=True,
qk_scale=None,
drop_rate=0.,
attn_drop_rate=0.,
drop_path_rate=0.2,
patch_norm=True,
out_indices=(0, 1, 2, 3),
with_cp=False,
convert_weights=True,
init_cfg=dict(type='Pretrained', checkpoint=pretrained)),
neck=dict(
_delete_=True,
type='FPN',
in_channels=[96, 192, 384, 768],
out_channels=256,
num_outs=5))
optimizer = dict(
_delete_=True,
type='AdamW',
lr=0.0001,
betas=(0.9, 0.999),
weight_decay=0.05,
paramwise_cfg=dict(
custom_keys={
'absolute_pos_embed': dict(decay_mult=0.),
'relative_position_bias_table': dict(decay_mult=0.),
'norm': dict(decay_mult=0.)
}))
![](https://img-blog.csdnimg.cn/img_convert/d5397e39fb15fc55717254d929a67427.png)
20、数据标签过多次显示会爆炸、预测后不出指标结果;当数据标签过多时,显存会爆,预测后指标结果不显示; #333
![](https://img-blog.csdnimg.cn/img_convert/d51b46b5c2974079a0097fc0cfc51b0c.png)
![](https://img-blog.csdnimg.cn/img_convert/71991767820c67e5d600a376816f952d.png)
![](https://img-blog.csdnimg.cn/img_convert/e06daabbba60812eee1144a9f3599688.png)
21、一个对象在 oriented-reppoints 中有两个预测类 #426
![](https://img-blog.csdnimg.cn/img_convert/441137278bd7c3333b7cff67cbc7e2c4.png)
![](https://img-blog.csdnimg.cn/img_convert/25794577f289eb1c23a56cf366c908bb.png)
![](https://img-blog.csdnimg.cn/img_convert/f3b042fa2ea574fc4a019d58d6eb52c2.png)
22、loss降不下来 #330
![](https://img-blog.csdnimg.cn/img_convert/f36b4d6528915a4596de8675bf18d3f6.png)
![](https://img-blog.csdnimg.cn/img_convert/c16774de3ca529189be6eabf8f1fefa3.png)
![](https://img-blog.csdnimg.cn/img_convert/ec31dc57134b406d1cf9a106421659bf.png)
23、当我使用 rmosaic 时如何可视化 #686
你好@QAQTATQAQTAT,您可以使用demo/image_demo.py可视化 rmosaic 的输出。rmosaic的使用方法可以参考https://github.com/open-mmlab/mmrotate/blob/dev-1.x/configs/rotated_rtmdet/rotated_rtmdet_tiny-300e-aug-hrsc.py 。
Mosaic( img_scale=(1024, 1024))-> Resize(scale=(2048, 2048))->RandomCrop(crop_size=(1024, 1024))
train_pipeline = [
dict(
type='mmdet.LoadImageFromFile',
file_client_args={{_base_.file_client_args}}),
dict(type='mmdet.LoadAnnotations', with_bbox=True, box_type='qbox'),
dict(type='ConvertBoxType', box_type_mapping=dict(gt_bboxes='rbox')),
dict(
type='mmdet.CachedMosaic',
img_scale=(800, 800),
pad_val=114.0,
max_cached_images=20,
random_pop=False),
dict(
type='mmdet.RandomResize',
resize_type='mmdet.Resize',
scale=(1600, 1600),
ratio_range=(0.5, 2.0),
keep_ratio=True),
dict(type='RandomRotate', prob=0.5, angle_range=180),
dict(type='mmdet.RandomCrop', crop_size=(800, 800)),
dict(type='mmdet.YOLOXHSVRandomAug'),
dict(
type='mmdet.RandomFlip',
prob=0.75,
direction=['horizontal', 'vertical', 'diagonal']),
dict(type='mmdet.Pad', size=(800, 800), pad_val=dict(img=(114, 114, 114))),
dict(
type='mmdet.CachedMixUp',
img_scale=(800, 800),
ratio_range=(1.0, 1.0),
max_cached_images=10,
random_pop=False,
pad_val=(114, 114, 114),
prob=0.5),
dict(type='mmdet.PackDetInputs')
]
24、[WIP] 在 TRR360D 中支持 RR360(旋转矩形 360)检测 #731
https://github.com/open-mmlab/mmrotate/pull/731
25、Oriented RCNN 不支持 iou loss? #649
![](https://img-blog.csdnimg.cn/img_convert/a4fd3a085ede2e33c95bc2af0aed4d71.png)
![](https://img-blog.csdnimg.cn/img_convert/9b078bd5ffbc393ee6c3dc30ba8d96ae.png)
![](https://img-blog.csdnimg.cn/img_convert/7da21cac8d92ef51e4df2204acd6cbf9.png)