From 9dc3c405a62f2beda55c1bdfb88b5d3cb0cdc2c2 Mon Sep 17 00:00:00 2001 From: Chris Dumas Date: Thu, 3 Sep 2026 20:15:58 +0000 Subject: [PATCH] Clamp latent upscale fallback tile minimum --- dumas_h3_latent_upscale.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dumas_h3_latent_upscale.py b/dumas_h3_latent_upscale.py index b544f91..81ecf85 100644 --- a/dumas_h3_latent_upscale.py +++ b/dumas_h3_latent_upscale.py @@ -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["fade_width"] = _halve_32(next_param.get("fade_width", 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 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["fade_width"] = _halve_32(next_param.get("fade_width", 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 @@ -526,6 +532,7 @@ def _upscale_video_model_tiled(video, param): 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) + 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 ) @@ -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)): 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) 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 )