Download UnSAMFlow/utils/config_parser.py from doanh25032004/models_animerun: direct link, hf CLI and curl.
- Browser
- Download file 904 Bytes
-
https://huggingface.co/doanh25032004/models_animerun/resolve/main/UnSAMFlow/utils/config_parser.py
- Command line
-
hf download hf://doanh25032004/models_animerun/UnSAMFlow/utils/config_parser.py
-
curl -L -o config_parser.py https://huggingface.co/doanh25032004/models_animerun/resolve/main/UnSAMFlow/utils/config_parser.py
904 Bytes
| """ | |
| Copyright (c) Meta Platforms, Inc. and affiliates. | |
| """ | |
| import json | |
| import os | |
| from easydict import EasyDict | |
| from utils.manifold_utils import pathmgr | |
| def update_config(base_cfg, new_cfg): | |
| for key in new_cfg: | |
| if key not in base_cfg: | |
| base_cfg[key] = new_cfg[key] | |
| elif type(base_cfg[key]) == EasyDict and type(new_cfg[key]) == EasyDict: | |
| update_config(base_cfg[key], new_cfg[key]) | |
| else: | |
| base_cfg[key] = new_cfg[key] | |
| return base_cfg | |
| def init_config(cfg_file): | |
| with open(pathmgr.get_local_path(cfg_file)) as f: | |
| cfg = EasyDict(json.load(f)) | |
| if "base_configs" in cfg: | |
| base_cfg_file = os.path.join(os.path.dirname(cfg_file), cfg.base_configs) | |
| with open(pathmgr.get_local_path(base_cfg_file)) as f: | |
| base_cfg = EasyDict(json.load(f)) | |
| cfg = update_config(base_cfg, cfg) | |
| return cfg | |