Fixed to using roles

This commit is contained in:
Sirshendu Ganguly
2026-05-28 19:59:46 +05:30
parent c84d195611
commit 58fd1a12d2
2 changed files with 19 additions and 21 deletions
+18 -20
View File
@@ -27,6 +27,10 @@ class imageInferenceInputs:
"tooltip": f"Optional tag describing {ordinal.capitalize()} Reference Image. Leave empty to omit.",
"default": "",
})
optionalInputs[f"Reference Role {i}"] = ("STRING", {
"tooltip": f"Optional role for {ordinal} reference image (e.g. person, garment). Leave empty to omit.",
"default": "",
})
optionalInputs[f"Reference Type {i}"] = ("STRING", {
"tooltip": f"Optional type for {ordinal} reference, e.g. 'sketch' for illustrative style models. Leave empty to omit.",
"default": "",
@@ -45,19 +49,12 @@ class imageInferenceInputs:
"tooltip": f"Specifies {ordinal.capitalize()} Super Resolution Reference Image for the inputs.",
})
optionalInputs["person"] = ("IMAGE", {
"tooltip": "Person image for inputs.person."
})
optionalInputs["garment"] = ("IMAGE", {
"tooltip": "Garment reference image for inputs.garment."
})
return {
"required": {},
"optional": optionalInputs
}
DESCRIPTION = "Configure custom inputs for Runware Image Inference, including image/mask, reference images (with optional type e.g. 'sketch' for illustrative style models, and strength 0-1 for sketch), super resolution references, and person/garment images."
DESCRIPTION = "Configure custom inputs for Runware Image Inference, including image/mask, reference images (with optional tag, role, type e.g. 'sketch' for illustrative style models, and strength 0-1 for sketch), and super resolution references."
FUNCTION = "createInputs"
RETURN_TYPES = ("RUNWAREIMAGEINFERENCEINPUTS",)
RETURN_NAMES = ("Inference Inputs",)
@@ -67,8 +64,6 @@ class imageInferenceInputs:
"""Create image inference inputs from provided parameters"""
image = kwargs.get("image", None)
mask = kwargs.get("mask", None)
person = kwargs.get("person", None)
garment = kwargs.get("garment", None)
inputs = {}
@@ -76,10 +71,6 @@ class imageInferenceInputs:
inputs["image"] = rwUtils.convertTensor2IMG(image)
if mask is not None:
inputs["mask"] = rwUtils.convertTensor2IMG(mask)
if person is not None:
inputs["person"] = rwUtils.convertTensor2IMG(person)
if garment is not None:
inputs["garment"] = rwUtils.convertTensor2IMG(garment)
references = self._collectReferences(kwargs)
if len(references) > 0:
@@ -98,34 +89,41 @@ class imageInferenceInputs:
for i in range(1, self.MAX_REFERENCE_IMAGES + 1):
image = kwargs.get(f"Reference Image {i}", None)
tag = kwargs.get(f"Reference Tag {i}", "")
role = kwargs.get(f"Reference Role {i}", "")
ref_type = kwargs.get(f"Reference Type {i}", "")
strength = kwargs.get(f"Reference Strength {i}", 0.0)
if image is not None:
reference_slots.append((image, tag, ref_type, strength))
reference_slots.append((image, tag, role, ref_type, strength))
if not reference_slots:
return []
has_tags = any(
isinstance(tag, str) and tag.strip() != ""
for _, tag, _, _ in reference_slots
for _, tag, _, _, _ in reference_slots
)
has_roles = any(
isinstance(role, str) and role.strip() != ""
for _, _, role, _, _ in reference_slots
)
has_type = any(
isinstance(rt, str) and rt.strip() != ""
for _, _, rt, _ in reference_slots
for _, _, _, rt, _ in reference_slots
)
if not has_tags and not has_type:
if not has_tags and not has_roles and not has_type:
return [
rwUtils.convertTensor2IMG(image)
for image, _, _, _ in reference_slots
for image, _, _, _, _ in reference_slots
]
references = []
for image, tag, ref_type, strength in reference_slots:
for image, tag, role, ref_type, strength in reference_slots:
entry = {"image": rwUtils.convertTensor2IMG(image)}
if isinstance(tag, str) and tag.strip() != "":
entry["tag"] = tag.strip()
if isinstance(role, str) and role.strip() != "":
entry["role"] = role.strip()
if isinstance(ref_type, str) and ref_type.strip() != "":
entry["type"] = ref_type.strip()
if ref_type.strip().lower() == "sketch":
File diff suppressed because one or more lines are too long