open-mmlab / mmrazor

OpenMMLab Model Compression Toolbox and Benchmark.
https://mmrazor.readthedocs.io/en/latest/
Apache License 2.0
1.47k stars 227 forks source link

How to make this code base support mmrotate model? I want to prune rotated object detection model. #335

Open JinqingZhengTju opened 1 year ago

JinqingZhengTju commented 1 year ago

Checklist

Describe the question you meet

  I want to prune rotated object detection model. The current newest version of mmrazor doesn't support this kind of task. I want to know how to make the mmrazor support mmrotate task. Is there any instruction for this kind modify? For example, if I want to use AutoSlim method to prune oriented R-CNN model, then what should I do? 

Post related information

  1. The output of pip list | grep "mmcv\|mmrazor\|^torch" [here]
  2. Your config file if you modified it or created a new one.
mmcv-full            1.6.0
mmrazor              0.3.1    
mmrotate             0.3.2   
  1. Your train log file if you meet the problem during training. [here]
  2. Other code you modified in the mmrazor folder. [here]
spynccat commented 1 year ago

Sorry for the late reply. There is no mmrotate model in current mmrazor. But mmrotate is accessible in temporary mmrazor library. We try to provide a guidance for using autoslim to prune oriented R-CNN:

  1. clone support libraries and checkout to corresponding branch:
    mmcv-full        2.x
    mmrotate         dev-1.x
    mmrazor          dev-1.x
    mmdet            dev-3.x
  2. Since _base_/config/model is not provided in mmrotate, please directly import
    mmrotate::oriented_rcnn/oriented-rcnn-le90_r50_fpn_1x_dota.py
  3. Please contact us if any problem exist. Thanks.
JinqingZhengTju commented 1 year ago

Sorry for the late reply. There is no mmrotate model in current mmrazor. But mmrotate is accessible in temporary mmrazor library. We try to provide a guidance for using autoslim to prune oriented R-CNN:

  1. clone support libraries and checkout to corresponding branch:
mmcv-full        2.x
mmrotate         dev-1.x
mmrazor          dev-1.x
mmdet            dev-3.x
  1. Since _base_/config/model is not provided in mmrotate, please directly import
mmrotate::oriented_rcnn/oriented-rcnn-le90_r50_fpn_1x_dota.py
  1. Please contact us if any problem exist. Thanks. Thank you very much for your reply. I will try to implement this function under your instruction.
JinqingZhengTju commented 1 year ago

Sorry for the late reply. There is no mmrotate model in current mmrazor. But mmrotate is accessible in temporary mmrazor library. We try to provide a guidance for using autoslim to prune oriented R-CNN:

  1. clone support libraries and checkout to corresponding branch:
mmcv-full        2.x
mmrotate         dev-1.x
mmrazor          dev-1.x
mmdet            dev-3.x
  1. Since _base_/config/model is not provided in mmrotate, please directly import
mmrotate::oriented_rcnn/oriented-rcnn-le90_r50_fpn_1x_dota.py
  1. Please contact us if any problem exist. Thanks.

Is it possible that make the openmmlab1.0 to support pruning mmrotate model? Because I found that there are some problems with the versions of different code bases in openmmlab2.0. Are there some instructions to help me to make the mmrazor to support pruning mmrotate model under these code bases with the versions as follows: mmcv-full 1.6.0 mmrotate 0.3.2 mmrazor 0.3.1 mmdet 2.25.2 mmdeploy 0.9.0

LKJacky commented 1 year ago

It's hard to support mmrotate models for openmmlab1.0.

Now, we released a branch named exp_pruning based on openmmlab 2.0. It supports pruning mmrotate models. Welcome to use this branch. And exp_pruning will be merged into dev-1.x in the future.

JinqingZhengTju commented 1 year ago

It's hard to support mmrotate models for openmmlab1.0.

Now, we released a branch named exp_pruning based on openmmlab 2.0. It supports pruning mmrotate models. Welcome to use this branch. And exp_pruning will be merged into dev-1.x in the future.

Thanks for replying. I am trying to use this branch to pruning mmrotate models.

the-bigE commented 1 year ago

Sorry for the late reply. There is no mmrotate model in current mmrazor. But mmrotate is accessible in temporary mmrazor library. We try to provide a guidance for using autoslim to prune oriented R-CNN:

  1. clone support libraries and checkout to corresponding branch:
mmcv-full        2.x
mmrotate         dev-1.x
mmrazor          dev-1.x
mmdet            dev-3.x
  1. Since _base_/config/model is not provided in mmrotate, please directly import
