deeplabcut.core.metrics.matching
Algorithms to match predictions to ground truth labels.
Classes:
| Name | Description |
|---|---|
PotentialMatch |
A potential match between predicted pose and ground truth pose. |
Functions:
| Name | Description |
|---|---|
match_greedy_oks |
Greedy matching of ground truth individuals to predicted individuals using OKS. |
match_greedy_rmse |
Greedy matching of ground truth individuals to predicted individuals using RMSE. |
PotentialMatch
dataclass
A potential match between predicted pose and ground truth pose.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
ndarray
|
An array of shape (num_bodyparts, 3) |
required |
|
float
|
The score for the prediction. This could be the mean of the confidence score for each bodypart, or another value representing how confident the model is that this assembly is correct. |
required |
|
ndarray | None
|
None if no ground truth pose was matched to the prediction. If defined, the ground truth to which the prediction is matched. It should be of shape (num_bodyparts, 3), where the 3 values are x, y and visibility. |
None
|
|
float
|
The OKS score between the pose and the ground truth. |
0.0
|
Methods:
| Name | Description |
|---|---|
keypoint_scores |
Returns: The confidence score for each bodypart in the predicted pose. |
match |
Adds a ground truth match to this PotentialMatch. |
pixel_errors |
Returns: |
Source code in deeplabcut/core/metrics/matching.py
keypoint_scores
match
Adds a ground truth match to this PotentialMatch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
ndarray
|
The ground truth to which the prediction is matched. The ground truth pose should be of shape (num_bodyparts, 3), where the 3 values are x, y and visibility. |
required |
|
float
|
The OKS similarity between the ground truth and this. |
required |
Source code in deeplabcut/core/metrics/matching.py
pixel_errors
Returns:
| Type | Description |
|---|---|
ndarray
|
The distance (in pixels) between each predicted and ground truth bodypart. If this prediction is unmatched, returns an array of length num_bodyparts containing all NaNs. |
Source code in deeplabcut/core/metrics/matching.py
match_greedy_oks
match_greedy_oks(
ground_truth: ndarray, predictions: ndarray, oks_matrix: ndarray, oks_threshold: float = 0.0
) -> list[PotentialMatch]
Greedy matching of ground truth individuals to predicted individuals using OKS.
This is done in the same way as done in pycocotools. The predictions must be sorted by score before being passed to this function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
ndarray
|
The ground truth labels for an image, of shape (n_idv, n_bpt, 2) |
required |
|
ndarray
|
The predictions for an image, of shape (n_idv, n_bpt, 2) |
required |
|
ndarray
|
A matrix of shape (n_pred, n_kpts) where entry (i, j) is the OKS between prediction i and ground truth j. |
required |
|
float
|
The min. OKS for a prediction to be matched to a GT pose |
0.0
|
Returns:
| Type | Description |
|---|---|
list[PotentialMatch]
|
A list containing a PotentialMatch for each predicted pose in the given predictions. |
Source code in deeplabcut/core/metrics/matching.py
match_greedy_rmse
match_greedy_rmse(ground_truth: ndarray, predictions: ndarray, keep_assemblies: bool = True) -> list[PotentialMatch]
Greedy matching of ground truth individuals to predicted individuals using RMSE.
The predictions must be sorted by score before being passed to this function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
ndarray
|
The ground truth labels for an image, of shape (n_idv, n_bpt, 2) |
required |
|
ndarray
|
The predictions for an image, of shape (n_idv, n_bpt, 2) |
required |
|
bool
|
Whether to match predicted keypoints to ground truth keypoints while enforcing that all bodyparts for a predicted individual are matched to bodyparts from the same ground truth assembly. When set to False, this corresponds to detection RMSE score. |
True
|
Returns:
| Type | Description |
|---|---|
list[PotentialMatch]
|
A list containing a PotentialMatch for each predicted pose in the given predictions. |