Harden H3 detail pass conditioning

This commit is contained in:
2026-08-28 09:37:22 +00:00
parent 5255c174fd
commit af226987d7
2 changed files with 77 additions and 7 deletions
+31 -4
View File
@@ -4031,6 +4031,21 @@ def _copy_sample_latent(out_latent):
return None
def _latent_with_replaced_samples(template_latent, sampled_latent):
"""Reuse the original latent payload, but swap in freshly sampled tensors."""
if not isinstance(template_latent, dict):
return sampled_latent
out = dict(template_latent)
if isinstance(sampled_latent, dict):
for key, value in sampled_latent.items():
if key != "samples" and key not in out:
out[key] = value
if "samples" in sampled_latent:
out["samples"] = sampled_latent["samples"]
return out
return sampled_latent
def _video_only_refined_latent(base_latent, refined_latent):
"""Keep the refined video latent, but preserve the original audio latent."""
base = base_latent.get("samples") if isinstance(base_latent, dict) else None
@@ -4047,6 +4062,16 @@ def _video_only_refined_latent(base_latent, refined_latent):
except Exception:
return refined_latent
return refined_latent
def _coerce_bool_flag(value):
if isinstance(value, str):
text = value.strip().lower()
if text in ("", "0", "false", "no", "off", "none", "null"):
return False
if text in ("1", "true", "yes", "on"):
return True
return bool(value)
# --- ref2va reference conditioning ----------------------------------------
@@ -6148,7 +6173,7 @@ class H3LongVideos:
"building a separate graph."}),
"detail_sampler_name": (comfy.samplers.KSampler.SAMPLERS, {"default": "euler",
"tooltip": "Sampler used for the optional refinement pass."}),
"detail_scheduler": (comfy.samplers.KSampler.SCHEDULERS, {"default": "karras",
"detail_scheduler": (comfy.samplers.KSampler.SCHEDULERS, {"default": "beta",
"tooltip": "Scheduler used for the optional refinement pass."}),
"detail_steps": ("INT", {"default": 8, "min": 1, "max": 200,
"tooltip": "Steps for the optional refinement pass."}),
@@ -6178,7 +6203,7 @@ class H3LongVideos:
def _render(self, model, clip, vae, audio_vae, negative, prompt, w, h, ln, fps, tiled, sa,
handoff, decode_tile_frames=0, decode_tile_size=0,
refs=None, ref_image_size="match", ref_noise_aug=None, silent=False,
detail_pass=False, detail_sampler_name="euler", detail_scheduler="karras",
detail_pass=False, detail_sampler_name="euler", detail_scheduler="beta",
detail_steps=8, detail_denoise=0.4):
positive, latent = _build_shot_conditioning(clip, vae, prompt, w, h, ln, fps, handoff,
ref_images=refs, ref_image_size=ref_image_size,
@@ -6200,11 +6225,13 @@ class H3LongVideos:
e._h3_stage = "sampling"
raise
refined_out = out
detail_pass = _coerce_bool_flag(detail_pass)
if detail_pass:
detail_latent = _latent_with_replaced_samples(latent, out)
try:
(refined_out,) = nodes.common_ksampler(
model, seed, int(detail_steps), cfg, detail_sampler_name, detail_scheduler,
positive, negative, out, denoise=float(detail_denoise))
positive, negative, detail_latent, denoise=float(detail_denoise))
except Exception as e:
if _is_oom(e):
e._h3_stage = "sampling"
@@ -6254,7 +6281,7 @@ class H3LongVideos:
ref_image_5=None, ref_image_6=None, ref_image_7=None, ref_image_8=None,
ref_image_9=None,
ref_mode="auto ref2v", ref_image_size="match", ref_noise_aug=0.95,
detail_pass=False, detail_sampler_name="euler", detail_scheduler="karras",
detail_pass=False, detail_sampler_name="euler", detail_scheduler="beta",
detail_steps=8, detail_denoise=0.4,
graph=None, node_id=None):