Add reproducible grayscale detector corpus
GeoIntel release gates / Compile, test, contracts and builds (push) Canceled after 0s
GeoIntel release gates / Python and npm vulnerability policy (push) Canceled after 0s
GeoIntel release gates / GIS image, SBOM and container scan (push) Canceled after 0s

This commit is contained in:
Jens
2026-07-27 05:21:53 +02:00
parent 741ad20dcb
commit 31c18792d1
4 changed files with 138 additions and 0 deletions
@@ -0,0 +1,47 @@
from __future__ import annotations
import json
import subprocess
import sys
from pathlib import Path
from PIL import Image
SCRIPT = Path(__file__).parents[2] / "scripts" / "build_grayscale_yolo_dataset.py"
def test_grayscale_builder_preserves_labels_and_split(tmp_path: Path) -> None:
source = tmp_path / "source"
(source / "images" / "train").mkdir(parents=True)
(source / "labels" / "train").mkdir(parents=True)
image = source / "images" / "train" / "tile.png"
label = source / "labels" / "train" / "tile.txt"
Image.new("RGB", (8, 8), (255, 0, 0)).save(image)
label.write_text("0 0.5 0.5 0.5 0.5\n", encoding="utf-8")
summary = source / "yolo_tile_dataset_summary.json"
summary.write_text(
json.dumps(
{
"tiles": [
{
"split": "train",
"image_path": str(image),
"label_path": str(label),
}
]
}
),
encoding="utf-8",
)
output = tmp_path / "gray"
subprocess.run(
[sys.executable, str(SCRIPT), "--summary", str(summary), "--output-dir", str(output)],
check=True,
)
converted = Image.open(output / "images" / "train" / "tile.png")
r, g, b = converted.getpixel((0, 0))
assert r == g == b
assert (output / "labels" / "train" / "tile.txt").read_text() == label.read_text()
evidence = json.loads((output / "grayscale-dataset-evidence.json").read_text())
assert evidence["converted_tile_count"] == 1