open-mmlab / mmyolo

OpenMMLab YOLO series toolbox and benchmark. Implemented RTMDet, RTMDet-Rotated,YOLOv5, YOLOv6, YOLOv7, YOLOv8,YOLOX, PPYOLOE, etc.
https://mmyolo.readthedocs.io/zh_CN/dev/
GNU General Public License v3.0
3k stars 542 forks source link

Fail to run NAS methods on yolov5,yolov6 and RTMDet #685

Closed LishaTang closed 1 year ago

LishaTang commented 1 year ago

Prerequisite

🐞 Describe the bug

Hi, I tried to run your config files listed in config/razor/subnets and all of them failed. It seems to be a problem caused by incompatible versions between mmyolo and mmrazor. Could you please help solve this? Or is there any way to test NAS-based methods and autoslim, a pruning method contained in mmrazor, on YOLO series and RTMDet? Thanks for your help! This is the bug produced: File "./tools/train.py", line 115, in main() File "./tools/train.py", line 104, in main runner = Runner.from_cfg(cfg) File "/home/tt/anaconda3/envs/mmyolo-v2/lib/python3.8/site-packages/mmengine/runner/runner.py", line 439, in from_cfg runner = cls( File "/home/tt/anaconda3/envs/mmyolo-v2/lib/python3.8/site-packages/mmengine/runner/runner.py", line 406, in init self.model = self.build_model(model) File "/home/tt/anaconda3/envs/mmyolo-v2/lib/python3.8/site-packages/mmengine/runner/runner.py", line 808, in build_model model = MODELS.build(model) File "/home/tt/anaconda3/envs/mmyolo-v2/lib/python3.8/site-packages/mmengine/registry/registry.py", line 548, in build return self.build_func(cfg, *args, **kwargs, registry=self) File "/home/tt/anaconda3/envs/mmyolo-v2/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 241, in build_model_from_cfg return build_from_cfg(cfg, registry, default_args) File "/home/tt/anaconda3/envs/mmyolo-v2/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 135, in build_from_cfg raise type(e)( TypeError: class YOLODetector in mmyolo/models/detectors/yolo_detector.py: class sub_model in mmrazor/registry/registry.py: class SearchableShuffleNetV2 in mmrazor/models/architectures/backbones/searchable_shufflenet_v2.py: init() takes 1 positional argument but 2 were given

Environment

sys.platform: linux Python: 3.8.16 (default, Mar 2 2023, 03:21:46) [GCC 11.2.0] CUDA available: True numpy_random_seed: 2147483648 GPU 0,1,2,3,4,5,6,7,8,9: NVIDIA GeForce RTX 3090 CUDA_HOME: /usr/local/cuda NVCC: Cuda compilation tools, release 11.6, V11.6.124 GCC: gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0 PyTorch: 1.12.0 PyTorch compiling details: PyTorch built with:

TorchVision: 0.13.0 OpenCV: 4.7.0 MMEngine: 0.7.0 MMCV: 2.0.0rc4 MMDetection: 3.0.0rc6 MMYOLO: 0.5.0+dc85144

Additional information

I didn't make any changes to the model or config. Besides, I have tried both 1.0.0rc2 and dev-1.x version for mmrazor, which didn't work.

gaoyang07 commented 1 year ago

mmcls is required when using backbones in mmrazor: https://github.com/open-mmlab/mmrazor/blob/90c5435bb0c49cf0c85fd316b078b1718952e21a/mmrazor/models/architectures/backbones/searchable_shufflenet_v2.py#L14-L18

LishaTang commented 1 year ago

Problem solved! Thanks so much for your time and help! Btw, is it possible for u to release a config file which supports pruning methods on MMYolo in the future? I just find that most model compression libraries show limited support for downstream tasks:) Thanks again.