Add Support for Google Imagen Models

This commit is contained in:
Jack
2025-06-16 15:11:36 +03:00
parent 7d4cca13cf
commit b0f70578f2
3 changed files with 118 additions and 1 deletions
+3 -1
View File
@@ -8,6 +8,7 @@ from .modules.bridges import mainRoute
from .modules.controlNet import controlNet
from .modules.multiInference import multiInference
from .modules.runwareBFL import runwareKontext
from .modules.runwareImagen import runwareImagen
from .modules.teaCache import teaCache
from .modules.deepCache import deepCache
from .modules.loraSearch import loraSearch
@@ -25,7 +26,7 @@ from .modules.ipAdapterCombine import ipAdapterCombine
from .modules.vaeSearch import vaeSearch
from .modules.referenceImages import referenceImages
RUNWARE_COMFYUI_VERSION = "1.1.0 Beta"
RUNWARE_COMFYUI_VERSION = "1.2.0 Beta"
RESET_COLOR = "\033[0m"
BLUE_COLOR = "\033[94m"
@@ -44,6 +45,7 @@ NODE_CLASS_MAPPINGS = {
"Runware Image Upscaler": upscaler,
"Runware Model Search": modelSearch,
"Runware Kontext Inference": runwareKontext,
"Runware Imagen Inference": runwareImagen,
"Runware Multi Inference": multiInference,
"Runware TeaCache": teaCache,
"Runware DeepCache": deepCache,
+5
View File
@@ -49,6 +49,7 @@ const MODEL_LIST_TERMS = ["ModelList", "LoraList", "ControlNetList", "EmbeddingL
const RUNWARE_NODE_TYPES = {
IMAGEINFERENCE: "Runware Image Inference",
KONTEXTINFERENCE: "Runware Kontext Inference",
IMAGENINFERENCE: "Runware Imagen Inference",
OUTPAINT: "Runware Outpaint",
PHOTOMAKER: "Runware PhotoMaker V2",
MODELSEARCH: "Runware Model Search",
@@ -84,6 +85,10 @@ const RUNWARE_NODE_PROPS = {
bgColor: DEFAULT_BGCOLOR,
promptEnhancer: true,
},
[RUNWARE_NODE_TYPES.IMAGENINFERENCE]: {
bgColor: DEFAULT_BGCOLOR,
colorModeOnly: true,
},
[RUNWARE_NODE_TYPES.REFERENCEIMAGES]: {
bgColor: DEFAULT_BGCOLOR,
colorModeOnly: true,
+110
View File
@@ -0,0 +1,110 @@
from .utils import runwareUtils as rwUtils
class runwareImagen:
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"Model": ([
"google:1@1 (Imagen 3)",
"google:1@2 (Imagen 3 Fast)",
"google:2@1 (Imagen 4 Preview)",
"google:2@2 (Imagen 4 Ultra)",
], {
"tooltip": "Select The Google Imagen Model For Image Generation.",
"default": "google:1@1 (Imagen 3)",
}),
"positivePrompt": ("STRING", {
"multiline": True,
"placeholder": "Text instruction to guide the model on generating the image. It is usually a sentence or a paragraph that provides positive guidance for the task. This parameter is essential to shape the desired results.",
"tooltip": "Text instruction to guide the model on generating the image."
}),
"Aspect Ratio": ([
"1:1 (Square)",
"9:16 (Vertical)",
"16:9 (Wide)",
"3:4 (Portrait)",
"4:3 (Landscape)"
], {
"default": "1:1 (Square)",
"tooltip": "Adjust the dimensions of the generated image. The width and height will be automatically adjusted based on the selected aspect ratio.",
}),
"seed": ("INT", {
"tooltip": "A value used to randomize the image generation. If you want to make images reproducible (generate the same image multiple times), you can use the same seed value.",
"default": rwUtils.genRandSeed(),
"min": 1,
"max": 9223372036854776000,
}),
"Multi Inference Mode": ("BOOLEAN", {
"tooltip": "If Enabled the node will skip the image generation process and will only return the Runware Task Object to be used in the Multi Inference Node.",
"default": False,
"label_on": "Enabled",
"label_off": "Disabled",
}),
"batchSize": ("INT", {
"tooltip": "The number of images to generate in a single request.",
"default": 1,
"min": 1,
"max": 10,
}),
}
}
@classmethod
def VALIDATE_INPUTS(cls, positivePrompt):
if (positivePrompt is not None and (positivePrompt == "" or len(positivePrompt) < 3 or len(positivePrompt) > 2000)):
raise Exception(
"Positive Prompt Must Be Between 3 And 2000 characters!")
return True
DESCRIPTION = "Generate Images Using Google Imagen Models."
FUNCTION = "imagenInference"
RETURN_TYPES = ("IMAGE", "RUNWARETASK")
RETURN_NAMES = ("IMAGE", "RW-Task")
CATEGORY = "Runware"
def imagenInference(self, **kwargs):
runwareModel = kwargs.get("Model")
runwareModel = runwareModel.split(" ")[0]
positivePrompt = kwargs.get("positivePrompt")
aspectRatio = kwargs.get("Aspect Ratio")
multiInferenceMode = kwargs.get("Multi Inference Mode", False)
seed = kwargs.get("seed")
batchSize = kwargs.get("batchSize", 1)
aspectRatioMap = {
"1:1": (1024, 1024),
"9:16": (768, 1408),
"16:9": (1408, 768),
"3:4": (896, 1280),
"4:3": (1280, 896),
}
secAspectRatio = aspectRatio.split(" ")[0]
width, height = aspectRatioMap.get(secAspectRatio, (1024, 1024))
genConfig = [
{
"taskType": "imageInference",
"taskUUID": rwUtils.genRandUUID(),
"positivePrompt": positivePrompt,
"height": height,
"width": width,
"model": runwareModel,
"seed": seed,
"outputType": "base64Data",
"outputFormat": rwUtils.OUTPUT_FORMAT,
"outputQuality": rwUtils.OUTPUT_QUALITY,
"numberResults": batchSize
}
]
# For Debugging Purposes Only
print(f"[Debugging] Task UUID: {genConfig[0]['taskUUID']}")
if (multiInferenceMode):
return (None, genConfig)
else:
genResult = rwUtils.inferenecRequest(genConfig)
images = rwUtils.convertImageB64List(genResult)
return (images, None)