MCPcopy Index your code
hub / github.com/DeepLabCut/DeepLabCut / evaluate_assembly

Function evaluate_assembly

deeplabcut/core/inferenceutils.py:1196–1266  ·  view source on GitHub ↗
(
    ass_pred_dict,
    ass_true_dict,
    oks_sigma=0.072,
    oks_thresholds=None,
    margin=0,
    symmetric_kpts=None,
    greedy_matching=False,
    with_tqdm: bool = True,
)

Source from the content-addressed store, hash-verified

1194
1195
1196def evaluate_assembly(
1197 ass_pred_dict,
1198 ass_true_dict,
1199 oks_sigma=0.072,
1200 oks_thresholds=None,
1201 margin=0,
1202 symmetric_kpts=None,
1203 greedy_matching=False,
1204 with_tqdm: bool = True,
1205):
1206 if oks_thresholds is None:
1207 oks_thresholds = np.linspace(0.5, 0.95, 10)
1208 if greedy_matching:
1209 return evaluate_assembly_greedy(
1210 ass_true_dict,
1211 ass_pred_dict,
1212 oks_sigma=oks_sigma,
1213 oks_thresholds=oks_thresholds,
1214 margin=margin,
1215 symmetric_kpts=symmetric_kpts,
1216 )
1217
1218 # sigma is taken as the median of all COCO keypoint standard deviations
1219 all_matched = []
1220 total_gt_assemblies = 0
1221
1222 gt_assemblies = ass_true_dict.items()
1223 if with_tqdm:
1224 gt_assemblies = tqdm(gt_assemblies)
1225
1226 for ind, gt_assembly in gt_assemblies:
1227 pred_assemblies = ass_pred_dict.get(ind, [])
1228 num_gt, matched = match_assemblies(
1229 pred_assemblies,
1230 gt_assembly,
1231 oks_sigma,
1232 margin,
1233 symmetric_kpts,
1234 greedy_matching,
1235 )
1236 all_matched.extend(matched)
1237 total_gt_assemblies += num_gt
1238
1239 if not all_matched:
1240 return {
1241 "precisions": np.array([]),
1242 "recalls": np.array([]),
1243 "mAP": 0.0,
1244 "mAR": 0.0,
1245 }
1246
1247 conf_pred = np.asarray([match.score for match in all_matched])
1248 idx = np.argsort(-conf_pred, kind="mergesort")
1249 # Sort matching score (OKS) in descending order of assembly affinity
1250 oks = np.asarray([match.oks for match in all_matched])[idx]
1251 recall_thresholds = np.linspace(0, 1, 101)
1252 precisions = []
1253 recalls = []

Callers 1

_benchmark_paf_graphsFunction · 0.90

Calls 5

evaluate_assembly_greedyFunction · 0.85
match_assembliesFunction · 0.85
itemsMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected