Load a config from file filename and merge it into the default options.
(filename)
| 41 | |
| 42 | |
| 43 | def cfg_from_file(filename): |
| 44 | """Load a config from file filename and merge it into the default options.""" |
| 45 | with open(filename) as f: |
| 46 | yaml_cfg = yaml.load(f, Loader=yaml.SafeLoader) |
| 47 | |
| 48 | # Update the snapshot path to the corresponding path! |
| 49 | trainpath = str(filename).split("pose_cfg.yaml")[0] |
| 50 | yaml_cfg["snapshot_prefix"] = trainpath + "snapshot" |
| 51 | # the default is: "./snapshot" |
| 52 | |
| 53 | # reloading defaults, as they can bleed over from a previous run otherwise |
| 54 | import importlib |
| 55 | |
| 56 | from . import default_config |
| 57 | |
| 58 | importlib.reload(default_config) |
| 59 | |
| 60 | default_cfg = default_config.cfg |
| 61 | _merge_a_into_b(yaml_cfg, default_cfg) |
| 62 | |
| 63 | logging.info("Config:\n" + pprint.pformat(default_cfg)) |
| 64 | return default_cfg # updated |
| 65 | |
| 66 | |
| 67 | def load_config(filename="pose_cfg.yaml"): |
no test coverage detected