Zzh-tju / Rotated-LD

Rotated Localization Distillation (CVPR 2022, TPAMI 2023)
Apache License 2.0
43 stars 2 forks source link

KeyError: 'KnowledgeDistillationRotatedSingleStageDetector is not in the models registry' #3

Closed Strontia closed 2 years ago

Strontia commented 2 years ago

尝试训练时,报错:KeyError: 'KnowledgeDistillationRotatedSingleStageDetector is not in the models registry' 在mmrotate下的model中似乎没有找到KnowledgeDistillationRotatedSingleStageDetector的注册文件

详细报错信息如下: `2022-10-04 17:11:27,172 - mmrotate - INFO - Environment info:

sys.platform: win32 Python: 3.7.13 (default, Mar 28 2022, 08:03:21) [MSC v.1916 64 bit (AMD64)] CUDA available: True GPU 0: GRID T4-16Q CUDA_HOME: E:\ProgramData\NVIDIA GPU Computing Toolkit\CUDA\v10.1 NVCC: Cuda compilation tools, release 10.1, V10.1.24 MSVC: 用于 x64 的 Microsoft (R) C/C++ 优化编译器 19.33.31630 版 GCC: n/a PyTorch: 1.8.0 PyTorch compiling details: PyTorch built with:

TorchVision: 0.9.0 OpenCV: 4.6.0 MMCV: 1.6.0 MMCV Compiler: MSVC 192930137 MMCV CUDA Compiler: 10.1 MMRotate: 0.3.2+d97743b

2022-10-04 17:11:28,339 - mmrotate - INFO - Distributed training: False 2022-10-04 17:11:29,563 - mmrotate - INFO - Config: dataset_type = 'DOTADataset' data_root = '/media/ssd/datasets/DOTAv1/split_ss_dota1_0/' 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']), dict( type='Normalize', mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True), 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=(1024, 1024), flip=False, transforms=[ dict(type='RResize'), dict( type='Normalize', mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True), dict(type='Pad', size_divisor=32), dict(type='DefaultFormatBundle'), dict(type='Collect', keys=['img']) ]) ] data = dict( samples_per_gpu=1, workers_per_gpu=2, train=dict( type='DOTADataset', ann_file='/media/ssd/datasets/DOTAv1/split_ss_dota1_0/train/annfiles/', img_prefix='/media/ssd/datasets/DOTAv1/split_ss_dota1_0/train/images/', 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']), dict( type='Normalize', mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True), dict(type='Pad', size_divisor=32), dict(type='DefaultFormatBundle'), dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels']) ], version='oc'), val=dict( type='DOTADataset', ann_file='/media/ssd/datasets/DOTAv1/split_ss_dota1_0/val/annfiles/', img_prefix='/media/ssd/datasets/DOTAv1/split_ss_dota1_0/val/images/', pipeline=[ dict(type='LoadImageFromFile'), dict( type='MultiScaleFlipAug', img_scale=(1024, 1024), flip=False, transforms=[ dict(type='RResize'), dict( type='Normalize', mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True), dict(type='Pad', size_divisor=32), dict(type='DefaultFormatBundle'), dict(type='Collect', keys=['img']) ]) ], version='oc'), test=dict( type='DOTADataset', ann_file='/media/ssd/datasets/DOTAv1/split_ss_dota1_0/val/annfiles/', img_prefix='/media/ssd/datasets/DOTAv1/split_ss_dota1_0/val/images/', pipeline=[ dict(type='LoadImageFromFile'), dict( type='MultiScaleFlipAug', img_scale=(1024, 1024), flip=False, transforms=[ dict(type='RResize'), dict( type='Normalize', mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True), dict(type='Pad', size_divisor=32), dict(type='DefaultFormatBundle'), dict(type='Collect', keys=['img']) ]) ], version='oc')) evaluation = dict(interval=12, metric='mAP') optimizer = dict(type='SGD', lr=0.0025, momentum=0.9, weight_decay=0.0001) optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2)) lr_config = dict( policy='step', warmup='linear', warmup_iters=500, warmup_ratio=0.3333333333333333, step=[8, 11]) runner = dict(type='EpochBasedRunner', max_epochs=12) checkpoint_config = dict(interval=12) log_config = dict(interval=50, hooks=[dict(type='TextLoggerHook')]) dist_params = dict(backend='nccl') log_level = 'INFO' load_from = None resume_from = None workflow = [('train', 1)] angle_version = 'oc' model = dict( type='KnowledgeDistillationRotatedSingleStageDetector', backbone=dict( type='ResNet', depth=18, num_stages=4, out_indices=(0, 1, 2, 3), frozen_stages=1, zero_init_residual=False, norm_cfg=dict(type='BN', requires_grad=True), norm_eval=True, style='pytorch', init_cfg=dict(type='Pretrained', checkpoint='torchvision://resnet18')), neck=dict( type='FPN', in_channels=[64, 128, 256, 512], out_channels=256, start_level=1, add_extra_convs='on_input', num_outs=5), bbox_head=dict( type='LDRotatedRetinaHead', num_classes=15, in_channels=256, stacked_convs=4, feat_channels=256, assign_by_circumhbbox='oc', anchor_generator=dict( type='RotatedAnchorGenerator', octave_base_scale=4, scales_per_octave=3, ratios=[1.0, 0.5, 2.0], strides=[8, 16, 32, 64, 128]), bbox_coder=dict( type='DeltaXYWHAOBBoxCoder', angle_range='oc', norm_factor=None, edge_swap=False, proj_xy=False, target_means=(0.0, 0.0, 0.0, 0.0, 0.0), target_stds=(1.0, 1.0, 1.0, 1.0, 1.0)), loss_cls=dict( type='FocalLoss', use_sigmoid=True, gamma=2.0, alpha=0.25, loss_weight=1.0), loss_bbox=dict( type='GDLoss_v1', loss_type='kld', fun='log1p', tau=1, loss_weight=1.0), reg_max=8, reg_decoded_bbox=True, loss_ld=dict( type='KnowledgeDistillationKLDivLoss', loss_weight=15, T=5), loss_kd=dict( type='KnowledgeDistillationKLDivLoss', loss_weight=15, T=5), loss_im=dict(type='IMLoss', loss_weight=0), imitation_method='finegrained'), train_cfg=dict( assigner=dict( type='MaxIoUAssigner', pos_iou_thr=0.5, neg_iou_thr=0.4, min_pos_iou=0, ignore_iof_thr=-1, iou_calculator=dict(type='RBboxOverlaps2D')), allowed_border=-1, pos_weight=-1, debug=False), test_cfg=dict( nms_pre=2000, min_bbox_size=0, score_thr=0.05, nms=dict(iou_thr=0.1), max_per_img=2000), teacher_config= 'configs/kld/rotated_retinanet_distribution_hbb_kld_r34_fpn_2x_dota_oc.py', teacher_ckpt='r34-kld-2x.pth', output_feature=True) teacher_ckpt = 'r34-kld-2x.pth' work_dir = './work_dirs\rotated_retinanet_distribution_hbb_kld_r18_r34_fpn_1x_dota_oc' auto_resume = False gpu_ids = range(0, 1)

2022-10-04 17:11:29,589 - mmrotate - INFO - Set random seed to 748900088, deterministic: False Traceback (most recent call last): File "tools/train.py", line 182, in main() File "tools/train.py", line 155, in main test_cfg=cfg.get('test_cfg')) File "E:\ProgramData\Miniconda3\envs\locdl\lib\site-packages\mmrotate\models\builder.py", line 56, in build_detector cfg, default_args=dict(train_cfg=train_cfg, test_cfg=test_cfg)) File "E:\ProgramData\Miniconda3\envs\locdl\lib\site-packages\mmcv\utils\registry.py", line 237, in build return self.build_func(*args, **kwargs, registry=self) File "E:\ProgramData\Miniconda3\envs\locdl\lib\site-packages\mmcv\cnn\builder.py", line 27, in build_model_from_cfg return build_from_cfg(cfg, registry, default_args) File "E:\ProgramData\Miniconda3\envs\locdl\lib\site-packages\mmcv\utils\registry.py", line 62, in build_from_cfg f'{obj_type} is not in the {registry.name} registry') KeyError: 'KnowledgeDistillationRotatedSingleStageDetector is not in the models registry'`

Zzh-tju commented 2 years ago

你应该是按照了官方的mmrotate进行了环境安装,它默认调用的是你的Miniconda3\envs\locdl\lib\site-packages\mmrotate\models\detectors中的文件,你需要添加本代码库中的rotated_kd_one_stage.py,并确保其被正常调用即可

Strontia commented 2 years ago

是的,报错是因为按官方mmrotate文档安装。按照repo的readme安装,可以正常运行