mmrotate icon indicating copy to clipboard operation
mmrotate copied to clipboard

mmrotate\models\losses\kf_iou_loss.py", line 21, in xy_wh_r_2_xy_sigma _shape = xywhr.shape AttributeError: 'NoneType' object has no attribute 'shape'[Bug]

Open xxxyyynnn opened this issue 10 months ago • 1 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

sys.platform: linux Python: 3.8.19 (default, Mar 20 2024, 19:58:24) [GCC 11.2.0] CUDA available: True GPU 0: NVIDIA GeForce RTX 4090 GPU 1: NVIDIA GeForce RTX 3090 CUDA_HOME: /usr/local/cuda-11.8 NVCC: Cuda compilation tools, release 11.8, V11.8.89 GCC: gcc (Ubuntu 11.1.0-1ubuntu1~18.04.1) 11.1.0 PyTorch: 2.0.1+cu118 PyTorch compiling details: PyTorch built with:

  • GCC 9.3
  • C++ Version: 201703
  • Intel(R) oneAPI Math Kernel Library Version 2022.2-Product Build 20220804 for Intel(R) 64 architecture applications
  • Intel(R) MKL-DNN v2.7.3 (Git Hash 6dbeffbae1f23cbbeae17adb7b5b13f1f37c080e)
  • OpenMP 201511 (a.k.a. OpenMP 4.5)
  • LAPACK is enabled (usually provided by MKL)
  • NNPACK is enabled
  • CPU capability usage: AVX2
  • CUDA Runtime 11.8
  • 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_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_80,code=sm_80;-gencode;arch=compute_86,code=sm_86;-gencode;arch=compute_90,code=sm_90
  • CuDNN 8.9.5
    • Built with CuDNN 8.7
  • Magma 2.6.1
  • Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=11.8, CUDNN_VERSION=8.7.0, CXX_COMPILER=/opt/rh/devtoolset-9/root/usr/bin/c++, CXX_FLAGS= -D_GLIBCXX_USE_CXX11_ABI=0 -fabi-version=11 -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -DNDEBUG -DUSE_KINETO -DLIBKINETO_NOROCTRACER -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -O2 -fPIC -Wall -Wextra -Werror=return-type -Werror=non-virtual-dtor -Werror=bool-operation -Wnarrowing -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wunused-local-typedefs -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -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 -Werror=cast-function-type -Wno-stringop-overflow, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_DISABLE_GPU_ASSERTS=ON, TORCH_VERSION=2.0.1, USE_CUDA=ON, USE_CUDNN=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=1, USE_NNPACK=ON, USE_OPENMP=ON, USE_ROCM=OFF,

TorchVision: 0.15.2+cu118 OpenCV: 4.9.0 MMCV: 1.7.2 MMCV Compiler: GCC 9.3 MMCV CUDA Compiler: 11.8 MMRotate: 0.3.4+

Reproduces the problem - code sample

base = [ '/home/xyn02/LSKNet2/configs/base/datasets/xyn_dotav1.py', '/home/xyn02/LSKNet2/configs/base/schedules/xyn_schedule_1x.py', '/home/xyn02/LSKNet2/configs/base/xyn_default_runtime.py' ]

angle_version = 'le90'

gpu_number = 8

fp16 = dict(loss_scale='dynamic')

model = dict( type='OrientedRCNN', backbone=dict( type='LSKNet', embed_dims=[64, 128, 320, 512], drop_rate=0.1, drop_path_rate=0.1, depths=[2,2,4,2], # init_cfg=dict(type='Pretrained', checkpoint="/data/pretrained/lsk_s_backbone.pth.tar"), norm_cfg=dict(type='SyncBN', requires_grad=True)), neck=dict( type='FPN', in_channels=[64, 128, 320, 512], out_channels=256, num_outs=5), rpn_head=dict( type='OrientedRPNHead', 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='MidpointOffsetCoder', angle_range=angle_version, target_means=[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], target_stds=[1.0, 1.0, 1.0, 1.0, 0.5, 0.5]), loss_cls=dict( type='CrossEntropyLoss', use_sigmoid=True, loss_weight=1.0), loss_bbox=dict( type='SmoothL1Loss', beta=0.1111111111111111, loss_weight=1.0)), roi_head=dict( type='OrientedStandardRoIHead', bbox_roi_extractor=dict( type='RotatedSingleRoIExtractor', roi_layer=dict( type='RoIAlignRotated', out_size=7, sample_num=2, 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=15, 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.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))), loss_bbox=dict(type='KFLoss', loss_weight=5.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, gpu_assign_thr=800, 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.8), 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, iou_calculator=dict(type='RBboxOverlaps2D'), gpu_assign_thr=800, ignore_iof_thr=-1), 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.8), 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=(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( samples_per_gpu=1, workers_per_gpu=2, train=dict(pipeline=train_pipeline, version=angle_version), val=dict(version=angle_version), test=dict(version=angle_version))

custom_hooks=[dict( type='ExpMomentumEMAHook', total_iter = 8541*12, priority=49) ]

optimizer = dict( delete=True, type='AdamW', lr=0.0002, #/8*gpu_number, betas=(0.9, 0.999), weight_decay=0.05)

Reproduces the problem - command or script

python ./tools/train.py

Reproduces the problem - error message

Traceback (most recent call last): File "E:\Projects\Codes202403\LSKNet\tools\train.py", line 195, in main() File "E:\Projects\Codes202403\LSKNet\tools\train.py", line 184, in main train_detector( File "E:\Projects\Codes202403\LSKNet\mmrotate\apis\train.py", line 141, in train_detector runner.run(data_loaders, cfg.workflow) File "D:\Programs\anaconda3\envs\LSKNet\lib\site-packages\mmcv\runner\epoch_based_runner.py", line 136, in run epoch_runner(data_loaders[i], **kwargs) File "D:\Programs\anaconda3\envs\LSKNet\lib\site-packages\mmcv\runner\epoch_based_runner.py", line 53, in train self.run_iter(data_batch, train_mode=True, **kwargs) File "D:\Programs\anaconda3\envs\LSKNet\lib\site-packages\mmcv\runner\epoch_based_runner.py", line 31, in run_iter outputs = self.model.train_step(data_batch, self.optimizer, File "D:\Programs\anaconda3\envs\LSKNet\lib\site-packages\mmcv\parallel\data_parallel.py", line 77, in train_step return self.module.train_step(*inputs[0], **kwargs[0]) File "D:\Programs\anaconda3\envs\LSKNet\lib\site-packages\mmdet\models\detectors\base.py", line 248, in train_step losses = self(**data) File "D:\Programs\anaconda3\envs\LSKNet\lib\site-packages\torch\nn\modules\module.py", line 1194, in _call_impl return forward_call(*input, **kwargs) File "D:\Programs\anaconda3\envs\LSKNet\lib\site-packages\mmcv\runner\fp16_utils.py", line 119, in new_func return old_func(*args, **kwargs) File "D:\Programs\anaconda3\envs\LSKNet\lib\site-packages\mmdet\models\detectors\base.py", line 172, in forward return self.forward_train(img, img_metas, **kwargs) File "E:\Projects\Codes202403\LSKNet\mmrotate\models\detectors\two_stage.py", line 147, in forward_train roi_losses = self.roi_head.forward_train(x, img_metas, proposal_list, File "E:\Projects\Codes202403\LSKNet\mmrotate\models\roi_heads\oriented_standard_roi_head.py", line 90, in forward_train bbox_results = self._bbox_forward_train(x, sampling_results, File "E:\Projects\Codes202403\LSKNet\mmrotate\models\roi_heads\oriented_standard_roi_head.py", line 119, in _bbox_forward_train loss_bbox = self.bbox_head.loss(bbox_results['cls_score'], File "D:\Programs\anaconda3\envs\LSKNet\lib\site-packages\mmcv\runner\fp16_utils.py", line 208, in new_func return old_func(*args, **kwargs) File "E:\Projects\Codes202403\LSKNet\mmrotate\models\roi_heads\bbox_heads\rotated_bbox_head.py", line 347, in loss losses['loss_bbox'] = self.loss_bbox( File "D:\Programs\anaconda3\envs\LSKNet\lib\site-packages\torch\nn\modules\module.py", line 1194, in _call_impl return forward_call(*input, **kwargs) File "E:\Projects\Codes202403\LSKNet\mmrotate\models\losses\kf_iou_loss.py", line 152, in forward return kfiou_loss( File "D:\Programs\anaconda3\envs\LSKNet\lib\site-packages\mmdet\models\losses\utils.py", line 101, in wrapper loss = loss_func(pred, target, **kwargs) File "E:\Projects\Codes202403\LSKNet\mmrotate\models\losses\kf_iou_loss.py", line 61, in kfiou_loss _, Sigma_p = xy_wh_r_2_xy_sigma(pred_decode) File "E:\Projects\Codes202403\LSKNet\mmrotate\models\losses\kf_iou_loss.py", line 21, in xy_wh_r_2_xy_sigma _shape = xywhr.shape AttributeError: 'NoneType' object has no attribute 'shape'

Additional information

No response

xxxyyynnn avatar Apr 09 '24 05:04 xxxyyynnn

Hello, I am also using Kfiou and encountered the same issue. Has it been resolved?

ZhenboZhao77 avatar Jul 13 '24 06:07 ZhenboZhao77