faisalhr1997
commited on
Commit
•
8074f11
1
Parent(s):
c07abba
Upload SDXLAspectRatio.py
Browse files- SDXLAspectRatio.py +70 -0
SDXLAspectRatio.py
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# quick node to set SDXL-friendly aspect ratios in 1024^2
|
2 |
+
# by throttlekitty
|
3 |
+
|
4 |
+
class SDXLAspectRatio:
|
5 |
+
def __init__(self):
|
6 |
+
pass
|
7 |
+
|
8 |
+
@classmethod
|
9 |
+
def INPUT_TYPES(s):
|
10 |
+
return {
|
11 |
+
"required": {
|
12 |
+
"width": ("INT", {"default": 64, "min": 64, "max": 2048,}),
|
13 |
+
"height": ("INT", {"default": 64, "min": 64, "max": 2048}),
|
14 |
+
"aspectRatio": ([
|
15 |
+
"1:1 - 1024x1024 square",
|
16 |
+
"2:3 - 832x1216 portrait",
|
17 |
+
"3:4 - 896x1152 portrait",
|
18 |
+
"5:8 - 768x1216 portrait",
|
19 |
+
"9:16 - 768x1344 portrait",
|
20 |
+
"9:19 - 704x1472 portrait",
|
21 |
+
"9:21 - 640x1536 portrait",
|
22 |
+
"3:2 - 1216x832 landscape",
|
23 |
+
"4:3 - 1152x896 landscape",
|
24 |
+
"8:5 - 1216x768 landscape",
|
25 |
+
"16:9 - 1344x768 landscape",
|
26 |
+
"19:9 - 1472x704 landscape",
|
27 |
+
"21:9 - 1536x640 landscape"],)
|
28 |
+
}
|
29 |
+
}
|
30 |
+
RETURN_TYPES = ("INT", "INT")
|
31 |
+
RETURN_NAMES = ("Width", "Height")
|
32 |
+
FUNCTION = "SDXL_AspectRatio"
|
33 |
+
CATEGORY = "image"
|
34 |
+
|
35 |
+
def SDXL_AspectRatio(self, width, height, aspectRatio):
|
36 |
+
if aspectRatio == "1:1 - 1024x1024 square":
|
37 |
+
width, height = 1024, 1024
|
38 |
+
elif aspectRatio == "2:3 - 832x1216 portrait":
|
39 |
+
width, height = 832, 1216
|
40 |
+
elif aspectRatio == "3:4 - 896x1152 portrait":
|
41 |
+
width, height = 896, 1152
|
42 |
+
elif aspectRatio == "5:8 - 768x1216 portrait":
|
43 |
+
width, height = 768, 1216
|
44 |
+
elif aspectRatio == "9:16 - 768x1344 portrait":
|
45 |
+
width, height = 768, 1344
|
46 |
+
elif aspectRatio == "9:19 - 704x1472 portrait":
|
47 |
+
width, height = 704, 1472
|
48 |
+
elif aspectRatio == "9:21 - 640x1536 portrait":
|
49 |
+
width, height = 640, 1536
|
50 |
+
elif aspectRatio == "3:2 - 1216x832 landscape":
|
51 |
+
width, height = 1216, 832
|
52 |
+
elif aspectRatio == "4:3 - 1152x896 landscape":
|
53 |
+
width, height = 1152, 896
|
54 |
+
elif aspectRatio == "8:5 - 1216x768 landscape":
|
55 |
+
width, height = 1216, 768
|
56 |
+
elif aspectRatio == "16:9 - 1344x768 landscape":
|
57 |
+
width, height = 1344, 768
|
58 |
+
elif aspectRatio == "19:9 - 1472x704 landscape":
|
59 |
+
width, height = 1472, 704
|
60 |
+
elif aspectRatio == "21:9 - 1536x640 landscape":
|
61 |
+
width, height = 1536, 640
|
62 |
+
return(width, height)
|
63 |
+
|
64 |
+
|
65 |
+
NODE_CLASS_MAPPINGS = {
|
66 |
+
"SDXLAspectRatio": SDXLAspectRatio
|
67 |
+
}
|
68 |
+
NODE_DISPLAY_NAME_MAPPINGS = {
|
69 |
+
"SDXLAspectRatio": "SDXL Aspect Ratio"
|
70 |
+
}
|