@@ -97,6 +97,21 @@ def add_metadata(
9797 return config
9898
9999
100+ def _get_torchvision_detector_config (detector_name : str ) -> dict :
101+ """Get a torchvision detector configuration for the superanimal humanbody model"""
102+ if detector_name is None :
103+ raise ValueError (f"Detector name is required for superanimal humanbody models. Must be one of { SUPPORTED_TORCHVISION_DETECTORS } ." )
104+ if detector_name not in SUPPORTED_TORCHVISION_DETECTORS :
105+ raise ValueError (f"Unsupported humanbody detector { detector_name } . Should be one of { SUPPORTED_TORCHVISION_DETECTORS } " )
106+ return {
107+ "type" : "TorchvisionDetectorAdaptor" ,
108+ "model" : detector_name ,
109+ "weights" : "COCO_V1" ,
110+ "num_classes" : None ,
111+ "box_score_thresh" : 0.6 ,
112+ }
113+
114+
100115# NOTE - DUPLICATED @deruyter92 2026-01-23: Copied from the original DeepLabCut codebase
101116# from deeplabcut/pose_estimation_pytorch/modelzoo/utils.py
102117def load_super_animal_config (
@@ -126,7 +141,7 @@ def load_super_animal_config(
126141 model_config = add_metadata (project_config , model_config )
127142 model_config = update_config (model_config , max_individuals , device )
128143
129- if detector_name is None and super_animal != "superanimal_humanbody" :
144+ if detector_name is None :
130145 model_config ["method" ] = "BU"
131146 else :
132147 model_config ["method" ] = "TD"
@@ -135,16 +150,11 @@ def load_super_animal_config(
135150 )
136151 detector_cfg = read_config_as_dict (detector_cfg_path )
137152 model_config ["detector" ] = detector_cfg
138- if super_animal == "superanimal_humanbody" :
139- # Apply specific updates required to run the torchvision detector with pretrained weights
140- assert detector_name in SUPPORTED_TORCHVISION_DETECTORS
141- model_config ["detector" ]['model' ]= {
142- "type" : "TorchvisionDetectorAdaptor" ,
143- "model" : detector_name ,
144- "weights" : "COCO_V1" ,
145- "num_classes" : None ,
146- "box_score_thresh" : 0.6 ,
147- }
153+
154+ if super_animal == "superanimal_humanbody" :
155+ # Raises ValueError if Detector name is not one of SUPPORTED_TORCHVISION_DETECTORS
156+ torchvision_detector_config = _get_torchvision_detector_config (detector_name )
157+ model_config ["detector" ]["model" ] = torchvision_detector_config
148158 return model_config
149159
150160
0 commit comments