Handle legacy latent upscale payloads
This commit is contained in:
+19
-7
@@ -4084,6 +4084,19 @@ def _latent_upscale_target_size(base_w, base_h, param):
|
|||||||
return int(base_w), int(base_h)
|
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):
|
def _latent_spatial_grid(h, w, th, tw, ol_h, ol_w):
|
||||||
if th <= 0 or tw <= 0:
|
if th <= 0 or tw <= 0:
|
||||||
raise ValueError("tile dimensions must be positive")
|
raise ValueError("tile dimensions must be positive")
|
||||||
@@ -6637,10 +6650,8 @@ class H3LongVideos:
|
|||||||
raise
|
raise
|
||||||
refined_out = out
|
refined_out = out
|
||||||
latent_upscale_param = latent_upscale_param or None
|
latent_upscale_param = latent_upscale_param or None
|
||||||
if (
|
latent_upscale_mode = _latent_upscale_mode(latent_upscale_param)
|
||||||
isinstance(latent_upscale_param, dict)
|
if latent_upscale_mode != "off":
|
||||||
and str(latent_upscale_param.get("mode", "off")) != "off"
|
|
||||||
):
|
|
||||||
try:
|
try:
|
||||||
latent_start = time.perf_counter()
|
latent_start = time.perf_counter()
|
||||||
out_samples = out["samples"]
|
out_samples = out["samples"]
|
||||||
@@ -6659,7 +6670,7 @@ class H3LongVideos:
|
|||||||
target_h = int(up_h) * 16
|
target_h = int(up_h) * 16
|
||||||
if target_w <= 0 or target_h <= 0:
|
if target_w <= 0 or target_h <= 0:
|
||||||
raise RuntimeError("latent upscale target size must be positive")
|
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.unload_model_and_clones(model, unload_additional_models=False)
|
||||||
mm.soft_empty_cache()
|
mm.soft_empty_cache()
|
||||||
upscale_cond, upscale_latent = _build_shot_conditioning(
|
upscale_cond, upscale_latent = _build_shot_conditioning(
|
||||||
@@ -6939,9 +6950,10 @@ class H3LongVideos:
|
|||||||
if apply_model_sampling:
|
if apply_model_sampling:
|
||||||
model, ms_note = apply_h3_model_sampling(model, shift_video, shift_audio)
|
model, ms_note = apply_h3_model_sampling(model, shift_video, shift_audio)
|
||||||
latent_upscale_note = ""
|
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)
|
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}"
|
detail = f" via {mode}"
|
||||||
if mode == "model":
|
if mode == "model":
|
||||||
detail += f"/{latent_upscale_param.get('model_name', 'none')}"
|
detail += f"/{latent_upscale_param.get('model_name', 'none')}"
|
||||||
|
|||||||
@@ -1148,6 +1148,12 @@ class DumasH3LongVideosHelperTests(unittest.TestCase):
|
|||||||
self.assertFalse(required["resize_conditioning"][1]["default"])
|
self.assertFalse(required["resize_conditioning"][1]["default"])
|
||||||
self.assertEqual(required["anchor_strength"][1]["default"], 0.999)
|
self.assertEqual(required["anchor_strength"][1]["default"], 0.999)
|
||||||
|
|
||||||
|
def test_latent_upscale_mode_infers_legacy_model_payloads(self):
|
||||||
|
self.assertEqual(self.module._latent_upscale_mode({"model_name": "foo.safetensors"}), "model")
|
||||||
|
self.assertEqual(self.module._latent_upscale_mode({"method": "bilinear"}), "interp")
|
||||||
|
self.assertEqual(self.module._latent_upscale_mode({"mode": "model"}), "model")
|
||||||
|
self.assertEqual(self.module._latent_upscale_mode({}), "off")
|
||||||
|
|
||||||
def test_compose_persistent_does_not_expand_ambiguous_plural_to_full_cast(self):
|
def test_compose_persistent_does_not_expand_ambiguous_plural_to_full_cast(self):
|
||||||
active = self.module.parse_wardrobe(
|
active = self.module.parse_wardrobe(
|
||||||
"Maya = she, red jacket\n"
|
"Maya = she, red jacket\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user