GeoIntel release gates / Compile, test, contracts and builds (push) Successful in 1m49s
GeoIntel release gates / Python and npm vulnerability policy (push) Successful in 21s
GeoIntel release gates / Production AI image, SBOM and container scan (push) Successful in 5m39s
GeoIntel release gates / Deploy exact gated revision to Unraid (push) Failing after 58m43s
50 lines
1.3 KiB
Python
50 lines
1.3 KiB
Python
from pathlib import Path
|
|
|
|
from PIL import Image
|
|
|
|
from scripts.derive_yolo_nonoverlap_evaluation_view import (
|
|
image_has_low_visual_variance,
|
|
select_nonoverlap_tiles,
|
|
)
|
|
|
|
|
|
def tile(name: str, index: int, split: str = "val") -> dict[str, object]:
|
|
return {
|
|
"image_path": f"/data/sample_{index:04d}_{name}.png",
|
|
"tile_index": index,
|
|
"sample_slug": "sample",
|
|
"split": split,
|
|
"kept": True,
|
|
}
|
|
|
|
|
|
def test_select_nonoverlap_tiles_keeps_complete_512_grid() -> None:
|
|
tiles = [
|
|
tile("r0_c0", 0),
|
|
tile("r0_c256", 1),
|
|
tile("r0_c512", 2),
|
|
tile("r256_c0", 3),
|
|
tile("r256_c256", 4),
|
|
tile("r256_c512", 5),
|
|
tile("r512_c0", 6),
|
|
tile("r512_c256", 7),
|
|
tile("r512_c512", 8),
|
|
tile("r0_c0", 9, split="train"),
|
|
]
|
|
|
|
selected = select_nonoverlap_tiles(tiles, 512)
|
|
|
|
assert [item["tile_index"] for item in selected] == [0, 2, 6, 8]
|
|
|
|
|
|
def test_image_has_low_visual_variance_rejects_blank_no_data(tmp_path: Path) -> None:
|
|
blank = tmp_path / "blank.png"
|
|
real = tmp_path / "real.png"
|
|
Image.new("L", (8, 8), color=255).save(blank)
|
|
image = Image.new("L", (8, 8), color=100)
|
|
image.putpixel((0, 0), 120)
|
|
image.save(real)
|
|
|
|
assert image_has_low_visual_variance(blank, 3) is True
|
|
assert image_has_low_visual_variance(real, 3) is False
|