Restore Continuum image reference inputs
This commit is contained in:
+9
-101
@@ -84,7 +84,7 @@ def _namespace_class(node_class, *, node_id, category, display_name):
|
||||
namespaced.CATEGORY = category
|
||||
namespaced.NODE_CATEGORY = category
|
||||
if node_id == "DumasH3Continuum_H3ContinuumSamplerV39":
|
||||
namespaced = _add_direct_refmod_input(namespaced)
|
||||
namespaced = _clean_v39_sampler_input(namespaced)
|
||||
namespaced.__module__ = __name__
|
||||
namespaced.__qualname__ = node_class.__qualname__
|
||||
namespaced.__name__ = node_class.__name__
|
||||
@@ -92,13 +92,13 @@ def _namespace_class(node_class, *, node_id, category, display_name):
|
||||
return namespaced
|
||||
|
||||
|
||||
def _add_direct_refmod_input(node_class):
|
||||
"""Add the DUMAS direct RefMod path to the vendored V3.9 sampler.
|
||||
def _clean_v39_sampler_input(node_class):
|
||||
"""Keep the DUMAS V3.9 manual-dimension surface without RefMods.
|
||||
|
||||
Continuum's normal image-reference bundle remains untouched. When a
|
||||
RefMod bundle is connected, the same model-scoped OUTER_SAMPLE bridge used
|
||||
by the maintained RefMod pack is attached to a cloned model for this run.
|
||||
This keeps RefMods on the native H3 ref2va path and avoids global state.
|
||||
The sampler uses Continuum's native V3.9 ``reference_images`` bundle. We
|
||||
retain the DUMAS cleanup that makes linked width/height authoritative and
|
||||
removes duplicate legacy audio controls, without adding a second RefMod
|
||||
conditioning path.
|
||||
"""
|
||||
original_input_types = node_class.INPUT_TYPES
|
||||
|
||||
@@ -107,116 +107,24 @@ def _add_direct_refmod_input(node_class):
|
||||
schema = original_input_types()
|
||||
schema = {name: dict(value) for name, value in schema.items()}
|
||||
required = dict(schema.get("required", {}))
|
||||
# V3.8 exposes both its newer resolution preset controls and the
|
||||
# original aspect/size controls. The DUMAS V3.9 node is intentionally
|
||||
# a clean manual-dimension node: width and height are the one source of
|
||||
# truth and can be converted to linked inputs in ComfyUI.
|
||||
for name in ("aspect", "preset", "custom_mp", "size_source"):
|
||||
required.pop(name, None)
|
||||
schema["required"] = required
|
||||
optional = dict(schema.get("optional", {}))
|
||||
# The bundled audio reference socket supersedes the two legacy scalar
|
||||
# audio inputs; exposing both makes it unclear which route is active.
|
||||
for name in ("reference_audio_1", "reference_audio_vae"):
|
||||
optional.pop(name, None)
|
||||
optional["refmods"] = (
|
||||
"H3_REF_MODS",
|
||||
{
|
||||
"display_name": "RefMods (Optional)",
|
||||
"tooltip": (
|
||||
"Optional MiniMax H3 RefMod bundle. RefMods are injected directly "
|
||||
"into this sampler for every generated chunk."
|
||||
),
|
||||
},
|
||||
)
|
||||
optional["refmod_retention"] = (
|
||||
"FLOAT",
|
||||
{
|
||||
"default": 1.0,
|
||||
"min": 0.0,
|
||||
"max": 1.0,
|
||||
"step": 0.01,
|
||||
"display": "number",
|
||||
"display_name": "RefMod Retention",
|
||||
"tooltip": "Master RefMod strength. 1.0 preserves the selected bundle fully.",
|
||||
},
|
||||
)
|
||||
optional["refmod_max_total_tokens"] = (
|
||||
"INT",
|
||||
{
|
||||
"default": 0,
|
||||
"min": 0,
|
||||
"max": 1048576,
|
||||
"step": 1,
|
||||
"display_name": "RefMod Token Budget",
|
||||
"tooltip": "0 uses the RefMod bundle's normal budget; otherwise enforce this maximum.",
|
||||
},
|
||||
)
|
||||
schema["optional"] = optional
|
||||
return schema
|
||||
|
||||
def run(self, refmods=None, refmod_retention=1.0,
|
||||
refmod_max_total_tokens=0, **kwargs):
|
||||
# The clean DUMAS surface always uses the explicitly supplied width /
|
||||
# height pair. Keep the upstream runtime's legacy arguments internal.
|
||||
def run(self, **kwargs):
|
||||
kwargs["size_source"] = "Manual"
|
||||
kwargs.pop("aspect", None)
|
||||
kwargs.pop("preset", None)
|
||||
kwargs.pop("custom_mp", None)
|
||||
if refmods:
|
||||
model = kwargs.get("model")
|
||||
if model is None:
|
||||
raise ValueError(
|
||||
"DUMAS H3 Continuum Sampler V3.9 requires a model when RefMods are connected."
|
||||
)
|
||||
try:
|
||||
pack = importlib.import_module(
|
||||
f"{__package__}.vendor.dumas_minimax_h3_refmod.nodes"
|
||||
if __package__ else "vendor.dumas_minimax_h3_refmod.nodes"
|
||||
)
|
||||
bridge = importlib.import_module(
|
||||
f"{__package__}.vendor.dumas_minimax_h3_refmod.continuum_bridge"
|
||||
if __package__ else "vendor.dumas_minimax_h3_refmod.continuum_bridge"
|
||||
)
|
||||
blocks = pack._ref_blocks(
|
||||
refmods,
|
||||
refmod_retention,
|
||||
seed=-1,
|
||||
scramble_mode="shuffle",
|
||||
max_total_tokens=int(refmod_max_total_tokens),
|
||||
)
|
||||
chunk_blocks = None
|
||||
chunk_refs = getattr(refmods, "chunk_refs", None)
|
||||
if chunk_refs:
|
||||
# Build the per-chunk payloads from the same selected
|
||||
# RefMods. Ordinary H3_REF_MODS lists have no routing
|
||||
# metadata and retain the upstream all-chunks behavior.
|
||||
chunk_blocks = []
|
||||
for positions in chunk_refs:
|
||||
chunk_mods = [refmods[index] for index in positions]
|
||||
chunk_blocks.append(pack._ref_blocks(
|
||||
chunk_mods,
|
||||
refmod_retention,
|
||||
seed=-1,
|
||||
scramble_mode="shuffle",
|
||||
max_total_tokens=int(refmod_max_total_tokens),
|
||||
))
|
||||
kwargs["model"] = bridge.attach(
|
||||
model, blocks, enabled=True, chunk_blocks=chunk_blocks,
|
||||
)
|
||||
print(
|
||||
"[DUMAS H3 Continuum Sampler V3.9] direct RefMods active "
|
||||
f"({len(blocks)} block(s))"
|
||||
)
|
||||
except Exception as exc:
|
||||
raise RuntimeError(
|
||||
"Unable to attach RefMods directly to DUMAS H3 Continuum "
|
||||
f"Sampler V3.9: {exc}"
|
||||
) from exc
|
||||
return super(node_class, self).run(**kwargs)
|
||||
|
||||
node_class.INPUT_TYPES = INPUT_TYPES
|
||||
node_class.run = run
|
||||
node_class.INPUT_TYPES = INPUT_TYPES
|
||||
return node_class
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user