Skip to content

Commit 4af9a47

Browse files
authored
[Partner Nodes] fix: add runtime check for SeeDance2 image inputs (Comfy-Org#14152)
Signed-off-by: bigcat88 <bigcat88@icloud.com>
1 parent be06873 commit 4af9a47

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

comfy_api_nodes/nodes_bytedance.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
ApiEndpoint,
4545
download_url_to_image_tensor,
4646
download_url_to_video_output,
47+
downscale_image_tensor_by_max_side,
4748
downscale_video_to_max_pixels,
4849
get_number_of_images,
4950
image_tensor_pair_to_batch,
@@ -122,6 +123,14 @@ def _validate_ref_video_pixels(video: Input.Video, model_id: str, resolution: st
122123
)
123124

124125

126+
def _prepare_seedance_image(image: Input.Image) -> Input.Image:
127+
"""Auto-downscale a Seedance image input to the per-side limits, then validate it."""
128+
validate_image_aspect_ratio(image, (2, 5), (5, 2), strict=False) # 0.4 to 2.5
129+
image = downscale_image_tensor_by_max_side(image, max_side=6000)
130+
validate_image_dimensions(image, min_width=300, min_height=300, max_width=6000, max_height=6000)
131+
return image
132+
133+
125134
async def _resolve_reference_assets(
126135
cls: type[IO.ComfyNode],
127136
asset_ids: list[str],
@@ -1781,6 +1790,11 @@ async def execute(
17811790
if last_frame is not None and last_frame_asset_id:
17821791
raise ValueError("Provide only one of last_frame or last_frame_asset_id, not both.")
17831792

1793+
if first_frame is not None:
1794+
first_frame = _prepare_seedance_image(first_frame)
1795+
if last_frame is not None:
1796+
last_frame = _prepare_seedance_image(last_frame)
1797+
17841798
asset_ids_to_resolve = [a for a in (first_frame_asset_id, last_frame_asset_id) if a]
17851799
image_assets: dict[str, str] = {}
17861800
if asset_ids_to_resolve:
@@ -1887,7 +1901,7 @@ def _seedance2_reference_inputs(resolutions: list[str], default_ratio: str = "16
18871901
),
18881902
IO.Boolean.Input(
18891903
"auto_downscale",
1890-
default=False,
1904+
default=True,
18911905
optional=True,
18921906
tooltip="Automatically downscale reference videos that exceed the model's pixel budget "
18931907
"for the selected resolution. Aspect ratio is preserved; videos already within limits are untouched.",
@@ -2055,6 +2069,9 @@ async def execute(
20552069
f"(audios={len(reference_audios)}, audio assets={len(reference_audio_assets)}). Maximum is 3."
20562070
)
20572071

2072+
for key in reference_images:
2073+
reference_images[key] = _prepare_seedance_image(reference_images[key])
2074+
20582075
model_id = SEEDANCE_MODELS[model["model"]]
20592076
has_video_input = total_videos > 0
20602077

0 commit comments

Comments
 (0)