forked from open-mmlab/mmdetection3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feture] Export preprocess and deploy information to SDK (open-mmlab#65)
* add export info * add dump-info funciton * add collect info * fix lint * add docstring * docstring * docstring
- Loading branch information
Showing
2 changed files
with
45 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from typing import Union | ||
|
||
import mmcv | ||
|
||
from mmdeploy.utils import load_config | ||
|
||
|
||
def dump_info(deploy_cfg: Union[str, mmcv.Config], | ||
model_cfg: Union[str, mmcv.Config], work_dir: str): | ||
"""Export information to SDK. | ||
Args: | ||
deploy_cfg (str | mmcv.Config): deploy config file or dict | ||
model_cfg (str | mmcv.Config): model config file or dict | ||
work_dir (str): work dir to save json files | ||
""" | ||
# TODO dump default values of transformation function to json | ||
deploy_cfg, model_cfg = load_config(deploy_cfg, model_cfg) | ||
meta_keys = [ | ||
'filename', 'ori_filename', 'ori_shape', 'img_shape', 'pad_shape', | ||
'scale_factor', 'flip', 'flip_direction', 'img_norm_cfg' | ||
] | ||
if 'transforms' in model_cfg.data.test.pipeline[-1]: | ||
model_cfg.data.test.pipeline[-1]['transforms'][-1][ | ||
'meta_keys'] = meta_keys | ||
else: | ||
model_cfg.data.test.pipeline[-1]['meta_keys'] = meta_keys | ||
mmcv.dump( | ||
model_cfg.data.test.pipeline, | ||
'{}/preprocess.json'.format(work_dir), | ||
sort_keys=False, | ||
indent=4) | ||
|
||
mmcv.dump( | ||
deploy_cfg._cfg_dict, | ||
'{}/deploy_cfg.json'.format(work_dir), | ||
sort_keys=False, | ||
indent=4) |
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