fix: guard against overlap >= tile_size in tiled inference
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
57c3aff913
commit
3d330d0e0b
@ -27,6 +27,10 @@ def _compute_tile_coords(
|
||||
|
||||
Tiles overlap by `overlap` pixels. Last tile is clamped to image boundary.
|
||||
"""
|
||||
if overlap >= tile_size:
|
||||
msg = f"overlap ({overlap}) must be less than tile_size ({tile_size})"
|
||||
raise ValueError(msg)
|
||||
|
||||
if image_size <= tile_size:
|
||||
return [(0, image_size)]
|
||||
|
||||
|
||||
@ -32,6 +32,12 @@ def model() -> GreenFormer:
|
||||
|
||||
|
||||
class TestTileCoords:
|
||||
def test_overlap_gte_tile_size_raises(self) -> None:
|
||||
with pytest.raises(ValueError, match="overlap.*must be less than tile_size"):
|
||||
_compute_tile_coords(512, 256, 256)
|
||||
with pytest.raises(ValueError, match="overlap.*must be less than tile_size"):
|
||||
_compute_tile_coords(512, 256, 300)
|
||||
|
||||
def test_single_tile(self) -> None:
|
||||
coords = _compute_tile_coords(200, 256, 32)
|
||||
assert coords == [(0, 200)]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user