open-mmlab / mmdetection

OpenMMLab Detection Toolbox and Benchmark
https://mmdetection.readthedocs.io
Apache License 2.0
29.69k stars 9.48k forks source link

How to use the mmpretrain model in mmdetection? #11978

Open sjtu-cz opened 1 month ago

sjtu-cz commented 1 month ago

for example, I want use simmim (https://github.com/open-mmlab/mmpretrain/tree/main/configs/simmim) to pretrain the swin_v2 (https://github.com/open-mmlab/mmpretrain/blob/main/mmpretrain/models/backbones/swin_transformer_v2.py), and use it in mmdetection, such as mmconfigs/cascade_rcnn Is it easy to use?

Darren759 commented 1 month ago

Did you solved it? I have the same problem!

sjtu-cz commented 1 month ago

@ZwwWayne @Keiku @anurag1paul help please!

Keiku commented 1 month ago

@sjtu-cz ChatGPT says the following, so could you try it for reference? In my environment, I can't run large models, so I can't verify it, so I'll consider whether there is any way to do it.

Yes, it's feasible to use SimMIM to pretrain the SwinV2 model and then use it in MMDetection with configurations like cascade_rcnn. However, the process involves several steps to ensure compatibility across different components. Here's a general outline of how you can achieve this:

1. Pretrain SwinV2 with SimMIM (MMPretrain)

2. Save and Export Pretrained Weights

3. Integrate Pretrained Weights into MMDetection

4. Ensure Compatibility (Input Size, Feature Maps)

5. Finetuning with Detection Task

6. Run the Training

Potential Challenges:

This workflow should allow you to pretrain SwinV2 with SimMIM and transfer the backbone for detection tasks like Cascade R-CNN within MMDetection.