mirror of
https://github.com/open-mmlab/mmengine.git
synced 2025-06-03 21:54:44 +08:00
[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:
parent
3aba989fbc
commit
618a063ddc
@ -533,7 +533,7 @@ print(custom_optim)
|
|||||||
configs/_base_/schedules/schedule_1x.py
|
configs/_base_/schedules/schedule_1x.py
|
||||||
configs/_base_/datasets.coco_instance.py
|
configs/_base_/datasets.coco_instance.py
|
||||||
configs/_base_/default_runtime.py
|
configs/_base_/default_runtime.py
|
||||||
configs/_base_/models/faster_rcnn_r50_fpn.py
|
configs/_base_/models/faster-rcnn_r50_fpn.py
|
||||||
```
|
```
|
||||||
|
|
||||||
如果没有配置文件跨项目继承的功能,我们就需要把 MMDetection 的配置文件拷贝到当前项目,而我们现在只需要安装 MMDetection
|
如果没有配置文件跨项目继承的功能,我们就需要把 MMDetection 的配置文件拷贝到当前项目,而我们现在只需要安装 MMDetection
|
||||||
@ -546,7 +546,7 @@ _base_ = [
|
|||||||
'mmdet::_base_/schedules/schedule_1x.py',
|
'mmdet::_base_/schedules/schedule_1x.py',
|
||||||
'mmdet::_base_/datasets/coco_instance.py',
|
'mmdet::_base_/datasets/coco_instance.py',
|
||||||
'mmdet::_base_/default_runtime.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
|
from mmengine.hub import get_model
|
||||||
|
|
||||||
model = 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))
|
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
|
from mmengine.hub import get_config
|
||||||
|
|
||||||
cfg = 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)
|
print(cfg.model_path)
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -106,7 +106,7 @@ def _get_package_and_cfg_path(cfg_path: str) -> Tuple[str, str]:
|
|||||||
raise ValueError(
|
raise ValueError(
|
||||||
'`_get_package_and_cfg_path` is used for get external package, '
|
'`_get_package_and_cfg_path` is used for get external package, '
|
||||||
'please specify the package name and relative config path, just '
|
'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('::')
|
package_cfg = cfg_path.split('::')
|
||||||
if len(package_cfg) > 2:
|
if len(package_cfg) > 2:
|
||||||
raise ValueError('`::` should only be used to separate package and '
|
raise ValueError('`::` should only be used to separate package and '
|
||||||
|
@ -21,9 +21,9 @@ def get_config(cfg_path: str, pretrained: bool = False) -> Config:
|
|||||||
by ``cfg.model_path``. Defaults to False.
|
by ``cfg.model_path``. Defaults to False.
|
||||||
|
|
||||||
Examples:
|
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
|
>>> # 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
|
>>> 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
|
https://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth
|
||||||
|
|
||||||
|
@ -17,23 +17,23 @@ data_path = osp.join(osp.dirname(osp.dirname(__file__)), 'data/')
|
|||||||
reason='mmdet and mmpose should be installed')
|
reason='mmdet and mmpose should be installed')
|
||||||
def test_get_config():
|
def test_get_config():
|
||||||
# Test load base 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')
|
package_path = get_installed_path('mmdet')
|
||||||
test_base_cfg = Config.fromfile(
|
test_base_cfg = Config.fromfile(
|
||||||
osp.join(package_path, '.mim',
|
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
|
assert test_base_cfg._cfg_dict == base_cfg._cfg_dict
|
||||||
|
|
||||||
# Test load faster_rcnn config
|
# 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(
|
test_cfg = Config.fromfile(
|
||||||
osp.join(package_path, '.mim',
|
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
|
assert cfg._cfg_dict == test_cfg._cfg_dict
|
||||||
|
|
||||||
# Test pretrained
|
# Test pretrained
|
||||||
cfg = 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)
|
||||||
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
|
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
|
# Test load mmpose
|
||||||
|
Loading…
x
Reference in New Issue
Block a user