feat: add Moxie MultiTrack Project Slow with latent-upscale refine pass
New project node variant (MoxieProjectSlow, display name 'Moxie MultiTrack Project Slow') that replaces the RTX VSR pixel restore with a latent upscaler plus a short refine pass: - identical UX to MoxieProject: end users only set steps and seed (plus the shared context_frames overlap); schema mirrors the base node via a shared _project_inputs() helper - first pass stays at the hidden half resolution (engine gains a _h3_first_pass_resolution_scale class hook, overriding the previous sampling_mode == 'single' hardcode; MoxieProjectSlow returns 0.5 under dual mode) - the half-res latent is upscaled to the final (editor) size by the H3 latent upscaler (minimax_h3_latent_upscaler_3d_fp16.safetensors, models/latent_upscale_models) and refined with a hidden 2-step euler pass at 0.33 denoise; the schedule replicates KSampler.set_steps (int(steps/denoise) total steps, last steps+1 sigmas) without relying on the denoise kwarg that newer comfy.samplers builds dropped - baked settings: sampling_mode dual, upscale_by 1.0 (final size IS the editor size), upscale_model as above; the engine's upscale-skip condition now compares actual first-pass vs target dimensions instead of upscale_by <= 1, which is behavior-identical for every existing configuration - segments are saved at the project resolution, so the Video Combine restore passes through untouched - no RTX VSR anywhere - MoxieProject refactor: component check and baked settings moved into reusable helpers (_require_moxie_components, _baked_project_settings classmethod) so the subclass composes cleanly; messages unchanged - tests: Slow schema mirror, execute passthrough (sigma schedule math, baked settings, context_frames forwarding, first-pass schedule), the resolution-scale hook, and the denoise truncation helper - docs: CHANGELOG entry, multitrack-schema.md note
This commit is contained in:
parent
0a9416b91a
commit
5a3b03ef61
@ -6,6 +6,8 @@
|
||||
|
||||
### ⚡ Improvements
|
||||
|
||||
- **Moxie MultiTrack Project Slow**: New project node variant that replaces the RTX VSR restore with a latent-upscale refine pass. The pipeline stays identical to Moxie MultiTrack Project — hidden half-resolution first pass with euler + beta sigmas from `steps` — but the low-resolution latent is upscaled to the final (editor) size by `minimax_h3_latent_upscaler_3d_fp16.safetensors` (from `ComfyUI/models/latent_upscale_models/`) and refined with a hidden 2-step euler pass at 0.33 denoise. Segments are saved at the project resolution, so the Video Combine restore passes through untouched and nothing in the node requires NVIDIA RTX VSR. End users still only set `steps` and `seed` (plus the shared `context_frames` overlap). The engine's first-pass downscale and upscale-skip logic were generalized (class hook + true size comparison) with zero behavior change for existing nodes.
|
||||
|
||||
- **MultiTrack Project**: The inter-segment context overlap is now configurable. The new `context_frames` widget (5 / 22 / 39 / 56 frames, default 22) chooses how many frames of the previous segment are copied in as continuation context for segments using Context or Context Swap continuity — previously this was fixed at 22 frames in code. Longer values hand off motion more smoothly but generate that many extra frames per continued segment (each continuation also generates 12 grid-alignment tail frames that are trimmed after decode). Values are the H3 temporal-grid lengths already offered by the Moxie context sampler nodes; existing workflows keep 22 and behave exactly as before. The same widget (between `steps` and `seed`) is also exposed on **Moxie MultiTrack Project** — its baked euler/beta sampling stack is unchanged, so end users still only need `steps` and `seed` unless they touch the overlap.
|
||||
|
||||
- **Moxie Multimedia Loader**: Removed the automatic LoRA application entirely. The 3-step distill (speedup) weights are now baked into the diffusion model itself, so the loader no longer reads `models/loras` — a leftover file there is silently ignored, and the `models/loras` folder can be deleted. The node schema, outputs, and load order (diffusion model → attention backend → CLIP → VAEs) are unchanged; workflows saved earlier keep working. The `Moxie Project` steps tooltip now references the baked-in distill instead of the LoRA.
|
||||
|
||||
@ -12,7 +12,7 @@ from .utils.bernini_s2v_model_patch import apply_bernini_s2v_model_patches
|
||||
from .utils.log import install_console_privacy_filter
|
||||
|
||||
from .moxie_loader import MoxieMultimediaLoader
|
||||
from .moxie_project import MoxieProject
|
||||
from .moxie_project import MoxieProject, MoxieProjectSlow
|
||||
from .moxie_combine import MoxieCombine
|
||||
from .moxie_preview import ModelPreviewOverrideKJ as MoxiePreviewOverride
|
||||
|
||||
@ -82,6 +82,7 @@ class EasyMediaExtension(ComfyExtension):
|
||||
MoxieMultimediaLoader,
|
||||
MoxiePreviewOverride,
|
||||
MoxieProject,
|
||||
MoxieProjectSlow,
|
||||
MoxieCombine,
|
||||
# TimelineEditor
|
||||
TimelineEditor,
|
||||
|
||||
221
moxie_project.py
221
moxie_project.py
@ -28,6 +28,63 @@ BAKED_PROJECT_SETTINGS = {
|
||||
BAKED_SAMPLER_NAME = "euler"
|
||||
BAKED_SCHEDULER = "beta"
|
||||
|
||||
# Moxie MultiTrack Project Slow: the hidden half-resolution first pass is
|
||||
# upscaled to the final size by the H3 latent upscaler model and refined with
|
||||
# a short low-denoise euler pass instead of the RTX VSR pixel restore.
|
||||
SLOW_UPSCALE_MODEL = "minimax_h3_latent_upscaler_3d_fp16.safetensors"
|
||||
SLOW_SECOND_PASS_STEPS = 2
|
||||
SLOW_SECOND_PASS_DENOISE = 0.33
|
||||
SLOW_PROJECT_SETTINGS_DELTA = {
|
||||
"sampling_mode": "dual",
|
||||
# The first pass already runs at half the editor resolution, so the final
|
||||
# size IS the editor size: a scale factor of 1.0 keeps the project
|
||||
# manifest at the editor dimensions while the latent upscaler (target
|
||||
# dimensions mode) bridges the half-res gap.
|
||||
"upscale_by": 1.0,
|
||||
"upscale_model": SLOW_UPSCALE_MODEL,
|
||||
}
|
||||
|
||||
|
||||
def _require_moxie_components(model, clip, video_vae, audio_vae) -> None:
|
||||
missing = [
|
||||
name
|
||||
for name, value in (
|
||||
("model", model),
|
||||
("clip", clip),
|
||||
("video_vae", video_vae),
|
||||
("audio_vae", audio_vae),
|
||||
)
|
||||
if value is None
|
||||
]
|
||||
if missing:
|
||||
raise ValueError(
|
||||
"MoxieProject: Missing required model components: "
|
||||
+ ", ".join(missing)
|
||||
+ ". Wire model, clip, video_vae, and audio_vae from Moxie Multimedia Loader."
|
||||
)
|
||||
|
||||
|
||||
def _denoise_truncated_sigmas(
|
||||
model_sampling, scheduler: str, steps: int, denoise: float
|
||||
):
|
||||
"""Sigma schedule for `steps` steps at `denoise`, matching KSampler.
|
||||
|
||||
Replicates comfy KSampler.set_steps: build the schedule at
|
||||
int(steps / denoise) total steps, then keep the last steps + 1 sigmas.
|
||||
Written out because newer ComfyUI builds dropped the denoise kwarg from
|
||||
comfy.samplers.calculate_sigmas.
|
||||
"""
|
||||
if denoise <= 0.0:
|
||||
raise ValueError("denoise must be positive")
|
||||
if denoise > 0.9999:
|
||||
total_steps = steps
|
||||
else:
|
||||
total_steps = int(steps / denoise)
|
||||
schedule = comfy.samplers.calculate_sigmas(
|
||||
model_sampling, scheduler, total_steps
|
||||
).cpu()
|
||||
return schedule[-(steps + 1):]
|
||||
|
||||
|
||||
class MoxieProject(EasyMultiTrackProject):
|
||||
"""MultiTrack Project with the sampling stack consolidated.
|
||||
@ -38,6 +95,51 @@ class MoxieProject(EasyMultiTrackProject):
|
||||
internally from the exposed `steps` widget.
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def _baked_project_settings(cls) -> dict:
|
||||
return dict(BAKED_PROJECT_SETTINGS)
|
||||
|
||||
@classmethod
|
||||
def _project_inputs(cls) -> list:
|
||||
return [
|
||||
TYPE_TRACKS_INFO.Input("tracks_info"),
|
||||
io.Model.Input("model", tooltip="Diffusion model from Moxie Multimedia Loader (attention backend already applied)."),
|
||||
io.Clip.Input("clip", tooltip="CLIP text encoder from Moxie Multimedia Loader."),
|
||||
io.Vae.Input("video_vae", tooltip="Video VAE from Moxie Multimedia Loader."),
|
||||
io.Vae.Input("audio_vae", tooltip="Audio VAE from Moxie Multimedia Loader (required to decode Moxie audio)."),
|
||||
io.String.Input("project_name", default="",
|
||||
tooltip="Name of the project; used for output folders."),
|
||||
io.Int.Input(
|
||||
"steps",
|
||||
default=3,
|
||||
min=1,
|
||||
max=10000,
|
||||
tooltip="Sampling steps for the beta scheduler (3 for the baked-in 3-step distill; "
|
||||
"8 for busy motion, 6 low motion, 4 runs/no dialogue).",
|
||||
),
|
||||
io.Combo.Input(
|
||||
"context_frames",
|
||||
options=[str(option) for option in H3_CONTEXT_LENGTH_OPTIONS],
|
||||
default=str(H3_CONTEXT_SOURCE_FRAMES),
|
||||
tooltip=(
|
||||
"Video frames copied from the previous segment as "
|
||||
"continuation context for segments whose continuity "
|
||||
"mode is Context or Context Swap. Longer values hand "
|
||||
"off motion more smoothly but generate that many extra "
|
||||
"frames per segment. Values are H3 temporal-grid "
|
||||
"lengths shared with the Moxie context sampler nodes."
|
||||
),
|
||||
),
|
||||
io.Int.Input(
|
||||
"seed",
|
||||
default=42,
|
||||
min=0,
|
||||
max=0xFFFFFFFFFFFFFFFF,
|
||||
step=1,
|
||||
control_after_generate=io.ControlAfterGenerate.randomize,
|
||||
),
|
||||
]
|
||||
|
||||
@classmethod
|
||||
def define_schema(cls) -> io.Schema:
|
||||
return io.Schema(
|
||||
@ -52,44 +154,7 @@ class MoxieProject(EasyMultiTrackProject):
|
||||
is_input_list=True,
|
||||
enable_expand=True,
|
||||
not_idempotent=True,
|
||||
inputs=[
|
||||
TYPE_TRACKS_INFO.Input("tracks_info"),
|
||||
io.Model.Input("model", tooltip="Diffusion model from Moxie Multimedia Loader (attention backend already applied)."),
|
||||
io.Clip.Input("clip", tooltip="CLIP text encoder from Moxie Multimedia Loader."),
|
||||
io.Vae.Input("video_vae", tooltip="Video VAE from Moxie Multimedia Loader."),
|
||||
io.Vae.Input("audio_vae", tooltip="Audio VAE from Moxie Multimedia Loader (required to decode Moxie audio)."),
|
||||
io.String.Input("project_name", default="",
|
||||
tooltip="Name of the project; used for output folders."),
|
||||
io.Int.Input(
|
||||
"steps",
|
||||
default=3,
|
||||
min=1,
|
||||
max=10000,
|
||||
tooltip="Sampling steps for the beta scheduler (3 for the baked-in 3-step distill; "
|
||||
"8 for busy motion, 6 low motion, 4 runs/no dialogue).",
|
||||
),
|
||||
io.Combo.Input(
|
||||
"context_frames",
|
||||
options=[str(option) for option in H3_CONTEXT_LENGTH_OPTIONS],
|
||||
default=str(H3_CONTEXT_SOURCE_FRAMES),
|
||||
tooltip=(
|
||||
"Video frames copied from the previous segment as "
|
||||
"continuation context for segments whose continuity "
|
||||
"mode is Context or Context Swap. Longer values hand "
|
||||
"off motion more smoothly but generate that many extra "
|
||||
"frames per segment. Values are H3 temporal-grid "
|
||||
"lengths shared with the Moxie context sampler nodes."
|
||||
),
|
||||
),
|
||||
io.Int.Input(
|
||||
"seed",
|
||||
default=42,
|
||||
min=0,
|
||||
max=0xFFFFFFFFFFFFFFFF,
|
||||
step=1,
|
||||
control_after_generate=io.ControlAfterGenerate.randomize,
|
||||
),
|
||||
],
|
||||
inputs=cls._project_inputs(),
|
||||
hidden=[io.Hidden.prompt, io.Hidden.unique_id],
|
||||
outputs=[
|
||||
io.String.Output("PROJECT_NAME"),
|
||||
@ -105,13 +170,7 @@ class MoxieProject(EasyMultiTrackProject):
|
||||
clip = _first_input(kwargs.get("clip"))
|
||||
video_vae = _first_input(kwargs.get("video_vae"))
|
||||
audio_vae = _first_input(kwargs.get("audio_vae"))
|
||||
|
||||
if model is None or clip is None or video_vae is None or audio_vae is None:
|
||||
missing = [k for k, v in [("model", model), ("clip", clip), ("video_vae", video_vae), ("audio_vae", audio_vae)] if v is None]
|
||||
raise ValueError(
|
||||
"MoxieProject: Missing required model components: " + ", ".join(missing) +
|
||||
". Wire model, clip, video_vae, and audio_vae from Moxie Multimedia Loader."
|
||||
)
|
||||
_require_moxie_components(model, clip, video_vae, audio_vae)
|
||||
|
||||
# Pack the direct inputs into the loader dict consumed by
|
||||
# EasyMultiTrackProject.execute (internal plumbing only).
|
||||
@ -130,8 +189,78 @@ class MoxieProject(EasyMultiTrackProject):
|
||||
sampler = comfy.samplers.sampler_object(BAKED_SAMPLER_NAME)
|
||||
|
||||
baked = dict(kwargs)
|
||||
baked.update(BAKED_PROJECT_SETTINGS)
|
||||
baked.update(cls._baked_project_settings())
|
||||
baked["model_loader"] = synthesized_loader
|
||||
baked["sampler"] = sampler
|
||||
baked["sigmas"] = sigmas
|
||||
return super().execute(**baked)
|
||||
|
||||
|
||||
class MoxieProjectSlow(MoxieProject):
|
||||
"""Moxie MultiTrack Project with a latent-upscale refine pass.
|
||||
|
||||
Identical pipeline to MoxieProject (hidden half-resolution first pass,
|
||||
euler + beta sampling from `steps`), except the low-resolution latent is
|
||||
upscaled to the final size by the H3 latent upscaler model and refined
|
||||
with a 2-step euler pass at 0.33 denoise. Segments are saved at the
|
||||
project resolution, so the Video Combine RTX restore passes through
|
||||
untouched - no NVIDIA RTX VSR is used anywhere.
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def _baked_project_settings(cls) -> dict:
|
||||
settings = dict(BAKED_PROJECT_SETTINGS)
|
||||
settings.update(SLOW_PROJECT_SETTINGS_DELTA)
|
||||
return settings
|
||||
|
||||
@classmethod
|
||||
def _h3_first_pass_resolution_scale(cls, sampling_mode: str) -> float:
|
||||
# Dual mode would sample the first pass at the editor size; the Slow
|
||||
# node keeps MoxieProject's hidden half-resolution speed trick and
|
||||
# lets the latent upscaler bridge the gap instead of RTX VSR.
|
||||
return 0.5
|
||||
|
||||
@classmethod
|
||||
def define_schema(cls) -> io.Schema:
|
||||
return io.Schema(
|
||||
node_id="MoxieProjectSlow",
|
||||
display_name="Moxie MultiTrack Project Slow",
|
||||
category="EasyUse/MultiTrackEditor",
|
||||
description=(
|
||||
"Build and execute a multi-track Moxie project with a "
|
||||
"latent-upscale refine pass. Takes model, clip, video_vae and "
|
||||
"audio_vae directly from the Moxie Multimedia Loader. The "
|
||||
"first pass samples euler + beta sigmas from steps, the "
|
||||
"half-resolution latent is upscaled to the final size with "
|
||||
"the H3 latent upscaler model, and a 2-step euler pass at "
|
||||
"0.33 denoise refines it; set only steps and seed."
|
||||
),
|
||||
is_input_list=True,
|
||||
enable_expand=True,
|
||||
not_idempotent=True,
|
||||
inputs=cls._project_inputs(),
|
||||
hidden=[io.Hidden.prompt, io.Hidden.unique_id],
|
||||
outputs=[
|
||||
io.String.Output("PROJECT_NAME"),
|
||||
io.Audio.Output("LOCKED_AUDIO"),
|
||||
],
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def execute(cls, **kwargs) -> io.NodeOutput:
|
||||
model = _first_input(kwargs.get("model"))
|
||||
clip = _first_input(kwargs.get("clip"))
|
||||
video_vae = _first_input(kwargs.get("video_vae"))
|
||||
audio_vae = _first_input(kwargs.get("audio_vae"))
|
||||
_require_moxie_components(model, clip, video_vae, audio_vae)
|
||||
|
||||
sigmas_2nd = _denoise_truncated_sigmas(
|
||||
model.get_model_object("model_sampling"),
|
||||
BAKED_SCHEDULER,
|
||||
SLOW_SECOND_PASS_STEPS,
|
||||
SLOW_SECOND_PASS_DENOISE,
|
||||
)
|
||||
injected = dict(kwargs)
|
||||
injected["sampler_2nd"] = comfy.samplers.sampler_object(BAKED_SAMPLER_NAME)
|
||||
injected["sigmas_2nd"] = sigmas_2nd
|
||||
return super().execute(**injected)
|
||||
|
||||
@ -880,6 +880,18 @@ class EasyMultiTrackProject(io.ComfyNode):
|
||||
"""Return sorted sampling plan keys: user presets first, then 'custom'."""
|
||||
return get_h3_preset_keys()
|
||||
|
||||
@classmethod
|
||||
def _h3_first_pass_resolution_scale(cls, sampling_mode: str) -> float:
|
||||
"""Hidden first-pass downscale applied before sampling.
|
||||
|
||||
Single-pass projects sample at half the editor resolution and recover
|
||||
the exact editor size in pixel space through the Video Combine RTX
|
||||
restore (utils/rtx_vsr.py). Project variants that upscale the latent
|
||||
to the final size instead override this to keep the same speed trick
|
||||
on other sampling modes; every other mode keeps the editor size.
|
||||
"""
|
||||
return 0.5 if sampling_mode == "single" else 1.0
|
||||
|
||||
@classmethod
|
||||
def define_schema(cls) -> io.Schema:
|
||||
return io.Schema(
|
||||
@ -1208,17 +1220,18 @@ class EasyMultiTrackProject(io.ComfyNode):
|
||||
editor_height = int(info["height"])
|
||||
audio_only = (editor_width, editor_height) == (32, 32)
|
||||
fps = float(info["frame_rate"])
|
||||
# Hidden half-res sampling (single-pass projects only): condition and
|
||||
# sample at half the editor-selected resolution; Moxie Project Video
|
||||
# Combine restores the exact editor resolution in pixel space before
|
||||
# its images output (utils/rtx_vsr.py). Every other sampling mode
|
||||
# keeps the editor size exactly as configured.
|
||||
# Hidden first-pass downscale: project classes may sample below the
|
||||
# editor-selected resolution (single-pass Moxie projects use half)
|
||||
# and recover the editor size later - in pixel space via the Video
|
||||
# Combine RTX restore, or in latent space via the upscaler pass on
|
||||
# the Slow variant. The hook returns 1.0 unless overridden.
|
||||
first_pass_width, first_pass_height = editor_width, editor_height
|
||||
if sampling_mode == "single" and not audio_only:
|
||||
half_width = max(32, editor_width // 2)
|
||||
half_height = max(32, editor_height // 2)
|
||||
if (half_width, half_height) != (32, 32):
|
||||
first_pass_width, first_pass_height = half_width, half_height
|
||||
first_pass_scale = float(cls._h3_first_pass_resolution_scale(sampling_mode))
|
||||
if first_pass_scale != 1.0 and not audio_only:
|
||||
scaled_width = max(32, int(editor_width * first_pass_scale))
|
||||
scaled_height = max(32, int(editor_height * first_pass_scale))
|
||||
if (scaled_width, scaled_height) != (32, 32):
|
||||
first_pass_width, first_pass_height = scaled_width, scaled_height
|
||||
target_width, target_height = h3_second_pass_dimensions(
|
||||
editor_width,
|
||||
editor_height,
|
||||
@ -1891,7 +1904,13 @@ class EasyMultiTrackProject(io.ComfyNode):
|
||||
and context_second_pass_sigmas is not None
|
||||
):
|
||||
segment_second_pass_sigmas = context_second_pass_sigmas
|
||||
if audio_only or upscale_by <= 1:
|
||||
# No upscale pass is needed when the first-pass latent already
|
||||
# sits at the target size (upscale_by <= 1 configurations, or
|
||||
# variants that downscale the first pass to the target size).
|
||||
if audio_only or (
|
||||
first_pass_width,
|
||||
first_pass_height,
|
||||
) == (target_width, target_height):
|
||||
report_segment_step(0.46)
|
||||
upscaled_latent = final_latent
|
||||
else:
|
||||
|
||||
@ -268,6 +268,7 @@ custom 示例:
|
||||
- `sampling_mode`: `single` 或 `dual`;`sampling_plan` 必须是当前节点可用预设。不要仅凭另一份流程中的值假设当前环境支持。
|
||||
- `context_frames`(默认 `"22"`,可选 `"5"` / `"22"` / `"39"` / `"56"`)控制 Context / Context Swap 续接片段从上一段拷贝为延续上下文的视频帧数;取值必须落在 H3 时间潜空间网格(17k+5 帧)上,与 Moxie 上下文采样节点的选项一致。数值越大运动衔接越平滑,但每个续接片段会多生成等量帧(实际生成长度为 `任务长度 + context_frames + 12`,其中 12 帧为网格尾帧,解码后裁掉)。
|
||||
- `Moxie MultiTrack Project`(`MoxieProject`)同样暴露同一个 `context_frames` 下拉,位于 `steps` 与 `seed` 之间;该节点的其余采样设置仍保持隐藏(euler + beta sigmas 由 `steps` 推导)。
|
||||
- `Moxie MultiTrack Project Slow`(`MoxieProjectSlow`)是 Moxie 变体:参数与 `Moxie MultiTrack Project` 完全一致,但用潜空间放大替代 RTX VSR——隐藏的半分辨率一采之后,用 `models/latent_upscale_models/minimax_h3_latent_upscaler_3d_fp16.safetensors` 把潜空间升到最终(编辑器)尺寸,再以 2 步 euler、0.33 denoise 的隐藏二采精修;片段按项目分辨率保存,Video Combine 的 RTX 还原会直接跳过。
|
||||
- 编辑器分辨率是一采尺寸;`dual` 不会反算缩小一采。二采宽高分别为 `round(编辑器尺寸 * upscale_by / 32) * 32`,采用 Python `round` 就近对齐,恰好居中时取偶数,不是固定向上对齐。
|
||||
- `upscale_by` 是 Project 的独立参数,默认 `1.250`,三位小数,步长 `0.001`;旧工作流保留已保存的值。两条放大路径及合并导出均使用放大并对齐后的尺寸。例如 `1344 × 768`、倍率 `1.250` 的二采为 `1664 × 960`。若用户指定最终输出尺寸,应同时核对编辑器尺寸与倍率,不能将编辑器尺寸直接当作双采样的最终尺寸。
|
||||
- 单采样、仅一采预览保持编辑器尺寸;`upscale_by = 1.000` 不放大但可二采;纯音频项目(`32 × 32`)不放大。旧版反算缩小尺寸的一采检查点和上下文潜空间应重新生成后再按新规则续跑。
|
||||
|
||||
@ -6267,3 +6267,124 @@ def test_moxie_project_forwards_context_frames_to_engine(monkeypatch):
|
||||
assert captured["sampling_mode"] == "single"
|
||||
assert captured["sampler"] == {"sampler": "euler"}
|
||||
assert captured["sigmas"].shape == (5,)
|
||||
|
||||
|
||||
def test_moxie_project_slow_schema_mirrors_moxie_project(monkeypatch):
|
||||
module = _load_moxie_project(monkeypatch)
|
||||
slow = module.MoxieProjectSlow.define_schema()
|
||||
base = module.MoxieProject.define_schema()
|
||||
slow_inputs = {port.name: port for port in slow.inputs}
|
||||
base_inputs = {port.name: port for port in base.inputs}
|
||||
|
||||
assert slow.node_id == "MoxieProjectSlow"
|
||||
assert slow.display_name == "Moxie MultiTrack Project Slow"
|
||||
assert slow.is_input_list is True
|
||||
assert slow.enable_expand is True
|
||||
assert list(slow_inputs) == list(base_inputs)
|
||||
assert [out.name for out in slow.outputs] == [out.name for out in base.outputs]
|
||||
assert "context_frames" in slow_inputs
|
||||
assert slow_inputs["context_frames"].kwargs["options"] == ["5", "22", "39", "56"]
|
||||
|
||||
|
||||
def test_moxie_project_slow_bakes_latent_upscale_refine(monkeypatch):
|
||||
module = _load_moxie_project(monkeypatch)
|
||||
|
||||
calls = []
|
||||
|
||||
def fake_calculate_sigmas(model_sampling, scheduler, steps):
|
||||
calls.append((scheduler, steps))
|
||||
return torch.arange(float(steps) + 7.0)
|
||||
|
||||
monkeypatch.setattr(
|
||||
module.comfy.samplers, "calculate_sigmas", fake_calculate_sigmas
|
||||
)
|
||||
|
||||
captured = {}
|
||||
|
||||
def fake_execute(cls, **kwargs):
|
||||
captured.update(kwargs)
|
||||
return "sentinel-output"
|
||||
|
||||
monkeypatch.setattr(
|
||||
module.EasyMultiTrackProject, "execute", classmethod(fake_execute)
|
||||
)
|
||||
|
||||
model = types.SimpleNamespace(
|
||||
get_model_object=lambda name: f"sampling:{name}"
|
||||
)
|
||||
result = module.MoxieProjectSlow.execute(
|
||||
tracks_info=[{"tracks": []}],
|
||||
model=[model],
|
||||
clip=[types.SimpleNamespace()],
|
||||
video_vae=[types.SimpleNamespace()],
|
||||
audio_vae=[types.SimpleNamespace()],
|
||||
project_name=["demo"],
|
||||
steps=["3"],
|
||||
context_frames=["5"],
|
||||
seed=["7"],
|
||||
)
|
||||
|
||||
assert result == "sentinel-output"
|
||||
# Second-pass schedule runs first (Slow.execute), then the first-pass
|
||||
# schedule inside MoxieProject.execute. 2 steps at denoise 0.33 must
|
||||
# build the schedule at int(2 / 0.33) = 6 total steps and keep the
|
||||
# last 3 sigmas (steps + 1), exactly like KSampler.set_steps.
|
||||
assert calls == [
|
||||
("beta", 6),
|
||||
("beta", 3),
|
||||
]
|
||||
assert calls[0] == ("beta", 6)
|
||||
assert captured["sigmas_2nd"].shape == (3,)
|
||||
assert torch.equal(captured["sigmas_2nd"], torch.tensor([10.0, 11.0, 12.0]))
|
||||
assert captured["sampler_2nd"] == {"sampler": "euler"}
|
||||
# Baked Slow settings reach the engine.
|
||||
assert captured["sampling_mode"] == "dual"
|
||||
assert captured["upscale_by"] == 1.0
|
||||
assert (
|
||||
captured["upscale_model"]
|
||||
== "minimax_h3_latent_upscaler_3d_fp16.safetensors"
|
||||
)
|
||||
assert captured["sampling_plan"] == "custom"
|
||||
assert captured["disable_2nd_noise"] is False
|
||||
# First pass unchanged: euler + beta from steps (3 -> 4 sigmas).
|
||||
assert captured["sampler"] == {"sampler": "euler"}
|
||||
assert captured["sigmas"].shape == (4,)
|
||||
assert torch.equal(captured["sigmas"], torch.tensor([6.0, 7.0, 8.0, 9.0]))
|
||||
assert captured["context_frames"] == ["5"]
|
||||
|
||||
|
||||
def test_moxie_project_slow_keeps_half_res_first_pass(monkeypatch):
|
||||
module = _load_moxie_project(monkeypatch)
|
||||
base = module.EasyMultiTrackProject
|
||||
assert base._h3_first_pass_resolution_scale("single") == 0.5
|
||||
assert base._h3_first_pass_resolution_scale("dual") == 1.0
|
||||
assert base._h3_first_pass_resolution_scale("selflift") == 1.0
|
||||
assert base._h3_first_pass_resolution_scale("passthrough") == 1.0
|
||||
slow = module.MoxieProjectSlow
|
||||
for mode in ("single", "dual", "selflift", "passthrough"):
|
||||
assert slow._h3_first_pass_resolution_scale(mode) == 0.5
|
||||
|
||||
|
||||
def test_denoise_truncated_sigmas_matches_ksampler_math(monkeypatch):
|
||||
module = _load_moxie_project(monkeypatch)
|
||||
calls = []
|
||||
|
||||
def fake_calculate_sigmas(model_sampling, scheduler, steps):
|
||||
calls.append((scheduler, steps))
|
||||
return torch.linspace(1.0, 0.0, steps + 1)
|
||||
|
||||
monkeypatch.setattr(
|
||||
module.comfy.samplers, "calculate_sigmas", fake_calculate_sigmas
|
||||
)
|
||||
|
||||
sigmas = module._denoise_truncated_sigmas("ms", "beta", 2, 0.33)
|
||||
assert calls == [("beta", 6)]
|
||||
assert sigmas.shape == (3,)
|
||||
assert sigmas[-1] == 0.0
|
||||
|
||||
full = module._denoise_truncated_sigmas("ms", "beta", 4, 1.0)
|
||||
assert calls == [("beta", 6), ("beta", 4)]
|
||||
assert full.shape == (5,)
|
||||
|
||||
with pytest.raises(ValueError, match="denoise must be positive"):
|
||||
module._denoise_truncated_sigmas("ms", "beta", 2, 0.0)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user