Gate YOLO tile labels by visible ratio
This commit is contained in:
@@ -38,6 +38,7 @@ def test_operator_yolo_tile_dataset_export_script_contract() -> None:
|
||||
assert "tile_size" in script
|
||||
assert "stride" in script
|
||||
assert "negative_keep_ratio" in script
|
||||
assert "min_label_visible_ratio" in script
|
||||
assert "positive_tile_count" in script
|
||||
assert "negative_tile_count" in script
|
||||
assert "skipped_negative_tile_count" in script
|
||||
@@ -64,6 +65,7 @@ def test_operator_yolo_tile_dataset_export_help_does_not_require_gis_dependencie
|
||||
assert "--tile-size" in result.stdout
|
||||
assert "--stride" in result.stdout
|
||||
assert "--negative-keep-ratio" in result.stdout
|
||||
assert "--min-label-visible-ratio" in result.stdout
|
||||
assert "--background-negative-repeat" in result.stdout
|
||||
|
||||
|
||||
@@ -96,6 +98,28 @@ def test_negative_tile_keep_is_deterministic_and_ratio_bound() -> None:
|
||||
assert not any(none_kept)
|
||||
|
||||
|
||||
def test_labels_for_tile_can_drop_tiny_visible_box_fragments() -> None:
|
||||
module = load_tile_exporter()
|
||||
tile = module.TileWindow(row_off=0, col_off=0, height=100, width=100)
|
||||
mostly_outside_box = module.PixelBox(min_col=90, min_row=10, max_col=190, max_row=90)
|
||||
|
||||
labels_without_gate = module.labels_for_tile(
|
||||
tile,
|
||||
[mostly_outside_box],
|
||||
min_label_px=4,
|
||||
min_visible_ratio=0.0,
|
||||
)
|
||||
labels_with_gate = module.labels_for_tile(
|
||||
tile,
|
||||
[mostly_outside_box],
|
||||
min_label_px=4,
|
||||
min_visible_ratio=0.25,
|
||||
)
|
||||
|
||||
assert labels_without_gate == ["0 0.95000000 0.50000000 0.10000000 0.80000000"]
|
||||
assert labels_with_gate == []
|
||||
|
||||
|
||||
def test_background_negative_repeat_only_applies_to_training_background_tiles() -> None:
|
||||
module = load_tile_exporter()
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ def test_operator_yolo_dataset_quality_audit_reports_dataset_risks(tmp_path: Pat
|
||||
"negative_keep_ratio": 1.0,
|
||||
"background_negative_repeat": 2,
|
||||
"min_label_px": 2,
|
||||
"min_label_visible_ratio": 0.25,
|
||||
"source_sample_count": 3,
|
||||
"tile_count": 4,
|
||||
"positive_tile_count": 2,
|
||||
@@ -146,6 +147,7 @@ def test_operator_yolo_dataset_quality_audit_reports_dataset_risks(tmp_path: Pat
|
||||
assert report["repeated_background_negative_tile_count"] == 1
|
||||
assert report["label_stats"]["parsed_label_count"] == 3
|
||||
assert report["label_stats"]["invalid_label_count"] == 0
|
||||
assert report["min_label_visible_ratio"] == 0.25
|
||||
|
||||
warning_codes = {warning["code"] for warning in report["warnings"]}
|
||||
assert "positive_sample_count_below_gate" in warning_codes
|
||||
@@ -157,4 +159,5 @@ def test_operator_yolo_dataset_quality_audit_reports_dataset_risks(tmp_path: Pat
|
||||
markdown = (output_dir / "operator_yolo_dataset_quality_audit.md").read_text(encoding="utf-8")
|
||||
assert "Operator YOLO Dataset Quality Audit" in markdown
|
||||
assert "Label Quality" in markdown
|
||||
assert "Minimum visible label ratio" in markdown
|
||||
assert "positive_sample_count_below_gate" in markdown
|
||||
|
||||
Reference in New Issue
Block a user