mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-07-12 01:17:46 +08:00
[Partner Nodes] chore(Ideogram): remove IdeogramV1 and IdeogramV2 nodes (#14712)
Some checks are pending
Detect Unreviewed Merge / detect (push) Waiting to run
Python Linting / Run Ruff (push) Waiting to run
Python Linting / Run Pylint (push) Waiting to run
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.10, [self-hosted Linux], stable) (push) Waiting to run
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.11, [self-hosted Linux], stable) (push) Waiting to run
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.12, [self-hosted Linux], stable) (push) Waiting to run
Full Comfy CI Workflow Runs / test-unix-nightly (12.1, , linux, 3.11, [self-hosted Linux], nightly) (push) Waiting to run
Execution Tests / test (ubuntu-latest) (push) Waiting to run
Execution Tests / test (macos-latest) (push) Waiting to run
Execution Tests / test (windows-latest) (push) Waiting to run
Test server launches without errors / test (push) Waiting to run
Unit Tests / test (macos-latest) (push) Waiting to run
Unit Tests / test (ubuntu-latest) (push) Waiting to run
Unit Tests / test (windows-2022) (push) Waiting to run
Some checks are pending
Detect Unreviewed Merge / detect (push) Waiting to run
Python Linting / Run Ruff (push) Waiting to run
Python Linting / Run Pylint (push) Waiting to run
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.10, [self-hosted Linux], stable) (push) Waiting to run
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.11, [self-hosted Linux], stable) (push) Waiting to run
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.12, [self-hosted Linux], stable) (push) Waiting to run
Full Comfy CI Workflow Runs / test-unix-nightly (12.1, , linux, 3.11, [self-hosted Linux], nightly) (push) Waiting to run
Execution Tests / test (ubuntu-latest) (push) Waiting to run
Execution Tests / test (macos-latest) (push) Waiting to run
Execution Tests / test (windows-latest) (push) Waiting to run
Test server launches without errors / test (push) Waiting to run
Unit Tests / test (macos-latest) (push) Waiting to run
Unit Tests / test (ubuntu-latest) (push) Waiting to run
Unit Tests / test (windows-2022) (push) Waiting to run
Signed-off-by: bigcat88 <bigcat88@icloud.com> Co-authored-by: Alexis Rolland <alexisrolland@hotmail.com>
This commit is contained in:
parent
92594ca84c
commit
694815f498
@ -33,53 +33,6 @@ class IdeogramColorPalette(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class ImageRequest(BaseModel):
|
|
||||||
aspect_ratio: Optional[str] = Field(
|
|
||||||
None,
|
|
||||||
description="Optional. The aspect ratio (e.g., 'ASPECT_16_9', 'ASPECT_1_1'). Cannot be used with resolution. Defaults to 'ASPECT_1_1' if unspecified.",
|
|
||||||
)
|
|
||||||
color_palette: Optional[Dict[str, Any]] = Field(
|
|
||||||
None, description='Optional. Color palette object. Only for V_2, V_2_TURBO.'
|
|
||||||
)
|
|
||||||
magic_prompt_option: Optional[str] = Field(
|
|
||||||
None, description="Optional. MagicPrompt usage ('AUTO', 'ON', 'OFF')."
|
|
||||||
)
|
|
||||||
model: str = Field(..., description="The model used (e.g., 'V_2', 'V_2A_TURBO')")
|
|
||||||
negative_prompt: Optional[str] = Field(
|
|
||||||
None,
|
|
||||||
description='Optional. Description of what to exclude. Only for V_1, V_1_TURBO, V_2, V_2_TURBO.',
|
|
||||||
)
|
|
||||||
num_images: Optional[int] = Field(
|
|
||||||
1,
|
|
||||||
description='Optional. Number of images to generate (1-8). Defaults to 1.',
|
|
||||||
ge=1,
|
|
||||||
le=8,
|
|
||||||
)
|
|
||||||
prompt: str = Field(
|
|
||||||
..., description='Required. The prompt to use to generate the image.'
|
|
||||||
)
|
|
||||||
resolution: Optional[str] = Field(
|
|
||||||
None,
|
|
||||||
description="Optional. Resolution (e.g., 'RESOLUTION_1024_1024'). Only for model V_2. Cannot be used with aspect_ratio.",
|
|
||||||
)
|
|
||||||
seed: Optional[int] = Field(
|
|
||||||
None,
|
|
||||||
description='Optional. A number between 0 and 2147483647.',
|
|
||||||
ge=0,
|
|
||||||
le=2147483647,
|
|
||||||
)
|
|
||||||
style_type: Optional[str] = Field(
|
|
||||||
None,
|
|
||||||
description="Optional. Style type ('AUTO', 'GENERAL', 'REALISTIC', 'DESIGN', 'RENDER_3D', 'ANIME'). Only for models V_2 and above.",
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class IdeogramGenerateRequest(BaseModel):
|
|
||||||
image_request: ImageRequest = Field(
|
|
||||||
..., description='The image generation request parameters.'
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class Datum(BaseModel):
|
class Datum(BaseModel):
|
||||||
is_image_safe: Optional[bool] = Field(
|
is_image_safe: Optional[bool] = Field(
|
||||||
None, description='Indicates whether the image is considered safe.'
|
None, description='Indicates whether the image is considered safe.'
|
||||||
@ -113,20 +66,6 @@ class StyleCode(RootModel[str]):
|
|||||||
root: str = Field(..., pattern='^[0-9A-Fa-f]{8}$')
|
root: str = Field(..., pattern='^[0-9A-Fa-f]{8}$')
|
||||||
|
|
||||||
|
|
||||||
class Datum1(BaseModel):
|
|
||||||
is_image_safe: Optional[bool] = None
|
|
||||||
prompt: Optional[str] = None
|
|
||||||
resolution: Optional[str] = None
|
|
||||||
seed: Optional[int] = None
|
|
||||||
style_type: Optional[str] = None
|
|
||||||
url: Optional[str] = None
|
|
||||||
|
|
||||||
|
|
||||||
class IdeogramV3IdeogramResponse(BaseModel):
|
|
||||||
created: Optional[datetime] = None
|
|
||||||
data: Optional[List[Datum1]] = None
|
|
||||||
|
|
||||||
|
|
||||||
class RenderingSpeed1(str, Enum):
|
class RenderingSpeed1(str, Enum):
|
||||||
TURBO = 'TURBO'
|
TURBO = 'TURBO'
|
||||||
DEFAULT = 'DEFAULT'
|
DEFAULT = 'DEFAULT'
|
||||||
|
|||||||
@ -5,9 +5,7 @@ from PIL import Image
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
import torch
|
import torch
|
||||||
from comfy_api_nodes.apis.ideogram import (
|
from comfy_api_nodes.apis.ideogram import (
|
||||||
IdeogramGenerateRequest,
|
|
||||||
IdeogramGenerateResponse,
|
IdeogramGenerateResponse,
|
||||||
ImageRequest,
|
|
||||||
IdeogramV3Request,
|
IdeogramV3Request,
|
||||||
IdeogramV3EditRequest,
|
IdeogramV3EditRequest,
|
||||||
IdeogramV4Request,
|
IdeogramV4Request,
|
||||||
@ -21,101 +19,6 @@ from comfy_api_nodes.util import (
|
|||||||
validate_string,
|
validate_string,
|
||||||
)
|
)
|
||||||
|
|
||||||
V1_V1_RES_MAP = {
|
|
||||||
"Auto":"AUTO",
|
|
||||||
"512 x 1536":"RESOLUTION_512_1536",
|
|
||||||
"576 x 1408":"RESOLUTION_576_1408",
|
|
||||||
"576 x 1472":"RESOLUTION_576_1472",
|
|
||||||
"576 x 1536":"RESOLUTION_576_1536",
|
|
||||||
"640 x 1024":"RESOLUTION_640_1024",
|
|
||||||
"640 x 1344":"RESOLUTION_640_1344",
|
|
||||||
"640 x 1408":"RESOLUTION_640_1408",
|
|
||||||
"640 x 1472":"RESOLUTION_640_1472",
|
|
||||||
"640 x 1536":"RESOLUTION_640_1536",
|
|
||||||
"704 x 1152":"RESOLUTION_704_1152",
|
|
||||||
"704 x 1216":"RESOLUTION_704_1216",
|
|
||||||
"704 x 1280":"RESOLUTION_704_1280",
|
|
||||||
"704 x 1344":"RESOLUTION_704_1344",
|
|
||||||
"704 x 1408":"RESOLUTION_704_1408",
|
|
||||||
"704 x 1472":"RESOLUTION_704_1472",
|
|
||||||
"720 x 1280":"RESOLUTION_720_1280",
|
|
||||||
"736 x 1312":"RESOLUTION_736_1312",
|
|
||||||
"768 x 1024":"RESOLUTION_768_1024",
|
|
||||||
"768 x 1088":"RESOLUTION_768_1088",
|
|
||||||
"768 x 1152":"RESOLUTION_768_1152",
|
|
||||||
"768 x 1216":"RESOLUTION_768_1216",
|
|
||||||
"768 x 1232":"RESOLUTION_768_1232",
|
|
||||||
"768 x 1280":"RESOLUTION_768_1280",
|
|
||||||
"768 x 1344":"RESOLUTION_768_1344",
|
|
||||||
"832 x 960":"RESOLUTION_832_960",
|
|
||||||
"832 x 1024":"RESOLUTION_832_1024",
|
|
||||||
"832 x 1088":"RESOLUTION_832_1088",
|
|
||||||
"832 x 1152":"RESOLUTION_832_1152",
|
|
||||||
"832 x 1216":"RESOLUTION_832_1216",
|
|
||||||
"832 x 1248":"RESOLUTION_832_1248",
|
|
||||||
"864 x 1152":"RESOLUTION_864_1152",
|
|
||||||
"896 x 960":"RESOLUTION_896_960",
|
|
||||||
"896 x 1024":"RESOLUTION_896_1024",
|
|
||||||
"896 x 1088":"RESOLUTION_896_1088",
|
|
||||||
"896 x 1120":"RESOLUTION_896_1120",
|
|
||||||
"896 x 1152":"RESOLUTION_896_1152",
|
|
||||||
"960 x 832":"RESOLUTION_960_832",
|
|
||||||
"960 x 896":"RESOLUTION_960_896",
|
|
||||||
"960 x 1024":"RESOLUTION_960_1024",
|
|
||||||
"960 x 1088":"RESOLUTION_960_1088",
|
|
||||||
"1024 x 640":"RESOLUTION_1024_640",
|
|
||||||
"1024 x 768":"RESOLUTION_1024_768",
|
|
||||||
"1024 x 832":"RESOLUTION_1024_832",
|
|
||||||
"1024 x 896":"RESOLUTION_1024_896",
|
|
||||||
"1024 x 960":"RESOLUTION_1024_960",
|
|
||||||
"1024 x 1024":"RESOLUTION_1024_1024",
|
|
||||||
"1088 x 768":"RESOLUTION_1088_768",
|
|
||||||
"1088 x 832":"RESOLUTION_1088_832",
|
|
||||||
"1088 x 896":"RESOLUTION_1088_896",
|
|
||||||
"1088 x 960":"RESOLUTION_1088_960",
|
|
||||||
"1120 x 896":"RESOLUTION_1120_896",
|
|
||||||
"1152 x 704":"RESOLUTION_1152_704",
|
|
||||||
"1152 x 768":"RESOLUTION_1152_768",
|
|
||||||
"1152 x 832":"RESOLUTION_1152_832",
|
|
||||||
"1152 x 864":"RESOLUTION_1152_864",
|
|
||||||
"1152 x 896":"RESOLUTION_1152_896",
|
|
||||||
"1216 x 704":"RESOLUTION_1216_704",
|
|
||||||
"1216 x 768":"RESOLUTION_1216_768",
|
|
||||||
"1216 x 832":"RESOLUTION_1216_832",
|
|
||||||
"1232 x 768":"RESOLUTION_1232_768",
|
|
||||||
"1248 x 832":"RESOLUTION_1248_832",
|
|
||||||
"1280 x 704":"RESOLUTION_1280_704",
|
|
||||||
"1280 x 720":"RESOLUTION_1280_720",
|
|
||||||
"1280 x 768":"RESOLUTION_1280_768",
|
|
||||||
"1280 x 800":"RESOLUTION_1280_800",
|
|
||||||
"1312 x 736":"RESOLUTION_1312_736",
|
|
||||||
"1344 x 640":"RESOLUTION_1344_640",
|
|
||||||
"1344 x 704":"RESOLUTION_1344_704",
|
|
||||||
"1344 x 768":"RESOLUTION_1344_768",
|
|
||||||
"1408 x 576":"RESOLUTION_1408_576",
|
|
||||||
"1408 x 640":"RESOLUTION_1408_640",
|
|
||||||
"1408 x 704":"RESOLUTION_1408_704",
|
|
||||||
"1472 x 576":"RESOLUTION_1472_576",
|
|
||||||
"1472 x 640":"RESOLUTION_1472_640",
|
|
||||||
"1472 x 704":"RESOLUTION_1472_704",
|
|
||||||
"1536 x 512":"RESOLUTION_1536_512",
|
|
||||||
"1536 x 576":"RESOLUTION_1536_576",
|
|
||||||
"1536 x 640":"RESOLUTION_1536_640",
|
|
||||||
}
|
|
||||||
|
|
||||||
V1_V2_RATIO_MAP = {
|
|
||||||
"1:1":"ASPECT_1_1",
|
|
||||||
"4:3":"ASPECT_4_3",
|
|
||||||
"3:4":"ASPECT_3_4",
|
|
||||||
"16:9":"ASPECT_16_9",
|
|
||||||
"9:16":"ASPECT_9_16",
|
|
||||||
"2:1":"ASPECT_2_1",
|
|
||||||
"1:2":"ASPECT_1_2",
|
|
||||||
"3:2":"ASPECT_3_2",
|
|
||||||
"2:3":"ASPECT_2_3",
|
|
||||||
"4:5":"ASPECT_4_5",
|
|
||||||
"5:4":"ASPECT_5_4",
|
|
||||||
}
|
|
||||||
|
|
||||||
V3_RATIO_MAP = {
|
V3_RATIO_MAP = {
|
||||||
"1:3":"1x3",
|
"1:3":"1x3",
|
||||||
@ -229,298 +132,6 @@ async def download_and_process_images(image_urls):
|
|||||||
return stacked_tensors
|
return stacked_tensors
|
||||||
|
|
||||||
|
|
||||||
class IdeogramV1(IO.ComfyNode):
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def define_schema(cls):
|
|
||||||
return IO.Schema(
|
|
||||||
node_id="IdeogramV1",
|
|
||||||
display_name="Ideogram V1",
|
|
||||||
category="partner/image/Ideogram",
|
|
||||||
description="Generates images using the Ideogram V1 model.",
|
|
||||||
inputs=[
|
|
||||||
IO.String.Input(
|
|
||||||
"prompt",
|
|
||||||
multiline=True,
|
|
||||||
default="",
|
|
||||||
tooltip="Prompt for the image generation",
|
|
||||||
),
|
|
||||||
IO.Boolean.Input(
|
|
||||||
"turbo",
|
|
||||||
default=False,
|
|
||||||
tooltip="Whether to use turbo mode (faster generation, potentially lower quality)",
|
|
||||||
),
|
|
||||||
IO.Combo.Input(
|
|
||||||
"aspect_ratio",
|
|
||||||
options=list(V1_V2_RATIO_MAP.keys()),
|
|
||||||
default="1:1",
|
|
||||||
tooltip="The aspect ratio for image generation.",
|
|
||||||
optional=True,
|
|
||||||
),
|
|
||||||
IO.Combo.Input(
|
|
||||||
"magic_prompt_option",
|
|
||||||
options=["AUTO", "ON", "OFF"],
|
|
||||||
default="AUTO",
|
|
||||||
tooltip="Determine if MagicPrompt should be used in generation",
|
|
||||||
optional=True,
|
|
||||||
advanced=True,
|
|
||||||
),
|
|
||||||
IO.Int.Input(
|
|
||||||
"seed",
|
|
||||||
default=0,
|
|
||||||
min=0,
|
|
||||||
max=2147483647,
|
|
||||||
step=1,
|
|
||||||
control_after_generate=True,
|
|
||||||
display_mode=IO.NumberDisplay.number,
|
|
||||||
optional=True,
|
|
||||||
),
|
|
||||||
IO.String.Input(
|
|
||||||
"negative_prompt",
|
|
||||||
multiline=True,
|
|
||||||
default="",
|
|
||||||
tooltip="Description of what to exclude from the image",
|
|
||||||
optional=True,
|
|
||||||
),
|
|
||||||
IO.Int.Input(
|
|
||||||
"num_images",
|
|
||||||
default=1,
|
|
||||||
min=1,
|
|
||||||
max=8,
|
|
||||||
step=1,
|
|
||||||
display_mode=IO.NumberDisplay.number,
|
|
||||||
optional=True,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
outputs=[
|
|
||||||
IO.Image.Output(),
|
|
||||||
],
|
|
||||||
hidden=[
|
|
||||||
IO.Hidden.auth_token_comfy_org,
|
|
||||||
IO.Hidden.api_key_comfy_org,
|
|
||||||
IO.Hidden.unique_id,
|
|
||||||
],
|
|
||||||
is_api_node=True,
|
|
||||||
price_badge=IO.PriceBadge(
|
|
||||||
depends_on=IO.PriceBadgeDepends(widgets=["num_images", "turbo"]),
|
|
||||||
expr="""
|
|
||||||
(
|
|
||||||
$n := widgets.num_images;
|
|
||||||
$base := (widgets.turbo = true) ? 0.0286 : 0.0858;
|
|
||||||
{"type":"usd","usd": $round($base * $n, 2)}
|
|
||||||
)
|
|
||||||
""",
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
async def execute(
|
|
||||||
cls,
|
|
||||||
prompt,
|
|
||||||
turbo=False,
|
|
||||||
aspect_ratio="1:1",
|
|
||||||
magic_prompt_option="AUTO",
|
|
||||||
seed=0,
|
|
||||||
negative_prompt="",
|
|
||||||
num_images=1,
|
|
||||||
):
|
|
||||||
# Determine the model based on turbo setting
|
|
||||||
aspect_ratio = V1_V2_RATIO_MAP.get(aspect_ratio, None)
|
|
||||||
model = "V_1_TURBO" if turbo else "V_1"
|
|
||||||
|
|
||||||
response = await sync_op(
|
|
||||||
cls,
|
|
||||||
ApiEndpoint(path="/proxy/ideogram/generate", method="POST"),
|
|
||||||
response_model=IdeogramGenerateResponse,
|
|
||||||
data=IdeogramGenerateRequest(
|
|
||||||
image_request=ImageRequest(
|
|
||||||
prompt=prompt,
|
|
||||||
model=model,
|
|
||||||
num_images=num_images,
|
|
||||||
seed=seed,
|
|
||||||
aspect_ratio=aspect_ratio if aspect_ratio != "ASPECT_1_1" else None,
|
|
||||||
magic_prompt_option=(magic_prompt_option if magic_prompt_option != "AUTO" else None),
|
|
||||||
negative_prompt=negative_prompt if negative_prompt else None,
|
|
||||||
)
|
|
||||||
),
|
|
||||||
max_retries=1,
|
|
||||||
)
|
|
||||||
|
|
||||||
if not response.data or len(response.data) == 0:
|
|
||||||
raise Exception("No images were generated in the response")
|
|
||||||
|
|
||||||
image_urls = [image_data.url for image_data in response.data if image_data.url]
|
|
||||||
if not image_urls:
|
|
||||||
raise Exception("No image URLs were generated in the response")
|
|
||||||
return IO.NodeOutput(await download_and_process_images(image_urls))
|
|
||||||
|
|
||||||
|
|
||||||
class IdeogramV2(IO.ComfyNode):
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def define_schema(cls):
|
|
||||||
return IO.Schema(
|
|
||||||
node_id="IdeogramV2",
|
|
||||||
display_name="Ideogram V2",
|
|
||||||
category="partner/image/Ideogram",
|
|
||||||
description="Generates images using the Ideogram V2 model.",
|
|
||||||
inputs=[
|
|
||||||
IO.String.Input(
|
|
||||||
"prompt",
|
|
||||||
multiline=True,
|
|
||||||
default="",
|
|
||||||
tooltip="Prompt for the image generation",
|
|
||||||
),
|
|
||||||
IO.Boolean.Input(
|
|
||||||
"turbo",
|
|
||||||
default=False,
|
|
||||||
tooltip="Whether to use turbo mode (faster generation, potentially lower quality)",
|
|
||||||
),
|
|
||||||
IO.Combo.Input(
|
|
||||||
"aspect_ratio",
|
|
||||||
options=list(V1_V2_RATIO_MAP.keys()),
|
|
||||||
default="1:1",
|
|
||||||
tooltip="The aspect ratio for image generation. Ignored if resolution is not set to AUTO.",
|
|
||||||
optional=True,
|
|
||||||
),
|
|
||||||
IO.Combo.Input(
|
|
||||||
"resolution",
|
|
||||||
options=list(V1_V1_RES_MAP.keys()),
|
|
||||||
default="Auto",
|
|
||||||
tooltip="The resolution for image generation. "
|
|
||||||
"If not set to AUTO, this overrides the aspect_ratio setting.",
|
|
||||||
optional=True,
|
|
||||||
),
|
|
||||||
IO.Combo.Input(
|
|
||||||
"magic_prompt_option",
|
|
||||||
options=["AUTO", "ON", "OFF"],
|
|
||||||
default="AUTO",
|
|
||||||
tooltip="Determine if MagicPrompt should be used in generation",
|
|
||||||
optional=True,
|
|
||||||
advanced=True,
|
|
||||||
),
|
|
||||||
IO.Int.Input(
|
|
||||||
"seed",
|
|
||||||
default=0,
|
|
||||||
min=0,
|
|
||||||
max=2147483647,
|
|
||||||
step=1,
|
|
||||||
control_after_generate=True,
|
|
||||||
display_mode=IO.NumberDisplay.number,
|
|
||||||
optional=True,
|
|
||||||
),
|
|
||||||
IO.Combo.Input(
|
|
||||||
"style_type",
|
|
||||||
options=["AUTO", "GENERAL", "REALISTIC", "DESIGN", "RENDER_3D", "ANIME"],
|
|
||||||
default="NONE",
|
|
||||||
tooltip="Style type for generation (V2 only)",
|
|
||||||
optional=True,
|
|
||||||
advanced=True,
|
|
||||||
),
|
|
||||||
IO.String.Input(
|
|
||||||
"negative_prompt",
|
|
||||||
multiline=True,
|
|
||||||
default="",
|
|
||||||
tooltip="Description of what to exclude from the image",
|
|
||||||
optional=True,
|
|
||||||
),
|
|
||||||
IO.Int.Input(
|
|
||||||
"num_images",
|
|
||||||
default=1,
|
|
||||||
min=1,
|
|
||||||
max=8,
|
|
||||||
step=1,
|
|
||||||
display_mode=IO.NumberDisplay.number,
|
|
||||||
optional=True,
|
|
||||||
),
|
|
||||||
#"color_palette": (
|
|
||||||
# IO.STRING,
|
|
||||||
# {
|
|
||||||
# "multiline": False,
|
|
||||||
# "default": "",
|
|
||||||
# "tooltip": "Color palette preset name or hex colors with weights",
|
|
||||||
# },
|
|
||||||
#),
|
|
||||||
],
|
|
||||||
outputs=[
|
|
||||||
IO.Image.Output(),
|
|
||||||
],
|
|
||||||
hidden=[
|
|
||||||
IO.Hidden.auth_token_comfy_org,
|
|
||||||
IO.Hidden.api_key_comfy_org,
|
|
||||||
IO.Hidden.unique_id,
|
|
||||||
],
|
|
||||||
is_api_node=True,
|
|
||||||
price_badge=IO.PriceBadge(
|
|
||||||
depends_on=IO.PriceBadgeDepends(widgets=["num_images", "turbo"]),
|
|
||||||
expr="""
|
|
||||||
(
|
|
||||||
$n := widgets.num_images;
|
|
||||||
$base := (widgets.turbo = true) ? 0.0715 : 0.1144;
|
|
||||||
{"type":"usd","usd": $round($base * $n, 2)}
|
|
||||||
)
|
|
||||||
""",
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
async def execute(
|
|
||||||
cls,
|
|
||||||
prompt,
|
|
||||||
turbo=False,
|
|
||||||
aspect_ratio="1:1",
|
|
||||||
resolution="Auto",
|
|
||||||
magic_prompt_option="AUTO",
|
|
||||||
seed=0,
|
|
||||||
style_type="NONE",
|
|
||||||
negative_prompt="",
|
|
||||||
num_images=1,
|
|
||||||
color_palette="",
|
|
||||||
):
|
|
||||||
aspect_ratio = V1_V2_RATIO_MAP.get(aspect_ratio, None)
|
|
||||||
resolution = V1_V1_RES_MAP.get(resolution, None)
|
|
||||||
# Determine the model based on turbo setting
|
|
||||||
model = "V_2_TURBO" if turbo else "V_2"
|
|
||||||
|
|
||||||
# Handle resolution vs aspect_ratio logic
|
|
||||||
# If resolution is not AUTO, it overrides aspect_ratio
|
|
||||||
final_resolution = None
|
|
||||||
final_aspect_ratio = None
|
|
||||||
|
|
||||||
if resolution != "AUTO":
|
|
||||||
final_resolution = resolution
|
|
||||||
else:
|
|
||||||
final_aspect_ratio = aspect_ratio if aspect_ratio != "ASPECT_1_1" else None
|
|
||||||
|
|
||||||
response = await sync_op(
|
|
||||||
cls,
|
|
||||||
endpoint=ApiEndpoint(path="/proxy/ideogram/generate", method="POST"),
|
|
||||||
response_model=IdeogramGenerateResponse,
|
|
||||||
data=IdeogramGenerateRequest(
|
|
||||||
image_request=ImageRequest(
|
|
||||||
prompt=prompt,
|
|
||||||
model=model,
|
|
||||||
num_images=num_images,
|
|
||||||
seed=seed,
|
|
||||||
aspect_ratio=final_aspect_ratio,
|
|
||||||
resolution=final_resolution,
|
|
||||||
magic_prompt_option=(magic_prompt_option if magic_prompt_option != "AUTO" else None),
|
|
||||||
style_type=style_type if style_type != "NONE" else None,
|
|
||||||
negative_prompt=negative_prompt if negative_prompt else None,
|
|
||||||
color_palette=color_palette if color_palette else None,
|
|
||||||
)
|
|
||||||
),
|
|
||||||
max_retries=1,
|
|
||||||
)
|
|
||||||
if not response.data or len(response.data) == 0:
|
|
||||||
raise Exception("No images were generated in the response")
|
|
||||||
|
|
||||||
image_urls = [image_data.url for image_data in response.data if image_data.url]
|
|
||||||
if not image_urls:
|
|
||||||
raise Exception("No image URLs were generated in the response")
|
|
||||||
return IO.NodeOutput(await download_and_process_images(image_urls))
|
|
||||||
|
|
||||||
|
|
||||||
class IdeogramV3(IO.ComfyNode):
|
class IdeogramV3(IO.ComfyNode):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -917,8 +528,6 @@ class IdeogramExtension(ComfyExtension):
|
|||||||
@override
|
@override
|
||||||
async def get_node_list(self) -> list[type[IO.ComfyNode]]:
|
async def get_node_list(self) -> list[type[IO.ComfyNode]]:
|
||||||
return [
|
return [
|
||||||
IdeogramV1,
|
|
||||||
IdeogramV2,
|
|
||||||
IdeogramV3,
|
IdeogramV3,
|
||||||
IdeogramV4,
|
IdeogramV4,
|
||||||
]
|
]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user