open-mmlab / mmrotate

OpenMMLab Rotated Object Detection Toolbox and Benchmark
https://mmrotate.readthedocs.io/en/latest/
Apache License 2.0
1.89k stars 559 forks source link

TypeError: S2ANet: ConvNeXt: __init__() got an unexpected keyword argument 'pretrained' #1015

Open xiaxiangyu opened 8 months ago

xiaxiangyu commented 8 months ago

Branch

master branch https://mmrotate.readthedocs.io/en/latest/

📚 The doc issue

Hello, I reported the following error when running the convnext model. My config is as follow

/home/S321087093/Mmrotate/mmrotate-main/mmrotate/utils/setup_env.py:39: UserWarning: Setting OMP_NUM_THREADS environment variable for each process to be 1 in default, to avoid your system being overloaded, please further tune the variable for optimal performance in your application as needed. f'Setting OMP_NUM_THREADS environment variable for each process ' /home/S321087093/Mmrotate/mmrotate-main/mmrotate/utils/setup_env.py:49: UserWarning: Setting MKL_NUM_THREADS environment variable for each process to be 1 in default, to avoid your system being overloaded, please further tune the variable for optimal performance in your application as needed. f'Setting MKL_NUM_THREADS environment variable for each process ' 2024-03-27 10:20:22,487 - mmrotate - INFO - Environment info:

sys.platform: linux Python: 3.7.13 (default, Mar 29 2022, 02:18:16) [GCC 7.5.0] CUDA available: True GPU 0: NVIDIA GeForce RTX 3090 CUDA_HOME: /usr/local/cuda NVCC: Cuda compilation tools, release 12.1, V12.1.66 GCC: gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0 PyTorch: 1.11.0 PyTorch compiling details: PyTorch built with:

TorchVision: 0.12.0 OpenCV: 4.6.0 MMCV: 1.6.0 MMCV Compiler: GCC 9.3 MMCV CUDA Compiler: 11.3 MMRotate: 0.3.2+c62f148

