open-mmlab / mmrazor

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

Can this library be used in mm detection? How to use? #162

Open sunanlin13174 opened 2 years ago

sunanlin13174 commented 2 years ago

Checklist

Describe the question you meet

[here]

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.
    [here]
  3. Your train log file if you meet the problem during training. [here]
  4. Other code you modified in the mmrazor folder. [here]
pprp commented 2 years ago

Hi, thank you for your attention. You can refer to DetNAS, which uses both SPOS from MMRazor and MMDet.

pppppM commented 2 years ago

@pprp 您好!我有两个问题: 1、只要mmdetection中有的模块mmrazor都能直接调用吗? 2、我在mmdetection中添加了其他的模块,这种情况怎么使用mmrazor中的蒸馏方法?

Please use English or English & Chinese for issues so that we could have broader discussion.

Audrey528 commented 2 years ago

OK! I have two questions. One is can mmrazor call directly all modules of mmdetection? The other is can I use distilling provided by mmrazor if I added other module in mmdetection? Appreciate it!

pppppM commented 2 years ago

Thanks for your understanding. If your custom modules are registered into mmdet's registry, you can call it by adding mmdet prefix. https://github.com/open-mmlab/mmrazor/blob/2dad24044d7f1dad88f20221f8fc071dd40fdd4f/configs/nas/detnas/detnas_supernet_frcnn_shufflenetv2_fpn_1x_coco.py#L9

pprp commented 2 years ago

Hi, @Audrey528, MMRazor currently can not be used in mmdet. On the contrary, you could implement mmdet in mmrazor.

In mmrazor, you should add mmdet prefix to get mmdet's registry.

norm_cfg = dict(type='SyncBN', requires_grad=True)
model = dict(
    type='mmdet.FasterRCNN',
    backbone=dict(
        type='mmcls.SearchableShuffleNetV2',
        norm_cfg=norm_cfg,
        out_indices=(0, 1, 2, 3),
        widen_factor=1.0,
        with_last_layer=False),

Maybe you can refer to CWD, an algorithm built based on mmseg.

In CWD, knowledge distillation is implemented in mmrazor. To complete the distillation-related training operations, you can migrate the mmdet part of the code to mmrazor.

sunanlin13174 commented 2 years ago

Hi, @pprp ,CWD is a good example, and it would be perfect if there was a general tutorial on how to implement mmdet and mmseg in MMRazor.

pprp commented 2 years ago

Hi, @sunanlin13174 , thank you for your advice! We will add this requirement to the backlog.

Audrey528 commented 2 years ago

@pprp @pppppM Thanks for your answers!Just like the following picture says, if I run 'pip install -v -e .', offical mmdet will be installed. I wanna know how can I install the mmdetection I changed modules. I need u help. 1652931394

pppppM commented 2 years ago

@pprp @pppppM Thanks for your answers!Just like the following picture says, if I run 'pip install -v -e .', offical mmdet will be installed. I wanna know how can I install the mmdetection I changed modules. I need u help. 1652931394

There should be no re-installation of mmdet. If you have already installed a develop version mmdet, you can use your installed mmdet directly.