Handle legacy latent upscale payloads

This commit is contained in:
2026-09-03 18:33:01 +00:00
parent 51e03a39b7
commit 3ab6342ce5
2 changed files with 25 additions and 7 deletions
+19 -7
View File
@@ -4084,6 +4084,19 @@ def _latent_upscale_target_size(base_w, base_h, param):
return int(base_w), int(base_h)
def _latent_upscale_mode(param):
if not isinstance(param, dict):
return "off"
mode = str(param.get("mode") or "").strip()
if mode:
return mode
if "model_name" in param and str(param.get("model_name") or "").strip() not in ("", "none"):
return "model"
if "method" in param:
return "interp"
return "off"
def _latent_spatial_grid(h, w, th, tw, ol_h, ol_w):
if th <= 0 or tw <= 0:
raise ValueError("tile dimensions must be positive")
@@ -6637,10 +6650,8 @@ class H3LongVideos:
raise
refined_out = out
latent_upscale_param = latent_upscale_param or None
if (
isinstance(latent_upscale_param, dict)
and str(latent_upscale_param.get("mode", "off")) != "off"
):
latent_upscale_mode = _latent_upscale_mode(latent_upscale_param)
if latent_upscale_mode != "off":
try:
latent_start = time.perf_counter()
out_samples = out["samples"]
@@ -6659,7 +6670,7 @@ class H3LongVideos:
target_h = int(up_h) * 16
if target_w <= 0 or target_h <= 0:
raise RuntimeError("latent upscale target size must be positive")
if latent_upscale_param.get("mode") == "model" and str(latent_upscale_param.get("device", "cuda")) == "cuda" and hasattr(model, "clone_base_uuid"):
if latent_upscale_mode == "model" and str(latent_upscale_param.get("device", "cuda")) == "cuda" and hasattr(model, "clone_base_uuid"):
mm.unload_model_and_clones(model, unload_additional_models=False)
mm.soft_empty_cache()
upscale_cond, upscale_latent = _build_shot_conditioning(
@@ -6939,9 +6950,10 @@ class H3LongVideos:
if apply_model_sampling:
model, ms_note = apply_h3_model_sampling(model, shift_video, shift_audio)
latent_upscale_note = ""
if isinstance(latent_upscale_param, dict) and str(latent_upscale_param.get("mode", "off")) != "off":
latent_upscale_mode = _latent_upscale_mode(latent_upscale_param)
if latent_upscale_mode != "off":
target_w, target_h = _latent_upscale_target_size(w, h, latent_upscale_param)
mode = str(latent_upscale_param.get("mode", "off"))
mode = latent_upscale_mode
detail = f" via {mode}"
if mode == "model":
detail += f"/{latent_upscale_param.get('model_name', 'none')}"