MCPcopy Create free account
hub / github.com/DeepLabCut/DeepLabCut / update_config

Function update_config

deeplabcut/pose_estimation_pytorch/config/utils.py:119–146  ·  view source on GitHub ↗

Updates items in the configuration file. The configuration dict should only be composed of primitive Python types (dict, list and values). This is the case when reading the file using `read_config_as_dict`. Args: config: the configuration dict to update updates: the

(config: dict, updates: dict, copy_original: bool = True)

Source from the content-addressed store, hash-verified

117
118
119def update_config(config: dict, updates: dict, copy_original: bool = True) -> dict:
120 """Updates items in the configuration file.
121
122 The configuration dict should only be composed of primitive Python types
123 (dict, list and values). This is the case when reading the file using
124 `read_config_as_dict`.
125
126 Args:
127 config: the configuration dict to update
128 updates: the updates to make to the configuration dict
129 copy_original: whether to copy the original dict before updating it
130
131 Returns:
132 the updated dictionary
133 """
134 if copy_original:
135 config = copy.deepcopy(config)
136
137 for k, v in updates.items():
138 if k in config and isinstance(config[k], dict) and isinstance(v, dict):
139 if k in ("optimizer", "scheduler") and config["type"] != v["type"]:
140 # if changing the optimizer or scheduler type, update all values
141 config[k] = v
142 else:
143 config[k] = update_config(config[k], v, copy_original=False)
144 else:
145 config[k] = copy.deepcopy(v)
146 return config
147
148
149def update_config_by_dotpath(config: dict, updates: dict, copy_original: bool = True) -> dict:

Callers 7

keypoint_matchingFunction · 0.90
__init__Method · 0.90
make_pytorch_pose_configFunction · 0.90
add_detectorFunction · 0.90
test_update_configFunction · 0.90

Calls 1

itemsMethod · 0.80

Tested by 1

test_update_configFunction · 0.72