Publish Seedance 2.5 draft mode and video updates
- Add the 样片模式 flow: 480p draft generation, a linkable draft task ID, and pre-flight verification before the 1080p final request. - Allow reference images and audio in video edit/extend requests, matching the provider's 2.5 contract. - Move 主模型 and 样片模式 ahead of 生成模式, default 主模型 to seedance 2.5, and migrate saved widget values. - Refresh the video panel, asset API response logs, and LLM node handling; cover the new behavior with offline tests.
This commit is contained in:
+37
-40
@@ -14,6 +14,7 @@ from ..clients.gemini_client import GeminiAPIClient
|
||||
from ..utils.image_utils import tensor_to_pil, pil_to_tensor
|
||||
from ..utils.r2_uploader import upload_image, upload_video, upload_audio
|
||||
from ..utils.config import get_base_url_by_route
|
||||
from ..utils.o1key_video_catalog import SEEDANCE_CAPABILITIES, SEEDANCE_MODEL_MATRIX
|
||||
from .seedance_autopass import (
|
||||
SeedanceAutoPass,
|
||||
_BASE_MODELS as _LATEST_BASE_MODELS,
|
||||
@@ -71,19 +72,23 @@ def _resolve_model(model: str) -> str:
|
||||
return _MM_MODEL_LABEL_TO_ID.get(model, model)
|
||||
|
||||
|
||||
# 多模态参考生视频支持 4k
|
||||
# 多模态参考生视频支持的分辨率下拉;2.5 与 fast/mini 的实际可用项由能力表过滤
|
||||
_MM_RESOLUTIONS = ["720p", "1080p", "4k", "480p"]
|
||||
# 受限模型仅支持 480p / 720p(前端做选择时报错提示)
|
||||
_LIMITED_RESOLUTION_MODELS = {
|
||||
"doubao-seedance-2-0-fast-260128",
|
||||
"doubao-seedance-2-0-fast-260128-max",
|
||||
"doubao-seedance-2-0-mini-260615-max",
|
||||
"dreamina-seedance-2-0-fast-hc",
|
||||
"seedance-2-0-fast-260128-d",
|
||||
"seedance-2-0-fast-d-ep",
|
||||
"dreamina-seedance-2-0-mini-hc",
|
||||
# 实际模型 ID → 支持的分辨率(共享能力表为唯一来源)
|
||||
_MODEL_RESOLUTIONS = {
|
||||
actual_model: tuple(SEEDANCE_CAPABILITIES[model]["resolutions"])
|
||||
for (model, _route), actual_model in SEEDANCE_MODEL_MATRIX.items()
|
||||
}
|
||||
# 批量节点仍在用的旧模型 ID,能力沿用同一系列
|
||||
_MODEL_RESOLUTIONS |= {
|
||||
actual_model: tuple(SEEDANCE_CAPABILITIES[model]["resolutions"])
|
||||
for actual_model, model in {
|
||||
"seedance-2-0-fast-260128-d": "seedance-2.0-fast",
|
||||
"seedance-2-0-fast-d-ep": "seedance-2.0-fast",
|
||||
"seedance-2-0-mini-260615-d": "seedance-2.0-mini",
|
||||
"seedance-2-0-mini-260615-d-ep": "seedance-2.0-mini",
|
||||
}.items()
|
||||
}
|
||||
_FAST_UNSUPPORTED_RESOLUTIONS = ["1080p", "4k"]
|
||||
|
||||
_MAX_IMAGE_BYTES = 30 * 1024 * 1024
|
||||
_MAX_REQUEST_BODY_BYTES = 64 * 1024 * 1024
|
||||
@@ -92,16 +97,17 @@ _MAX_REQUEST_BODY_BYTES = 64 * 1024 * 1024
|
||||
# ── 模型能力判断 ──────────────────────────────────────────────────────────────
|
||||
|
||||
def _check_fast_resolution(model: str, resolution: str):
|
||||
"""受限模型不支持 1080p / 4k,提交前拦截(保留旧函数名兼容调用方)。"""
|
||||
if model in _LIMITED_RESOLUTION_MODELS and resolution in _FAST_UNSUPPORTED_RESOLUTIONS:
|
||||
"""按模型能力表在提交前拦截不支持的分辨率。"""
|
||||
supported = _MODEL_RESOLUTIONS.get(model)
|
||||
if supported and resolution not in supported:
|
||||
raise ValueError(
|
||||
f"{model} 不支持 {resolution} 分辨率,"
|
||||
f"请改用 {_FAST_UNSUPPORTED_RESOLUTIONS} 以外的分辨率(如 720p)。"
|
||||
f"请改用 {' / '.join(supported)} 之一。"
|
||||
)
|
||||
|
||||
|
||||
def _is_new_format_model(model: str) -> bool:
|
||||
"""判断是否使用新请求体格式的模型(顶层 content,role 用 subject)
|
||||
"""判断是否使用新请求体格式的模型(顶层 content)
|
||||
|
||||
端点与老格式模型相同(均为 /v1/video/generations),
|
||||
仅请求体结构不同,由此函数控制节点侧如何拼装 body。
|
||||
@@ -312,7 +318,13 @@ class SeedanceMultiModal(io.ComfyNode):
|
||||
io.Combo.Input("生成音频", options=["关闭", "打开"], default="关闭"),
|
||||
io.Combo.Input("联网搜索", options=["关闭", "打开"], default="关闭"),
|
||||
io.Combo.Input("返回末帧图片", options=["关闭", "打开"], default="关闭"),
|
||||
io.Int.Input("seed", default=0, min=0, max=0xffffffffffffffff),
|
||||
io.Int.Input(
|
||||
"seed",
|
||||
default=0,
|
||||
min=0,
|
||||
max=0xffffffffffffffff,
|
||||
tooltip="仅用于触发重新执行,不会发送给接口;种子由 Seedance 自行生成。",
|
||||
),
|
||||
io.Autogrow.Input(
|
||||
"参考图片",
|
||||
optional=True,
|
||||
@@ -400,7 +412,6 @@ class SeedanceMultiModal(io.ComfyNode):
|
||||
gen_audio = _first(kwargs.get("生成音频"), "关闭") == "打开"
|
||||
web_search = _first(kwargs.get("联网搜索"), "关闭") == "打开"
|
||||
return_last = _first(kwargs.get("返回末帧图片"), "关闭") == "打开"
|
||||
seed = _first(kwargs.get("seed"), 0)
|
||||
|
||||
ref_images = cls._autogrow_values(kwargs, "参考图片", "参考图片", _MM_IMAGE_LIMIT)
|
||||
ref_videos = cls._autogrow_values(kwargs, "参考视频", "参考视频", _MM_VIDEO_LIMIT)
|
||||
@@ -448,23 +459,17 @@ class SeedanceMultiModal(io.ComfyNode):
|
||||
content = []
|
||||
base_url = get_base_url_by_route()
|
||||
|
||||
# 真人素材 ID(与参考图片共用当前模型的图片额度,优先级最高)
|
||||
# 真人素材 ID(与参考图片共用当前模型的图片额度)
|
||||
if has_element:
|
||||
for idx, eid in enumerate(element_ids, start=1):
|
||||
# 确保 element_id 格式正确
|
||||
asset_url = eid if eid.startswith("asset://") else f"asset://{eid}"
|
||||
# 第一个素材ID作为主体(subject),其余作为参考图片(reference_image)
|
||||
if idx == 1:
|
||||
role = "subject" if use_new_format else "reference_image"
|
||||
else:
|
||||
role = "reference_image"
|
||||
content.append({
|
||||
"type": "image_url",
|
||||
"image_url": {"url": asset_url},
|
||||
"role": role,
|
||||
"role": "reference_image",
|
||||
})
|
||||
role_label = "主体" if role == "subject" else "参考"
|
||||
print(f"[SeedanceMultiModal] 使用图片素材ID{idx}({role_label}) → {asset_url}")
|
||||
print(f"[SeedanceMultiModal] 使用图片素材ID{idx} → {asset_url}")
|
||||
|
||||
# 参考图片(2.5 最多 30 个独立槽位,用户自行选择连接哪几个)
|
||||
if has_image:
|
||||
@@ -517,12 +522,8 @@ class SeedanceMultiModal(io.ComfyNode):
|
||||
})
|
||||
print(f"[SeedanceMultiModal] 使用音频素材ID{idx} → {asset_url}")
|
||||
|
||||
# 文本提示词(放最后)
|
||||
if prompt:
|
||||
content.append({"type": "text", "text": prompt})
|
||||
|
||||
if not content:
|
||||
raise ValueError("content 为空,请至少提供参考图片、参考视频或提示词。")
|
||||
# 文本提示词:content 必须包含非空文本项,纯素材请求也要带上占位
|
||||
content.append({"type": "text", "text": prompt or " "})
|
||||
|
||||
# ── 构建请求体 ──────────────────────────────────────────────────────
|
||||
if use_new_format:
|
||||
@@ -541,15 +542,14 @@ class SeedanceMultiModal(io.ComfyNode):
|
||||
body = {
|
||||
"model": model,
|
||||
"content": ordered_content,
|
||||
"duration": duration if duration != -1 else 5,
|
||||
"duration": duration,
|
||||
"resolution": resolution,
|
||||
"ratio": ratio if ratio not in ("智能", "adaptive") else "16:9", # adaptive 为旧工作流兼容
|
||||
# adaptive 让模型跟随首帧或参考素材比例;旧工作流的「智能」同样映射到它
|
||||
"ratio": ratio if ratio and ratio not in ("智能", "adaptive") else "adaptive",
|
||||
"generate_audio": gen_audio,
|
||||
"watermark": False,
|
||||
"return_last_frame": return_last,
|
||||
}
|
||||
if seed != 0:
|
||||
body["seed"] = seed
|
||||
|
||||
print(f"[SeedanceMultiModal] 新格式请求体: model={model}, content_len={len(ordered_content)}, duration={body['duration']}, resolution={body['resolution']}")
|
||||
else:
|
||||
@@ -562,14 +562,11 @@ class SeedanceMultiModal(io.ComfyNode):
|
||||
|
||||
if ratio not in ("智能", "adaptive"): # adaptive 为旧工作流兼容
|
||||
metadata["ratio"] = ratio
|
||||
if duration != -1:
|
||||
metadata["duration"] = duration
|
||||
metadata["duration"] = duration
|
||||
if gen_audio:
|
||||
metadata["generate_audio"] = True
|
||||
if return_last:
|
||||
metadata["return_last_frame"] = True
|
||||
if seed != 0:
|
||||
metadata["seed"] = seed
|
||||
if web_search:
|
||||
metadata["tools"] = [{"type": "web_search"}]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user