File tree Expand file tree Collapse file tree 1 file changed +39
-4
lines changed
src/diffusers/pipelines/prx Expand file tree Collapse file tree 1 file changed +39
-4
lines changed Original file line number Diff line number Diff line change 6969 "2.0" : [704 , 352 ],
7070}
7171
72+ ASPECT_RATIO_1024_BIN = {
73+ "0.49" : [704 , 1440 ],
74+ "0.52" : [736 , 1408 ],
75+ "0.53" : [736 , 1376 ],
76+ "0.57" : [768 , 1344 ],
77+ "0.59" : [768 , 1312 ],
78+ "0.62" : [800 , 1280 ],
79+ "0.67" : [832 , 1248 ],
80+ "0.68" : [832 , 1216 ],
81+ "0.78" : [896 , 1152 ],
82+ "0.83" : [928 , 1120 ],
83+ "0.94" : [992 , 1056 ],
84+ "1.0" : [1024 , 1024 ],
85+ "1.06" : [1056 , 992 ],
86+ "1.13" : [1088 , 960 ],
87+ "1.21" : [1120 , 928 ],
88+ "1.29" : [1152 , 896 ],
89+ "1.37" : [1184 , 864 ],
90+ "1.46" : [1216 , 832 ],
91+ "1.5" : [1248 , 832 ],
92+ "1.71" : [1312 , 768 ],
93+ "1.75" : [1344 , 768 ],
94+ "1.87" : [1376 , 736 ],
95+ "1.91" : [1408 , 736 ],
96+ "2.05" : [1440 , 704 ],
97+ }
98+
99+ ASPECT_RATIO_BINS = {
100+ 256 : ASPECT_RATIO_256_BIN ,
101+ 512 : ASPECT_RATIO_512_BIN ,
102+ 1024 : ASPECT_RATIO_1024_BIN ,
103+ }
104+
72105logger = logging .get_logger (__name__ )
73106
74107
@@ -600,10 +633,12 @@ def __call__(
600633 "Resolution binning requires a VAE with image_processor, but VAE is not available. "
601634 "Set use_resolution_binning=False or provide a VAE."
602635 )
603- if self .default_sample_size <= 256 :
604- aspect_ratio_bin = ASPECT_RATIO_256_BIN
605- else :
606- aspect_ratio_bin = ASPECT_RATIO_512_BIN
636+ if self .default_sample_size not in ASPECT_RATIO_BINS :
637+ raise ValueError (
638+ f"Resolution binning is only supported for default_sample_size in { list (ASPECT_RATIO_BINS .keys ())} , "
639+ f"but got { self .default_sample_size } . Set use_resolution_binning=False to disable aspect ratio binning."
640+ )
641+ aspect_ratio_bin = ASPECT_RATIO_BINS [self .default_sample_size ]
607642
608643 # Store original dimensions
609644 orig_height , orig_width = height , width
You can’t perform that action at this time.
0 commit comments