mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-05-28 01:47:32 +08:00
Merge bc1a2188e7 into 41812fa0ac
This commit is contained in:
commit
6b64c852fe
@ -158,8 +158,9 @@ class SeedanceCreateAssetResponse(BaseModel):
|
|||||||
|
|
||||||
|
|
||||||
class SeedanceVirtualLibraryCreateAssetRequest(BaseModel):
|
class SeedanceVirtualLibraryCreateAssetRequest(BaseModel):
|
||||||
url: str = Field(..., description="Publicly accessible URL of the image asset to upload.")
|
url: str = Field(..., description="Publicly accessible URL of the asset to upload.")
|
||||||
hash: str = Field(..., description="Dedup key. Re-submitting the same hash returns the existing asset id.")
|
hash: str = Field(..., description="Dedup key. Re-submitting the same hash returns the existing asset id.")
|
||||||
|
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).
|
||||||
|
|||||||
@ -2,11 +2,12 @@ import hashlib
|
|||||||
import logging
|
import logging
|
||||||
import math
|
import math
|
||||||
import re
|
import re
|
||||||
|
from io import BytesIO
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
from typing_extensions import override
|
from typing_extensions import override
|
||||||
|
|
||||||
from comfy_api.latest import IO, ComfyExtension, Input
|
from comfy_api.latest import IO, ComfyExtension, Input, Types
|
||||||
from comfy_api_nodes.apis.bytedance import (
|
from comfy_api_nodes.apis.bytedance import (
|
||||||
RECOMMENDED_PRESETS,
|
RECOMMENDED_PRESETS,
|
||||||
RECOMMENDED_PRESETS_SEEDREAM_4,
|
RECOMMENDED_PRESETS_SEEDREAM_4,
|
||||||
@ -308,6 +309,26 @@ async def _seedance_virtual_library_upload_image_asset(
|
|||||||
return f"asset://{create_resp.asset_id}"
|
return f"asset://{create_resp.asset_id}"
|
||||||
|
|
||||||
|
|
||||||
|
async def _seedance_virtual_library_upload_video_asset(
|
||||||
|
cls: type[IO.ComfyNode],
|
||||||
|
video: Input.Video,
|
||||||
|
*,
|
||||||
|
wait_label: str = "Uploading video",
|
||||||
|
) -> str:
|
||||||
|
buf = BytesIO()
|
||||||
|
video.save_to(buf, format=Types.VideoContainer.MP4, codec=Types.VideoCodec.H264)
|
||||||
|
video_hash = hashlib.sha256(buf.getbuffer()).hexdigest()
|
||||||
|
public_url = await upload_video_to_comfyapi(cls, video, wait_label=wait_label)
|
||||||
|
create_resp = await sync_op(
|
||||||
|
cls,
|
||||||
|
ApiEndpoint(path="/proxy/seedance/virtual-library/assets", method="POST"),
|
||||||
|
response_model=SeedanceCreateAssetResponse,
|
||||||
|
data=SeedanceVirtualLibraryCreateAssetRequest(url=public_url, hash=video_hash, asset_type="Video"),
|
||||||
|
)
|
||||||
|
await _wait_for_asset_active(cls, create_resp.asset_id, group_id="virtual-library")
|
||||||
|
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):
|
||||||
"""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.get((model_id, has_video_input))
|
||||||
@ -2106,7 +2127,7 @@ class ByteDance2ReferenceNode(IO.ComfyNode):
|
|||||||
content.append(
|
content.append(
|
||||||
TaskVideoContent(
|
TaskVideoContent(
|
||||||
video_url=TaskVideoContentUrl(
|
video_url=TaskVideoContentUrl(
|
||||||
url=await upload_video_to_comfyapi(
|
url=await _seedance_virtual_library_upload_video_asset(
|
||||||
cls,
|
cls,
|
||||||
reference_videos[key],
|
reference_videos[key],
|
||||||
wait_label=f"Uploading video {i}",
|
wait_label=f"Uploading video {i}",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user