feat: Moxie Preview Override reads tiny VAEs from the pack's models/vae_approx
This commit is contained in:
parent
ccf7093ad2
commit
659778c38c
@ -6,6 +6,7 @@
|
||||
|
||||
### ⚡ Improvements
|
||||
|
||||
- **Moxie Preview Override**: The `tiny_vae` combo now lists files from the node pack's own `models/vae_approx` folder first (shipping `MM-preview.safetensors` for MiniMax H3 previews as the default), falling back to ComfyUI's standard `models/vae_approx` directory. The folder is rescanned on every schema refresh, so newly dropped files appear without restarting ComfyUI.
|
||||
- **Moxie Multimedia Loader**: Locked the loader to the MiniMax H3 model set. The `clip_type` dropdown (which previously exposed every CLIP recipe in ComfyUI) was removed; the H3 Qwen3-VL text encoder is now always loaded with the `minimax` CLIP recipe. Any older ComfyUI build without `CLIPType.MINIMAX` raises a clear startup error instead of silently loading the wrong encoder.
|
||||
- **Moxie Multimedia Loader / Moxie MultiTrack Project**: Removed the legacy `FAST_MODEL_LOADER` (`model_loader`) bundle. The loader now outputs exactly `model`, `clip`, `video_vae`, and `audio_vae` (with the attention backend and LoRA already applied to the model), and the Moxie MultiTrack Project takes those four outputs as required direct inputs instead of a bundled loader. `Moxie Preview Override` likewise dropped its `model_loader` pass-through slots and now patches the `model` input directly. The generic `easy multitrackProject` node keeps its `model_loader` input for non-Moxie workflows.
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@ import latent_preview
|
||||
from comfy_api.latest import io
|
||||
from PIL import Image, ImageOps
|
||||
|
||||
from .tiny_vae import load_tiny_vae_decoder
|
||||
from .tiny_vae import load_tiny_vae_decoder, pack_vae_approx_files
|
||||
|
||||
try:
|
||||
from .ltxv_nodes import WrappedPreviewer as _LTXWrappedPreviewer, get_ltx_rgb_factors as _ltx_rgb_factors
|
||||
@ -970,9 +970,30 @@ class _PreviewOverrideWrapper:
|
||||
pass
|
||||
|
||||
|
||||
def _tiny_vae_choices():
|
||||
"""Tiny VAE options: pack-shipped models/vae_approx files first, then
|
||||
ComfyUI's standard vae_approx entries. Rescanned on every schema request,
|
||||
so newly dropped files show up without a restart."""
|
||||
options = ["none"] + pack_vae_approx_files()
|
||||
for global_name in folder_paths.get_filename_list("vae_approx"):
|
||||
if global_name not in options:
|
||||
options.append(global_name)
|
||||
return options
|
||||
|
||||
|
||||
def _tiny_vae_default(options):
|
||||
"""Prefer the shipped H3 preview VAE, then any pack-shipped file, else none."""
|
||||
if "MM-preview.safetensors" in options:
|
||||
return "MM-preview.safetensors"
|
||||
if len(options) > 1:
|
||||
return options[1]
|
||||
return "none"
|
||||
|
||||
|
||||
class ModelPreviewOverrideKJ(io.ComfyNode):
|
||||
@classmethod
|
||||
def define_schema(cls) -> io.Schema:
|
||||
tiny_vae_options = _tiny_vae_choices()
|
||||
return io.Schema(
|
||||
node_id="MoxiePreviewOverride",
|
||||
display_name="Moxie Preview Override",
|
||||
@ -1031,9 +1052,11 @@ class ModelPreviewOverrideKJ(io.ComfyNode):
|
||||
),
|
||||
io.Combo.Input(
|
||||
"tiny_vae",
|
||||
options=["none"] + folder_paths.get_filename_list("vae_approx"),
|
||||
default="taeh3.safetensors",
|
||||
tooltip="Tiny VAE decoder from models/vae_approx for true-RGB previews (e.g. taeh3.safetensors).",
|
||||
options=tiny_vae_options,
|
||||
default=_tiny_vae_default(tiny_vae_options),
|
||||
tooltip="Tiny VAE decoder for true-RGB previews. Listed from the node pack's "
|
||||
"models/vae_approx folder first, then ComfyUI's models/vae_approx "
|
||||
"(ships with MM-preview.safetensors for MiniMax H3).",
|
||||
),
|
||||
],
|
||||
outputs=[
|
||||
@ -1055,7 +1078,7 @@ class ModelPreviewOverrideKJ(io.ComfyNode):
|
||||
suppress_default_preview=True,
|
||||
preview_frames=48,
|
||||
preview_fps=24,
|
||||
tiny_vae="taeh3.safetensors",
|
||||
tiny_vae="MM-preview.safetensors",
|
||||
) -> io.NodeOutput:
|
||||
if model is None:
|
||||
raise TypeError("Moxie Preview Override: 'model' input is required.")
|
||||
|
||||
36
tiny_vae.py
36
tiny_vae.py
@ -9,6 +9,7 @@ TAEHVDecoder handles the temporal taehv format, which core builds but can't size
|
||||
"""
|
||||
|
||||
import logging
|
||||
import os
|
||||
|
||||
import torch
|
||||
import torch.nn as nn
|
||||
@ -175,13 +176,44 @@ class TAEHVDecoder:
|
||||
return out
|
||||
|
||||
|
||||
# Tiny VAEs shipped with the node pack live in <pack>/models/vae_approx,
|
||||
# the same pack-local convention as the Moxie Multimedia Loader's models/.
|
||||
PACK_VAE_APPROX_DIR = os.path.join(
|
||||
os.path.dirname(os.path.abspath(__file__)), "models", "vae_approx"
|
||||
)
|
||||
|
||||
TINY_VAE_EXTENSIONS = (".safetensors", ".sft", ".ckpt", ".pt", ".pth", ".bin")
|
||||
|
||||
|
||||
def pack_vae_approx_files():
|
||||
"""Tiny VAE files in the pack's models/vae_approx folder, as relative paths (sorted)."""
|
||||
results = []
|
||||
if os.path.isdir(PACK_VAE_APPROX_DIR):
|
||||
for root, _dirs, files in os.walk(PACK_VAE_APPROX_DIR):
|
||||
for filename in files:
|
||||
if filename.lower().endswith(TINY_VAE_EXTENSIONS):
|
||||
rel = os.path.relpath(os.path.join(root, filename), PACK_VAE_APPROX_DIR)
|
||||
results.append(rel.replace("\\", "/"))
|
||||
results.sort()
|
||||
return results
|
||||
|
||||
|
||||
def load_tiny_vae_decoder(name, device=None, dtype=None):
|
||||
"""Load by vae_approx filename. Returns None (and logs) if it can't be used."""
|
||||
"""Load by vae_approx filename, searching the node pack's models/vae_approx
|
||||
folder first and ComfyUI's standard models/vae_approx second.
|
||||
Returns None (and logs) if it can't be used."""
|
||||
import folder_paths
|
||||
|
||||
pack_path = os.path.join(PACK_VAE_APPROX_DIR, name)
|
||||
if os.path.isfile(pack_path):
|
||||
path = pack_path
|
||||
else:
|
||||
path = folder_paths.get_full_path("vae_approx", name)
|
||||
if path is None:
|
||||
logging.warning(f"[KJ TinyVAE] '{name}' not found in models/vae_approx.")
|
||||
logging.warning(
|
||||
f"[Moxie TinyVAE] '{name}' not found in the pack's models/vae_approx "
|
||||
"or ComfyUI's models/vae_approx."
|
||||
)
|
||||
return None
|
||||
try:
|
||||
sd = comfy.utils.load_torch_file(path, safe_load=True)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user