|
2 | 2 | from typing import Any, Callable, Optional, TypeVar |
3 | 3 | import torch |
4 | 4 | from typing_extensions import override |
5 | | -from comfy_api_nodes.util.validation_utils import ( |
6 | | - get_image_dimensions, |
7 | | - validate_image_dimensions, |
8 | | -) |
9 | | - |
| 5 | +from comfy_api_nodes.util.validation_utils import validate_image_dimensions |
10 | 6 |
|
11 | 7 | from comfy_api_nodes.apis import ( |
12 | 8 | MoonvalleyTextToVideoRequest, |
@@ -132,47 +128,6 @@ def validate_prompts( |
132 | 128 | return True |
133 | 129 |
|
134 | 130 |
|
135 | | -def validate_input_media(width, height, with_frame_conditioning, num_frames_in=None): |
136 | | - # inference validation |
137 | | - # T = num_frames |
138 | | - # in all cases, the following must be true: T divisible by 16 and H,W by 8. in addition... |
139 | | - # with image conditioning: H*W must be divisible by 8192 |
140 | | - # without image conditioning: T divisible by 32 |
141 | | - if num_frames_in and not num_frames_in % 16 == 0: |
142 | | - return False, ("The input video total frame count must be divisible by 16!") |
143 | | - |
144 | | - if height % 8 != 0 or width % 8 != 0: |
145 | | - return False, ( |
146 | | - f"Height ({height}) and width ({width}) must be " "divisible by 8" |
147 | | - ) |
148 | | - |
149 | | - if with_frame_conditioning: |
150 | | - if (height * width) % 8192 != 0: |
151 | | - return False, ( |
152 | | - f"Height * width ({height * width}) must be " |
153 | | - "divisible by 8192 for frame conditioning" |
154 | | - ) |
155 | | - else: |
156 | | - if num_frames_in and not num_frames_in % 32 == 0: |
157 | | - return False, ("The input video total frame count must be divisible by 32!") |
158 | | - |
159 | | - |
160 | | -def validate_input_image( |
161 | | - image: torch.Tensor, with_frame_conditioning: bool = False |
162 | | -) -> None: |
163 | | - """ |
164 | | - Validates the input image adheres to the expectations of the API: |
165 | | - - The image resolution should not be less than 300*300px |
166 | | - - The aspect ratio of the image should be between 1:2.5 ~ 2.5:1 |
167 | | -
|
168 | | - """ |
169 | | - height, width = get_image_dimensions(image) |
170 | | - validate_input_media(width, height, with_frame_conditioning) |
171 | | - validate_image_dimensions( |
172 | | - image, min_width=300, min_height=300, max_height=MAX_HEIGHT, max_width=MAX_WIDTH |
173 | | - ) |
174 | | - |
175 | | - |
176 | 131 | def validate_video_to_video_input(video: VideoInput) -> VideoInput: |
177 | 132 | """ |
178 | 133 | Validates and processes video input for Moonvalley Video-to-Video generation. |
@@ -499,7 +454,7 @@ async def execute( |
499 | 454 | seed: int, |
500 | 455 | steps: int, |
501 | 456 | ) -> comfy_io.NodeOutput: |
502 | | - validate_input_image(image, True) |
| 457 | + validate_image_dimensions(image, min_width=300, min_height=300, max_height=MAX_HEIGHT, max_width=MAX_WIDTH) |
503 | 458 | validate_prompts(prompt, negative_prompt, MOONVALLEY_MAREY_MAX_PROMPT_LENGTH) |
504 | 459 | width_height = parse_width_height_from_res(resolution) |
505 | 460 |
|
|
0 commit comments