Merge remote-tracking branch 'origin/main' into feature-pixverseModify

This commit is contained in:
Sirshendu Ganguly
2026-04-28 19:58:35 +05:30
4 changed files with 116 additions and 21 deletions
+94 -2
View File
@@ -4,6 +4,89 @@ import comfy.model_management
class txt2vid:
@staticmethod
def _format_reference_images(referenceImages):
"""
Shape referenceImages by payload style:
- If any entry uses `images` (Images1..N style), return grouped objects
[{type, tag, images, audio?}]
- Otherwise return flat list[str] (legacy behavior)
"""
if referenceImages is None:
return []
if not isinstance(referenceImages, list):
referenceImages = [referenceImages]
has_grouped_images = any(
isinstance(ref, dict) and isinstance(ref.get("images"), list) and len(ref.get("images")) > 0
for ref in referenceImages
)
if has_grouped_images:
grouped = []
for idx, ref in enumerate(referenceImages, start=1):
images = []
ref_type = "image"
ref_tag = f"@image{idx}"
ref_audio = ""
if isinstance(ref, str):
if ref.strip():
images = [ref.strip()]
elif isinstance(ref, dict):
ref_type = (str(ref.get("type", "image")).strip() or "image")
raw_tag = str(ref.get("tag", "")).strip()
ref_tag = raw_tag if raw_tag else ref_tag
if not ref_tag.startswith("@"):
ref_tag = f"@{ref_tag}"
raw_audio = ref.get("audio", "")
if isinstance(raw_audio, str) and raw_audio.strip():
ref_audio = raw_audio.strip()
image_value = ref.get("image")
if isinstance(image_value, str) and image_value.strip():
images.append(image_value.strip())
image_group = ref.get("images")
if isinstance(image_group, list):
for item in image_group:
if isinstance(item, str) and item.strip():
images.append(item.strip())
if not images:
continue
group = {
"type": ref_type,
"tag": ref_tag,
"images": images[:5], # provider limit: max 5
}
if ref_audio:
group["audio"] = ref_audio
grouped.append(group)
return grouped
# Legacy/default path: flatten to list of image strings
flattened = []
for ref in referenceImages:
if isinstance(ref, str):
if ref.strip():
flattened.append(ref.strip())
elif isinstance(ref, dict):
image_value = ref.get("image")
if isinstance(image_value, str) and image_value.strip():
flattened.append(image_value.strip())
image_group = ref.get("images")
if isinstance(image_group, list):
for item in image_group:
if isinstance(item, str) and item.strip():
flattened.append(item.strip())
return flattened
@classmethod
def INPUT_TYPES(cls):
return {
@@ -278,8 +361,10 @@ class txt2vid:
print(f"[Debugging] Frame images array: {rwUtils.sanitize_for_logging(frameImages)}")
# Add referenceImages if provided from Runware Reference Images node
if referenceImages is not None and len(referenceImages) > 0:
genConfig[0]["referenceImages"] = referenceImages
print(f"[Debugging] Reference images array: {rwUtils.sanitize_for_logging(referenceImages)}")
formattedReferenceImages = self._format_reference_images(referenceImages)
if len(formattedReferenceImages) > 0:
genConfig[0]["referenceImages"] = formattedReferenceImages
print(f"[Debugging] Reference images array: {rwUtils.sanitize_for_logging(formattedReferenceImages)}")
# Add inputAudios if provided
if inputAudios is not None and len(inputAudios) > 0:
genConfig[0]["inputAudios"] = inputAudios
@@ -308,6 +393,13 @@ class txt2vid:
# Merge each input from inputs (only actual input data, not provider settings)
for key, value in inputs.items():
# Normalize referenceImages by payload style:
# grouped objects when using ImagesN; otherwise flat string[]
if key == "referenceImages":
formatted_input_refs = self._format_reference_images(value)
if len(formatted_input_refs) > 0:
genConfig[0]["inputs"][key] = formatted_input_refs
continue
genConfig[0]["inputs"][key] = value
print(f"[Debugging] Video inference inputs merged: {rwUtils.sanitize_for_logging(inputs)}")
+20 -18
View File
@@ -6,6 +6,7 @@ class videoInputsReferences:
"""Video Inputs References node for configuring reference images with types"""
MAX_REFERENCES = 10
MAX_GROUPED_REFERENCES = 4
@classmethod
def INPUT_TYPES(cls):
@@ -16,21 +17,22 @@ class videoInputsReferences:
optionalInputs[f"Image{i}"] = ("IMAGE", {
"tooltip": f"{ordinal.capitalize()} single reference image (mutually exclusive with Images{i}).",
})
optionalInputs[f"Images{i}"] = ("RUNWAREVIDEOINPUTSREFERENCEMULTIIMAGES", {
"tooltip": f"{ordinal.capitalize()} reference image group from the Multiple Images Connector (mutually exclusive with Image{i}).",
})
optionalInputs[f"Tag{i}"] = ("STRING", {
"tooltip": f"Optional tag for the {ordinal} reference (e.g., @image{i}, @Actor-1).",
"default": "",
})
optionalInputs[f"Type{i}"] = ("STRING", {
"tooltip": f"Type for the {ordinal} reference (e.g., image or grid). Leave empty to omit.",
"default": "",
})
optionalInputs[f"Audio{i}"] = ("STRING", {
"tooltip": f"Optional audio URL/mediaUUID for the {ordinal} reference.",
"default": "",
})
if i <= cls.MAX_GROUPED_REFERENCES:
optionalInputs[f"Images{i}"] = ("RUNWAREVIDEOINPUTSREFERENCEMULTIIMAGES", {
"tooltip": f"{ordinal.capitalize()} reference image group from the Multiple Images Connector (mutually exclusive with Image{i}).",
})
optionalInputs[f"Tag{i}"] = ("STRING", {
"tooltip": f"Optional tag for the {ordinal} reference (e.g., @image{i}, @Actor-1).",
"default": "",
})
optionalInputs[f"Type{i}"] = ("STRING", {
"tooltip": f"Type for the {ordinal} reference (e.g., image or grid). Leave empty to omit.",
"default": "",
})
optionalInputs[f"Audio{i}"] = ("STRING", {
"tooltip": f"Optional audio URL/mediaUUID for the {ordinal} reference.",
"default": "",
})
return {
"required": {},
@@ -38,8 +40,8 @@ class videoInputsReferences:
}
DESCRIPTION = (
"Configure multiple reference image entries for video inference inputs. "
"For each slot, provide either ImageN (single image) or ImagesN (connector output), not both."
"Configure up to 10 reference image entries for video inference inputs. "
"For slots 1-4, provide either ImageN (single image) or ImagesN (connector output), not both."
)
FUNCTION = "createReferences"
RETURN_TYPES = ("RUNWAREVIDEOINPUTSREFERENCEIMAGES",)
@@ -62,7 +64,7 @@ class videoInputsReferences:
refTag = (kwargs.get(tagKey) or "").strip()
refType = kwargs.get(typeKey, "")
refAudio = (kwargs.get(audioKey) or "").strip()
has_image = image is not None
has_images = isinstance(images, list) and len(images) > 0
if has_image and has_images:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long