Clamp latent upscale fallback tile minimum

This commit is contained in:
2026-09-03 20:15:58 +00:00
parent 21ae4d62e0
commit 9dc3c405a6
+8
View File
@@ -440,6 +440,7 @@ def _shrink_model_tile_param(param):
next_param["spatial_h_overlap"] = _halve_32(next_param.get("spatial_h_overlap", 0)) next_param["spatial_h_overlap"] = _halve_32(next_param.get("spatial_h_overlap", 0))
next_param["fade_width"] = _halve_32(next_param.get("fade_width", 0)) next_param["fade_width"] = _halve_32(next_param.get("fade_width", 0))
next_param["fade_height"] = _halve_32(next_param.get("fade_height", 0)) next_param["fade_height"] = _halve_32(next_param.get("fade_height", 0))
next_param["min_tile_size"] = _halve_32(next_param.get("min_tile_size", 0))
return next_param return next_param
tile_w = int(next_param.get("tile_width", 0) or 0) tile_w = int(next_param.get("tile_width", 0) or 0)
@@ -455,6 +456,11 @@ def _shrink_model_tile_param(param):
next_param["overlap"] = _halve_32(next_param.get("overlap", 0)) next_param["overlap"] = _halve_32(next_param.get("overlap", 0))
next_param["fade_width"] = _halve_32(next_param.get("fade_width", 0)) next_param["fade_width"] = _halve_32(next_param.get("fade_width", 0))
next_param["fade_height"] = _halve_32(next_param.get("fade_height", 0)) next_param["fade_height"] = _halve_32(next_param.get("fade_height", 0))
next_param["min_tile_size"] = min(
_halve_32(next_param.get("min_tile_size", 0)),
new_w,
new_h,
)
return next_param return next_param
@@ -526,6 +532,7 @@ def _upscale_video_model_tiled(video, param):
if mode == "rows_cols": if mode == "rows_cols":
tile_w = max(32, int(round(w_out / float(grid_cols) / 32.0)) * 32) 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) tile_h = max(32, int(round(h_out / float(grid_rows) / 32.0)) * 32)
min_tile_size = min(min_tile_size, tile_w, tile_h)
rows, cols, trows, tcols, row_ovl, col_ovl = _compute_spatial_grid( 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 h_out, w_out, tile_h, tile_w, spatial_h_overlap, spatial_w_overlap, min_tile_size, min_tile_size
) )
@@ -535,6 +542,7 @@ def _upscale_video_model_tiled(video, param):
for name, value in (("tile_width", tile_w), ("tile_height", tile_h), ("overlap", overlap), ("fade_width", fade_w), ("fade_height", fade_h), ("min_tile_size", min_tile_size)): for name, value in (("tile_width", tile_w), ("tile_height", tile_h), ("overlap", overlap), ("fade_width", fade_w), ("fade_height", fade_h), ("min_tile_size", min_tile_size)):
if value % 32 != 0: if value % 32 != 0:
raise ValueError(f"'{name}' must be a multiple of 32 pixels; got {value}.") raise ValueError(f"'{name}' must be a multiple of 32 pixels; got {value}.")
min_tile_size = min(min_tile_size, tile_w, tile_h)
rows, cols, trows, tcols, row_ovl, col_ovl = _compute_spatial_grid( 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 h_out, w_out, tile_h, tile_w, overlap, overlap, min_tile_size, min_tile_size
) )