Skip to content

[SANA-Sprint] remove used multi-scale bin #11131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 3 additions & 56 deletions src/diffusers/pipelines/sana/pipeline_sana_sprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@
)
from ...utils.torch_utils import randn_tensor
from ..pipeline_utils import DiffusionPipeline
from ..pixart_alpha.pipeline_pixart_alpha import (
ASPECT_RATIO_512_BIN,
ASPECT_RATIO_1024_BIN,
)
from ..pixart_alpha.pipeline_pixart_sigma import ASPECT_RATIO_2048_BIN
from ..pixart_alpha.pipeline_pixart_alpha import ASPECT_RATIO_1024_BIN
from .pipeline_output import SanaPipelineOutput


Expand All @@ -64,49 +60,6 @@
import ftfy


ASPECT_RATIO_4096_BIN = {
"0.25": [2048.0, 8192.0],
"0.26": [2048.0, 7936.0],
"0.27": [2048.0, 7680.0],
"0.28": [2048.0, 7424.0],
"0.32": [2304.0, 7168.0],
"0.33": [2304.0, 6912.0],
"0.35": [2304.0, 6656.0],
"0.4": [2560.0, 6400.0],
"0.42": [2560.0, 6144.0],
"0.48": [2816.0, 5888.0],
"0.5": [2816.0, 5632.0],
"0.52": [2816.0, 5376.0],
"0.57": [3072.0, 5376.0],
"0.6": [3072.0, 5120.0],
"0.68": [3328.0, 4864.0],
"0.72": [3328.0, 4608.0],
"0.78": [3584.0, 4608.0],
"0.82": [3584.0, 4352.0],
"0.88": [3840.0, 4352.0],
"0.94": [3840.0, 4096.0],
"1.0": [4096.0, 4096.0],
"1.07": [4096.0, 3840.0],
"1.13": [4352.0, 3840.0],
"1.21": [4352.0, 3584.0],
"1.29": [4608.0, 3584.0],
"1.38": [4608.0, 3328.0],
"1.46": [4864.0, 3328.0],
"1.67": [5120.0, 3072.0],
"1.75": [5376.0, 3072.0],
"2.0": [5632.0, 2816.0],
"2.09": [5888.0, 2816.0],
"2.4": [6144.0, 2560.0],
"2.5": [6400.0, 2560.0],
"2.89": [6656.0, 2304.0],
"3.0": [6912.0, 2304.0],
"3.11": [7168.0, 2304.0],
"3.62": [7424.0, 2048.0],
"3.75": [7680.0, 2048.0],
"3.88": [7936.0, 2048.0],
"4.0": [8192.0, 2048.0],
}

EXAMPLE_DOC_STRING = """
Examples:
```py
Expand All @@ -118,7 +71,7 @@
... )
>>> pipe.to("cuda")

>>> image = pipe(prompt='a cyberpunk cat with a neon sign that says "Sana"')[0]
>>> image = pipe(prompt='a tiny astronaut hatching from an egg on the moon')[0]
>>> image[0].save("output.png")
```
"""
Expand Down Expand Up @@ -762,14 +715,8 @@ def __call__(

# 1. Check inputs. Raise error if not correct
if use_resolution_binning:
if self.transformer.config.sample_size == 128:
aspect_ratio_bin = ASPECT_RATIO_4096_BIN
elif self.transformer.config.sample_size == 64:
aspect_ratio_bin = ASPECT_RATIO_2048_BIN
elif self.transformer.config.sample_size == 32:
if self.transformer.config.sample_size == 32:
aspect_ratio_bin = ASPECT_RATIO_1024_BIN
elif self.transformer.config.sample_size == 16:
aspect_ratio_bin = ASPECT_RATIO_512_BIN
else:
raise ValueError("Invalid sample size")
orig_height, orig_width = height, width
Expand Down