-
Notifications
You must be signed in to change notification settings - Fork 26
/
__init__.py
339 lines (246 loc) · 10.5 KB
/
__init__.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
import inspect
import json
import os
import folder_paths
import importlib
NODE_CLASS_MAPPINGS = {
}
NODE_DISPLAY_NAME_MAPPINGS = {
}
MAX_RESOLUTION = 16384
AUTHOR_NAME = "MinusZone"
CATEGORY_NAME = f"{AUTHOR_NAME} - Kolors"
folder_paths.add_model_folder_path(
"LLM", os.path.join(folder_paths.models_dir, "LLM"))
class MZ_ChatGLM3Loader:
@classmethod
def INPUT_TYPES(s):
# from .mz_kolors_utils import Utils
# llm_dir = os.path.join(Utils.get_models_path(), "LLM")
# print("llm_dir:", llm_dir)
llm_models = folder_paths.get_filename_list("LLM")
# 筛选safetensors结尾的文件
llm_models = [
model for model in llm_models if model.endswith("safetensors")]
return {"required": {
"chatglm3_checkpoint": (llm_models,),
}}
RETURN_TYPES = ("CHATGLM3MODEL",)
RETURN_NAMES = ("chatglm3_model",)
FUNCTION = "load_chatglm3"
CATEGORY = CATEGORY_NAME
def load_chatglm3(self, **kwargs):
from . import mz_kolors_core
importlib.reload(mz_kolors_core)
return mz_kolors_core.MZ_ChatGLM3Loader_call(kwargs)
NODE_CLASS_MAPPINGS["MZ_ChatGLM3Loader"] = MZ_ChatGLM3Loader
NODE_DISPLAY_NAME_MAPPINGS["MZ_ChatGLM3Loader"] = f"{AUTHOR_NAME} - ChatGLM3Loader"
class MZ_ChatGLM3TextEncodeV2:
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"chatglm3_model": ("CHATGLM3MODEL", ),
"text": ("STRING", {"multiline": True, "dynamicPrompts": True}),
}
}
RETURN_TYPES = ("CONDITIONING",)
FUNCTION = "encode"
CATEGORY = CATEGORY_NAME
def encode(self, **kwargs):
from . import mz_kolors_core
importlib.reload(mz_kolors_core)
return mz_kolors_core.MZ_ChatGLM3TextEncodeV2_call(kwargs)
NODE_CLASS_MAPPINGS["MZ_ChatGLM3_V2"] = MZ_ChatGLM3TextEncodeV2
NODE_DISPLAY_NAME_MAPPINGS[
"MZ_ChatGLM3_V2"] = f"{AUTHOR_NAME} - ChatGLM3TextEncodeV2"
class MZ_ChatGLM3Embeds2Conditioning:
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"kolors_embeds": ("KOLORS_EMBEDS", ),
"width": ("INT", {"default": 1024.0, "min": 0, "max": MAX_RESOLUTION}),
"height": ("INT", {"default": 1024.0, "min": 0, "max": MAX_RESOLUTION}),
"crop_w": ("INT", {"default": 0, "min": 0, "max": MAX_RESOLUTION}),
"crop_h": ("INT", {"default": 0, "min": 0, "max": MAX_RESOLUTION}),
"target_width": ("INT", {"default": 1024.0, "min": 0, "max": MAX_RESOLUTION}),
"target_height": ("INT", {"default": 1024.0, "min": 0, "max": MAX_RESOLUTION}),
}
}
RETURN_TYPES = ("CONDITIONING", "CONDITIONING",)
RETURN_NAMES = ("positive", "negative",)
FUNCTION = "embeds2conditioning"
CATEGORY = CATEGORY_NAME
def embeds2conditioning(self, **kwargs):
from . import mz_kolors_core
importlib.reload(mz_kolors_core)
return mz_kolors_core.MZ_ChatGLM3Embeds2Conditioning_call(kwargs)
NODE_CLASS_MAPPINGS["MZ_ChatGLM3Embeds2Conditioning"] = MZ_ChatGLM3Embeds2Conditioning
NODE_DISPLAY_NAME_MAPPINGS[
"MZ_ChatGLM3Embeds2Conditioning"] = f"{AUTHOR_NAME} - ChatGLM3Embeds2Conditioning"
# for 2048 resolution
class MZ_ChatGLM3TextEncodeAdvanceV2:
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"chatglm3_model": ("CHATGLM3MODEL", ),
"text": ("STRING", {"multiline": True, "dynamicPrompts": True}),
"width": ("INT", {"default": 1024.0, "min": 0, "max": MAX_RESOLUTION}),
"height": ("INT", {"default": 1024.0, "min": 0, "max": MAX_RESOLUTION}),
"crop_w": ("INT", {"default": 0, "min": 0, "max": MAX_RESOLUTION}),
"crop_h": ("INT", {"default": 0, "min": 0, "max": MAX_RESOLUTION}),
"target_width": ("INT", {"default": 1024.0, "min": 0, "max": MAX_RESOLUTION}),
"target_height": ("INT", {"default": 1024.0, "min": 0, "max": MAX_RESOLUTION}),
}
}
RETURN_TYPES = ("CONDITIONING",)
FUNCTION = "encode"
CATEGORY = CATEGORY_NAME
def encode(self, **kwargs):
from . import mz_kolors_core
importlib.reload(mz_kolors_core)
return mz_kolors_core.MZ_ChatGLM3TextEncodeV2_call(kwargs)
NODE_CLASS_MAPPINGS["MZ_ChatGLM3_Advance_V2"] = MZ_ChatGLM3TextEncodeAdvanceV2
NODE_DISPLAY_NAME_MAPPINGS[
"MZ_ChatGLM3_Advance_V2"] = f"{AUTHOR_NAME} - ChatGLM3TextEncodeAdvanceV2"
class MZ_KolorsCheckpointLoaderSimple():
@classmethod
def INPUT_TYPES(s):
return {"required": {"ckpt_name": (folder_paths.get_filename_list("checkpoints"), ),
}}
RETURN_TYPES = ("MODEL", "VAE")
FUNCTION = "load_checkpoint"
CATEGORY = CATEGORY_NAME
def load_checkpoint(self, **kwargs):
from . import mz_kolors_core
importlib.reload(mz_kolors_core)
return mz_kolors_core.MZ_KolorsCheckpointLoaderSimple_call(kwargs)
NODE_CLASS_MAPPINGS["MZ_KolorsCheckpointLoaderSimple"] = MZ_KolorsCheckpointLoaderSimple
NODE_DISPLAY_NAME_MAPPINGS[
"MZ_KolorsCheckpointLoaderSimple"] = f"{AUTHOR_NAME} - KolorsCheckpointLoaderSimple"
class MZ_KolorsControlNetLoader:
@classmethod
def INPUT_TYPES(s):
return {"required": {
"control_net_name": (folder_paths.get_filename_list("controlnet"), ),
# "seed": ("INT", {"default": 0, "min": 0, "max": 1000000}),
}}
RETURN_TYPES = ("CONTROL_NET",)
RETURN_NAMES = ("ControlNet",)
FUNCTION = "load_controlnet"
CATEGORY = CATEGORY_NAME
def load_controlnet(self, **kwargs):
from . import mz_kolors_core
importlib.reload(mz_kolors_core)
return mz_kolors_core.MZ_KolorsControlNetLoader_call(kwargs)
NODE_CLASS_MAPPINGS["MZ_KolorsControlNetLoader"] = MZ_KolorsControlNetLoader
NODE_DISPLAY_NAME_MAPPINGS[
"MZ_KolorsControlNetLoader"] = f"{AUTHOR_NAME} - KolorsControlNetLoader"
class MZ_KolorsUNETLoaderV2():
@classmethod
def INPUT_TYPES(s):
return {"required": {
"unet_name": (folder_paths.get_filename_list("unet"), ),
}}
RETURN_TYPES = ("MODEL",)
RETURN_NAMES = ("model",)
FUNCTION = "load_unet"
CATEGORY = CATEGORY_NAME
def load_unet(self, **kwargs):
from . import mz_kolors_core
importlib.reload(mz_kolors_core)
return mz_kolors_core.MZ_KolorsUNETLoaderV2_call(kwargs)
NODE_CLASS_MAPPINGS["MZ_KolorsUNETLoaderV2"] = MZ_KolorsUNETLoaderV2
NODE_DISPLAY_NAME_MAPPINGS[
"MZ_KolorsUNETLoaderV2"] = f"{AUTHOR_NAME} - KolorsUNETLoaderV2"
class MZ_KolorsControlNetPatch:
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"control_net": ("CONTROL_NET", ),
"model": ("MODEL", ),
}
}
RETURN_TYPES = ("CONTROL_NET",)
FUNCTION = "start"
CATEGORY = CATEGORY_NAME
def start(self, **kwargs):
from . import mz_kolors_core
importlib.reload(mz_kolors_core)
return mz_kolors_core.MZ_KolorsControlNetPatch_call(kwargs)
NODE_CLASS_MAPPINGS["MZ_KolorsControlNetPatch"] = MZ_KolorsControlNetPatch
NODE_DISPLAY_NAME_MAPPINGS[
"MZ_KolorsControlNetPatch"] = f"{AUTHOR_NAME} - KolorsControlNetPatch"
class MZ_KolorsCLIPVisionLoader:
@classmethod
def INPUT_TYPES(s):
return {"required": {"clip_name": (folder_paths.get_filename_list("clip_vision"), ),
}}
RETURN_TYPES = ("CLIP_VISION",)
FUNCTION = "load_clip"
CATEGORY = CATEGORY_NAME + "/Legacy"
def load_clip(self, **kwargs):
from . import mz_kolors_core
importlib.reload(mz_kolors_core)
return mz_kolors_core.MZ_KolorsCLIPVisionLoader_call(kwargs)
NODE_CLASS_MAPPINGS["MZ_KolorsCLIPVisionLoader"] = MZ_KolorsCLIPVisionLoader
NODE_DISPLAY_NAME_MAPPINGS["MZ_KolorsCLIPVisionLoader"] = f"{AUTHOR_NAME} - KolorsCLIPVisionLoader - Legacy"
class MZ_ApplySDXLSamplingSettings():
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"model": ("MODEL", ),
}
}
RETURN_TYPES = ("MODEL", )
FUNCTION = "apply_sampling_settings"
CATEGORY = CATEGORY_NAME
def apply_sampling_settings(self, **kwargs):
from . import mz_kolors_core
importlib.reload(mz_kolors_core)
return mz_kolors_core.MZ_ApplySDXLSamplingSettings_call(kwargs)
NODE_CLASS_MAPPINGS["MZ_ApplySDXLSamplingSettings"] = MZ_ApplySDXLSamplingSettings
NODE_DISPLAY_NAME_MAPPINGS[
"MZ_ApplySDXLSamplingSettings"] = f"{AUTHOR_NAME} - ApplySDXLSamplingSettings"
class MZ_ApplyCUDAGenerator():
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"model": ("MODEL", ),
}
}
RETURN_TYPES = ("MODEL", )
FUNCTION = "apply_cuda_generator"
CATEGORY = CATEGORY_NAME
def apply_cuda_generator(self, **kwargs):
from . import mz_kolors_core
importlib.reload(mz_kolors_core)
return mz_kolors_core.MZ_ApplyCUDAGenerator_call(kwargs)
NODE_CLASS_MAPPINGS["MZ_ApplyCUDAGenerator"] = MZ_ApplyCUDAGenerator
NODE_DISPLAY_NAME_MAPPINGS[
"MZ_ApplyCUDAGenerator"] = f"{AUTHOR_NAME} - ApplyCUDAGenerator"
from .ComfyUI_IPAdapter_plus.IPAdapterPlus import IPAdapterAdvanced, IPAdapterModelLoader, IPAdapterInsightFaceLoader, IPAdapterFaceID
IPAdapterModelLoader.CATEGORY = CATEGORY_NAME + "/IPAdapter"
NODE_CLASS_MAPPINGS["MZ_IPAdapterModelLoaderKolors"] = IPAdapterModelLoader
NODE_DISPLAY_NAME_MAPPINGS[
"MZ_IPAdapterModelLoaderKolors"] = f"IPAdapterModelLoader(kolors) - Legacy"
IPAdapterAdvanced.CATEGORY = CATEGORY_NAME + "/IPAdapter"
NODE_CLASS_MAPPINGS["MZ_IPAdapterAdvancedKolors"] = IPAdapterAdvanced
NODE_DISPLAY_NAME_MAPPINGS[
"MZ_IPAdapterAdvancedKolors"] = f"IPAdapterAdvanced(kolors) - Legacy"
IPAdapterInsightFaceLoader.CATEGORY = CATEGORY_NAME + "/IPAdapter"
NODE_CLASS_MAPPINGS["MZ_IPAdapterInsightFaceLoader"] = IPAdapterInsightFaceLoader
NODE_DISPLAY_NAME_MAPPINGS[
"MZ_IPAdapterInsightFaceLoader"] = f"IPAdapterInsightFaceLoader(kolors) - Legacy"
IPAdapterFaceID.CATEGORY = CATEGORY_NAME + "/IPAdapter"
NODE_CLASS_MAPPINGS["MZ_IPAdapterFaceID"] = IPAdapterFaceID
NODE_DISPLAY_NAME_MAPPINGS[
"MZ_IPAdapterFaceID"] = f"IPAdapterFaceID(kolors) - Legacy"
from . import mz_kolors_legacy
NODE_CLASS_MAPPINGS.update(mz_kolors_legacy.NODE_CLASS_MAPPINGS)
NODE_DISPLAY_NAME_MAPPINGS.update(mz_kolors_legacy.NODE_DISPLAY_NAME_MAPPINGS)