fruit_project.utils.metrics

Classes

ConfusionMatrix

Object Detection Confusion Matrix inspired by Ultralytics.

Module Contents

class fruit_project.utils.metrics.ConfusionMatrix(nc: int, conf: float = 0.25, iou_thres: float = 0.45)[source]

Object Detection Confusion Matrix inspired by Ultralytics.

Parameters:
  • nc (int) – Number of classes.

  • conf (float) – Confidence threshold for detections.

  • iou_thres (float) – IoU threshold for matching.

nc[source]
conf = 0.25[source]
iou_thres = 0.45[source]
matrix[source]
eps = 1e-06[source]
process_batch(detections: torch.Tensor, labels: torch.Tensor)[source]

Update the confusion matrix with a batch of detections and ground truths.

Parameters:
  • detections (torch.Tensor) – Tensor of detections, shape [N, 6] (x1, y1, x2, y2, conf, class).

  • labels (torch.Tensor) – Tensor of ground truths, shape [M, 5] (class, x1, y1, x2, y2).

plot(class_names: List, normalize=True) matplotlib.pyplot.Figure[source]

Generates and returns a matplotlib figure of the confusion matrix.

get_matrix()[source]