mim icon indicating copy to clipboard operation
mim copied to clipboard

use site-packages/${project}/.mim/config as the base config

Open okotaku opened this issue 3 years ago • 4 comments

Describe the feature I would like to be able to specify the config under .mim as the base config and run it as shown below.

_base_ = [
    'site-packages/mmcls/.mim/config/_base_/models/resnet18_cifar.py',
    'site-packages/mmcls/.mim/config/_base_/datasets/cifar10_bs16.py',
    'site-packages/mmcls/.mim/config/_base_/schedules/cifar10_bs128.py',
    'site-packages/mmcls/.mim/config/_base_/default_runtime.py'
]

Motivation When specifying the config in the repo as the base config, I find it inconvenient that I need to either download it locally by git clone or copy the config to be used itself under .mim.

Additional context The following part of mmcv is the load part of the base config. I think it is possible to load the config from .mim by changing this part, is this the proper way? https://github.com/open-mmlab/mmcv/blob/76cfd77b3a88ce17508471bf335829eb0628abcf/mmcv/utils/config.py#L239-L269

Is this the proper way to do it, or is there a way to complete it with a .mim repo?

okotaku avatar Nov 16 '21 23:11 okotaku

related: https://github.com/open-mmlab/mmdetection/issues/4481

yu4u avatar Nov 17 '21 01:11 yu4u

Hi, it is a great idea. In fact, mmcv also supports loading base config with an absolute path.

        if BASE_KEY in cfg_dict:
            cfg_dir = osp.dirname(filename)
            base_filename = cfg_dict.pop(BASE_KEY)
            base_filename = base_filename if isinstance(
                base_filename, list) else [base_filename]

            cfg_dict_list = list()
            cfg_text_list = list()
            for f in base_filename:
                _cfg_dict, _cfg_text = Config._file2dict(osp.join(cfg_dir, f))
                cfg_dict_list.append(_cfg_dict)
                cfg_text_list.append(_cfg_text)

https://github.com/open-mmlab/mmcv/blob/76cfd77b3a88ce17508471bf335829eb0628abcf/mmcv/utils/config.py#L248

If the f is an absolute path, the osp.join(cfg_dir, f) will return the f without concatenating the cfg_dir

zhouzaida avatar Nov 17 '21 12:11 zhouzaida

However, I think it is slightly inconvenient that the path of site-packages changes depending on the environment.

okotaku avatar Dec 21 '21 01:12 okotaku

Totally agree, but we need an elegant way to implement this feature.

zhouzaida avatar Dec 21 '21 09:12 zhouzaida

Hi~ We recently did an architectural upgrade and released MMEngine, and we suggest to use Config in MMEngine. It can load config from other repos like this:

_base_ = [
    'mmdet::_base_/schedules/schedule_1x.py',
    'mmdet::_base_/datasets/coco_instance.py',
    'mmdet::_base_/default_runtime.py',
    'mmdet::_base_/models/faster_rcnn_r50_fpn.py',
]

HAOCHENYE avatar Sep 21 '22 03:09 HAOCHENYE

Cool! Thank you for your great effort:)

okotaku avatar Sep 21 '22 03:09 okotaku