mmrotate icon indicating copy to clipboard operation
mmrotate copied to clipboard

KFIOU+rtmdet

Open zhu011 opened this issue 1 year ago • 7 comments

Prerequisite

Task

I'm using the official example scripts/configs for the officially supported tasks/models/datasets.

Branch

master branch https://github.com/open-mmlab/mmrotate

Environment

ystem environment: sys.platform: linux Python: 3.8.16 (default, Jan 17 2023, 23:13:24) [GCC 11.2.0] CUDA available: True numpy_random_seed: 667925676 GPU 0: NVIDIA GeForce RTX 3080 Ti CUDA_HOME: /usr/local/cuda NVCC: Cuda compilation tools, release 11.3, V11.3.109 GCC: gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0 PyTorch: 1.7.0 PyTorch compiling details: PyTorch built with:

  • GCC 7.3

  • C++ Version: 201402

  • Intel(R) oneAPI Math Kernel Library Version 2021.4-Product Build 20210904 for Intel(R) 64 architecture applications

  • Intel(R) MKL-DNN v1.6.0 (Git Hash 5ef631a030a6f73131c77892041042805a06064f)

  • OpenMP 201511 (a.k.a. OpenMP 4.5)

  • NNPACK is enabled

  • CPU capability usage: AVX2

  • CUDA Runtime 11.0

  • NVCC architecture flags: -gencode;arch=compute_37,code=sm_37;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_61,code=sm_61;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_80,code=sm_80;-gencode;arch=compute_37,code=compute_37

  • CuDNN 8.0.3

  • Magma 2.5.2

  • Build settings: BLAS=MKL, BUILD_TYPE=Release, CXX_FLAGS= -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DUSE_VULKAN_WRAPPER -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Wno-stringop-overflow, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, USE_CUDA=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=ON, USE_NNPACK=ON, USE_OPENMP=ON,

    TorchVision: 0.8.0 OpenCV: 4.6.0 MMEngine: 0.3.2

Runtime environment: cudnn_benchmark: False mp_cfg: {'mp_start_method': 'fork', 'opencv_num_threads': 0} dist_cfg: {'backend': 'nccl'} seed: None Distributed launcher: none Distributed training: False GPU number: 1

