Expand latent upscale spatial stitch controls
This commit is contained in:
+16
-6
@@ -4104,10 +4104,18 @@ def _latent_spatial_grid(h, w, th, tw, ol_h, ol_w):
|
||||
return rows, cols, trows, tcols
|
||||
|
||||
|
||||
def _latent_spatial_blend_weights(t, overlap_mode):
|
||||
def _latent_spatial_blend_weights(t, overlap_mode, overlap_blend="linear"):
|
||||
if overlap_blend == "overwrite":
|
||||
return torch.ones_like(t) if overlap_mode == "later" else torch.zeros_like(t)
|
||||
if overlap_blend == "midpoint":
|
||||
base = (t >= 0.5).to(t.dtype)
|
||||
elif overlap_blend == "smoothstep":
|
||||
base = t * t * (3.0 - 2.0 * t)
|
||||
else:
|
||||
base = t
|
||||
if overlap_mode == "later":
|
||||
return 1.0 - t
|
||||
return t
|
||||
return base
|
||||
return 1.0 - base
|
||||
|
||||
|
||||
def _nested_tensor_parts(samples):
|
||||
@@ -6510,6 +6518,7 @@ class H3LongVideos:
|
||||
overlap_px = max(0, int(latent_upscale_param.get("overlap", 64) or 64))
|
||||
fade_px = max(0, int(latent_upscale_param.get("fade_width", 0) or 0))
|
||||
overlap_mode = str(latent_upscale_param.get("overlap_mode", "earlier"))
|
||||
overlap_blend = str(latent_upscale_param.get("overlap_blend", "linear"))
|
||||
tile_tw = max(1, min(int(up_w), max(1, tile_w_px // 16)))
|
||||
tile_th = max(1, min(int(up_h), max(1, tile_h_px // 16)))
|
||||
ol_tw = max(0, min(tile_tw - 1, overlap_px // 16))
|
||||
@@ -6548,7 +6557,7 @@ class H3LongVideos:
|
||||
region.copy_(tile_video_out)
|
||||
if col_index > 0 and ol_tw > 0:
|
||||
t = torch.linspace(0.0, 1.0, ol_tw, device=region.device, dtype=region.dtype)
|
||||
w = _latent_spatial_blend_weights(t, overlap_mode)
|
||||
w = _latent_spatial_blend_weights(t, overlap_mode, overlap_blend)
|
||||
if fw_tw > 0:
|
||||
w = w.clone()
|
||||
w[:fw_tw] = 0.0
|
||||
@@ -6558,7 +6567,7 @@ class H3LongVideos:
|
||||
)
|
||||
if row_index > 0 and ol_th > 0:
|
||||
t = torch.linspace(0.0, 1.0, ol_th, device=region.device, dtype=region.dtype)
|
||||
w = _latent_spatial_blend_weights(t, overlap_mode)
|
||||
w = _latent_spatial_blend_weights(t, overlap_mode, overlap_blend)
|
||||
if fw_th > 0:
|
||||
w = w.clone()
|
||||
w[:fw_th] = 0.0
|
||||
@@ -6707,8 +6716,9 @@ class H3LongVideos:
|
||||
tile_w_px = int(latent_upscale_param.get("tile_width", 512) or 512)
|
||||
tile_h_px = int(latent_upscale_param.get("tile_height", 512) or 512)
|
||||
overlap_px = max(0, int(latent_upscale_param.get("overlap", 64) or 64))
|
||||
overlap_blend = str(latent_upscale_param.get("overlap_blend", "linear"))
|
||||
if tile_w_px > 0 and tile_h_px > 0 and (tile_w_px < target_w or tile_h_px < target_h):
|
||||
batch_note = f"; spatial batches {tile_w_px}x{tile_h_px}px overlap {overlap_px}px"
|
||||
batch_note = f"; spatial batches {tile_w_px}x{tile_h_px}px overlap {overlap_px}px {overlap_blend}"
|
||||
latent_upscale_note = (
|
||||
f" latent upscale: target {target_w}x{target_h}px{detail}; "
|
||||
f"{int(latent_upscale_param.get('steps', 2) or 2)}-step refinement "
|
||||
|
||||
Reference in New Issue
Block a user