Added backward compatibility
This commit is contained in:
@@ -5,11 +5,12 @@ import comfy.model_management
|
||||
|
||||
class txt2vid:
|
||||
@staticmethod
|
||||
def _format_reference_images(referenceImages, model):
|
||||
def _format_reference_images(referenceImages):
|
||||
"""
|
||||
Shape referenceImages per model requirements:
|
||||
- skywork:skyreels@v4 -> list of groups: {type, tag, images, audio?}
|
||||
- others -> flat list[str] (legacy behavior)
|
||||
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 []
|
||||
@@ -17,9 +18,12 @@ class txt2vid:
|
||||
if not isinstance(referenceImages, list):
|
||||
referenceImages = [referenceImages]
|
||||
|
||||
is_skyreels = model == "skywork:skyreels@v4"
|
||||
has_grouped_images = any(
|
||||
isinstance(ref, dict) and isinstance(ref.get("images"), list) and len(ref.get("images")) > 0
|
||||
for ref in referenceImages
|
||||
)
|
||||
|
||||
if is_skyreels:
|
||||
if has_grouped_images:
|
||||
grouped = []
|
||||
for idx, ref in enumerate(referenceImages, start=1):
|
||||
images = []
|
||||
@@ -357,7 +361,7 @@ 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:
|
||||
formattedReferenceImages = self._format_reference_images(referenceImages, model)
|
||||
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)}")
|
||||
@@ -391,7 +395,7 @@ class txt2vid:
|
||||
for key, value in inputs.items():
|
||||
# Normalize referenceImages so non-SkyReels models keep legacy string[] payload
|
||||
if key == "referenceImages":
|
||||
formatted_input_refs = self._format_reference_images(value, model)
|
||||
formatted_input_refs = self._format_reference_images(value)
|
||||
if len(formatted_input_refs) > 0:
|
||||
genConfig[0]["inputs"][key] = formatted_input_refs
|
||||
continue
|
||||
|
||||
@@ -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):
|
||||
@@ -14,20 +15,24 @@ class videoInputsReferences:
|
||||
for i in range(1, cls.MAX_REFERENCES + 1):
|
||||
ordinal = rwUtils.getOrdinal(i)
|
||||
optionalInputs[f"Image{i}"] = ("IMAGE", {
|
||||
"tooltip": f"{ordinal.capitalize()} reference image.",
|
||||
})
|
||||
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": "",
|
||||
"tooltip": f"{ordinal.capitalize()} single reference image (mutually exclusive with Images{i}).",
|
||||
})
|
||||
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": {},
|
||||
@@ -35,8 +40,8 @@ class videoInputsReferences:
|
||||
}
|
||||
|
||||
DESCRIPTION = (
|
||||
"Configure multiple reference images for video inference inputs. "
|
||||
"Use ImageN slots (Image1..Image10)."
|
||||
"Configure up to 4 reference image entries for video inference inputs. "
|
||||
"For each slot, provide either ImageN (single image) or ImagesN (connector output), not both."
|
||||
)
|
||||
FUNCTION = "createReferences"
|
||||
RETURN_TYPES = ("RUNWAREVIDEOINPUTSREFERENCEIMAGES",)
|
||||
@@ -49,26 +54,39 @@ class videoInputsReferences:
|
||||
|
||||
for i in range(1, self.MAX_REFERENCES + 1):
|
||||
imageKey = f"Image{i}"
|
||||
imagesKey = f"Images{i}"
|
||||
tagKey = f"Tag{i}"
|
||||
typeKey = f"Type{i}"
|
||||
audioKey = f"Audio{i}"
|
||||
|
||||
image = kwargs.get(imageKey)
|
||||
images = kwargs.get(imagesKey)
|
||||
refTag = (kwargs.get(tagKey) or "").strip()
|
||||
refType = kwargs.get(typeKey, "")
|
||||
refAudio = (kwargs.get(audioKey) or "").strip()
|
||||
|
||||
if image is not None:
|
||||
reference = self._createReference(image, refTag, refType, refAudio)
|
||||
has_image = image is not None
|
||||
has_images = isinstance(images, list) and len(images) > 0
|
||||
if has_image and has_images:
|
||||
raise ValueError(
|
||||
f"Reference {i}: use either {imageKey} or {imagesKey}, not both."
|
||||
)
|
||||
|
||||
if has_image or has_images:
|
||||
reference = self._createReference(image, images, refTag, refType, refAudio)
|
||||
references.append(reference)
|
||||
|
||||
return (references,)
|
||||
|
||||
def _createReference(self, image, refTag: str, refType: str, refAudio: str):
|
||||
def _createReference(self, image, images, refTag: str, refType: str, refAudio: str):
|
||||
"""Create reference entry."""
|
||||
entry: Dict[str, Any] = {
|
||||
"image": rwUtils.convertTensor2IMG(image)
|
||||
}
|
||||
entry: Dict[str, Any] = {}
|
||||
if image is not None:
|
||||
entry["image"] = rwUtils.convertTensor2IMG(image)
|
||||
elif isinstance(images, list) and len(images) > 0:
|
||||
entry["images"] = images
|
||||
else:
|
||||
return entry
|
||||
|
||||
if refTag:
|
||||
entry["tag"] = refTag
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user