2024-03-27 10:20:23,855 - mmrotate - INFO - Distributed training: False 2024-03-27 10:20:24,747 - mmrotate - INFO - Config: dataset_type = 'SARDataset' data_root = 'data/ssdd/' 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=(608, 608)), dict( type='RRandomFlip', flip_ratio=[0.25, 0.25, 0.25], direction=['horizontal', 'vertical', 'diagonal'], version='le135'), 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=(608, 608), 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=2, workers_per_gpu=2, train=dict( type='SARDataset', ann_file='data/ssdd/train/labelTxt/', img_prefix='data/ssdd/train/images/', pipeline=[ dict(type='LoadImageFromFile'), dict(type='LoadAnnotations', with_bbox=True), dict(type='RResize', img_scale=(608, 608)), dict( type='RRandomFlip', flip_ratio=[0.25, 0.25, 0.25], direction=['horizontal', 'vertical', 'diagonal'], version='le135'), 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='le135'), val=dict( type='SARDataset', ann_file='data/ssdd/test/inshore/labelTxt/', img_prefix='data/ssdd/test/inshore/images/', pipeline=[ dict(type='LoadImageFromFile'), dict( type='MultiScaleFlipAug', img_scale=(608, 608), 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='le135'), test=dict( type='SARDataset', ann_file='data/ssdd/test/all/labelTxt/', img_prefix='data/ssdd/test/all/images/', pipeline=[ dict(type='LoadImageFromFile'), dict( type='MultiScaleFlipAug', img_scale=(608, 608), 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='le135')) evaluation = dict(interval=1, metric='mAP') optimizer = dict( type='AdamW', lr=0.0001, betas=(0.9, 0.999), weight_decay=0.05, paramwise_cfg=dict( custom_keys=dict( absolute_pos_embed=dict(decay_mult=0.0), relative_position_bias_table=dict(decay_mult=0.0), norm=dict(decay_mult=0.0)))) optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2)) lr_config = dict( policy='step', warmup='linear', warmup_iters=1000, warmup_ratio=0.3333333333333333, step=[48, 66]) runner = dict(type='EpochBasedRunner', max_epochs=72) checkpoint_config = dict(interval=1) log_config = dict( interval=50, hooks=[dict(type='TextLoggerHook'), dict(type='TensorboardLoggerHook')]) dist_params = dict(backend='nccl') log_level = 'INFO' load_from = None resume_from = None workflow = [('train', 1)] opencv_num_threads = 0 mp_start_method = 'fork' angle_version = 'le135' model = dict( type='S2ANet', neck=dict( type='FPN', in_channels=[96, 192, 384, 768], out_channels=256, start_level=1, add_extra_convs='on_input', num_outs=5), fam_head=dict( type='KFIoURRetinaHead', num_classes=1, in_channels=256, stacked_convs=2, feat_channels=256, assign_by_circumhbbox=None, anchor_generator=dict( type='RotatedAnchorGenerator', scales=[4], ratios=[1.0], strides=[8, 16, 32, 64, 128]), bbox_coder=dict( type='DeltaXYWHAOBBoxCoder', angle_range='le135', norm_factor=1, edge_swap=False, proj_xy=True, 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='KFLoss', beta=0.11, loss_weight=1.0, fun='ln')), align_cfgs=dict( type='AlignConv', kernel_size=3, channels=256, featmap_strides=[8, 16, 32, 64, 128]), odm_head=dict( type='KFIoUODMRefineHead', num_classes=1, in_channels=256, stacked_convs=2, feat_channels=256, assign_by_circumhbbox=None, anchor_generator=dict( type='PseudoAnchorGenerator', strides=[8, 16, 32, 64, 128]), bbox_coder=dict( type='DeltaXYWHAOBBoxCoder', angle_range='le135', norm_factor=1, edge_swap=False, proj_xy=True, 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='KFLoss', beta=0.11, loss_weight=1.0, fun='ln')), train_cfg=dict( fam_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), odm_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), backbone=dict( type='mmcls.ConvNeXt', arch='tiny', out_indices=[0, 1, 2, 3], drop_path_rate=0.4, layer_scale_init_value=1.0, gap_before_final_norm=False, init_cfg=dict( type='Pretrained', checkpoint= 'https://download.openmmlab.com/mmclassification/v0/convnext/downstream/convnext-tiny_3rdparty_32xb128-noema_in1k_20220301-795e9634.pth', prefix='backbone.'))) custom_imports = dict(imports=['mmcls.models'], allow_failed_imports=False) checkpoint_file = 'https://download.openmmlab.com/mmclassification/v0/convnext/downstream/convnext-tiny_3rdparty_32xb128-noema_in1k_20220301-795e9634.pth' find_unused_parameters = True work_dir = 'run_s2anet_convnext_kfiou_inshore' auto_resume = False gpu_ids = range(0, 1)

2024-03-27 10:20:24,747 - mmrotate - INFO - Set random seed to 1728223801, deterministic: False Traceback (most recent call last): File "/home/S321087093/anaconda3/envs/mmrotate/lib/python3.7/site-packages/mmcv/utils/registry.py", line 69, in build_from_cfg return obj_cls(**args) TypeError: init() got an unexpected keyword argument 'pretrained'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/S321087093/anaconda3/envs/mmrotate/lib/python3.7/site-packages/mmcv/utils/registry.py", line 69, in build_from_cfg return obj_cls(*args) File "/home/S321087093/Mmrotate/mmrotate-main/mmrotate/models/detectors/s2anet.py", line 27, in init self.backbone = build_backbone(backbone) File "/home/S321087093/Mmrotate/mmrotate-main/mmrotate/models/builder.py", line 17, in build_backbone return ROTATED_BACKBONES.build(cfg) File "/home/S321087093/anaconda3/envs/mmrotate/lib/python3.7/site-packages/mmcv/utils/registry.py", line 237, in build return self.build_func(args, **kwargs, registry=self) File "/home/S321087093/anaconda3/envs/mmrotate/lib/python3.7/site-packages/mmcv/cnn/builder.py", line 27, in build_model_from_cfg return build_from_cfg(cfg, registry, default_args) File "/home/S321087093/anaconda3/envs/mmrotate/lib/python3.7/site-packages/mmcv/utils/registry.py", line 72, in build_from_cfg raise type(e)(f'{obj_cls.name}: {e}') TypeError: ConvNeXt: init() got an unexpected keyword argument 'pretrained'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "tools/train.py", line 192, in main() File "tools/train.py", line 165, in main test_cfg=cfg.get('test_cfg')) File "/home/S321087093/Mmrotate/mmrotate-main/mmrotate/models/builder.py", line 56, in build_detector cfg, default_args=dict(train_cfg=train_cfg, test_cfg=test_cfg)) File "/home/S321087093/anaconda3/envs/mmrotate/lib/python3.7/site-packages/mmcv/utils/registry.py", line 237, in build return self.build_func(*args, **kwargs, registry=self) File "/home/S321087093/anaconda3/envs/mmrotate/lib/python3.7/site-packages/mmcv/cnn/builder.py", line 27, in build_model_from_cfg return build_from_cfg(cfg, registry, default_args) File "/home/S321087093/anaconda3/envs/mmrotate/lib/python3.7/site-packages/mmcv/utils/registry.py", line 72, in build_from_cfg raise type(e)(f'{obj_cls.name}: {e}') TypeError: S2ANet: ConvNeXt: init() got an unexpected keyword argument 'pretrained'

Suggest a potential alternative/fix

No response

xiaxiangyu commented 8 months ago

I have already installed mmcls 0.25.0