mmrotate::oriented_rcnn/oriented-rcnn-le90_r50_fpn_1x_dota.py
  1. Please contact us if any problem exist. Thanks. Thank you very much for your reply. I will try to implement this function under your instruction.

Hello, I have installed mmrazor and mmrotate according to the above requirements. I want to use mmrazor to perform knowledge distillation on the model in mmroate, but an error is reported. The following is my error report. 02/28 20:24:13 - mmengine - WARNING - The "visualizer" registry in mmrotate did not set import location. Fallback to callmmrotate.utils.register_all_modulesinstead. 02/28 20:24:13 - mmengine - WARNING - The "vis_backend" registry in mmrotate did not set import location. Fallback to callmmrotate.utils.register_all_modulesinstead. 02/28 20:24:13 - mmengine - WARNING - The "model" registry in mmrazor did not set import location. Fallback to callmmrazor.utils.register_all_modules` instead. Traceback (most recent call last): File "/home/juzh/softerware/anaconda3/envs/mmlab2/lib/python3.7/site-packages/mmengine/registry/build_functions.py", line 121, in build_from_cfg obj = obj_cls(args) # type: ignore File "/home/juzh/softerware/anaconda3/envs/mmlab2/lib/python3.7/site-packages/mmrazor/models/algorithms/distill/configurable/single_teacher_distill.py", line 46, in init super().init(kwargs) File "/home/juzh/softerware/anaconda3/envs/mmlab2/lib/python3.7/site-packages/mmrazor/models/algorithms/base.py", line 64, in init architecture = MODELS.build(architecture) File "/home/juzh/softerware/anaconda3/envs/mmlab2/lib/python3.7/site-packages/mmengine/registry/registry.py", line 521, in build return self.build_func(cfg, *args, kwargs, registry=self) File "/home/juzh/softerware/anaconda3/envs/mmlab2/lib/python3.7/site-packages/mmrazor/registry/registry.py", line 43, in build_razor_model_from_cfg model = get_model(cfg) # type: ignore File "/home/juzh/softerware/anaconda3/envs/mmlab2/lib/python3.7/site-packages/mmengine/hub/hub.py", line 77, in get_model cfg = get_config(cfg_path, pretrained) File "/home/juzh/softerware/anaconda3/envs/mmlab2/lib/python3.7/site-packages/mmengine/hub/hub.py", line 34, in get_config package, cfg_path = _get_package_and_cfg_path(cfg_path) File "/home/juzh/softerware/anaconda3/envs/mmlab2/lib/python3.7/site-packages/mmengine/config/utils.py", line 124, in _get_package_and_cfg_path f'mmengine does not support to load {package} config.') AssertionError: mmengine does not support to load mmroate config.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "tools/train.py", line 66, in main() File "tools/train.py", line 59, in main runner = Runner.from_cfg(cfg) File "/home/juzh/softerware/anaconda3/envs/mmlab2/lib/python3.7/site-packages/mmengine/runner/runner.py", line 458, in from_cfg cfg=cfg, File "/home/juzh/softerware/anaconda3/envs/mmlab2/lib/python3.7/site-packages/mmengine/runner/runner.py", line 398, in init self.model = self.build_model(model) File "/home/juzh/softerware/anaconda3/envs/mmlab2/lib/python3.7/site-packages/mmengine/runner/runner.py", line 800, in build_model model = MODELS.build(model) File "/home/juzh/softerware/anaconda3/envs/mmlab2/lib/python3.7/site-packages/mmengine/registry/registry.py", line 521, in build return self.build_func(cfg, *args, **kwargs, registry=self) File "/home/juzh/softerware/anaconda3/envs/mmlab2/lib/python3.7/site-packages/mmengine/registry/build_functions.py", line 240, in build_model_from_cfg return build_from_cfg(cfg, registry, default_args) File "/home/juzh/softerware/anaconda3/envs/mmlab2/lib/python3.7/site-packages/mmengine/registry/build_functions.py", line 136, in build_from_cfg f'class {obj_cls.__name__} in ' # type: ignore AssertionError: class FpnTeacherDistill in mmrazor/models/algorithms/distill/configurable/fpn_teacher_distill.py: mmengine does not support to load mmroate config. `

LKJacky commented 1 year ago

@the-bigE It may be a spell error which is 'mmrotate', rather than 'mmroate'.

LakeOcean commented 10 months ago

Sorry for the late reply. There is no mmrotate model in current mmrazor. But mmrotate is accessible in temporary mmrazor library. We try to provide a guidance for using autoslim to prune oriented R-CNN:

  1. clone support libraries and checkout to corresponding branch:
