mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-03-14 13:47:44 +08:00
feat(api-nodes): add ByteDance Seedream-5 model
This commit is contained in:
parent
048dd2f321
commit
7fc1aa2323
@ -27,6 +27,7 @@ class Seedream4TaskCreationRequest(BaseModel):
|
|||||||
sequential_image_generation: str = Field("disabled")
|
sequential_image_generation: str = Field("disabled")
|
||||||
sequential_image_generation_options: Seedream4Options = Field(Seedream4Options(max_images=15))
|
sequential_image_generation_options: Seedream4Options = Field(Seedream4Options(max_images=15))
|
||||||
watermark: bool = Field(False)
|
watermark: bool = Field(False)
|
||||||
|
output_format: str | None = None
|
||||||
|
|
||||||
|
|
||||||
class ImageTaskCreationResponse(BaseModel):
|
class ImageTaskCreationResponse(BaseModel):
|
||||||
@ -106,6 +107,7 @@ RECOMMENDED_PRESETS_SEEDREAM_4 = [
|
|||||||
("2496x1664 (3:2)", 2496, 1664),
|
("2496x1664 (3:2)", 2496, 1664),
|
||||||
("1664x2496 (2:3)", 1664, 2496),
|
("1664x2496 (2:3)", 1664, 2496),
|
||||||
("3024x1296 (21:9)", 3024, 1296),
|
("3024x1296 (21:9)", 3024, 1296),
|
||||||
|
("3072x3072 (1:1)", 3072, 3072),
|
||||||
("4096x4096 (1:1)", 4096, 4096),
|
("4096x4096 (1:1)", 4096, 4096),
|
||||||
("Custom", None, None),
|
("Custom", None, None),
|
||||||
]
|
]
|
||||||
|
|||||||
@ -180,14 +180,13 @@ class ByteDanceSeedreamNode(IO.ComfyNode):
|
|||||||
def define_schema(cls):
|
def define_schema(cls):
|
||||||
return IO.Schema(
|
return IO.Schema(
|
||||||
node_id="ByteDanceSeedreamNode",
|
node_id="ByteDanceSeedreamNode",
|
||||||
display_name="ByteDance Seedream 4.5",
|
display_name="ByteDance Seedream 5.0",
|
||||||
category="api node/image/ByteDance",
|
category="api node/image/ByteDance",
|
||||||
description="Unified text-to-image generation and precise single-sentence editing at up to 4K resolution.",
|
description="Unified text-to-image generation and precise single-sentence editing at up to 4K resolution.",
|
||||||
inputs=[
|
inputs=[
|
||||||
IO.Combo.Input(
|
IO.Combo.Input(
|
||||||
"model",
|
"model",
|
||||||
options=["seedream-4-5-251128", "seedream-4-0-250828"],
|
options=["seedream-5-0-260128", "seedream-4-5-251128", "seedream-4-0-250828"],
|
||||||
tooltip="Model name",
|
|
||||||
),
|
),
|
||||||
IO.String.Input(
|
IO.String.Input(
|
||||||
"prompt",
|
"prompt",
|
||||||
@ -198,7 +197,7 @@ class ByteDanceSeedreamNode(IO.ComfyNode):
|
|||||||
IO.Image.Input(
|
IO.Image.Input(
|
||||||
"image",
|
"image",
|
||||||
tooltip="Input image(s) for image-to-image generation. "
|
tooltip="Input image(s) for image-to-image generation. "
|
||||||
"List of 1-10 images for single or multi-reference generation.",
|
"Reference image(s) for single or multi-reference generation.",
|
||||||
optional=True,
|
optional=True,
|
||||||
),
|
),
|
||||||
IO.Combo.Input(
|
IO.Combo.Input(
|
||||||
@ -210,8 +209,8 @@ class ByteDanceSeedreamNode(IO.ComfyNode):
|
|||||||
"width",
|
"width",
|
||||||
default=2048,
|
default=2048,
|
||||||
min=1024,
|
min=1024,
|
||||||
max=4096,
|
max=6240,
|
||||||
step=8,
|
step=2,
|
||||||
tooltip="Custom width for image. Value is working only if `size_preset` is set to `Custom`",
|
tooltip="Custom width for image. Value is working only if `size_preset` is set to `Custom`",
|
||||||
optional=True,
|
optional=True,
|
||||||
),
|
),
|
||||||
@ -219,8 +218,8 @@ class ByteDanceSeedreamNode(IO.ComfyNode):
|
|||||||
"height",
|
"height",
|
||||||
default=2048,
|
default=2048,
|
||||||
min=1024,
|
min=1024,
|
||||||
max=4096,
|
max=4992,
|
||||||
step=8,
|
step=2,
|
||||||
tooltip="Custom height for image. Value is working only if `size_preset` is set to `Custom`",
|
tooltip="Custom height for image. Value is working only if `size_preset` is set to `Custom`",
|
||||||
optional=True,
|
optional=True,
|
||||||
),
|
),
|
||||||
@ -283,7 +282,8 @@ class ByteDanceSeedreamNode(IO.ComfyNode):
|
|||||||
depends_on=IO.PriceBadgeDepends(widgets=["model"]),
|
depends_on=IO.PriceBadgeDepends(widgets=["model"]),
|
||||||
expr="""
|
expr="""
|
||||||
(
|
(
|
||||||
$price := $contains(widgets.model, "seedream-4-5-251128") ? 0.04 : 0.03;
|
$price := $contains(widgets.model, "seedream-5-0") ? 0.035 :
|
||||||
|
$contains(widgets.model, "seedream-4-5") ? 0.04 : 0.03;
|
||||||
{
|
{
|
||||||
"type":"usd",
|
"type":"usd",
|
||||||
"usd": $price,
|
"usd": $price,
|
||||||
@ -318,13 +318,10 @@ class ByteDanceSeedreamNode(IO.ComfyNode):
|
|||||||
|
|
||||||
if w is None or h is None:
|
if w is None or h is None:
|
||||||
w, h = width, height
|
w, h = width, height
|
||||||
if not (1024 <= w <= 4096) or not (1024 <= h <= 4096):
|
|
||||||
raise ValueError(
|
|
||||||
f"Custom size out of range: {w}x{h}. " "Both width and height must be between 1024 and 4096 pixels."
|
|
||||||
)
|
|
||||||
out_num_pixels = w * h
|
out_num_pixels = w * h
|
||||||
mp_provided = out_num_pixels / 1_000_000.0
|
mp_provided = out_num_pixels / 1_000_000.0
|
||||||
if "seedream-4-5" in model and out_num_pixels < 3686400:
|
if ("seedream-4-5" in model or "seedream-5-0" in model) and out_num_pixels < 3686400:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"Minimum image resolution that Seedream 4.5 can generate is 3.68MP, "
|
f"Minimum image resolution that Seedream 4.5 can generate is 3.68MP, "
|
||||||
f"but {mp_provided:.2f}MP provided."
|
f"but {mp_provided:.2f}MP provided."
|
||||||
@ -334,9 +331,18 @@ class ByteDanceSeedreamNode(IO.ComfyNode):
|
|||||||
f"Minimum image resolution that the selected model can generate is 0.92MP, "
|
f"Minimum image resolution that the selected model can generate is 0.92MP, "
|
||||||
f"but {mp_provided:.2f}MP provided."
|
f"but {mp_provided:.2f}MP provided."
|
||||||
)
|
)
|
||||||
|
max_pixels = 10_404_496 if "seedream-5-0" in model else 16_777_216
|
||||||
|
if out_num_pixels > max_pixels:
|
||||||
|
raise ValueError(
|
||||||
|
f"Maximum image resolution for the selected model is {max_pixels / 1_000_000:.2f}MP, "
|
||||||
|
f"but {mp_provided:.2f}MP provided."
|
||||||
|
)
|
||||||
n_input_images = get_number_of_images(image) if image is not None else 0
|
n_input_images = get_number_of_images(image) if image is not None else 0
|
||||||
if n_input_images > 10:
|
max_num_of_images = 14 if model == "seedream-5-0-260128" else 10
|
||||||
raise ValueError(f"Maximum of 10 reference images are supported, but {n_input_images} received.")
|
if n_input_images > max_num_of_images:
|
||||||
|
raise ValueError(
|
||||||
|
f"Maximum of {max_num_of_images} reference images are supported, but {n_input_images} received."
|
||||||
|
)
|
||||||
if sequential_image_generation == "auto" and n_input_images + max_images > 15:
|
if sequential_image_generation == "auto" and n_input_images + max_images > 15:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"The maximum number of generated images plus the number of reference images cannot exceed 15."
|
"The maximum number of generated images plus the number of reference images cannot exceed 15."
|
||||||
@ -364,6 +370,7 @@ class ByteDanceSeedreamNode(IO.ComfyNode):
|
|||||||
sequential_image_generation=sequential_image_generation,
|
sequential_image_generation=sequential_image_generation,
|
||||||
sequential_image_generation_options=Seedream4Options(max_images=max_images),
|
sequential_image_generation_options=Seedream4Options(max_images=max_images),
|
||||||
watermark=watermark,
|
watermark=watermark,
|
||||||
|
output_format="png" if model == "seedream-5-0-260128" else None,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
if len(response.data) == 1:
|
if len(response.data) == 1:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user