-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathlatent_resolution_selector.py
90 lines (76 loc) · 3.85 KB
/
latent_resolution_selector.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import torch
import numpy as np
from nodes import EmptyLatentImage
class LatentResolutionSelector:
def __init__(self):
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"resolution_preset": ([
# SD 1.5 Resolutions - Square
"SD1.5 - Square - 512x512 (1:1)",
"SD1.5 - Square - 640x640 (1:1)",
"SD1.5 - Square - 768x768 (1:1)",
# SD 1.5 Resolutions - Landscape
"SD1.5 - Landscape - 640x480 (4:3)",
"SD1.5 - Landscape - 768x512 (3:2)",
"SD1.5 - Landscape - 704x384 (16:9)",
"SD1.5 - Landscape - 768x384 (2:1)",
# SD 1.5 Resolutions - Portrait
"SD1.5 - Portrait - 480x640 (3:4)",
"SD1.5 - Portrait - 512x768 (2:3)",
"SD1.5 - Portrait - 384x704 (9:16)",
"SD1.5 - Portrait - 384x768 (1:2)",
# SDXL Resolutions - Square
"SDXL - Square - 1024x1024 (1:1)",
"SDXL - Square - 1280x1280 (1:1)",
# SDXL Resolutions - Landscape
"SDXL - Landscape - 1024x768 (4:3)",
"SDXL - Landscape - 1152x864 (4:3)",
"SDXL - Landscape - 1280x960 (4:3)",
"SDXL - Landscape - 1152x768 (3:2)",
"SDXL - Landscape - 1344x896 (3:2)",
"SDXL - Landscape - 1344x768 (16:9)",
"SDXL - Landscape - 1344x576 (21:9)",
# SDXL Resolutions - Portrait
"SDXL - Portrait - 768x1024 (3:4)",
"SDXL - Portrait - 864x1152 (3:4)",
"SDXL - Portrait - 960x1280 (3:4)",
"SDXL - Portrait - 768x1152 (2:3)",
"SDXL - Portrait - 896x1344 (2:3)",
"SDXL - Portrait - 768x1344 (9:16)",
# FLUX High Resolutions - Square
"FLUX - Square - 1536x1536 (1:1)",
"FLUX - Square - 1920x1920 (1:1)",
# FLUX High Resolutions - Landscape
"FLUX - Landscape - 1536x1152 (4:3)",
"FLUX - Landscape - 1920x1440 (4:3)",
"FLUX - Landscape - 1536x1024 (3:2)",
"FLUX - Landscape - 1856x1088 (~16:9)",
"FLUX - Landscape - 1920x1280 (3:2)",
"FLUX - Landscape - 1920x1080 (16:9)",
"FLUX - Landscape - 1920x816 (21:9)",
# FLUX High Resolutions - Portrait
"FLUX - Portrait - 1152x1536 (3:4)",
"FLUX - Portrait - 1440x1920 (3:4)",
"FLUX - Portrait - 1024x1536 (2:3)",
"FLUX - Portrait - 1088x1856 (~16:9)",
"FLUX - Portrait - 1280x1920 (2:3)",
"FLUX - Portrait - 1080x1920 (9:16)",
"FLUX - Portrait - 816x1920 (21:9)"
],),
"batch_size": ("INT", {"default": 1, "min": 1, "max": 64})
}
}
RETURN_TYPES = ("LATENT",)
FUNCTION = "generate_latent"
CATEGORY = "Bjornulf"
def generate_latent(self, resolution_preset, batch_size=1):
# Extract dimensions from the preset string
resolution = resolution_preset.split(' - ')[2].split(' ')[0]
width, height = map(int, resolution.split('x'))
# Create empty latent image with the selected dimensions
latent = EmptyLatentImage().generate(width, height, batch_size)[0]
return (latent,)