[Docs] Fix docstring and documentation used for hub.get_model (#659)

* fix docstring and documentation used for hub.get_model

* fix config name in test_hub

* fix docstring mentioned faster-rcnn in utils
This commit is contained in:
Yanhong Zeng 2022-11-02 10:16:56 +08:00 committed by GitHub
parent 3aba989fbc
commit 618a063ddc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 12 deletions

View File

@ -533,7 +533,7 @@ print(custom_optim)
configs/_base_/schedules/schedule_1x.py
configs/_base_/datasets.coco_instance.py
configs/_base_/default_runtime.py
configs/_base_/models/faster_rcnn_r50_fpn.py
configs/_base_/models/faster-rcnn_r50_fpn.py
```
如果没有配置文件跨项目继承的功能,我们就需要把 MMDetection 的配置文件拷贝到当前项目,而我们现在只需要安装 MMDetection
@ -546,7 +546,7 @@ _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',
'mmdet::_base_/models/faster-rcnn_r50_fpn.py',
]
```
@ -575,7 +575,7 @@ MMEngine 还提供了 `get_config` 和 `get_model` 两个接口,支持对符
from mmengine.hub import get_model
model = get_model(
'mmdet::faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py', pretrained=True)
'mmdet::faster_rcnn/faster-rcnn_r50_fpn_1x_coco.py', pretrained=True)
print(type(model))
```
@ -592,7 +592,7 @@ http loads checkpoint from path: https://download.openmmlab.com/mmdetection/v2.0
from mmengine.hub import get_config
cfg = get_config(
'mmdet::faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py', pretrained=True)
'mmdet::faster_rcnn/faster-rcnn_r50_fpn_1x_coco.py', pretrained=True)
print(cfg.model_path)
```

View File

@ -106,7 +106,7 @@ def _get_package_and_cfg_path(cfg_path: str) -> Tuple[str, str]:
raise ValueError(
'`_get_package_and_cfg_path` is used for get external package, '
'please specify the package name and relative config path, just '
'like `mmdet::faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py`')
'like `mmdet::faster_rcnn/faster-rcnn_r50_fpn_1x_coco.py`')
package_cfg = cfg_path.split('::')
if len(package_cfg) > 2:
raise ValueError('`::` should only be used to separate package and '

View File

@ -21,9 +21,9 @@ def get_config(cfg_path: str, pretrained: bool = False) -> Config:
by ``cfg.model_path``. Defaults to False.
Examples:
>>> cfg = get_config('mmdet::faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py', pretrained=True)
>>> cfg = get_config('mmdet::faster_rcnn/faster-rcnn_r50_fpn_1x_coco.py', pretrained=True)
>>> # Equivalent to
>>> # cfg = Config.fromfile('/path/to/faster_rcnn_r50_fpn_1x_coco.py')
>>> # cfg = Config.fromfile('/path/to/faster-rcnn_r50_fpn_1x_coco.py')
>>> cfg.model_path
https://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth

View File

@ -17,23 +17,23 @@ data_path = osp.join(osp.dirname(osp.dirname(__file__)), 'data/')
reason='mmdet and mmpose should be installed')
def test_get_config():
# Test load base config.
base_cfg = get_config('mmdet::_base_/models/faster_rcnn_r50_fpn.py')
base_cfg = get_config('mmdet::_base_/models/faster-rcnn_r50_fpn.py')
package_path = get_installed_path('mmdet')
test_base_cfg = Config.fromfile(
osp.join(package_path, '.mim',
'configs/_base_/models/faster_rcnn_r50_fpn.py'))
'configs/_base_/models/faster-rcnn_r50_fpn.py'))
assert test_base_cfg._cfg_dict == base_cfg._cfg_dict
# Test load faster_rcnn config
cfg = get_config('mmdet::faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py')
cfg = get_config('mmdet::faster_rcnn/faster-rcnn_r50_fpn_1x_coco.py')
test_cfg = Config.fromfile(
osp.join(package_path, '.mim',
'configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py'))
'configs/faster_rcnn/faster-rcnn_r50_fpn_1x_coco.py'))
assert cfg._cfg_dict == test_cfg._cfg_dict
# Test pretrained
cfg = get_config(
'mmdet::faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py', pretrained=True)
'mmdet::faster_rcnn/faster-rcnn_r50_fpn_1x_coco.py', pretrained=True)
assert cfg.model_path == 'https://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth' # noqa E301
# Test load mmpose