The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.
[Partner Nodes] feat(Bytedance): add new Seedream node with Fast Mode widget (#15750)
Alexander Piskun18c9aa48734e
diff --git a/comfy_api_nodes/apis/bytedance.py b/comfy_api_nodes/apis/bytedance.pyindex 6b854631d..87d22034a 100644--- a/comfy_api_nodes/apis/bytedance.py+++ b/comfy_api_nodes/apis/bytedance.py@@ -18,7 +18,8 @@ class Seedream4Options(BaseModel):class Seedream5OptimizePromptOptions(BaseModel):- thinking: Literal["auto", "enabled", "disabled"] = Field(...)+ thinking: Literal["auto", "enabled", "disabled"] | None = Field(None)+ mode: Literal["standard", "fast"] | None = Field(None)class Seedream4TaskCreationRequest(BaseModel):diff --git a/comfy_api_nodes/nodes_bytedance.py b/comfy_api_nodes/nodes_bytedance.pyindex ddef41ff1..1f2dfd21b 100644--- a/comfy_api_nodes/nodes_bytedance.py+++ b/comfy_api_nodes/nodes_bytedance.py@@ -755,6 +755,8 @@ def _seedream_model_inputs(max_width: int = 6240,max_height: int = 4992,supports_batch: bool = True,+ supports_fast: bool = False,+ include_common: bool = False,):inputs = [IO.Combo.Input(@@ -815,15 +817,57 @@ def _seedream_model_inputs(advanced=True,))+ if supports_fast:+ inputs.append(+ IO.Combo.Input(+ "prompt_optimization",+ options=["standard", "fast"],+ default="standard",+ tooltip="Prompt-optimization mode when reference images are provided: "+ "'standard' gives higher quality, 'fast' shorter generation time.",+ advanced=True,+ )+ )+ if include_common:+ inputs.extend(+ [+ IO.Int.Input(+ "seed",+ default=42,+ min=0,+ max=2147483647,+ step=1,+ display_mode=IO.NumberDisplay.number,+ control_after_generate=True,+ tooltip="Seed to use for generation.",+ ),+ IO.Boolean.Input(+ "watermark",+ default=False,+ tooltip='Whether to add an "AI generated" watermark to the image.',+ advanced=True,+ ),+ IO.Boolean.Input(+ "thinking",+ default=True,+ tooltip=(+ "Enable the model's prompt-optimization reasoning ('thinking') for better adherence. "+ "Can substantially increase generation time — notably on Seedream 5.0 Pro. "+ "Can only be disabled for text-to-image (not when reference images are provided)."+ ),+ advanced=True,+ ),+ ]+ )return inputs-class ByteDanceSeedreamNodeV2(IO.ComfyNode):+class ByteDanceSeedreamNodeV3(IO.ComfyNode):@classmethoddef define_schema(cls):return IO.Schema(- node_id="ByteDanceSeedreamNodeV2",+ node_id="ByteDanceSeedreamNodeV3",display_name="ByteDance Seedream 4.5 & 5.0",category="partner/image/ByteDance",description="Unified text-to-image generation and precise single-sentence editing at up to 4K resolution.",@@ -845,49 +889,36 @@ class ByteDanceSeedreamNodeV2(IO.ComfyNode):max_width=3136,max_height=2496,supports_batch=False,+ supports_fast=True,+ include_common=True,),),IO.DynamicCombo.Option("seedream 5.0 lite",- _seedream_model_inputs(max_ref_images=14, presets=RECOMMENDED_PRESETS_SEEDREAM_5_LITE),+ _seedream_model_inputs(+ max_ref_images=14,+ presets=RECOMMENDED_PRESETS_SEEDREAM_5_LITE,+ include_common=True,+ ),),IO.DynamicCombo.Option("seedream-4-5-251128",- _seedream_model_inputs(max_ref_images=10, presets=RECOMMENDED_PRESETS_SEEDREAM_4_5),+ _seedream_model_inputs(+ max_ref_images=10,+ presets=RECOMMENDED_PRESETS_SEEDREAM_4_5,+ include_common=True,+ ),),IO.DynamicCombo.Option("seedream-4-0-250828",- _seedream_model_inputs(max_ref_images=10, presets=RECOMMENDED_PRESETS_SEEDREAM_4_0),+ _seedream_model_inputs(+ max_ref_images=10,+ presets=RECOMMENDED_PRESETS_SEEDREAM_4_0,+ include_common=True,+ ),),],),- IO.Int.Input(- "seed",- default=0,- min=0,- max=2147483647,- step=1,- display_mode=IO.NumberDisplay.number,- control_after_generate=True,- tooltip="Seed to use for generation.",- ),- IO.Boolean.Input(- "watermark",- default=False,- tooltip='Whether to add an "AI generated" watermark to the image.',- advanced=True,- ),- IO.Boolean.Input(- "thinking",- default=True,- tooltip=(- "Enable the model's prompt-optimization reasoning ('thinking') for better adherence. "- "Can substantially increase generation time — notably on Seedream 5.0 Pro. "- "Can only be disabled for text-to-image (not when reference images are provided)."- ),- optional=True,- advanced=True,- ),],outputs=[IO.Image.Output(),@@ -900,27 +931,39 @@ class ByteDanceSeedreamNodeV2(IO.ComfyNode):is_api_node=True,price_badge=IO.PriceBadge(depends_on=IO.PriceBadgeDepends(- widgets=["model", "model.size_preset", "model.width", "model.height"]+ widgets=["model", "model.size_preset", "model.width", "model.height"],+ input_groups=["model.images"],),expr="""(- $sp := $lookup(widgets, "model.size_preset");- $px := $lookup(widgets, "model.width") * $lookup(widgets, "model.height");- $isPro := $contains(widgets.model, "5.0 pro");- $price := $isPro- ? (- $contains($sp, "custom")- ? ($px <= 2360000 ? 0.045 : 0.09)- : ($contains($sp, "1k") ? 0.045 : 0.09)- )- : $contains(widgets.model, "5.0 lite") ? 0.035- : $contains(widgets.model, "4-5") ? 0.04- : 0.03;- {- "type": "usd",- "usd": $price,- "format": { "suffix": $isPro ? "/Image" : " x images/Run", "approximate": true }- }+ $model := $string(widgets.model);+ $sp := $string($lookup(widgets, "model.size_preset"));+ $w := $lookup(widgets, "model.width");+ $h := $lookup(widgets, "model.height");+ $px := ($type($w) = "number" and $type($h) = "number") ? $w * $h : 0;+ $refs := $lookup(inputGroups, "model.images");+ $extra := ($type($refs) = "number" and $refs > 1) ? ($refs - 1) * 0.003 : 0;+ $isPro := $contains($model, "5.0 pro");+ $isCustom := $contains($sp, "custom");+ $sizeKnown := $isCustom ? $px > 0 : ($contains($sp, "1k") or $contains($sp, "2k"));+ $proPrice := $isCustom+ ? ($px < 2610000 ? 0.045 : 0.09)+ : ($contains($sp, "1k") ? 0.045 : 0.09);+ ($isPro and ($sizeKnown = false))+ ? {+ "type": "range_usd",+ "min_usd": 0.045 + $extra,+ "max_usd": 0.09 + $extra,+ "format": { "suffix": "/Image", "approximate": true }+ }+ : {+ "type": "usd",+ "usd": $isPro ? $proPrice + $extra+ : $contains($model, "5.0 lite") ? 0.035+ : $contains($model, "4-5") ? 0.04+ : 0.03,+ "format": { "suffix": $isPro ? "/Image" : " x images/Run", "approximate": true }+ })""",),@@ -947,6 +990,10 @@ class ByteDanceSeedreamNodeV2(IO.ComfyNode):sequential_image_generation = "disabled" if max_images == 1 else "auto"images_dict = model.get("images") or {}fail_on_partial = model.get("fail_on_partial", False)+ prompt_optimization = model.get("prompt_optimization", "standard")+ seed = model.get("seed", seed)+ watermark = model.get("watermark", watermark)+ thinking = model.get("thinking", thinking)w = h = Nonefor label, tw, th in presets:@@ -1013,6 +1060,8 @@ class ByteDanceSeedreamNodeV2(IO.ComfyNode):optimize_prompt_options = Noneif n_input_images == 0:optimize_prompt_options = Seedream5OptimizePromptOptions(thinking="enabled" if thinking else "disabled")+ elif prompt_optimization == "fast":+ optimize_prompt_options = Seedream5OptimizePromptOptions(mode="fast")response = await sync_op(cls,ApiEndpoint(path=BYTEPLUS_IMAGE_ENDPOINT, method="POST"),@@ -1037,6 +1086,115 @@ class ByteDanceSeedreamNodeV2(IO.ComfyNode):return IO.NodeOutput(torch.cat([await download_url_to_image_tensor(i) for i in urls]))+class ByteDanceSeedreamNodeV2(ByteDanceSeedreamNodeV3):++ @classmethod+ def define_schema(cls):+ return IO.Schema(+ node_id="ByteDanceSeedreamNodeV2",+ display_name="ByteDance Seedream 4.5 & 5.0 (Legacy)",+ category="partner/image/ByteDance",+ description="Unified text-to-image generation and precise single-sentence editing at up to 4K resolution.",+ inputs=[+ IO.String.Input(+ "prompt",+ multiline=True,+ default="",+ tooltip="Text prompt for creating or editing an image.",+ ),+ IO.DynamicCombo.Input(+ "model",+ options=[+ IO.DynamicCombo.Option(+ "seedream 5.0 pro",+ _seedream_model_inputs(+ max_ref_images=10,+ presets=RECOMMENDED_PRESETS_SEEDREAM_5_PRO,+ max_width=3136,+ max_height=2496,+ supports_batch=False,+ ),+ ),+ IO.DynamicCombo.Option(+ "seedream 5.0 lite",+ _seedream_model_inputs(max_ref_images=14, presets=RECOMMENDED_PRESETS_SEEDREAM_5_LITE),+ ),+ IO.DynamicCombo.Option(+ "seedream-4-5-251128",+ _seedream_model_inputs(max_ref_images=10, presets=RECOMMENDED_PRESETS_SEEDREAM_4_5),+ ),+ IO.DynamicCombo.Option(+ "seedream-4-0-250828",+ _seedream_model_inputs(max_ref_images=10, presets=RECOMMENDED_PRESETS_SEEDREAM_4_0),+ ),+ ],+ ),+ IO.Int.Input(+ "seed",+ default=0,+ min=0,+ max=2147483647,+ step=1,+ display_mode=IO.NumberDisplay.number,+ control_after_generate=True,+ tooltip="Seed to use for generation.",+ ),+ IO.Boolean.Input(+ "watermark",+ default=False,+ tooltip='Whether to add an "AI generated" watermark to the image.',+ advanced=True,+ ),+ IO.Boolean.Input(+ "thinking",+ default=True,+ tooltip=(+ "Enable the model's prompt-optimization reasoning ('thinking') for better adherence. "+ "Can substantially increase generation time — notably on Seedream 5.0 Pro. "+ "Can only be disabled for text-to-image (not when reference images are provided)."+ ),+ optional=True,+ advanced=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,+ is_deprecated=True,+ price_badge=IO.PriceBadge(+ depends_on=IO.PriceBadgeDepends(+ widgets=["model", "model.size_preset", "model.width", "model.height"]+ ),+ expr="""+ (+ $sp := $lookup(widgets, "model.size_preset");+ $px := $lookup(widgets, "model.width") * $lookup(widgets, "model.height");+ $isPro := $contains(widgets.model, "5.0 pro");+ $price := $isPro+ ? (+ $contains($sp, "custom")+ ? ($px <= 2360000 ? 0.045 : 0.09)+ : ($contains($sp, "1k") ? 0.045 : 0.09)+ )+ : $contains(widgets.model, "5.0 lite") ? 0.035+ : $contains(widgets.model, "4-5") ? 0.04+ : 0.03;+ {+ "type": "usd",+ "usd": $price,+ "format": { "suffix": $isPro ? "/Image" : " x images/Run", "approximate": true }+ }+ )+ """,+ ),+ )+class ByteDanceSeedreamLayerSeparationNode(IO.ComfyNode):@classmethod@@ -3516,6 +3674,7 @@ class ByteDanceExtension(ComfyExtension):ByteDanceImageNode,ByteDanceSeedreamNode,ByteDanceSeedreamNodeV2,+ ByteDanceSeedreamNodeV3,ByteDanceSeedreamLayerSeparationNode,ByteDanceTextToVideoNode,ByteDanceImageToVideoNode,