Increase reference images limit to 14 and prompt limit to 10000 for image inference
This commit is contained in:
@@ -206,11 +206,11 @@ class txt2img:
|
||||
negativePrompt = kwargs.get("negativePrompt", "")
|
||||
|
||||
# Only validate positivePrompt length if it's provided
|
||||
if positivePrompt and len(positivePrompt) > 2000:
|
||||
return "Positive Prompt is too long. Maximum length is 2000 characters."
|
||||
if positivePrompt and len(positivePrompt) > 10000:
|
||||
return "Positive Prompt is too long. Maximum length is 10000 characters."
|
||||
|
||||
if negativePrompt and len(negativePrompt) > 2000:
|
||||
return "Negative Prompt is too long. Maximum length is 2000 characters."
|
||||
if negativePrompt and len(negativePrompt) > 10000:
|
||||
return "Negative Prompt is too long. Maximum length is 10000 characters."
|
||||
|
||||
return True
|
||||
|
||||
|
||||
@@ -4,43 +4,29 @@ from .utils import runwareUtils as rwUtils
|
||||
class imageInferenceInputs:
|
||||
"""Image Inference Inputs node for configuring image generation inputs"""
|
||||
|
||||
MAX_REFERENCE_IMAGES = 14
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
optionalInputs = {
|
||||
"image": ("IMAGE", {
|
||||
"tooltip": "Specifies an image input for the inference process."
|
||||
}),
|
||||
}
|
||||
|
||||
for i in range(1, cls.MAX_REFERENCE_IMAGES + 1):
|
||||
ordinal = rwUtils.getOrdinal(i)
|
||||
optionalInputs[f"Reference Image {i}"] = ("IMAGE", {
|
||||
"tooltip": f"Specifies {ordinal.capitalize()} Reference Image for the inputs. These reference images help guide the image generation process."
|
||||
})
|
||||
optionalInputs[f"Reference Tag {i}"] = ("STRING", {
|
||||
"tooltip": f"Optional tag describing {ordinal.capitalize()} Reference Image. Leave empty to omit.",
|
||||
"default": "",
|
||||
})
|
||||
|
||||
return {
|
||||
"required": {},
|
||||
"optional": {
|
||||
"image": ("IMAGE", {
|
||||
"tooltip": "Specifies an image input for the inference process."
|
||||
}),
|
||||
"Reference Image 1": ("IMAGE", {
|
||||
"tooltip": "Specifies Reference Image 1 for the inputs. These reference images help guide the image generation process."
|
||||
}),
|
||||
"Reference Tag 1": ("STRING", {
|
||||
"tooltip": "Optional tag describing Reference Image 1. Leave empty to omit.",
|
||||
"default": "",
|
||||
}),
|
||||
"Reference Image 2": ("IMAGE", {
|
||||
"tooltip": "Specifies Reference Image 2 for the inputs. These reference images help guide the image generation process."
|
||||
}),
|
||||
"Reference Tag 2": ("STRING", {
|
||||
"tooltip": "Optional tag describing Reference Image 2. Leave empty to omit.",
|
||||
"default": "",
|
||||
}),
|
||||
"Reference Image 3": ("IMAGE", {
|
||||
"tooltip": "Specifies Reference Image 3 for the inputs. These reference images help guide the image generation process."
|
||||
}),
|
||||
"Reference Tag 3": ("STRING", {
|
||||
"tooltip": "Optional tag describing Reference Image 3. Leave empty to omit.",
|
||||
"default": "",
|
||||
}),
|
||||
"Reference Image 4": ("IMAGE", {
|
||||
"tooltip": "Specifies Reference Image 4 for the inputs. These reference images help guide the image generation process."
|
||||
}),
|
||||
"Reference Tag 4": ("STRING", {
|
||||
"tooltip": "Optional tag describing Reference Image 4. Leave empty to omit.",
|
||||
"default": "",
|
||||
}),
|
||||
}
|
||||
"optional": optionalInputs
|
||||
}
|
||||
|
||||
DESCRIPTION = "Configure custom inputs for Runware Image Inference, including reference images that can be passed to the inference node."
|
||||
@@ -52,36 +38,32 @@ class imageInferenceInputs:
|
||||
def createInputs(self, **kwargs):
|
||||
"""Create image inference inputs from provided parameters"""
|
||||
image = kwargs.get("image", None)
|
||||
refImage1 = kwargs.get("Reference Image 1", None)
|
||||
refTag1 = kwargs.get("Reference Tag 1", "")
|
||||
refImage2 = kwargs.get("Reference Image 2", None)
|
||||
refTag2 = kwargs.get("Reference Tag 2", "")
|
||||
refImage3 = kwargs.get("Reference Image 3", None)
|
||||
refTag3 = kwargs.get("Reference Tag 3", "")
|
||||
refImage4 = kwargs.get("Reference Image 4", None)
|
||||
refTag4 = kwargs.get("Reference Tag 4", "")
|
||||
|
||||
inputs = {}
|
||||
|
||||
if image is not None:
|
||||
inputs["image"] = rwUtils.convertTensor2IMG(image)
|
||||
|
||||
references = self._collectReferences(
|
||||
refImage1, refTag1,
|
||||
refImage2, refTag2,
|
||||
refImage3, refTag3,
|
||||
refImage4, refTag4,
|
||||
)
|
||||
references = self._collectReferences(kwargs)
|
||||
if len(references) > 0:
|
||||
inputs["referenceImages"] = references
|
||||
|
||||
return (inputs,)
|
||||
|
||||
def _collectReferences(self, *referenceArgs):
|
||||
def _collectReferences(self, kwargs):
|
||||
"""Collect and convert reference images to list"""
|
||||
# Build list of (image, tag) pairs from the flat arguments
|
||||
referencePairs = list(zip(referenceArgs[0::2], referenceArgs[1::2]))
|
||||
|
||||
referencePairs = []
|
||||
|
||||
# Collect all reference image and tag pairs
|
||||
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}", "")
|
||||
if image is not None:
|
||||
referencePairs.append((image, tag))
|
||||
|
||||
if not referencePairs:
|
||||
return []
|
||||
|
||||
# Determine if any tag is provided
|
||||
hasTags = any(
|
||||
isinstance(tag, str) and tag.strip() != ""
|
||||
@@ -93,14 +75,10 @@ class imageInferenceInputs:
|
||||
return [
|
||||
rwUtils.convertTensor2IMG(image)
|
||||
for image, _ in referencePairs
|
||||
if image is not None
|
||||
]
|
||||
|
||||
references = []
|
||||
for image, tag in referencePairs:
|
||||
if image is None:
|
||||
continue
|
||||
|
||||
entry = {"image": rwUtils.convertTensor2IMG(image)}
|
||||
if isinstance(tag, str) and tag.strip() != "":
|
||||
entry["tag"] = tag.strip()
|
||||
|
||||
+26
-24
@@ -4,25 +4,26 @@ from .utils import runwareUtils as rwUtils
|
||||
class referenceImages:
|
||||
"""Reference Images node for providing reference images for identity consistency"""
|
||||
|
||||
MAX_IMAGES = 14
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
requiredInputs = {
|
||||
"Image 1": ("IMAGE", {
|
||||
"tooltip": "Specifies Reference Image 1 that will be used as reference for the subject. These reference images help the AI to maintain identity consistency during the generation process."
|
||||
}),
|
||||
}
|
||||
|
||||
optionalInputs = {}
|
||||
for i in range(2, cls.MAX_IMAGES + 1):
|
||||
ordinal = rwUtils.getOrdinal(i)
|
||||
optionalInputs[f"Image {i}"] = ("IMAGE", {
|
||||
"tooltip": f"Specifies {ordinal.capitalize()} Reference Image that will be used as reference for the subject. These reference images help the AI to maintain identity consistency during the generation process."
|
||||
})
|
||||
|
||||
return {
|
||||
"required": {
|
||||
"Image 1": ("IMAGE", {
|
||||
"tooltip": "Specifies Reference Image 1 that will be used as reference for the subject. These reference images help the AI to maintain identity consistency during the generation process."
|
||||
}),
|
||||
},
|
||||
"optional": {
|
||||
"Image 2": ("IMAGE", {
|
||||
"tooltip": "Specifies Reference Image 2 that will be used as reference for the subject. These reference images help the AI to maintain identity consistency during the generation process."
|
||||
}),
|
||||
"Image 3": ("IMAGE", {
|
||||
"tooltip": "Specifies Reference Image 3 that will be used as reference for the subject. These reference images help the AI to maintain identity consistency during the generation process."
|
||||
}),
|
||||
"Image 4": ("IMAGE", {
|
||||
"tooltip": "Specifies Reference Image 4 that will be used as reference for the subject. These reference images help the AI to maintain identity consistency during the generation process."
|
||||
}),
|
||||
}
|
||||
"required": requiredInputs,
|
||||
"optional": optionalInputs
|
||||
}
|
||||
|
||||
DESCRIPTION = "Used With Runware Tasks To Provide Reference Images For The Subject. These Reference Images Help The AI To Maintain Identity Consistency During The Generation Process."
|
||||
@@ -33,15 +34,16 @@ class referenceImages:
|
||||
|
||||
def referenceImages(self, **kwargs):
|
||||
"""Collect and convert reference images to list"""
|
||||
image1 = kwargs.get("Image 1")
|
||||
image2 = kwargs.get("Image 2", None)
|
||||
image3 = kwargs.get("Image 3", None)
|
||||
image4 = kwargs.get("Image 4", None)
|
||||
|
||||
imageList = [rwUtils.convertTensor2IMG(image1)]
|
||||
imageList = []
|
||||
|
||||
optionalImages = [image2, image3, image4]
|
||||
for image in optionalImages:
|
||||
# Always include Image 1 (required)
|
||||
image1 = kwargs.get("Image 1")
|
||||
if image1 is not None:
|
||||
imageList.append(rwUtils.convertTensor2IMG(image1))
|
||||
|
||||
# Add optional images 2 through MAX_IMAGES
|
||||
for i in range(2, self.MAX_IMAGES + 1):
|
||||
image = kwargs.get(f"Image {i}", None)
|
||||
if image is not None:
|
||||
imageList.append(rwUtils.convertTensor2IMG(image))
|
||||
|
||||
|
||||
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