Clamp H3 spatial overlaps to tile size

This commit is contained in:
2026-09-04 09:05:29 +00:00
parent 7e45c81589
commit 5b52793fad
+10
View File
@@ -634,9 +634,18 @@ def _upscale_video_model_tiled(video, param):
spatial_h_overlap = max(0, int(param.get("spatial_h_overlap", overlap) or overlap))
min_tile_size = max(0, int(param.get("min_tile_size", 0) or 0))
def _fit_overlap(value, tile):
value = max(0, int(value or 0))
tile = max(0, int(tile or 0))
if tile <= 32:
return 0
return min(value, ((tile - 1) // 32) * 32)
if mode == "rows_cols":
tile_w = max(32, int(round(w_out / float(grid_cols) / 32.0)) * 32)
tile_h = max(32, int(round(h_out / float(grid_rows) / 32.0)) * 32)
spatial_w_overlap = _fit_overlap(spatial_w_overlap, tile_w)
spatial_h_overlap = _fit_overlap(spatial_h_overlap, tile_h)
min_tile_size = min(min_tile_size, tile_w, tile_h)
rows, cols, trows, tcols, row_ovl, col_ovl = _compute_spatial_grid(
h_out, w_out, tile_h, tile_w, spatial_h_overlap, spatial_w_overlap, min_tile_size, min_tile_size
@@ -648,6 +657,7 @@ def _upscale_video_model_tiled(video, param):
if value % 32 != 0:
raise ValueError(f"'{name}' must be a multiple of 32 pixels; got {value}.")
min_tile_size = min(min_tile_size, tile_w, tile_h)
overlap = _fit_overlap(overlap, min(tile_w, tile_h))
rows, cols, trows, tcols, row_ovl, col_ovl = _compute_spatial_grid(
h_out, w_out, tile_h, tile_w, overlap, overlap, min_tile_size, min_tile_size
)