68 lines
2.2 KiB
Python
68 lines
2.2 KiB
Python
from .utils import runwareUtils as rwUtils
|
|
from typing import List, Dict, Any
|
|
|
|
|
|
class videoInputsReferences:
|
|
"""Video Inputs References node for configuring reference images with types"""
|
|
|
|
MAX_REFERENCES = 10
|
|
|
|
@classmethod
|
|
def INPUT_TYPES(cls):
|
|
optionalInputs = {}
|
|
|
|
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"Type{i}"] = ("STRING", {
|
|
"tooltip": f"Type for the {ordinal} reference (e.g., 'asset'). Leave empty to omit.",
|
|
"default": "",
|
|
})
|
|
|
|
return {
|
|
"required": {},
|
|
"optional": optionalInputs
|
|
}
|
|
|
|
DESCRIPTION = "Configure multiple reference images with optional types for video inference inputs."
|
|
FUNCTION = "createReferences"
|
|
RETURN_TYPES = ("RUNWAREVIDEOINPUTSREFERENCEIMAGES",)
|
|
RETURN_NAMES = ("Video Inputs Reference Images",)
|
|
CATEGORY = "Runware"
|
|
|
|
def createReferences(self, **kwargs) -> tuple[List[Dict[str, Any]]]:
|
|
"""Create list of reference objects from provided parameters"""
|
|
references = []
|
|
|
|
for i in range(1, self.MAX_REFERENCES + 1):
|
|
imageKey = f"Image{i}"
|
|
typeKey = f"Type{i}"
|
|
|
|
image = kwargs.get(imageKey)
|
|
refType = kwargs.get(typeKey, "")
|
|
|
|
if image is not None:
|
|
reference = self._createReference(image, refType)
|
|
references.append(reference)
|
|
|
|
return (references,)
|
|
|
|
def _createReference(self, image, refType):
|
|
"""Create reference entry (API expects direct strings)"""
|
|
imageUrl = rwUtils.convertTensor2IMG(image)
|
|
# API expects referenceImages to be a list of strings (UUID/URL/data URI)
|
|
# so we return the converted string directly.
|
|
return imageUrl
|
|
|
|
|
|
# Node class mappings
|
|
NODE_CLASS_MAPPINGS = {
|
|
"RunwareVideoInputsReferences": videoInputsReferences,
|
|
}
|
|
|
|
NODE_DISPLAY_NAME_MAPPINGS = {
|
|
"RunwareVideoInputsReferences": "Runware Video Inference Inputs Reference Images",
|
|
}
|