04/09 20:44:06 - mmengine - INFO - Config: default_scope = 'mmrotate' default_hooks = dict( timer=dict(type='IterTimerHook'), logger=dict(type='LoggerHook', interval=50), param_scheduler=dict(type='ParamSchedulerHook'), checkpoint=dict(type='CheckpointHook', interval=12, max_keep_ckpts=3), sampler_seed=dict(type='DistSamplerSeedHook'), visualization=dict(type='mmdet.DetVisualizationHook')) env_cfg = dict( cudnn_benchmark=False, mp_cfg=dict(mp_start_method='fork', opencv_num_threads=0), dist_cfg=dict(backend='nccl')) vis_backends = [dict(type='LocalVisBackend')] visualizer = dict( type='RotLocalVisualizer', vis_backends=[dict(type='LocalVisBackend')], name='visualizer') log_processor = dict(type='LogProcessor', window_size=50, by_epoch=True) log_level = 'INFO' load_from = None resume = False custom_hooks = [ dict(type='mmdet.NumClassCheckHook'), dict( type='EMAHook', ema_type='mmdet.ExpMomentumEMA', momentum=0.0002, update_buffers=True, priority=49) ] max_epochs = 180 base_lr = 0.0001 interval = 5 train_cfg = dict(type='EpochBasedTrainLoop', max_epochs=180, val_interval=5) val_cfg = dict(type='ValLoop') test_cfg = dict(type='TestLoop') param_scheduler = [ dict( type='LinearLR', start_factor=1e-05, by_epoch=False, begin=0, end=1000), dict( type='CosineAnnealingLR', eta_min=5e-06, begin=90, end=180, T_max=90, by_epoch=True, convert_to_iter_based=True) ] optim_wrapper = dict( type='OptimWrapper', optimizer=dict(type='AdamW', lr=0.0001, weight_decay=0.05), paramwise_cfg=dict( norm_decay_mult=0, bias_decay_mult=0, bypass_duplicate=True)) dataset_type = 'SARDataset' data_root = 'data/ssdd/' file_client_args = dict(backend='disk') train_pipeline = [ dict( type='mmdet.LoadImageFromFile', file_client_args=dict(backend='disk')), dict(type='mmdet.LoadAnnotations', with_bbox=True, box_type='qbox'), dict(type='ConvertBoxType', box_type_mapping=dict(gt_bboxes='rbox')), dict(type='mmdet.Resize', scale=(512, 512), keep_ratio=True), dict(type='mmdet.Pad', size=(512, 512), pad_val=dict(img=(114, 114, 114))), dict( type='mmdet.RandomFlip', prob=0.75, direction=['horizontal', 'vertical', 'diagonal']), dict(type='mmdet.PackDetInputs') ] val_pipeline = [ dict( type='mmdet.LoadImageFromFile', file_client_args=dict(backend='disk')), dict(type='mmdet.Resize', scale=(512, 512), keep_ratio=True), dict(type='mmdet.Pad', size=(512, 512), pad_val=dict(img=(114, 114, 114))), dict(type='mmdet.LoadAnnotations', with_bbox=True, box_type='qbox'), dict(type='ConvertBoxType', box_type_mapping=dict(gt_bboxes='rbox')), dict( type='mmdet.PackDetInputs', meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape', 'scale_factor')) ] test_pipeline = [ dict( type='mmdet.LoadImageFromFile', file_client_args=dict(backend='disk')), dict(type='mmdet.Resize', scale=(512, 512), keep_ratio=True), dict(type='mmdet.Pad', size=(512, 512), pad_val=dict(img=(114, 114, 114))), dict( type='mmdet.PackDetInputs', meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape', 'scale_factor')) ] train_dataloader = dict( batch_size=8, num_workers=4, persistent_workers=True, sampler=dict(type='DefaultSampler', shuffle=True), batch_sampler=None, dataset=dict( type='SARDataset', data_root='data/ssdd/', ann_file='train/labelTxt/', data_prefix=dict(img_path='train/images/'), img_shape=(512, 512), filter_cfg=dict(filter_empty_gt=True), pipeline=[ dict( type='mmdet.LoadImageFromFile', file_client_args=dict(backend='disk')), dict( type='mmdet.LoadAnnotations', with_bbox=True, box_type='qbox'), dict( type='ConvertBoxType', box_type_mapping=dict(gt_bboxes='rbox')), dict(type='mmdet.Resize', scale=(512, 512), keep_ratio=True), dict( type='mmdet.Pad', size=(512, 512), pad_val=dict(img=(114, 114, 114))), dict( type='mmdet.RandomFlip', prob=0.75, direction=['horizontal', 'vertical', 'diagonal']), dict(type='mmdet.PackDetInputs') ])) val_dataloader = dict( batch_size=1, num_workers=2, persistent_workers=True, drop_last=False, sampler=dict(type='DefaultSampler', shuffle=False), dataset=dict( type='SARDataset', data_root='data/ssdd/', ann_file='test/inshore/labelTxt/', data_prefix=dict(img_path='test/inshore/images/'), img_shape=(512, 512), test_mode=True, pipeline=[ dict( type='mmdet.LoadImageFromFile', file_client_args=dict(backend='disk')), dict(type='mmdet.Resize', scale=(512, 512), keep_ratio=True), dict( type='mmdet.Pad', size=(512, 512), pad_val=dict(img=(114, 114, 114))), dict( type='mmdet.LoadAnnotations', with_bbox=True, box_type='qbox'), dict( type='ConvertBoxType', box_type_mapping=dict(gt_bboxes='rbox')), dict( type='mmdet.PackDetInputs', meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape', 'scale_factor')) ])) test_dataloader = dict( batch_size=1, num_workers=2, persistent_workers=True, drop_last=False, sampler=dict(type='DefaultSampler', shuffle=False), dataset=dict( type='SARDataset', data_root='data/ssdd/', ann_file='test/inshore/labelTxt/', data_prefix=dict(img_path='test/inshore/images/'), img_shape=(512, 512), test_mode=True, pipeline=[ dict( type='mmdet.LoadImageFromFile', file_client_args=dict(backend='disk')), dict(type='mmdet.Resize', scale=(512, 512), keep_ratio=True), dict( type='mmdet.Pad', size=(512, 512), pad_val=dict(img=(114, 114, 114))), dict( type='mmdet.LoadAnnotations', with_bbox=True, box_type='qbox'), dict( type='ConvertBoxType', box_type_mapping=dict(gt_bboxes='rbox')), dict( type='mmdet.PackDetInputs', meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape', 'scale_factor')) ])) val_evaluator = dict(type='DOTAMetric', metric='mAP') test_evaluator = dict(type='DOTAMetric', metric='mAP') checkpoint = 'https://download.openmmlab.com/mmdetection/v3.0/rtmdet/cspnext_rsb_pretrain/cspnext-l_8xb256-rsb-a1-600e_in1k-6a760974.pth' angle_version = 'le90' model = dict( type='mmdet.RTMDet', data_preprocessor=dict( type='mmdet.DetDataPreprocessor', mean=[103.53, 116.28, 123.675], std=[57.375, 57.12, 58.395], bgr_to_rgb=False, boxtype2tensor=False, batch_augments=None), backbone=dict( type='mmdet.CSPNeXt', arch='P5', expand_ratio=0.5, deepen_factor=1, widen_factor=1, channel_attention=True, norm_cfg=dict(type='SyncBN'), act_cfg=dict(type='SiLU'), init_cfg=dict( type='Pretrained', prefix='backbone.', checkpoint= 'https://download.openmmlab.com/mmdetection/v3.0/rtmdet/cspnext_rsb_pretrain/cspnext-l_8xb256-rsb-a1-600e_in1k-6a760974.pth' )), neck=dict( type='mmdet.CSPNeXtPAFPN', in_channels=[256, 512, 1024], out_channels=256, num_csp_blocks=3, expand_ratio=0.5, norm_cfg=dict(type='SyncBN'), act_cfg=dict(type='SiLU')), bbox_head=dict( type='RotatedRTMDetSepBNHead', num_classes=1, in_channels=256, stacked_convs=2, feat_channels=256, angle_version='le90', anchor_generator=dict( type='mmdet.MlvlPointGenerator', offset=0, strides=[8, 16, 32]), angle_coder=dict( type='PSCCoder', angle_version='le90', dual_freq=True, num_step=4), bbox_coder=dict(type='DistanceAnglePointCoder', angle_version='le90'), loss_cls=dict( type='mmdet.QualityFocalLoss', use_sigmoid=True, beta=2.0, loss_weight=1.0), loss_bbox_type='kfiou', loss_bbox=dict(type='KFLoss', fun='ln', loss_weight=5.0), loss_angle=dict(type='mmdet.L1Loss', loss_weight=0.1), with_objectness=False, exp_on_reg=True, share_conv=True, pred_kernel_size=1, use_hbbox_loss=False, scale_angle=False, norm_cfg=dict(type='SyncBN'), act_cfg=dict(type='SiLU')), train_cfg=dict( assigner=dict( type='mmdet.DynamicSoftLabelAssigner', iou_calculator=dict(type='RBboxOverlaps2D'), topk=13), allowed_border=-1, pos_weight=-1, debug=False), test_cfg=dict( nms_pre=2000, min_bbox_size=0, score_thr=0.05, nms=dict(type='nms_rotated', iou_threshold=0.1), max_per_img=2000)) launcher = 'none' work_dir = './work_dirs/rotated_rtmdet_psc_l-6x-ssddvoc12-kfiou'

