Single-pass MultiTrack projects now condition and sample at half the editor-selected resolution; Moxie Project Video Combine restores the exact editor resolution on the combined frames before export, so the editor resolution remains what the user sees and gets. - utils/rtx_vsr.py (new): RTX Video Super Resolution core adapted from Comfy-Org/Nvidia_RTX_Nodes_ComfyUI (Apache 2.0) driving the optional nvidia-vfx package per frame, with automatic Lanczos fallback and exact-size correction; owns the sampling-dimension policy and the project_data gating so only half-res signatures are upscaled - nodes/project.py: gate half-res conditioning/sampling to single-pass mode (dual-pass, SelfLift, passthrough, audio-only unchanged) - moxie_combine.py: restore editor resolution right before the images output; VIDEO preview output passthrough unchanged - scripts/test_rtx_upscale_integration.py: standalone sanity checks (no ComfyUI/torch needed) for the dimension policy and gating
85 lines
2.9 KiB
Python
85 lines
2.9 KiB
Python
"""Standalone sanity checks for the hidden half-res output upscale contract.
|
|
|
|
Loads utils/rtx_vsr.py directly (no ComfyUI, no torch) and verifies the
|
|
dimension policy and the project_data gating that MoxieCombine relies on.
|
|
The torch/nvvfx execution path is covered by the user's on-machine tests.
|
|
|
|
Run: python scripts/test_rtx_upscale_integration.py
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import importlib.util
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
PACK_ROOT = Path(__file__).resolve().parents[1]
|
|
MODULE_PATH = PACK_ROOT / "utils" / "rtx_vsr.py"
|
|
|
|
spec = importlib.util.spec_from_file_location("rtx_vsr_standalone", MODULE_PATH)
|
|
rtx_vsr = importlib.util.module_from_spec(spec)
|
|
spec.loader.exec_module(rtx_vsr)
|
|
|
|
assert "torch" not in sys.modules, "rtx_vsr must import torch lazily"
|
|
|
|
failures = []
|
|
|
|
|
|
def check(name, got, expected):
|
|
ok = got == expected
|
|
print(f"{'PASS' if ok else 'FAIL'} {name}: got={got!r} expected={expected!r}")
|
|
if not ok:
|
|
failures.append(name)
|
|
|
|
|
|
# --- dimension policy ---
|
|
cases = [
|
|
((544, 960), (272, 480)),
|
|
((960, 544), (480, 272)),
|
|
((1088, 1920), (544, 960)),
|
|
((1344, 768), (672, 384)),
|
|
((552, 968), (288, 496)),
|
|
((552, 488), (288, 256)),
|
|
((256, 256), (128, 128)),
|
|
((32, 32), None), # audio-only sentinel
|
|
((64, 64), None), # half would collapse onto the sentinel
|
|
((32, 64), None),
|
|
((33, 33), None),
|
|
((0, 100), None),
|
|
((100, -5), None),
|
|
(("abc", 100), None),
|
|
]
|
|
for (w, h), expected in cases:
|
|
got = rtx_vsr.h3_halfres_sampling_dimensions(w, h)
|
|
check(f"dims({w}x{h})", got, expected)
|
|
|
|
# --- round trip: sampling canvas restores the editor selection ---
|
|
for w, h in [(544, 960), (960, 544), (1088, 1920), (1344, 768), (552, 968), (272, 480)]:
|
|
sampling = rtx_vsr.h3_halfres_sampling_dimensions(w, h)
|
|
if sampling is None:
|
|
continue
|
|
target = rtx_vsr.resolve_output_upscale_target(
|
|
sampling, {"width": w, "height": h}
|
|
)
|
|
check(f"round-trip {w}x{h}", target, (w, h))
|
|
|
|
# --- gating (MoxieCombine contract) ---
|
|
G = rtx_vsr.resolve_output_upscale_target
|
|
data = {"width": 960, "height": 544}
|
|
check("fires on half-res signature", G((480, 272), data), (960, 544))
|
|
check("no-op at target size", G((960, 544), data), None)
|
|
check("no-op for foreign size", G((500, 300), data), None)
|
|
check("no-op for dual-pass size", G((1664, 960), data), None)
|
|
check("json string project data", G((272, 480), '{"width": 544, "height": 960}'), (544, 960))
|
|
check("bad json", G((272, 480), "{oops"), None)
|
|
check("empty dict", G((272, 480), {}), None)
|
|
check("none data", G((272, 480), None), None)
|
|
check("missing height", G((272, 480), {"width": 960}), None)
|
|
check("zero dims", G((272, 480), {"width": 0, "height": 0}), None)
|
|
check("sentinel project", G((32, 32), {"width": 32, "height": 32}), None)
|
|
|
|
print()
|
|
if failures:
|
|
print(f"{len(failures)} FAILED: {failures}")
|
|
sys.exit(1)
|
|
print("All sanity checks passed.")
|