TonyLianLong / stable-diffusion-xl-demo

A gradio web UI demo for Stable Diffusion XL 1.0, with refiner and MultiGPU support
https://colab.research.google.com/github/TonyLianLong/stable-diffusion-xl-demo/blob/main/Stable_Diffusion_XL_Demo.ipynb
267 stars 67 forks source link

[suggestion] add aspect ratio options #8

Open YuenSzeHong opened 1 year ago

YuenSzeHong commented 1 year ago

colab dropdown, just turn it to html

 # @param ["1:1", "4:1", "16:9", "5:2", "2:1", "7:4", "3:2", "8:7", "9:8", "8:9", "7:8", "2:3", "4:7", "1:2", "2:5", "1:3", "9:16"] {allow-input: true}

python code

aspect_ratio = "9:16"
max_pixel = 1024*1024
w, h = (int(e) for e in aspect_ratio.split(':'))
width, height = (round(math.sqrt(max_pixel * x / y) / 8) * 8 for x, y in ((w, h), (h, w)))

width and height can be the param of the param of the model

TonyLianLong commented 10 months ago

Great idea! Do you mind giving us a PR for this?