Release H3 Continuum V3.3.0

This commit is contained in:
ukr8b3g-cmyk
2026-08-16 20:32:47 +09:00
parent a908e4884f
commit fb22c20149
38 changed files with 3598 additions and 363 deletions
+59 -18
View File
@@ -17,6 +17,7 @@ import torch
REFERENCE_CONTRACT_VERSION = 1
REFERENCE_PREPROCESS_VERSION = 1
REFERENCE_SIZE_MATCH_OUTPUT = "Match Output"
REFERENCE_SIZE_MAX_IDENTITY = "Max Identity"
REFERENCE_SIZE_OPTIONS = (
@@ -46,13 +47,26 @@ class ReferenceAssets:
@property
def contract(self) -> dict[str, Any]:
return {
result = {
"reference_contract_version": REFERENCE_CONTRACT_VERSION,
"count": self.count,
"size_mode": self.size_mode,
"image_hashes": list(self.image_hashes),
"combined_hash": self.combined_hash,
}
# Preserve the V3.2.2 JSON contract byte-for-byte for zero, one, and
# two references. The V3.2.3 extension exists only when Image 3 is
# connected, so removing it can resolve back to an older Revision.
if self.count == 3:
image = self.images[2]
result["reference_image_3"] = {
"reference_position": 3,
"shape": [int(value) for value in image.shape],
"dtype": str(image.dtype),
"sha256": self.image_hashes[2],
"preprocess_version": REFERENCE_PREPROCESS_VERSION,
}
return result
def _canonical_hash(value: Any) -> str:
@@ -133,16 +147,18 @@ def prepare_reference_assets(
output_width: int,
output_height: int,
size_mode: str,
reference_image_3: torch.Tensor | None = None,
) -> ReferenceAssets | None:
if reference_image_1 is None:
if reference_image_2 is not None:
raise ReferenceConditioningError(
"Reference Image 2 requires Reference Image 1"
)
# Match Core's dynamic Reference inputs: bypassed or otherwise absent
# sockets are ignored, then active images are numbered contiguously in
# connection order as Picture 1..N.
inputs = [
image
for image in (reference_image_1, reference_image_2, reference_image_3)
if image is not None
]
if not inputs:
return None
inputs = [reference_image_1]
if reference_image_2 is not None:
inputs.append(reference_image_2)
images = tuple(
_resize_reference(
_validate_image(f"Reference Image {index}", image),
@@ -181,24 +197,37 @@ def validate_reference_prompts(prompts: list[str], reference_count: int) -> str:
for prompt in prompts:
found.update(int(value) for value in _PICTURE_TAG.findall(str(prompt)))
invalid = sorted(value for value in found if value < 1 or value > reference_count)
warnings: list[str] = []
if invalid:
raise ReferenceConditioningError(
f"Prompt references unavailable <Picture {invalid[0]}>; "
f"connected reference count is {reference_count}"
unavailable = ", ".join(f"<Picture {value}>" for value in invalid)
warnings.append(
f"H3C-P102 Warning: prompt references unavailable {unavailable}; only "
f"{reference_count} active reference image(s) reached the Sampler. "
"ComfyUI Core permits this and generation will continue, but the "
"unavailable reference may be ignored or hallucinated. Enable the "
"corresponding Reference Image input or remove the unavailable tag."
)
if not found:
return (
"Reference images are connected but the prompt contains no "
"<Picture N> tag; images still condition generation, but explicit "
"identity references are recommended."
missing = sorted(set(range(1, reference_count + 1)) - found)
if missing:
labels = ", ".join(f"<Picture {value}>" for value in missing)
detail = (
"the prompt contains no <Picture N> tag"
if not found
else f"connected reference {labels} is not explicitly mentioned in the prompt"
)
return ""
warnings.append(
f"H3C-P103 Warning: {detail}; images still condition generation, but "
"explicit identity references are recommended."
)
return "\n".join(warnings)
def encode_reference_prompt(
clip: Any,
prompt: str,
assets: ReferenceAssets,
reference_audio_assets=None,
timeline_video_assets=None,
) -> list[list[Any]]:
if any(latent is None for latent in assets.latents):
raise ReferenceConditioningError("reference latents were not encoded")
@@ -206,6 +235,12 @@ def encode_reference_prompt(
{"type": "image", "data": image}
for image in assets.images
]
if timeline_video_assets is not None:
reference_items.append(dict(timeline_video_assets.item))
if reference_audio_assets is not None:
from .reference_audio import reference_audio_item
reference_items.append(reference_audio_item())
try:
tokens = clip.tokenize(str(prompt), minimax_ref_items=reference_items)
except TypeError as exc:
@@ -223,6 +258,12 @@ def encode_reference_prompt(
"latent": latent,
}
)
if timeline_video_assets is not None:
refs.append(dict(timeline_video_assets.block))
if reference_audio_assets is not None:
from .reference_audio import reference_audio_block
refs.append(reference_audio_block(reference_audio_assets))
return [
[tensor, {**dict(metadata), "minimax_refs": list(refs)}]
for tensor, metadata in conditioning