lazyslide.metrics.segmentation.get_instance_stats

lazyslide.metrics.segmentation.get_instance_stats#

get_instance_stats(gdf_true, gdf_pred, iou_threshold=0.5)#

Compute instance segmentation statistics using Hungarian algorithm matching.

This function evaluates instance segmentation performance by matching predicted instances to ground truth instances using optimal assignment based on intersection over union (IoU) scores. Uses the Hungarian algorithm to find the optimal one-to-one matching that maximizes total IoU.

Parameters:
gdf_trueGeoDataFrame

Ground truth instances as a GeoDataFrame with geometry column containing polygon geometries representing true object instances.

gdf_predgpd.GeoDataFrame

Predicted instances as a GeoDataFrame with geometry column containing polygon geometries representing predicted object instances.

iou_thresholdfloat, default=0.5

Minimum IoU threshold for considering a match as a true positive. Matches with IoU below this threshold are considered false positives.

Returns:
SegmentationStats

Statistics object containing: - tp: Number of true positive matches (IoU >= threshold) - fp: Number of false positive predictions (unmatched predictions) - fn: Number of false negative ground truths (unmatched ground truths) - tn: Always 0 (not meaningful for instance segmentation) - ious: List of IoU values for all valid matches