Added backward compatibility
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user