discopat.nn_training.evaluation package
Submodules
discopat.nn_training.evaluation.base module
- discopat.nn_training.evaluation.base.compute_ap(matching_dict, threshold)[source]
Compute the Average Precision (AP) for a given localization threshold.
- Parameters:
matching_dict (dict[str, dict[str, array]]) –
dictionary in the form: image_id: {
”matching_matrix”: array of shape (N_preds, N_gts), “scores”: array of shape (N_preds,)
}
threshold (float) – localization threshold,
- Returns:
The AP.
- Return type:
float
Note
The predictions and scores should already be sorted by descending score.
- discopat.nn_training.evaluation.base.evaluate(model, data_loader, localization_criterion, device)[source]
Evaluate a model on a data loader.
- Parameters:
model (NeuralNet) – the neural network to be evaluated,
data_loader (DataLoader) – the evaluation dataloader,
localization_criterion (str) – metric used for GT-pred matching,
device (ComputingDevice) – computing device on which the model is stored.
- Returns:
AP50, AP[50:95:05].
- Return type:
A dict containing the name and values of the following metrics
discopat.nn_training.evaluation.matching module
- discopat.nn_training.evaluation.matching.compute_center_distance_matrix(groundtruths, predictions)[source]
Compute pairwise Euclidean distance between box centers.
- Parameters:
groundtruths (array) – (N_gt, 4)
predictions (array) – (N_pred, 4)
- Returns:
(N_pred, N_gt) matrix of pairwise center distances.
- Return type:
array
- discopat.nn_training.evaluation.matching.compute_iomean_matrix(groundtruths, predictions)[source]
Compute IoMean matrix between predicted and GT boxes (both [N, 4] arrays in xyxy format).
- Parameters:
groundtruths (array) – (N_gt, 4)
predictions (array) – (N_pred, 4)
- Returns:
(N_pred, N_gt) matrix of pairwise IoUs
- Return type:
array
- discopat.nn_training.evaluation.matching.compute_iou_matrix(groundtruths, predictions)[source]
Compute IoU matrix between predicted and GT boxes (both [N, 4] arrays in xyxy format).
- Parameters:
groundtruths (array) – (N_gt, 4)
predictions (array) – (N_pred, 4)
- Returns:
(N_pred, N_gt) matrix of pairwise IoUs
- Return type:
array
- discopat.nn_training.evaluation.matching.match_groundtruths_and_predictions(groundtruths, predictions, scores, localization_criterion)[source]
Match GTs and predictions on an image in the dataset.
- Parameters:
groundtruths (list) – list of groundtruths, boxes [x1, y1, x2, y2],
predictions (list) – list of predictions, boxes [x1, y1, x2, y2],
scores (list) – list of confidence score, same length as predictions
localization_criterion (str) – metric used to assess the fit between GTs and predictions.
- Returns:
The total number of groundtruths,
For each pred, a tuple (score, is_tp).
- Return type:
A report for the considered image, containing
Module contents
- discopat.nn_training.evaluation.compute_ap(matching_dict, threshold)[source]
Compute the Average Precision (AP) for a given localization threshold.
- Parameters:
matching_dict (dict[str, dict[str, array]]) –
dictionary in the form: image_id: {
”matching_matrix”: array of shape (N_preds, N_gts), “scores”: array of shape (N_preds,)
}
threshold (float) – localization threshold,
- Returns:
The AP.
- Return type:
float
Note
The predictions and scores should already be sorted by descending score.
- discopat.nn_training.evaluation.evaluate(model, data_loader, localization_criterion, device)[source]
Evaluate a model on a data loader.
- Parameters:
model (NeuralNet) – the neural network to be evaluated,
data_loader (DataLoader) – the evaluation dataloader,
localization_criterion (str) – metric used for GT-pred matching,
device (ComputingDevice) – computing device on which the model is stored.
- Returns:
AP50, AP[50:95:05].
- Return type:
A dict containing the name and values of the following metrics