mmcv-full        2.x
mmrotate         dev-1.x
mmrazor          dev-1.x
mmdet            dev-3.x
  1. Since _base_/config/model is not provided in mmrotate, please directly import
mmrotate::oriented_rcnn/oriented-rcnn-le90_r50_fpn_1x_dota.py
  1. Please contact us if any problem exist. Thanks. Thank you very much for your reply. I will try to implement this function under your instruction.

Hello, I have installed mmrazor and mmrotate according to the above requirements. I want to use mmrazor to perform knowledge distillation on the model in mmroate, but an error is reported. The following is my error report. 02/28 20:24:13 - mmengine - WARNING - The "visualizer" registry in mmrotate did not set import location. Fallback to callmmrotate.utils.register_all_modulesinstead. 02/28 20:24:13 - mmengine - WARNING - The "vis_backend" registry in mmrotate did not set import location. Fallback to callmmrotate.utils.register_all_modulesinstead. 02/28 20:24:13 - mmengine - WARNING - The "model" registry in mmrazor did not set import location. Fallback to callmmrazor.utils.register_all_modules` instead. Traceback (most recent call last): File "/home/juzh/softerware/anaconda3/envs/mmlab2/lib/python3.7/site-packages/mmengine/registry/build_functions.py", line 121, in build_from_cfg obj = obj_cls(args) # type: ignore File "/home/juzh/softerware/anaconda3/envs/mmlab2/lib/python3.7/site-packages/mmrazor/models/algorithms/distill/configurable/single_teacher_distill.py", line 46, in init super().init(kwargs) File "/home/juzh/softerware/anaconda3/envs/mmlab2/lib/python3.7/site-packages/mmrazor/models/algorithms/base.py", line 64, in init architecture = MODELS.build(architecture) File "/home/juzh/softerware/anaconda3/envs/mmlab2/lib/python3.7/site-packages/mmengine/registry/registry.py", line 521, in build return self.build_func(cfg, *args, kwargs, registry=self) File "/home/juzh/softerware/anaconda3/envs/mmlab2/lib/python3.7/site-packages/mmrazor/registry/registry.py", line 43, in build_razor_model_from_cfg model = get_model(cfg) # type: ignore File "/home/juzh/softerware/anaconda3/envs/mmlab2/lib/python3.7/site-packages/mmengine/hub/hub.py", line 77, in get_model cfg = get_config(cfg_path, pretrained) File "/home/juzh/softerware/anaconda3/envs/mmlab2/lib/python3.7/site-packages/mmengine/hub/hub.py", line 34, in get_config package, cfg_path = _get_package_and_cfg_path(cfg_path) File "/home/juzh/softerware/anaconda3/envs/mmlab2/lib/python3.7/site-packages/mmengine/config/utils.py", line 124, in _get_package_and_cfg_path f'mmengine does not support to load {package} config.') AssertionError: mmengine does not support to load mmroate config.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "tools/train.py", line 66, in main() File "tools/train.py", line 59, in main runner = Runner.from_cfg(cfg) File "/home/juzh/softerware/anaconda3/envs/mmlab2/lib/python3.7/site-packages/mmengine/runner/runner.py", line 458, in from_cfg cfg=cfg, File "/home/juzh/softerware/anaconda3/envs/mmlab2/lib/python3.7/site-packages/mmengine/runner/runner.py", line 398, in init self.model = self.build_model(model) File "/home/juzh/softerware/anaconda3/envs/mmlab2/lib/python3.7/site-packages/mmengine/runner/runner.py", line 800, in build_model model = MODELS.build(model) File "/home/juzh/softerware/anaconda3/envs/mmlab2/lib/python3.7/site-packages/mmengine/registry/registry.py", line 521, in build return self.build_func(cfg, *args, **kwargs, registry=self) File "/home/juzh/softerware/anaconda3/envs/mmlab2/lib/python3.7/site-packages/mmengine/registry/build_functions.py", line 240, in build_model_from_cfg return build_from_cfg(cfg, registry, default_args) File "/home/juzh/softerware/anaconda3/envs/mmlab2/lib/python3.7/site-packages/mmengine/registry/build_functions.py", line 136, in build_from_cfg f'class {obj_cls.__name__} in ' # type: ignore AssertionError: class FpnTeacherDistill in mmrazor/models/algorithms/distill/configurable/fpn_teacher_distill.py: mmengine does not support to load mmroate config. `

Did you solve the problem?