-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmeta_consts.py
131 lines (103 loc) · 3.55 KB
/
meta_consts.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
from enum import auto
from strenum import StrEnum
class MODEL_STYLE(StrEnum):
"""An enum of all the model styles."""
generalist = auto()
anime = auto()
furry = auto()
artistic = auto()
other = auto()
realistic = auto()
class CONTROLNET_STYLE(StrEnum):
control_seg = auto()
control_scribble = auto()
control_fakescribbles = auto()
control_openpose = auto()
control_normal = auto()
control_mlsd = auto()
control_hough = auto()
control_hed = auto()
control_canny = auto()
control_depth = auto()
control_qr = auto()
control_qr_xl = auto()
KNOWN_TAGS = [
"anime",
"manga",
"cyberpunk",
"tv show",
"booru",
"retro",
"character",
"hentai",
"scenes",
"low poly",
"cg",
"sketch",
"high resolution",
"landscapes",
"comic",
"cartoon",
"painting",
"game",
]
class MODEL_REFERENCE_CATEGORY(StrEnum):
"""The categories of model reference entries."""
blip = auto()
clip = auto()
codeformer = auto()
controlnet = auto()
esrgan = auto()
gfpgan = auto()
safety_checker = auto()
stable_diffusion = auto()
miscellaneous = auto()
class MODEL_PURPOSE(StrEnum):
image_generation = auto()
"""The model is for image generation."""
controlnet = auto()
"""The model is a controlnet."""
clip = auto()
"""The model is a CLIP model."""
blip = auto()
"""The model is a BLIP model."""
post_processor = auto()
"""The model is a post processor (after image generation) of some variety."""
miscellaneous = auto()
class STABLE_DIFFUSION_BASELINE_CATEGORY(StrEnum):
"""An enum of all the image generation baselines."""
stable_diffusion_1 = auto()
stable_diffusion_2_768 = auto()
stable_diffusion_2_512 = auto()
stable_diffusion_xl = auto()
stable_cascade = auto()
flux_1 = auto() # TODO: Extract flux and create "IMAGE_GENERATION_BASELINE_CATEGORY" due to name inconsistency
MODEL_PURPOSE_LOOKUP: dict[MODEL_REFERENCE_CATEGORY, MODEL_PURPOSE] = {
MODEL_REFERENCE_CATEGORY.clip: MODEL_PURPOSE.clip,
MODEL_REFERENCE_CATEGORY.blip: MODEL_PURPOSE.blip,
MODEL_REFERENCE_CATEGORY.codeformer: MODEL_PURPOSE.post_processor,
MODEL_REFERENCE_CATEGORY.controlnet: MODEL_PURPOSE.controlnet,
MODEL_REFERENCE_CATEGORY.esrgan: MODEL_PURPOSE.post_processor,
MODEL_REFERENCE_CATEGORY.gfpgan: MODEL_PURPOSE.post_processor,
MODEL_REFERENCE_CATEGORY.safety_checker: MODEL_PURPOSE.post_processor,
MODEL_REFERENCE_CATEGORY.stable_diffusion: MODEL_PURPOSE.image_generation,
MODEL_REFERENCE_CATEGORY.miscellaneous: MODEL_PURPOSE.miscellaneous,
}
STABLE_DIFFUSION_BASELINE_NATIVE_RESOLUTION_LOOKUP: dict[STABLE_DIFFUSION_BASELINE_CATEGORY, int] = {
STABLE_DIFFUSION_BASELINE_CATEGORY.stable_diffusion_1: 512,
STABLE_DIFFUSION_BASELINE_CATEGORY.stable_diffusion_2_768: 768,
STABLE_DIFFUSION_BASELINE_CATEGORY.stable_diffusion_2_512: 512,
STABLE_DIFFUSION_BASELINE_CATEGORY.stable_diffusion_xl: 1024,
STABLE_DIFFUSION_BASELINE_CATEGORY.stable_cascade: 1024,
STABLE_DIFFUSION_BASELINE_CATEGORY.flux_1: 1024,
}
"""The single-side preferred resolution for each known stable diffusion baseline."""
def get_baseline_native_resolution(baseline: STABLE_DIFFUSION_BASELINE_CATEGORY) -> int:
"""
Get the native resolution of a stable diffusion baseline.
Args:
baseline: The stable diffusion baseline.
Returns:
The native resolution of the baseline.
"""
return STABLE_DIFFUSION_BASELINE_NATIVE_RESOLUTION_LOOKUP[baseline]