-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fix] Avoid scope switching when using mmdet inference interface (#2039)
- Loading branch information
Showing
4 changed files
with
33 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
# Copyright (c) OpenMMLab. All rights reserved. | ||
from .camera import SimpleCamera, SimpleCameraTorch | ||
from .collect_env import collect_env | ||
from .config_utils import adapt_mmdet_pipeline | ||
from .logger import get_root_logger | ||
from .setup_env import register_all_modules, setup_multi_processes | ||
from .timer import StopWatch | ||
|
||
__all__ = [ | ||
'get_root_logger', 'collect_env', 'StopWatch', 'setup_multi_processes', | ||
'register_all_modules', 'SimpleCamera', 'SimpleCameraTorch' | ||
'register_all_modules', 'SimpleCamera', 'SimpleCameraTorch', | ||
'adapt_mmdet_pipeline' | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Copyright (c) OpenMMLab. All rights reserved. | ||
from mmpose.utils.typing import ConfigDict | ||
|
||
|
||
def adapt_mmdet_pipeline(cfg: ConfigDict) -> ConfigDict: | ||
"""Converts pipeline types in MMDetection's test dataloader to use the | ||
'mmdet' namespace. | ||
Args: | ||
cfg (ConfigDict): Configuration dictionary for MMDetection. | ||
Returns: | ||
ConfigDict: Configuration dictionary with updated pipeline types. | ||
""" | ||
# use lazy import to avoid hard dependence on mmdet | ||
from mmdet.datasets import transforms | ||
|
||
if 'test_dataloader' not in cfg: | ||
return cfg | ||
|
||
pipeline = cfg.test_dataloader.dataset.pipeline | ||
for trans in pipeline: | ||
if trans['type'] in dir(transforms): | ||
trans['type'] = 'mmdet.' + trans['type'] | ||
|
||
return cfg |