Reproduces the problem - code sample

1

Reproduces the problem - command or script

1

Reproduces the problem - error message

File "/root/autodl-tmp/mmrotate/mmrotate/models/dense_heads/rotated_rtmdet_head.py", line 314, in loss_by_feat bbox_avg_factors, angle_avg_factors) = multi_apply( File "/root/miniconda3/envs/openmmlab/lib/python3.8/site-packages/mmdet/models/utils/misc.py", line 219, in multi_apply return tuple(map(list, zip(*map_results))) File "/root/autodl-tmp/mmrotate/mmrotate/models/dense_heads/rotated_rtmdet_head.py", line 217, in loss_by_feat_single loss_bbox = self.loss_bbox( File "/root/miniconda3/envs/openmmlab/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(*input, **kwargs) File "/root/autodl-tmp/mmrotate/mmrotate/models/losses/kf_iou_loss.py", line 152, in forward return kfiou_loss( File "/root/miniconda3/envs/openmmlab/lib/python3.8/site-packages/mmdet/models/losses/utils.py", line 121, in wrapper loss = loss_func(pred, target, **kwargs) File "/root/autodl-tmp/mmrotate/mmrotate/models/losses/kf_iou_loss.py", line 61, in kfiou_loss _, Sigma_p = xy_wh_r_2_xy_sigma(pred_decode) File "/root/autodl-tmp/mmrotate/mmrotate/models/losses/kf_iou_loss.py", line 21, in xy_wh_r_2_xy_sigma _shape = xywhr.shape

config如下_

base_ = './rotated_rtmdet_psc_l-6x-ssddvoc12.py' model = dict( bbox_head=dict( type='RotatedRTMDetSepBNHead', loss_bbox_type='kfiou', loss_bbox=dict(type='KFLoss', fun='ln', loss_weight=5.0)),) 大佬们,我应该如何改动才能加入KFIOU

Additional information

No response

zhu011 avatar Apr 09 '23 12:04 zhu011