Audit and suppress nested detector proposals

This commit is contained in:
Jens
2026-07-27 09:58:25 +02:00
parent efd3272bda
commit 51db5baa9c
6 changed files with 264 additions and 4 deletions
@@ -113,6 +113,13 @@ def safe_median(values: list[float]) -> float | None:
return round(float(statistics.median(values)), 12) if values else None
def safe_percentile(values: list[float], fraction: float) -> float | None:
if not values:
return None
ordered = sorted(values)
return round(float(ordered[round((len(ordered) - 1) * fraction)]), 12)
def summarize_label_files(
label_file_paths: set[Path],
small_box_area_threshold: float,
@@ -131,6 +138,7 @@ def summarize_label_files(
areas = [box["area"] for box in boxes]
widths = [box["width"] for box in boxes]
heights = [box["height"] for box in boxes]
aspect_ratios = [max(box["width"] / box["height"], box["height"] / box["width"]) for box in boxes]
small_box_count = sum(1 for area in areas if area < small_box_area_threshold)
return {
@@ -143,6 +151,11 @@ def summarize_label_files(
"mean_box_area": safe_mean(areas),
"median_box_width": safe_median(widths),
"median_box_height": safe_median(heights),
"box_area_p99": safe_percentile(areas, 0.99),
"box_area_max": max(areas) if areas else None,
"aspect_ratio_median": safe_median(aspect_ratios),
"aspect_ratio_p99": safe_percentile(aspect_ratios, 0.99),
"aspect_ratio_max": max(aspect_ratios) if aspect_ratios else None,
"small_box_area_threshold": small_box_area_threshold,
"small_box_count": small_box_count,
"small_box_share": small_box_count / len(areas) if areas else 0.0,