[Bugfix] Fix Qwen-Image min-size normalization for tiny requests (#2637)
Signed-off-by: David Chen <530634352@qq.com>
This commit is contained in:
1 parent
956f53b278
commit
85d63c47f9
6 files changed
+65
-18
No files matched your search
@@ -0,0 +1,20 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
|
||||
"""Shared size normalization helpers for diffusion pipelines."""
|
||||
|
||||
|
||||
def normalize_min_aligned_size(height: int, width: int, alignment: int) -> tuple[int, int]:
|
||||
"""Clamp dimensions to the minimum valid aligned size.
|
||||
|
||||
This preserves floor-to-alignment behavior for normal requests while
|
||||
preventing very small dimensions from collapsing to zero after alignment.
|
||||
"""
|
||||
|
||||
alignment = int(alignment)
|
||||
if alignment <= 0:
|
||||
raise ValueError(f"Expected positive alignment, got {alignment}")
|
||||
|
||||
normalized_height = max(alignment, (int(height) // alignment) * alignment)
|
||||
normalized_width = max(alignment, (int(width) // alignment) * alignment)
|
||||
return normalized_height, normalized_width
|
||||
Reference in new issue
Block a user