mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-06-25 01:09:24 +08:00
[Partner Nodes] feat(ByteDance): add 4K resolution support for SeeDance 2.0 (#14588)
Signed-off-by: bigcat88 <bigcat88@icloud.com>
This commit is contained in:
parent
0a92ed161e
commit
0ba903bd5b
@ -163,15 +163,27 @@ class SeedanceVirtualLibraryCreateAssetRequest(BaseModel):
|
|||||||
asset_type: str | None = Field(None, description="BytePlus asset type. Defaults to Image server-side when omitted.")
|
asset_type: str | None = Field(None, description="BytePlus asset type. Defaults to Image server-side when omitted.")
|
||||||
|
|
||||||
|
|
||||||
# Dollars per 1K tokens, keyed by (model_id, has_video_input).
|
# Dollars per 1K tokens, keyed by (model_id, has_video_input, resolution).
|
||||||
SEEDANCE2_PRICE_PER_1K_TOKENS = {
|
SEEDANCE2_PRICE_PER_1K_TOKENS = {
|
||||||
("dreamina-seedance-2-0-260128", False): 0.007,
|
("dreamina-seedance-2-0-260128", False, "480p"): 0.007,
|
||||||
("dreamina-seedance-2-0-260128", True): 0.0043,
|
("dreamina-seedance-2-0-260128", True, "480p"): 0.0043,
|
||||||
("dreamina-seedance-2-0-fast-260128", False): 0.0056,
|
("dreamina-seedance-2-0-260128", False, "720p"): 0.007,
|
||||||
("dreamina-seedance-2-0-fast-260128", True): 0.0033,
|
("dreamina-seedance-2-0-260128", True, "720p"): 0.0043,
|
||||||
|
("dreamina-seedance-2-0-260128", False, "1080p"): 0.0077,
|
||||||
|
("dreamina-seedance-2-0-260128", True, "1080p"): 0.0047,
|
||||||
|
("dreamina-seedance-2-0-260128", False, "4k"): 0.004,
|
||||||
|
("dreamina-seedance-2-0-260128", True, "4k"): 0.0024,
|
||||||
|
("dreamina-seedance-2-0-fast-260128", False, "480p"): 0.0056,
|
||||||
|
("dreamina-seedance-2-0-fast-260128", True, "480p"): 0.0033,
|
||||||
|
("dreamina-seedance-2-0-fast-260128", False, "720p"): 0.0056,
|
||||||
|
("dreamina-seedance-2-0-fast-260128", True, "720p"): 0.0033,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def seedance2_price_per_1k_tokens(model_id: str, has_video_input: bool, resolution: str) -> float | None:
|
||||||
|
return SEEDANCE2_PRICE_PER_1K_TOKENS.get((model_id, has_video_input, resolution))
|
||||||
|
|
||||||
|
|
||||||
RECOMMENDED_PRESETS = [
|
RECOMMENDED_PRESETS = [
|
||||||
("1024x1024 (1:1)", 1024, 1024),
|
("1024x1024 (1:1)", 1024, 1024),
|
||||||
("864x1152 (3:4)", 864, 1152),
|
("864x1152 (3:4)", 864, 1152),
|
||||||
|
|||||||
@ -15,7 +15,6 @@ from comfy_api_nodes.apis.bytedance import (
|
|||||||
RECOMMENDED_PRESETS_SEEDREAM_4_0,
|
RECOMMENDED_PRESETS_SEEDREAM_4_0,
|
||||||
RECOMMENDED_PRESETS_SEEDREAM_4_5,
|
RECOMMENDED_PRESETS_SEEDREAM_4_5,
|
||||||
RECOMMENDED_PRESETS_SEEDREAM_5_LITE,
|
RECOMMENDED_PRESETS_SEEDREAM_5_LITE,
|
||||||
SEEDANCE2_PRICE_PER_1K_TOKENS,
|
|
||||||
SEEDANCE2_REF_VIDEO_PIXEL_LIMITS,
|
SEEDANCE2_REF_VIDEO_PIXEL_LIMITS,
|
||||||
VIDEO_TASKS_EXECUTION_TIME,
|
VIDEO_TASKS_EXECUTION_TIME,
|
||||||
GetAssetResponse,
|
GetAssetResponse,
|
||||||
@ -40,6 +39,7 @@ from comfy_api_nodes.apis.bytedance import (
|
|||||||
TaskVideoContentUrl,
|
TaskVideoContentUrl,
|
||||||
Text2ImageTaskCreationRequest,
|
Text2ImageTaskCreationRequest,
|
||||||
Text2VideoTaskCreationRequest,
|
Text2VideoTaskCreationRequest,
|
||||||
|
seedance2_price_per_1k_tokens,
|
||||||
)
|
)
|
||||||
from comfy_api_nodes.util import (
|
from comfy_api_nodes.util import (
|
||||||
ApiEndpoint,
|
ApiEndpoint,
|
||||||
@ -141,7 +141,7 @@ SEEDANCE2_RATIO_WH = {
|
|||||||
"9:16": (9, 16),
|
"9:16": (9, 16),
|
||||||
"21:9": (21, 9),
|
"21:9": (21, 9),
|
||||||
}
|
}
|
||||||
SEEDANCE2_RES_SHORT_SIDE = {"480p": 480, "720p": 720, "1080p": 1080}
|
SEEDANCE2_RES_SHORT_SIDE = {"480p": 480, "720p": 720, "1080p": 1080, "4k": 2160}
|
||||||
|
|
||||||
|
|
||||||
def _seedance2_target_dims(resolution: str, ratio: str, image: torch.Tensor) -> tuple[int, int]:
|
def _seedance2_target_dims(resolution: str, ratio: str, image: torch.Tensor) -> tuple[int, int]:
|
||||||
@ -377,9 +377,9 @@ async def _seedance_virtual_library_upload_video_asset(
|
|||||||
return f"asset://{create_resp.asset_id}"
|
return f"asset://{create_resp.asset_id}"
|
||||||
|
|
||||||
|
|
||||||
def _seedance2_price_extractor(model_id: str, has_video_input: bool):
|
def _seedance2_price_extractor(model_id: str, has_video_input: bool, resolution: str):
|
||||||
"""Returns a price_extractor closure for Seedance 2.0 poll_op."""
|
"""Returns a price_extractor closure for Seedance 2.0 poll_op."""
|
||||||
rate = SEEDANCE2_PRICE_PER_1K_TOKENS.get((model_id, has_video_input))
|
rate = seedance2_price_per_1k_tokens(model_id, has_video_input, resolution)
|
||||||
if rate is None:
|
if rate is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -1621,7 +1621,7 @@ class ByteDance2TextToVideoNode(IO.ComfyNode):
|
|||||||
IO.DynamicCombo.Input(
|
IO.DynamicCombo.Input(
|
||||||
"model",
|
"model",
|
||||||
options=[
|
options=[
|
||||||
IO.DynamicCombo.Option("Seedance 2.0", _seedance2_text_inputs(["480p", "720p", "1080p"])),
|
IO.DynamicCombo.Option("Seedance 2.0", _seedance2_text_inputs(["480p", "720p", "1080p", "4k"])),
|
||||||
IO.DynamicCombo.Option("Seedance 2.0 Fast", _seedance2_text_inputs(["480p", "720p"])),
|
IO.DynamicCombo.Option("Seedance 2.0 Fast", _seedance2_text_inputs(["480p", "720p"])),
|
||||||
],
|
],
|
||||||
tooltip="Seedance 2.0 for maximum quality; Seedance 2.0 Fast for speed optimization.",
|
tooltip="Seedance 2.0 for maximum quality; Seedance 2.0 Fast for speed optimization.",
|
||||||
@ -1660,11 +1660,15 @@ class ByteDance2TextToVideoNode(IO.ComfyNode):
|
|||||||
$rate480 := 10044;
|
$rate480 := 10044;
|
||||||
$rate720 := 21600;
|
$rate720 := 21600;
|
||||||
$rate1080 := 48800;
|
$rate1080 := 48800;
|
||||||
|
$rate4k := 195200;
|
||||||
$m := widgets.model;
|
$m := widgets.model;
|
||||||
$pricePer1K := $contains($m, "fast") ? 0.008008 : 0.01001;
|
|
||||||
$res := $lookup(widgets, "model.resolution");
|
$res := $lookup(widgets, "model.resolution");
|
||||||
$dur := $lookup(widgets, "model.duration");
|
$dur := $lookup(widgets, "model.duration");
|
||||||
$rate := $res = "1080p" ? $rate1080 :
|
$pricePer1K := $res = "4k" ? 0.00572 :
|
||||||
|
$res = "1080p" ? 0.011011 :
|
||||||
|
$contains($m, "fast") ? 0.008008 : 0.01001;
|
||||||
|
$rate := $res = "4k" ? $rate4k :
|
||||||
|
$res = "1080p" ? $rate1080 :
|
||||||
$res = "720p" ? $rate720 :
|
$res = "720p" ? $rate720 :
|
||||||
$rate480;
|
$rate480;
|
||||||
$cost := $dur * $rate * $pricePer1K / 1000;
|
$cost := $dur * $rate * $pricePer1K / 1000;
|
||||||
@ -1703,7 +1707,7 @@ class ByteDance2TextToVideoNode(IO.ComfyNode):
|
|||||||
ApiEndpoint(path=f"{BYTEPLUS_SEEDANCE2_TASK_STATUS_ENDPOINT}/{initial_response.id}"),
|
ApiEndpoint(path=f"{BYTEPLUS_SEEDANCE2_TASK_STATUS_ENDPOINT}/{initial_response.id}"),
|
||||||
response_model=TaskStatusResponse,
|
response_model=TaskStatusResponse,
|
||||||
status_extractor=lambda r: r.status,
|
status_extractor=lambda r: r.status,
|
||||||
price_extractor=_seedance2_price_extractor(model_id, has_video_input=False),
|
price_extractor=_seedance2_price_extractor(model_id, has_video_input=False, resolution=model["resolution"]),
|
||||||
poll_interval=9,
|
poll_interval=9,
|
||||||
)
|
)
|
||||||
return IO.NodeOutput(await download_url_to_video_output(response.content.video_url))
|
return IO.NodeOutput(await download_url_to_video_output(response.content.video_url))
|
||||||
@ -1724,7 +1728,7 @@ class ByteDance2FirstLastFrameNode(IO.ComfyNode):
|
|||||||
options=[
|
options=[
|
||||||
IO.DynamicCombo.Option(
|
IO.DynamicCombo.Option(
|
||||||
"Seedance 2.0",
|
"Seedance 2.0",
|
||||||
_seedance2_text_inputs(["480p", "720p", "1080p"], default_ratio="adaptive"),
|
_seedance2_text_inputs(["480p", "720p", "1080p", "4k"], default_ratio="adaptive"),
|
||||||
),
|
),
|
||||||
IO.DynamicCombo.Option(
|
IO.DynamicCombo.Option(
|
||||||
"Seedance 2.0 Fast",
|
"Seedance 2.0 Fast",
|
||||||
@ -1791,11 +1795,15 @@ class ByteDance2FirstLastFrameNode(IO.ComfyNode):
|
|||||||
$rate480 := 10044;
|
$rate480 := 10044;
|
||||||
$rate720 := 21600;
|
$rate720 := 21600;
|
||||||
$rate1080 := 48800;
|
$rate1080 := 48800;
|
||||||
|
$rate4k := 195200;
|
||||||
$m := widgets.model;
|
$m := widgets.model;
|
||||||
$pricePer1K := $contains($m, "fast") ? 0.008008 : 0.01001;
|
|
||||||
$res := $lookup(widgets, "model.resolution");
|
$res := $lookup(widgets, "model.resolution");
|
||||||
$dur := $lookup(widgets, "model.duration");
|
$dur := $lookup(widgets, "model.duration");
|
||||||
$rate := $res = "1080p" ? $rate1080 :
|
$pricePer1K := $res = "4k" ? 0.00572 :
|
||||||
|
$res = "1080p" ? 0.011011 :
|
||||||
|
$contains($m, "fast") ? 0.008008 : 0.01001;
|
||||||
|
$rate := $res = "4k" ? $rate4k :
|
||||||
|
$res = "1080p" ? $rate1080 :
|
||||||
$res = "720p" ? $rate720 :
|
$res = "720p" ? $rate720 :
|
||||||
$rate480;
|
$rate480;
|
||||||
$cost := $dur * $rate * $pricePer1K / 1000;
|
$cost := $dur * $rate * $pricePer1K / 1000;
|
||||||
@ -1913,7 +1921,7 @@ class ByteDance2FirstLastFrameNode(IO.ComfyNode):
|
|||||||
ApiEndpoint(path=f"{BYTEPLUS_SEEDANCE2_TASK_STATUS_ENDPOINT}/{initial_response.id}"),
|
ApiEndpoint(path=f"{BYTEPLUS_SEEDANCE2_TASK_STATUS_ENDPOINT}/{initial_response.id}"),
|
||||||
response_model=TaskStatusResponse,
|
response_model=TaskStatusResponse,
|
||||||
status_extractor=lambda r: r.status,
|
status_extractor=lambda r: r.status,
|
||||||
price_extractor=_seedance2_price_extractor(model_id, has_video_input=False),
|
price_extractor=_seedance2_price_extractor(model_id, has_video_input=False, resolution=model["resolution"]),
|
||||||
poll_interval=9,
|
poll_interval=9,
|
||||||
)
|
)
|
||||||
return IO.NodeOutput(await download_url_to_video_output(response.content.video_url))
|
return IO.NodeOutput(await download_url_to_video_output(response.content.video_url))
|
||||||
@ -2010,7 +2018,7 @@ class ByteDance2ReferenceNode(IO.ComfyNode):
|
|||||||
options=[
|
options=[
|
||||||
IO.DynamicCombo.Option(
|
IO.DynamicCombo.Option(
|
||||||
"Seedance 2.0",
|
"Seedance 2.0",
|
||||||
_seedance2_reference_inputs(["480p", "720p", "1080p"], default_ratio="adaptive"),
|
_seedance2_reference_inputs(["480p", "720p", "1080p", "4k"], default_ratio="adaptive"),
|
||||||
),
|
),
|
||||||
IO.DynamicCombo.Option(
|
IO.DynamicCombo.Option(
|
||||||
"Seedance 2.0 Fast",
|
"Seedance 2.0 Fast",
|
||||||
@ -2056,13 +2064,19 @@ class ByteDance2ReferenceNode(IO.ComfyNode):
|
|||||||
$rate480 := 10044;
|
$rate480 := 10044;
|
||||||
$rate720 := 21600;
|
$rate720 := 21600;
|
||||||
$rate1080 := 48800;
|
$rate1080 := 48800;
|
||||||
|
$rate4k := 195200;
|
||||||
$m := widgets.model;
|
$m := widgets.model;
|
||||||
$hasVideo := $lookup(inputGroups, "model.reference_videos") > 0;
|
$hasVideo := $lookup(inputGroups, "model.reference_videos") > 0;
|
||||||
$noVideoPricePer1K := $contains($m, "fast") ? 0.008008 : 0.01001;
|
|
||||||
$videoPricePer1K := $contains($m, "fast") ? 0.004719 : 0.006149;
|
|
||||||
$res := $lookup(widgets, "model.resolution");
|
$res := $lookup(widgets, "model.resolution");
|
||||||
$dur := $lookup(widgets, "model.duration");
|
$dur := $lookup(widgets, "model.duration");
|
||||||
$rate := $res = "1080p" ? $rate1080 :
|
$noVideoPricePer1K := $res = "4k" ? 0.00572 :
|
||||||
|
$res = "1080p" ? 0.011011 :
|
||||||
|
$contains($m, "fast") ? 0.008008 : 0.01001;
|
||||||
|
$videoPricePer1K := $res = "4k" ? 0.003432 :
|
||||||
|
$res = "1080p" ? 0.006721 :
|
||||||
|
$contains($m, "fast") ? 0.004719 : 0.006149;
|
||||||
|
$rate := $res = "4k" ? $rate4k :
|
||||||
|
$res = "1080p" ? $rate1080 :
|
||||||
$res = "720p" ? $rate720 :
|
$res = "720p" ? $rate720 :
|
||||||
$rate480;
|
$rate480;
|
||||||
$noVideoCost := $dur * $rate * $noVideoPricePer1K / 1000;
|
$noVideoCost := $dur * $rate * $noVideoPricePer1K / 1000;
|
||||||
@ -2258,7 +2272,9 @@ class ByteDance2ReferenceNode(IO.ComfyNode):
|
|||||||
ApiEndpoint(path=f"{BYTEPLUS_SEEDANCE2_TASK_STATUS_ENDPOINT}/{initial_response.id}"),
|
ApiEndpoint(path=f"{BYTEPLUS_SEEDANCE2_TASK_STATUS_ENDPOINT}/{initial_response.id}"),
|
||||||
response_model=TaskStatusResponse,
|
response_model=TaskStatusResponse,
|
||||||
status_extractor=lambda r: r.status,
|
status_extractor=lambda r: r.status,
|
||||||
price_extractor=_seedance2_price_extractor(model_id, has_video_input=has_video_input),
|
price_extractor=_seedance2_price_extractor(
|
||||||
|
model_id, has_video_input=has_video_input, resolution=model["resolution"]
|
||||||
|
),
|
||||||
poll_interval=9,
|
poll_interval=9,
|
||||||
)
|
)
|
||||||
return IO.NodeOutput(await download_url_to_video_output(response.content.video_url))
|
return IO.NodeOutput(await download_url_to_video_output(response.content.video_url))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user