55# This should be removed once a solution is found to address duplicate code.
66
77import copy
8- from pathlib import Path
98import logging
9+ from pathlib import Path
1010
11+ from dlclibrary .dlcmodelzoo .modelzoo_download import download_huggingface_model
1112from ruamel .yaml import YAML
1213
13- from dlclibrary .dlcmodelzoo .modelzoo_download import download_huggingface_model
1414from dlclive .modelzoo .resolve_config import update_config
1515
16- _MODELZOO_PATH = Path (__file__ ).parent
16+ _MODELZOO_PATH = Path (__file__ ).parent
1717
1818
1919def get_super_animal_model_config_path (model_name : str ) -> Path :
2020 """Get the path to the model configuration file for a model and validate choice of model"""
21- cfg_path = _MODELZOO_PATH / ' model_configs' / f"{ model_name } .yaml"
21+ cfg_path = _MODELZOO_PATH / " model_configs" / f"{ model_name } .yaml"
2222 if not cfg_path .exists ():
2323 raise FileNotFoundError (
24- f"Modelzoo model configuration file not found: { cfg_path } "
25- f"Available models: { list_available_models ()} "
24+ f"Modelzoo model configuration file not found: { cfg_path } Available models: { list_available_models ()} "
2625 )
2726 return cfg_path
2827
2928
3029def get_super_animal_project_config_path (super_animal : str ) -> Path :
3130 """Get the path to the project configuration file for a project and validate choice of project"""
32- cfg_path = _MODELZOO_PATH / ' project_configs' / f"{ super_animal } .yaml"
31+ cfg_path = _MODELZOO_PATH / " project_configs" / f"{ super_animal } .yaml"
3332 if not cfg_path .exists ():
3433 raise FileNotFoundError (
35- f"Modelzoo project configuration file not found: { cfg_path } "
36- f"Available projects: { list_available_projects ()} "
34+ f"Modelzoo project configuration file not found: { cfg_path } Available projects: { list_available_projects ()} "
3735 )
3836 return cfg_path
3937
4038
4139def get_snapshot_folder_path () -> Path :
42- return _MODELZOO_PATH / ' snapshots'
40+ return _MODELZOO_PATH / " snapshots"
4341
4442
4543def list_available_models () -> list [str ]:
46- return [p .stem for p in _MODELZOO_PATH .glob (' model_configs/*.yaml' )]
44+ return [p .stem for p in _MODELZOO_PATH .glob (" model_configs/*.yaml" )]
4745
4846
4947def list_available_projects () -> list [str ]:
50- return [p .stem for p in _MODELZOO_PATH .glob (' project_configs/*.yaml' )]
48+ return [p .stem for p in _MODELZOO_PATH .glob (" project_configs/*.yaml" )]
5149
5250
5351def list_available_combinations () -> list [str ]:
5452 models = list_available_models ()
5553 projects = list_available_projects ()
56- combinations = ['_' .join ([p , m ]) for p in projects for m in models ]
54+ combinations = ["_" .join ([p , m ]) for p in projects for m in models ]
5755 return combinations
5856
5957
@@ -65,14 +63,18 @@ def read_config_as_dict(config_path: str | Path) -> dict:
6563 Returns:
6664 The configuration file with pure Python classes
6765 """
68- with open (config_path , "r" ) as f :
69- cfg = YAML (typ = ' safe' , pure = True ).load (f )
66+ with open (config_path ) as f :
67+ cfg = YAML (typ = " safe" , pure = True ).load (f )
7068
7169 return cfg
7270
7371
74- # NOTE JR 2026-23-01: This is duplicate code, copied from the original DeepLabCut-Live codebase.
75- def add_metadata (project_config : dict , config : dict ,) -> dict :
72+ # NOTE - DUPLICATED @deruyter92 2026-23-01: Copied from the original DeepLabCut codebase
73+ # from deeplabcut/pose_estimation_pytorch/config/make_pose_config.py
74+ def add_metadata (
75+ project_config : dict ,
76+ config : dict ,
77+ ) -> dict :
7678 """Adds metadata to a pytorch pose configuration
7779
7880 Args:
@@ -95,7 +97,8 @@ def add_metadata(project_config: dict, config: dict,) -> dict:
9597 return config
9698
9799
98- # NOTE JR 2026-23-01: This is duplicate code, copied from the original DeepLabCut-Live codebase.
100+ # NOTE - DUPLICATED @deruyter92 2026-23-01: Copied from the original DeepLabCut codebase
101+ # from deeplabcut/pose_estimation_pytorch/modelzoo/utils.py
99102def load_super_animal_config (
100103 super_animal : str ,
101104 model_name : str ,
@@ -128,9 +131,7 @@ def load_super_animal_config(
128131 else :
129132 model_config ["method" ] = "TD"
130133 if super_animal != "superanimal_humanbody" :
131- detector_cfg_path = get_super_animal_model_config_path (
132- model_name = detector_name
133- )
134+ detector_cfg_path = get_super_animal_model_config_path (model_name = detector_name )
134135 detector_cfg = read_config_as_dict (detector_cfg_path )
135136 model_config ["detector" ] = detector_cfg
136137 return model_config
@@ -159,9 +160,7 @@ def download_super_animal_snapshot(dataset: str, model_name: str) -> Path:
159160 return model_path
160161
161162 try :
162- download_huggingface_model (
163- model_name , target_dir = str (snapshot_dir ), rename_mapping = model_filename
164- )
163+ download_huggingface_model (model_name , target_dir = str (snapshot_dir ), rename_mapping = model_filename )
165164
166165 if not model_path .exists ():
167166 raise RuntimeError (f"Failed to download { model_name } to { model_path } " )
@@ -171,5 +170,3 @@ def download_super_animal_snapshot(dataset: str, model_name: str) -> Path:
171170 raise e
172171
173172 return model_path
174-
175-
0 commit comments