evaluation
sleap_nn.evaluation
¶
This module is to compute evaluation metrics for trained models.
Classes:
| Name | Description |
|---|---|
Evaluator |
Compute the standard evaluation metrics with the predicted and the ground-truth Labels. |
IdentityMetrics |
Identity-persistence metrics for one tracked prediction. |
MatchInstance |
Class to have a new structure for sio.Instance object. |
Functions:
| Name | Description |
|---|---|
compare_identity_metrics |
Render a Markdown comparison table across tracker arms. |
compute_distance_match_score |
Compute a pixel-distance-based match score for degenerate-scale GT instances. |
compute_dists |
Compute Euclidean distances between matched pairs of instances. |
compute_gt_centroids |
Compute ground-truth centroids for a numpy array of instance keypoints. |
compute_instance_area |
Compute the area of the bounding box of a set of keypoints. |
compute_oks |
Compute the object keypoints similarity between sets of points. |
embedding_full_eval |
Combined retrieval + verification + kNN-accuracy metrics dict. |
embedding_leave_self_out_eval |
Leave-self-out retrieval/verification/kNN over one labeled embedding set. |
find_frame_pairs |
Find corresponding frames across two sets of labels. |
get_instances |
Get a list of instances of type MatchInstance from the Labeled Frame. |
identity_metrics |
Score a tracked prediction against tracked ground truth. |
knn_classify |
Cosine k-NN classification (weighted vote). Returns (pred, conf). |
load_metrics |
Load metrics from a model folder or metrics file. |
mask_cldice |
Centerline Dice (clDice) between two binary masks. |
match_centroids |
Match predicted centroids to ground truth using Hungarian algorithm. |
match_frame_pairs |
Match all ground truth and predicted instances within each pair of frames. |
match_instances |
Match pairs of instances between ground truth and predictions in a frame. |
match_masks |
Match predicted masks to ground-truth masks by IoU (Hungarian). |
motion_diagnostic |
Judge whether a labels file is continuous video or temporally sparse samples. |
retrieval_metrics |
Rank-1 (CMC@1) + mAP of queries against a gallery (cosine similarity). |
run_evaluation |
Evaluate SLEAP-NN model predictions against ground truth labels. |
run_identity_evaluation |
Evaluate identity persistence of a tracked prediction against tracked GT. |
verification_metrics |
ROC-AUC + EER over all query x gallery pairs (same vs different identity). |
Evaluator
¶
Compute the standard evaluation metrics with the predicted and the ground-truth Labels.
This class is used to calculate the common metrics for pose estimation models which includes voc metrics (with oks and pck), mOKS, distance metrics, pck metrics and visibility metrics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ground_truth_instances
|
Labels
|
The |
required |
predicted_instances
|
Labels
|
The |
required |
oks_stddev
|
float
|
The standard deviation to use for calculating object
keypoint similarity; see |
0.025
|
oks_scale
|
Optional[float]
|
The scale to use for calculating object
keypoint similarity; see |
None
|
match_threshold
|
float
|
The threshold to use when determining which instances
match between ground truth and predicted frames. For
|
0
|
user_labels_only
|
bool
|
If False, predicted instances in the ground truth frame may be considered for matching. |
True
|
match_method
|
str
|
Either |
'oks'
|
anchor_ind
|
Optional[int]
|
For |
None
|
centroid_method
|
Optional[str]
|
For |
None
|
centroid_fallback
|
Optional[str]
|
Reduce method used when the anchor node is not visible. |
None
|
Methods:
| Name | Description |
|---|---|
__init__ |
Initialize the Evaluator class with ground-truth and predicted labels. |
detection_metrics |
Compute detection metrics (precision/recall/F1) over TP/FP/FN counts. |
distance_metrics |
Compute the Euclidean distance error at different percentiles using the pairwise distances. |
evaluate |
Return the evaluation metrics. |
mOKS |
Return the meanOKS value. |
mask_metrics |
Compute mask-IoU summary statistics for |
mask_voc_metrics |
COCO-style score-ranked mask Average Precision / Recall. |
pck_metrics |
Compute PCK across a range of thresholds using the pair-wise distances. |
semantic_metrics |
Aggregate whole-frame foreground metrics for |
visibility_metrics |
Compute node visibility metrics for the matched pair of instances. |
voc_metrics |
Compute VOC metrics for a matched pairs of instances positive pairs and false negatives. |
Source code in sleap_nn/evaluation.py
1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 | |
__init__(ground_truth_instances, predicted_instances, oks_stddev=0.025, oks_scale=None, match_threshold=0, user_labels_only=True, match_method='oks', anchor_ind=None, centroid_method=None, centroid_fallback=None, exclude_predicted_instance_masks=False)
¶
Initialize the Evaluator class with ground-truth and predicted labels.
exclude_predicted_instance_masks (match_method="mask" only) drops
masks linked to a PredictedInstance from the ground-truth labels, so a
labels file that carries stray predicted instances (each of which gets a
mask when masks are built from poses) does not treat them as ground truth.
It is kept separate from user_labels_only (which controls the frame-pair
filter) because mask mode disables that frame filter -- see
:func:run_evaluation.
Source code in sleap_nn/evaluation.py
detection_metrics()
¶
Compute detection metrics (precision/recall/F1) over TP/FP/FN counts.
Used by both match_method="centroid" and match_method="mask"
(it only reads the matched/unmatched list lengths and dists_dict).
Mirrors CentroidEvaluationCallback._compute_metrics. For centroid
mode the localization-error percentiles are computed over the Euclidean
distances of matched centroid pairs; for mask mode dists_dict is
empty so those percentiles are NaN (per-pair IoU is reported separately
via :meth:mask_metrics). Not used for match_method="oks" (which
reports OKS-based VOC metrics instead).
Returns:
| Type | Description |
|---|---|
dict
|
A dict with |
Source code in sleap_nn/evaluation.py
distance_metrics()
¶
Compute the Euclidean distance error at different percentiles using the pairwise distances.
Returns:
| Type | Description |
|---|---|
|
A dictionary of distance metrics. |
Source code in sleap_nn/evaluation.py
evaluate()
¶
Return the evaluation metrics.
Source code in sleap_nn/evaluation.py
mOKS()
¶
mask_metrics()
¶
Compute mask-IoU summary statistics for match_method="mask".
Reports complementary IoU summaries, panoptic-quality, boundary-IoU, fragmentation, and per-object-size breakdowns:
mean_iou(andmin/max/percentiles) over the matched (TP) pairs only — COCO-style segmentation quality, blind to misses.mean_iou_all_gt— IoU averaged over all ground-truth masks, where an unmatched GT (a miss) contributes0. This penalizes recall and complements the TP-only mean.- Panoptic Quality
pq = sq * rqwithsq = mean_iou(segmentation quality) andrq = TP / (TP + 0.5*FP + 0.5*FN)(recognition quality, == detection F1). See Kirillov et al., "Panoptic Segmentation" (2019). mean_boundary_iou— boundary IoU over the matched pairs (Cheng et al., 2021), more sensitive to contour error than mask IoU.mean_cldice— centerline Dice over the matched pairs (Shit et al., CVPR 2021), connectivity-aware and nearly width-insensitive; a fairer score than IoU for thin/tubular structures. NaN if scikit-image is unavailable.oversegmentation/undersegmentation— fragmentation counts: GT masks split across >=2 predictions, and predictions spanning >=2 GT masks (each with >=10% area overlap). The headline over-/under- segmentation failure mode is invisible to the 1-to-1 match.per_size— COCO small/medium/large breakdown of GT count, TP count, and TP-only mean IoU (buckets sum to the GT total).
Returns:
| Type | Description |
|---|---|
dict
|
A dict with |
Source code in sleap_nn/evaluation.py
1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 | |
mask_voc_metrics(iou_thresholds=MASK_IOU_THRESHOLDS, recall_thresholds=np.linspace(0, 1, 101), size_percentiles=DEFAULT_SIZE_PERCENTILES)
¶
COCO-style score-ranked mask Average Precision / Recall.
Re-matches predictions to GT independently at each IoU threshold
(:meth:_match_masks_coco), score-ranks the resulting TP/FP flags, and
integrates the precision-recall curve (101-point interpolation, mirrors
:meth:voc_metrics). Reports overall AP@[.5:.95]/AP50/AP75/AR plus a
per-object-size AP breakdown under two bucketing schemes (GT outside a
bucket is ignored, as in pycocotools areaRng): the primary
(default) buckets use dataset-relative percentile edges (terciles), and
the COCO fixed-cutoff buckets are reported additionally under the
mask_voc.coco. prefix — analogous to the dual OKS/PCK VOC.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iou_thresholds
|
ndarray
|
IoU thresholds to average AP over. |
MASK_IOU_THRESHOLDS
|
recall_thresholds
|
ndarray
|
Recall grid for 101-point interpolation. |
linspace(0, 1, 101)
|
size_percentiles
|
Tuple[float, float]
|
Two percentiles of the GT area distribution delimiting the primary small/medium/large buckets. |
DEFAULT_SIZE_PERCENTILES
|
Returns:
| Type | Description |
|---|---|
dict
|
A dict keyed under |
Source code in sleap_nn/evaluation.py
1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 | |
pck_metrics(thresholds=np.linspace(1, 10, 10))
¶
Compute PCK across a range of thresholds using the pair-wise distances.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
thresholds
|
ndarray
|
A list of distance thresholds in pixels. |
linspace(1, 10, 10)
|
Returns:
| Type | Description |
|---|---|
|
A dictionary of PCK metrics evaluated at each threshold. |
Source code in sleap_nn/evaluation.py
semantic_metrics()
¶
Aggregate whole-frame foreground metrics for match_method="semantic".
Averages the per-frame foreground IoU, centerline Dice (clDice), and
boundary IoU computed by :meth:_process_frames_semantic over all frames
with non-empty ground-truth foreground. clDice entries that are NaN
(scikit-image unavailable) are dropped from the clDice mean; if every entry
is NaN the reported mean_cldice is NaN.
Returns:
| Type | Description |
|---|---|
dict
|
A dict with |
Source code in sleap_nn/evaluation.py
visibility_metrics()
¶
Compute node visibility metrics for the matched pair of instances.
Returns:
| Type | Description |
|---|---|
|
A dictionary of visibility metrics, including the confusion matrix. |
Source code in sleap_nn/evaluation.py
voc_metrics(match_score_by='oks', match_score_thresholds=np.linspace(0.5, 0.95, 10), recall_thresholds=np.linspace(0, 1, 101))
¶
Compute VOC metrics for a matched pairs of instances positive pairs and false negatives.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
match_score_by
|
The score to be used for computing the metrics. "ock" or "pck" |
'oks'
|
|
match_score_thresholds
|
ndarray
|
Score thresholds at which to consider matches as a true positive match. |
linspace(0.5, 0.95, 10)
|
recall_thresholds
|
ndarray
|
Recall thresholds at which to evaluate Average Precision. |
linspace(0, 1, 101)
|
Returns:
| Type | Description |
|---|---|
|
A dictionary of VOC metrics. |
Source code in sleap_nn/evaluation.py
1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 | |
IdentityMetrics
¶
Identity-persistence metrics for one tracked prediction.
Attributes:
| Name | Type | Description |
|---|---|---|
id_switches |
int
|
CLEAR-MOT ID switches, summed over ground-truth trajectories. |
idf1 |
float
|
Identity F1 (Ristani et al.). |
idp |
float
|
Identity precision. |
idr |
float
|
Identity recall. |
mostly_tracked |
int
|
Ground-truth trajectories covered at or above
|
partly_tracked |
int
|
Ground-truth trajectories between the two coverage cuts. |
mostly_lost |
int
|
Ground-truth trajectories covered below |
fragmentations |
int
|
Matched -> unmatched -> matched interruptions of a ground-truth trajectory. |
mean_gt_coverage |
float
|
Mean share of each trajectory's frames that matched. |
mean_track_purity |
float
|
Length-weighted mean dominant-identity share per predicted track. |
n_gt_dets |
int
|
Tracked ground-truth detections compared. |
n_pred_dets |
int
|
Predicted detections in the compared frames. |
n_matched |
int
|
Ground-truth/predicted pairs matched above threshold. |
n_frames_compared |
int
|
Frames present on both sides. |
n_gt_tracks |
int
|
Distinct ground-truth track names seen. |
n_pred_tracks |
int
|
Distinct predicted track names seen. |
n_pred_untracked |
int
|
Predicted detections with no |
notes |
List[str]
|
Human-readable caveats raised while comparing. |
Methods:
| Name | Description |
|---|---|
as_dict |
Return the metrics as a plain, JSON-serializable dict. |
summary |
Return a one-line summary of the headline metrics. |
Source code in sleap_nn/evaluation.py
3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 | |
as_dict()
¶
summary()
¶
Return a one-line summary of the headline metrics.
Source code in sleap_nn/evaluation.py
MatchInstance
¶
Class to have a new structure for sio.Instance object.
Source code in sleap_nn/evaluation.py
compare_identity_metrics(arms)
¶
Render a Markdown comparison table across tracker arms.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
arms
|
Dict[str, IdentityMetrics]
|
Mapping of arm name (e.g. |
required |
Returns:
| Type | Description |
|---|---|
str
|
A Markdown table, one row per arm, with a footer naming the direction of improvement for each column. |
Source code in sleap_nn/evaluation.py
compute_distance_match_score(points_gt, points_pr, pixel_threshold=50.0)
¶
Compute a pixel-distance-based match score for degenerate-scale GT instances.
Used as a fallback for GT instances whose visible-keypoint bounding box has zero
area (see _DEGENERATE_AREA_EPS), where compute_oks degenerates into a strict
equality test. Mirrors the pixel-distance matching already used for centroid-only
models (match_method="centroid"), but restricted to the nodes that are visible
in both the ground truth and predicted instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points_gt
|
ndarray
|
Ground truth instances of shape (n_gt, n_nodes, n_ed). |
required |
points_pr
|
ndarray
|
Predicted instances of shape (n_pr, n_nodes, n_ed). |
required |
pixel_threshold
|
float
|
Distance (in pixels) at which the score reaches 0. |
50.0
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Match scores of shape (n_gt, n_pr) in the range [0, 1], with 1.0 denoting a
perfect match and 0.0 denoting no jointly-visible nodes or a mean distance at
or beyond |
Source code in sleap_nn/evaluation.py
compute_dists(positive_pairs)
¶
Compute Euclidean distances between matched pairs of instances.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positive_pairs
|
List[Tuple[Instance, PredictedInstance, Any]]
|
A list of tuples of the form |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Union[ndarray, List[int], List[str]]]
|
A dictionary with the following keys:
dists: An array of pairwise distances of shape |
Source code in sleap_nn/evaluation.py
compute_gt_centroids(instance_gt_points, anchor_ind=None, method=None, fallback=None)
¶
Compute ground-truth centroids for a numpy array of instance keypoints.
A thin numpy-in/numpy-out wrapper around
:func:sleap_nn.data.instance_centroids.generate_centroids, which is the
single definition of what a centroid MEANS (see also #586). It used to be a
hand-written numpy mirror; delegating removes the drift that
sleap_nn.inference.centroid_convert warns about — evaluation now cannot
disagree with the trained target about the centroid, including for the
bbox_center / geometric_median methods.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instance_gt_points
|
ndarray
|
Ground-truth keypoints of shape |
required |
anchor_ind
|
Optional[int]
|
Index of the node to use as the anchor. Required by (and only
used by) |
None
|
method
|
Optional[str]
|
One of |
None
|
fallback
|
Optional[str]
|
Reduce method for a missing anchor. |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Centroids of shape |
Source code in sleap_nn/evaluation.py
compute_instance_area(points)
¶
Compute the area of the bounding box of a set of keypoints.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
ndarray
|
A numpy array of coordinates. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
The area of the bounding box of the points. |
Source code in sleap_nn/evaluation.py
compute_oks(points_gt, points_pr, scale=None, stddev=0.025, use_cocoeval=True)
¶
Compute the object keypoints similarity between sets of points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points_gt
|
ndarray
|
Ground truth instances of shape (n_gt, n_nodes, n_ed), where n_nodes is the number of body parts/keypoint types, and n_ed is the number of Euclidean dimensions (typically 2 or 3). Keypoints that are missing/not visible should be represented as NaNs. |
required |
points_pr
|
ndarray
|
Predicted instance of shape (n_pr, n_nodes, n_ed). |
required |
use_cocoeval
|
bool
|
Indicates whether the OKS score is calculated like cocoeval method or not. True indicating the score is calculated using the cocoeval method (widely used and the code can be found here at https://github.com/cocodataset/cocoapi/blob/8c9bcc3cf640524c4c20a9c40e89cb6a2f2fa0e9/PythonAPI/pycocotools/cocoeval.py#L192C5-L233C20) and False indicating the score is calculated using the method exactly as given in the paper referenced in the Notes below. |
True
|
scale
|
Optional[float]
|
Size scaling factor to use when weighing the scores, typically the area of the bounding box of the instance (in pixels). This should be of the length n_gt. If a scalar is provided, the same number is used for all ground truth instances. If set to None, the bounding box area of the ground truth instances will be calculated. |
None
|
stddev
|
float
|
The standard deviation associated with the spread in the localization accuracy of each node/keypoint type. This should be of the length n_nodes. "Easier" keypoint types will have lower values to reflect the smaller spread expected in localizing it. |
0.025
|
Returns:
| Type | Description |
|---|---|
ndarray
|
The object keypoints similarity between every pair of ground truth and predicted instance, a numpy array of of shape (n_gt, n_pr) in the range of [0, 1.0], with 1.0 denoting a perfect match. |
Notes
It's important to set the stddev appropriately when accounting for the difficulty of each keypoint type. For reference, the median value for all keypoint types in COCO is 0.072. The "easiest" keypoint is the left eye, with stddev of 0.025, since it is easy to precisely locate the eyes when labeling. The "hardest" keypoint is the left hip, with stddev of 0.107, since it's hard to locate the left hip bone without external anatomical features and since it is often occluded by clothing.
The implementation here is based off of the descriptions in: Ronch & Perona. "Benchmarking and Error Diagnosis in Multi-Instance Pose Estimation." ICCV (2017).
Source code in sleap_nn/evaluation.py
695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 | |
embedding_full_eval(gallery_emb, gallery_y, query_emb, query_y, k=7)
¶
Combined retrieval + verification + kNN-accuracy metrics dict.
Source code in sleap_nn/evaluation.py
embedding_leave_self_out_eval(emb, y, k=7, max_n=5000)
¶
Leave-self-out retrieval/verification/kNN over one labeled embedding set.
Gallery == query == the same set, with each item's self-match excluded (the
similarity diagonal is masked to -inf so an item is never retrieved by itself).
This is exactly the protocol the per-epoch
:class:~sleap_nn.training.callbacks.EmbeddingEvaluationCallback uses for
checkpoint selection, so the post-training headline matches the selected metric.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
emb
|
|
required | |
y
|
|
required | |
k
|
int
|
|
7
|
max_n
|
int
|
Cap on the number of embeddings used for the |
5000
|
Returns:
| Type | Description |
|---|---|
|
dict with |
Source code in sleap_nn/evaluation.py
2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 | |
find_frame_pairs(labels_gt, labels_pr, user_labels_only=True, keep_user_centroid_frames=False)
¶
Find corresponding frames across two sets of labels.
This function uses sleap-io's robust video matching API to handle various scenarios including embedded videos, cross-platform paths, and videos with different metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
labels_gt
|
Labels
|
A |
required |
labels_pr
|
Labels
|
A |
required |
keep_user_centroid_frames
|
bool
|
If True, a ground-truth frame also survives the
|
False
|
user_labels_only
|
bool
|
If False, frames with predicted instances in |
True
|
Returns:
| Type | Description |
|---|---|
List[Tuple[LabeledFrame, LabeledFrame]]
|
A list of pairs of |
Source code in sleap_nn/evaluation.py
597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 | |
get_instances(labeled_frame)
¶
Get a list of instances of type MatchInstance from the Labeled Frame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
labeled_frame
|
LabeledFrame
|
Input Labeled frame of type sio.LabeledFrame. |
required |
Returns:
| Type | Description |
|---|---|
List[MatchInstance]
|
List of MatchInstance objects for the given labeled frame. |
Source code in sleap_nn/evaluation.py
identity_metrics(gt_labels, pred_labels, carrier='pose', *, match_threshold=0.5, mt_threshold=0.8, ml_threshold=0.2, user_labels_only=False)
¶
Score a tracked prediction against tracked ground truth.
Detections are Hungarian-matched to ground truth within each frame (OKS for
"pose", mask IoU for "mask"), then identity is scored over those
matches. Detections with no track set are counted but never matched, on
either side.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gt_labels
|
Labels
|
Ground truth with |
required |
pred_labels
|
Labels
|
Prediction with |
required |
carrier
|
str
|
|
'pose'
|
match_threshold
|
float
|
Minimum similarity for a ground-truth/predicted pair to count as matched (OKS or IoU, per carrier). |
0.5
|
mt_threshold
|
float
|
Coverage at or above which a ground-truth trajectory counts as mostly-tracked. |
0.8
|
ml_threshold
|
float
|
Coverage below which a ground-truth trajectory counts as mostly-lost. |
0.2
|
user_labels_only
|
bool
|
Drop model output ( |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
An |
IdentityMetrics
|
class: |
Source code in sleap_nn/evaluation.py
3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 | |
knn_classify(gallery_emb, gallery_y, query_emb, k=7)
¶
Cosine k-NN classification (weighted vote). Returns (pred, conf).
Source code in sleap_nn/evaluation.py
load_metrics(path, split='test', dataset_idx=0)
¶
Load metrics from a model folder or metrics file.
This function supports both the new format (single "metrics" key) and the old format (individual metric keys at top level). It also handles both old and new file naming conventions in model folders.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Path to a model folder or metrics file (.npz). |
required |
split
|
str
|
Name of the split to load. Must be "train", "val", or "test". Default: "test". If "test" is not found, falls back to "val". Ignored if path points directly to a .npz file. |
'test'
|
dataset_idx
|
int
|
Index of the dataset (for multi-dataset training). Default: 0. Ignored if path points directly to a .npz file. |
0
|
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary containing metrics with keys: voc_metrics, mOKS, distance_metrics, pck_metrics, visibility_metrics. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If no metrics file is found. |
Examples:
>>> # Load from model folder (tries test, falls back to val)
>>> metrics = load_metrics("/path/to/model")
>>> print(metrics["mOKS"]["mOKS"])
>>> # Load specific split and dataset
>>> metrics = load_metrics("/path/to/model", split="val", dataset_idx=1)
Source code in sleap_nn/evaluation.py
mask_cldice(pred, gt)
¶
Centerline Dice (clDice) between two binary masks.
Shit et al., "clDice — A Novel Topology-Preserving Loss Function for Tubular Structure Segmentation," CVPR 2021 (arXiv:2003.07311). The connectivity-aware F-score of two skeleton-overlap terms:
Tprec= fraction of the predicted skeleton lying inside the GT mask (is my centerline drawn on a real object?),Tsens= fraction of the GT skeleton lying inside the predicted mask (did I cover every real object along its length?),
with clDice = 2·Tprec·Tsens / (Tprec + Tsens). Nearly width-insensitive
and connectivity-sensitive, so it is a fairer quality measure than area IoU
for thin/tubular structures (roots, vessels, neurites). Uses a hard
morphological skeleton (exact, no k to tune).
Two empty masks return 1.0 (matching the _mask_iou "identical -> 1.0"
contract). Returns nan when scikit-image is unavailable so callers can
drop clDice from the summary without failing.
Source code in sleap_nn/evaluation.py
match_centroids(pred_centroids, gt_centroids, max_distance=50.0)
¶
Match predicted centroids to ground truth using Hungarian algorithm.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pred_centroids
|
ndarray
|
Predicted centroid locations, shape (n_pred, 2). |
required |
gt_centroids
|
ndarray
|
Ground truth centroid locations, shape (n_gt, 2). |
required |
max_distance
|
float
|
Maximum distance threshold for valid matches (in pixels). |
50.0
|
Returns:
| Type | Description |
|---|---|
tuple
|
Tuple of: - matched_pred_indices: Indices of matched predictions - matched_gt_indices: Indices of matched ground truth - unmatched_pred_indices: Indices of unmatched predictions (false positives) - unmatched_gt_indices: Indices of unmatched ground truth (false negatives) |
Source code in sleap_nn/evaluation.py
match_frame_pairs(frame_pairs, stddev=0.025, scale=None, threshold=0)
¶
Match all ground truth and predicted instances within each pair of frames.
This is a wrapper for match_instances() but operates on lists of frames.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frame_pairs
|
List[Tuple[LabeledFrame, LabeledFrame]]
|
A list of pairs of |
required |
stddev
|
float
|
The expected spread of coordinates for OKS computation. |
0.025
|
scale
|
Optional[float]
|
The scale for normalizing the OKS. If not set, the bounding box area will be used. |
None
|
threshold
|
float
|
The minimum OKS between a candidate pair of instances to be considered a match. |
0
|
Returns:
| Type | Description |
|---|---|
Tuple[List[Tuple[Instance, PredictedInstance, float]], List[Instance]]
|
A tuple of (
|
Source code in sleap_nn/evaluation.py
match_instances(frame_gt, frame_pr, stddev=0.025, scale=None, threshold=0, degenerate_pixel_threshold=50.0)
¶
Match pairs of instances between ground truth and predictions in a frame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frame_gt
|
LabeledFrame
|
A |
required |
frame_pr
|
LabeledFrame
|
A |
required |
stddev
|
float
|
The expected spread of coordinates for OKS computation. |
0.025
|
scale
|
Optional[float]
|
The scale for normalizing the OKS. If not set, the bounding box area will be used. |
None
|
threshold
|
float
|
The minimum OKS between a candidate pair of instances to be considered a match. |
0
|
degenerate_pixel_threshold
|
float
|
Pixel distance threshold used to score GT
instances whose visible-keypoint bounding box has zero area (see
|
50.0
|
Returns:
| Type | Description |
|---|---|
Tuple[List[Tuple[Instance, PredictedInstance, float]], List[Instance]]
|
A tuple of (
|
Notes
This function uses the approach from the PASCAL VOC scoring procedure. Briefly, predictions are sorted descending by their instance-level prediction scores and greedily matched to ground truth instances which are then removed from the pool of available instances.
Ground truth instances that remain unmatched are considered false negatives.
Source code in sleap_nn/evaluation.py
876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 | |
match_masks(pred_masks, gt_masks, min_iou=0.5)
¶
Match predicted masks to ground-truth masks by IoU (Hungarian).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pred_masks
|
List[ndarray]
|
List of boolean arrays, one per predicted instance. |
required |
gt_masks
|
List[ndarray]
|
List of boolean arrays, one per ground-truth instance. |
required |
min_iou
|
float
|
Minimum IoU for a matched pair to count as a true positive. |
0.5
|
Returns:
| Type | Description |
|---|---|
tuple
|
Tuple of:
- matched_pred_indices: Indices of matched predictions.
- matched_gt_indices: Indices of matched ground truth.
- unmatched_pred_indices: Unmatched predictions (false positives).
- unmatched_gt_indices: Unmatched ground truth (false negatives).
- matched_ious: IoU of each matched pair, aligned to
|
Source code in sleap_nn/evaluation.py
motion_diagnostic(labels, carrier='pose')
¶
Judge whether a labels file is continuous video or temporally sparse samples.
Identity metrics are meaningless on a sparse set, and nothing in the file
says so. Embedded .pkg.slp training splits renumber their frames
0..N-1 and record frame_numbers as contiguous, so every index-based
contiguity check passes -- while the animal has actually moved across the
arena between two "consecutive" frames. Run this before quoting a tracking
number on an unfamiliar file.
The decisive quantity is how far the same animal moves between consecutive
frames relative to its own size. Measured on real files, step_over_size
lands near 0.01-0.06 for genuine video and 3-9 for sparse training
splits -- and at the high end same-animal consecutive mask IoU is 0.000
for most pairs, so geometric association has no signal to work with and any
IoU tracker must fail.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
labels
|
Labels
|
Tracked labels to inspect. |
required |
carrier
|
str
|
|
'pose'
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dict with |
Source code in sleap_nn/evaluation.py
2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 | |
retrieval_metrics(gallery_emb, gallery_y, query_emb, query_y)
¶
Rank-1 (CMC@1) + mAP of queries against a gallery (cosine similarity).
Source code in sleap_nn/evaluation.py
run_evaluation(ground_truth_path, predicted_path, oks_stddev=0.025, oks_scale=None, match_threshold=0, user_labels_only=True, save_metrics=None, match_method='oks', anchor_part=None, centroid_method=None, centroid_fallback=None)
¶
Evaluate SLEAP-NN model predictions against ground truth labels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ground_truth_path
|
str
|
Path to the ground-truth |
required |
predicted_path
|
str
|
Path to the predicted |
required |
oks_stddev
|
float
|
OKS standard deviation (OKS mode only). |
0.025
|
oks_scale
|
Optional[float]
|
OKS scale override (OKS mode only). |
None
|
match_threshold
|
float
|
Matching threshold. OKS threshold for OKS mode; PIXEL
distance for centroid mode. In centroid mode, if the caller leaves
the OKS default of |
0
|
user_labels_only
|
bool
|
If False, predicted instances in the GT frame may be
matched. For |
True
|
save_metrics
|
Optional[str]
|
Optional |
None
|
match_method
|
str
|
|
'oks'
|
anchor_part
|
Optional[str]
|
Name of the GT skeleton node used to compute GT centroids
(centroid mode). Resolved against the GT skeleton; |
None
|
centroid_method
|
Optional[str]
|
How GT centroids are derived (centroid mode) --
|
None
|
centroid_fallback
|
Optional[str]
|
Reduce method used when the anchor node is not visible. |
None
|
Returns:
| Type | Description |
|---|---|
|
The metrics dict, or |
Source code in sleap_nn/evaluation.py
2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 | |
run_identity_evaluation(ground_truth_path, predicted_path, carrier='auto', match_threshold=0.5, mt_threshold=0.8, ml_threshold=0.2, user_labels_only=False, save_metrics=None)
¶
Evaluate identity persistence of a tracked prediction against tracked GT.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ground_truth_path
|
str
|
Path to the ground-truth |
required |
predicted_path
|
str
|
Path to the predicted |
required |
carrier
|
str
|
|
'auto'
|
match_threshold
|
float
|
Minimum OKS (pose) or IoU (mask) for a detection pair to count as matched. |
0.5
|
mt_threshold
|
float
|
Mostly-tracked coverage cut. |
0.8
|
ml_threshold
|
float
|
Mostly-lost coverage cut. |
0.2
|
user_labels_only
|
bool
|
Drop model output from the ground-truth side; off by
default (see :func: |
False
|
save_metrics
|
Optional[str]
|
Optional |
None
|
Returns:
| Type | Description |
|---|---|
Optional[Dict[str, Any]]
|
Dict with the :class: |
Source code in sleap_nn/evaluation.py
3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 | |
verification_metrics(gallery_emb, gallery_y, query_emb, query_y, exclude_diagonal=False)
¶
ROC-AUC + EER over all query x gallery pairs (same vs different identity).
When exclude_diagonal (gallery == query in the same order), the self-pairs on
the similarity diagonal are dropped before scoring so a leave-self-out evaluation is
not optimistically biased by N perfect same-identity matches at sim=1.0.