open-mmlab / mmrotate

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

[Bug] ``get_flops.py`` can get flops on FCOS, but not on roi_trans, it will report an error #848

Open LittleWhitemi opened 1 year ago

LittleWhitemi commented 1 year ago

Prerequisite

Task

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

Branch

1.x branch https://github.com/open-mmlab/mmrotate/tree/1.x

Environment

System environment: sys.platform: win32 Python: 3.9.16 (main, Mar 8 2023, 10:39:24) [MSC v.1916 64 bit (AMD64)] CUDA available: True numpy_random_seed: 451610591 GPU 0: NVIDIA GeForce RTX 3060 Laptop GPU CUDA_HOME: D:\Program Files (x86)\NVIDA GPU Computing Toolkit\CUDA\v11.6 NVCC: Cuda compilation tools, release 11.6, V11.6.124 MSVC: ���� x64 �� Microsoft (R) C/C++ �Ż������� 19.35.32215 �� GCC: n/a PyTorch: 1.12.1 PyTorch compiling details: PyTorch built with:

Reproduces the problem - code sample

python tools\analysis_tools\get_flops.py configs\roi_trans\roi-trans-le90_r50_fpn_1x_dota.py

Reproduces the problem - command or script

Traceback (most recent call last): File "D:\documentation\study\ships_detection\Rotated Detector\mmrotatesar_1.x\tools\analysis_tools\get_flops.py", line 88, in main() File "D:\documentation\study\ships_detection\Rotated Detector\mmrotatesar_1.x\tools\analysis_tools\get_flops.py", line 73, in main flops, params = get_model_complexity_info(model, input_shape) File "D:\APP\Anaconda3\envs\mmrotate1.x\lib\site-packages\mmcv\cnn\utils\flops_counter.py", line 107, in get_model_complexityinfo = flops_model(batch) File "D:\APP\Anaconda3\envs\mmrotate1.x\lib\site-packages\torch\nn\modules\module.py", line 1148, in _call_impl result = forward_call(*input, **kwargs) File "d:\documentation\study\ships_detection\object detection\mmdetection3.x\mmdetection\mmdet\models\detectors\base.py", line 96, in forward
return self._forward(inputs, data_samples) File "d:\documentation\study\ships_detection\object detection\mmdetection3.x\mmdetection\mmdet\models\detectors\two_stage.py", line 134, in _forward rpn_results_list = self.rpn_head.predict( File "d:\documentation\study\ships_detection\object detection\mmdetection3.x\mmdetection\mmdet\models\dense_heads\base_dense_head.py", line 191, in predict batch_img_metas = [ TypeError: 'NoneType' object is not iterable

Reproduces the problem - error message

TypeError: 'NoneType' object is not iterable

Additional information

when I use python tools\analysis_tools\get_flops.py configs\rotated_fcos\rotated-fcos-hbox-le90_r50_fpn_1x_dota.py, I got right result. However,when I use ``python tools\analysis_tools\get_flops.py configs\roi_trans\roi-trans-le90_r50_fpn_1x_dota.py```, there are "TypeError: 'NoneType' object is not iterable"

zytx121 commented 1 year ago

Hi @LittleWhitemi, since operators such as RotatedRoIAlign do not support calculating FLOPS, FLOPS cannot be calculated in the two-stage detectors.

Calendula597 commented 1 month ago

Hi @LittleWhitemi, since operators such as RotatedRoIAlign do not support calculating FLOPS, FLOPS cannot be calculated in the two-stage detectors.

How can I calculate FLOPS in the two-stage detectors?