forked from ClownsharkBatwing/RES4LYF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__init__.py
370 lines (285 loc) · 14.9 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
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
from . import legacy_sampler_rk
from . import legacy_samplers
from . import rk_sampler
from . import samplers
from . import samplers_extensions
from . import samplers_tiled
from . import loaders
from . import sigmas
from . import latents
from . import latent_images
from . import conditioning
from . import images
from . import models
from . import helper_sigma_preview_image_preproc
from . import nodes_misc
from .res4lyf import init, get_ext_dir
import torch
import os
import shutil
import sys
#torch.use_deterministic_algorithms(True)
#torch.backends.cudnn.deterministic = True
#torch.backends.cudnn.benchmark = False
flags = {
"test_samplers": False,
"beta_samplers": False,
}
try:
from . import test_samplers
flags["test_samplers"] = True
print("Importing test_samplers.py")
except ImportError:
pass
try:
from . import rk_sampler_beta
flags["beta_samplers"] = True
print("Importing rk_sampler_beta.py")
except ImportError:
pass
res4lyf.init()
discard_penultimate_sigma_samplers = set((
))
def add_samplers():
from comfy.samplers import KSampler, k_diffusion_sampling
if hasattr(KSampler, "DISCARD_PENULTIMATE_SIGMA_SAMPLERS"):
KSampler.DISCARD_PENULTIMATE_SIGMA_SAMPLERS |= discard_penultimate_sigma_samplers
added = 0
for sampler in extra_samplers: #getattr(self, "sample_{}".format(extra_samplers))
if sampler not in KSampler.SAMPLERS:
try:
idx = KSampler.SAMPLERS.index("uni_pc_bh2") # *should* be last item in samplers list
KSampler.SAMPLERS.insert(idx+1, sampler) # add custom samplers (presumably) to end of list
setattr(k_diffusion_sampling, "sample_{}".format(sampler), extra_samplers[sampler])
added += 1
except ValueError as _err:
pass
if added > 0:
import importlib
importlib.reload(k_diffusion_sampling)
extra_samplers = {
"res_2m": rk_sampler.sample_res_2m,
"res_2s": rk_sampler.sample_res_2s,
"res_3s": rk_sampler.sample_res_3s,
"res_5s": rk_sampler.sample_res_5s,
"res_6s": rk_sampler.sample_res_6s,
"res_2m_sde": rk_sampler.sample_res_2m_sde,
"res_2s_sde": rk_sampler.sample_res_2s_sde,
"res_3s_sde": rk_sampler.sample_res_3s_sde,
"res_5s_sde": rk_sampler.sample_res_5s_sde,
"res_6s_sde": rk_sampler.sample_res_6s_sde,
"deis_2m": rk_sampler.sample_deis_2m,
"deis_3m": rk_sampler.sample_deis_3m,
"deis_4m": rk_sampler.sample_deis_4m,
"deis_2m_sde": rk_sampler.sample_deis_2m_sde,
"deis_3m_sde": rk_sampler.sample_deis_3m_sde,
"deis_4m_sde": rk_sampler.sample_deis_4m_sde,
"rk": rk_sampler.sample_rk,
"legacy_rk": legacy_sampler_rk.legacy_sample_rk,
}
extra_samplers = dict(reversed(extra_samplers.items()))
NODE_CLASS_MAPPINGS = {
"Legacy_ClownSampler": legacy_samplers.Legacy_SamplerRK,
"Legacy_SharkSampler": legacy_samplers.Legacy_SharkSampler,
"Legacy_ClownsharKSampler": legacy_samplers.Legacy_ClownsharKSampler,
"Legacy_ClownsharKSamplerGuides": legacy_samplers.Legacy_ClownsharKSamplerGuides,
"ClownSampler": samplers.ClownSampler,
"ClownSamplerAdvanced": samplers.ClownSamplerAdvanced,
"SharkSampler": samplers.SharkSampler,
"ClownsharKSampler": samplers.ClownsharKSampler,
"ClownsharKSamplerGuides": samplers_extensions.ClownsharKSamplerGuides,
"ClownsharKSamplerGuide": samplers_extensions.ClownsharKSamplerGuide,
"ClownsharKSamplerGuides_Beta": samplers_extensions.ClownsharKSamplerGuides_Beta,
"ClownsharKSamplerGuide_Beta": samplers_extensions.ClownsharKSamplerGuide_Beta,
"ClownInpaint": samplers_extensions.ClownInpaint,
"ClownInpaintSimple": samplers_extensions.ClownInpaintSimple,
"ClownsharKSamplerOptions": samplers_extensions.ClownsharKSamplerOptions,
"ClownsharKSamplerOptions_SDE_Noise": samplers_extensions.ClownsharKSamplerOptions_SDE_Noise,
"ClownsharkSamplerOptions_FrameWeights": samplers_extensions.ClownsharKSamplerOptions_FrameWeights,
"ClownsharKSamplerAutomation": samplers_extensions.ClownsharKSamplerAutomation,
"ClownsharKSamplerAutomation_Beta": samplers_extensions.ClownsharKSamplerAutomation_Beta,
"ClownsharKSamplerAutomation_Advanced": samplers_extensions.ClownsharKSamplerAutomation_Advanced,
"UltraSharkSampler": samplers.UltraSharkSampler,
"UltraSharkSampler Tiled": samplers_tiled.UltraSharkSampler_Tiled,
"SamplerOptions_TimestepScaling": samplers_extensions.SamplerOptions_TimestepScaling,
"SamplerOptions_GarbageCollection": samplers_extensions.SamplerOptions_GarbageCollection,
"ModelSamplingAdvanced": models.ModelSamplingAdvanced,
"ModelTimestepPatcher": models.ModelSamplingAdvanced,
"TorchCompileModelFluxAdv": models.TorchCompileModelFluxAdvanced,
"ModelSamplingAdvancedResolution": models.ModelSamplingAdvancedResolution,
"FluxGuidanceDisable": models.FluxGuidanceDisable,
"AdvancedNoise": latents.AdvancedNoise,
"FluxLoader": loaders.FluxLoader,
"SD35Loader": loaders.SD35Loader,
"TextBox1": nodes_misc.TextBox1,
"TextBox3": nodes_misc.TextBox3,
"CLIPTextEncodeFluxUnguided": conditioning.CLIPTextEncodeFluxUnguided,
"ConditioningOrthoCollin": conditioning.ConditioningOrthoCollin,
"ConditioningAverageScheduler": conditioning.ConditioningAverageScheduler,
"ConditioningMultiply": conditioning.ConditioningMultiply,
"ConditioningAdd": conditioning.ConditioningAdd,
"Conditioning Recast FP64": conditioning.Conditioning_Recast64,
"StableCascade_StageB_Conditioning64": conditioning.StableCascade_StageB_Conditioning64,
"ConditioningZeroAndTruncate": conditioning.ConditioningZeroAndTruncate,
"ConditioningTruncate": conditioning.ConditioningTruncate,
"StyleModelApplyAdvanced": conditioning.StyleModelApplyAdvanced,
"FluxRegionalPrompt": conditioning.FluxRegionalPrompt,
"FluxRegionalConditioning": conditioning.FluxRegionalConditioning,
"ConditioningToBase64": conditioning.ConditioningToBase64,
"Base64ToConditioning": conditioning.Base64ToConditioning,
"Set Precision": latents.set_precision,
"Set Precision Universal": latents.set_precision_universal,
"Set Precision Advanced": latents.set_precision_advanced,
"Latent Match Channelwise": latent_images.latent_channelwise_match,
"LatentNoised": latents.LatentNoised,
"LatentNoiseList": latents.LatentNoiseList,
"LatentBatch_channels": latents.LatentBatch_channels,
"LatentBatch_channels_16": latents.LatentBatch_channels_16,
"LatentNoiseBatch_perlin": latents.LatentNoiseBatch_perlin,
"LatentNoiseBatch_fractal": latents.LatentNoiseBatch_fractal,
"LatentNoiseBatch_gaussian": latents.LatentNoiseBatch_gaussian,
"LatentNoiseBatch_gaussian_channels": latents.LatentNoiseBatch_gaussian_channels,
"Latent to Cuda": latents.latent_to_cuda,
"Latent Batcher": latents.latent_batch,
"Latent Normalize Channels": latents.latent_normalize_channels,
"EmptyLatentImage64": latents.EmptyLatentImage64,
"EmptyLatentImageCustom": latents.EmptyLatentImageCustom,
"StableCascade_StageC_VAEEncode_Exact": latents.StableCascade_StageC_VAEEncode_Exact,
"LatentPhaseMagnitude": latents.LatentPhaseMagnitude,
"LatentPhaseMagnitudeMultiply": latents.LatentPhaseMagnitudeMultiply,
"LatentPhaseMagnitudeOffset": latents.LatentPhaseMagnitudeOffset,
"LatentPhaseMagnitudePower": latents.LatentPhaseMagnitudePower,
"MaskToggle": latents.MaskToggle,
"Sigmas Recast": sigmas.set_precision_sigmas,
"Sigmas Noise Inversion": sigmas.sigmas_noise_inversion,
"Sigmas From Text": sigmas.sigmas_from_text,
"Sigmas Variance Floor": sigmas.sigmas_variance_floor,
"Sigmas Truncate": sigmas.sigmas_truncate,
"Sigmas Start": sigmas.sigmas_start,
"Sigmas Split": sigmas.sigmas_split,
"Sigmas Concat": sigmas.sigmas_concatenate,
"Sigmas Pad": sigmas.sigmas_pad,
"Sigmas Unpad": sigmas.sigmas_unpad,
"Sigmas SetFloor": sigmas.sigmas_set_floor,
"Sigmas DeleteBelowFloor": sigmas.sigmas_delete_below_floor,
"Sigmas DeleteDuplicates": sigmas.sigmas_delete_consecutive_duplicates,
"Sigmas Cleanup": sigmas.sigmas_cleanup,
"Sigmas Mult": sigmas.sigmas_mult,
"Sigmas Modulus": sigmas.sigmas_modulus,
"Sigmas Quotient": sigmas.sigmas_quotient,
"Sigmas Add": sigmas.sigmas_add,
"Sigmas Power": sigmas.sigmas_power,
"Sigmas Abs": sigmas.sigmas_abs,
"Sigmas2 Mult": sigmas.sigmas2_mult,
"Sigmas2 Add": sigmas.sigmas2_add,
"Sigmas Rescale": sigmas.sigmas_rescale,
"Sigmas Math1": sigmas.sigmas_math1,
"Sigmas Math3": sigmas.sigmas_math3,
"Sigmas Iteration Karras": sigmas.sigmas_iteration_karras,
"Sigmas Iteration Polyexp": sigmas.sigmas_iteration_polyexp,
"Tan Scheduler": sigmas.tan_scheduler,
"Tan Scheduler 2": sigmas.tan_scheduler_2stage,
"Tan Scheduler 2 Simple": sigmas.tan_scheduler_2stage_simple,
"Constant Scheduler": sigmas.constant_scheduler,
"Linear Quadratic Advanced": sigmas.linear_quadratic_advanced,
#"VGG19StyleTransfer": images.VGG19StyleTransfer,
"Image Channels LAB": images.Image_Channels_LAB,
"Image Median Blur": images.ImageMedianBlur,
"Image Pair Split": images.Image_Pair_Split,
"Image Crop Location Exact": images.Image_Crop_Location_Exact,
"Film Grain": images.Film_Grain,
"Frequency Separation Hard Light": images.Frequency_Separation_Hard_Light,
"Frequency Separation Hard Light LAB": images.Frequency_Separation_Hard_Light_LAB,
"UNetSave": models.UNetSave,
"PrepForUnsampling": helper_sigma_preview_image_preproc.VAEEncodeAdvanced,
"VAEEncodeAdvanced": helper_sigma_preview_image_preproc.VAEEncodeAdvanced,
"SigmasPreview": helper_sigma_preview_image_preproc.SigmasPreview,
"SigmasSchedulePreview": helper_sigma_preview_image_preproc.SigmasSchedulePreview,
"ReFluxPatcher": models.ReFluxPatcher,
"FluxOrthoCFGPatcher": models.FluxOrthoCFGPatcher,
"ClownsharkSamplerOptions_FrameWeights": samplers_extensions.ClownsharKSamplerOptions_FrameWeights,
}
if flags["test_samplers"]:
NODE_CLASS_MAPPINGS.update({
"SamplerRK_Test": test_samplers.SamplerRK_Test,
"Zampler_Test": test_samplers.Zampler_Test,
"UltraSharkSamplerRBTest": test_samplers.UltraSharkSamplerRBTest,
})
extra_samplers.update({
"rk_test": test_samplers.sample_rk_test,
"rk_sphere": test_samplers.sample_rk_sphere,
"rk_vpsde": test_samplers.sample_rk_vpsde,
"rk_vpsde_ddpm": test_samplers.sample_rk_vpsde_ddpm,
"rk_vpsde_csbw": test_samplers.sample_rk_vpsde_csbw,
"rk_momentum": test_samplers.sample_rk_momentum,
"rk_ralston_2s": test_samplers.sample_rk_ralston_2s,
"rk_implicit_res_2s": test_samplers.sample_rk_implicit_res_2s,
"res_multistep": test_samplers.sample_res_multistep,
"rk_res_2m": test_samplers.sample_rk_res_2m,
"rk_res_2s": test_samplers.sample_rk_res_2s,
"rk_res_2s_prenoise": test_samplers.sample_rk_res_2s_prenoise,
"rk_ralston_2s_prenoise": test_samplers.sample_rk_ralston_2s_prenoise,
"rk_ralston_2s_prenoise_alt": test_samplers.sample_rk_ralston_2s_prenoise_alt,
"rk_res_2s_prenoise_alt": test_samplers.sample_rk_res_2s_prenoise_alt,
"rk_crazy": test_samplers.sample_rk_crazy,
"rk_crazy2": test_samplers.sample_rk_crazy2,
"rk_crazymod43": test_samplers.sample_rk_crazymod43,
"rk_crazymod44": test_samplers.sample_rk_crazymod44,
"rk_crazymod45": test_samplers.sample_rk_crazymod45,
"rk_pec423": test_samplers.sample_rk_pec423,
"rk_pec433": test_samplers.sample_rk_pec433,
"rk_gausslang_full": test_samplers.sample_rk_gausslang_full,
"rk_gausslang_3s_full": test_samplers.sample_rk_gausslang_3s_full,
"rk_gausslang_3s_full_guide": test_samplers.sample_rk_gausslang_3s_full_guide,
"rk_radau_iia_alt_lang_3s_full": test_samplers.sample_rk_radau_iia_alt_lang_3s_full,
"rk_implicit": test_samplers.sample_rk_implicit,
"rk_gausslang": test_samplers.sample_rk_gausslang,
"rk_gausslangeps": test_samplers.sample_rk_gausslangeps,
"rk_ralradau": test_samplers.sample_rk_ralradau,
"rk_gausscycle": test_samplers.sample_rk_gausscycle,
"rk_gausscycle2": test_samplers.sample_rk_gausscycle2,
"rk_radaucycle": test_samplers.sample_rk_radaucycle,
"rk_radaucycle_ia": test_samplers.sample_rk_radaucycle_ia,
"rk_radaucycle_3s": test_samplers.sample_rk_radaucycle_3s,
"rk_radaucycle_retry": test_samplers.sample_rk_radaucycle_retry,
"rk_radaucycle_staggered": test_samplers.sample_rk_radaucycle_staggered,
"rk_implicit_euler_von_svd": test_samplers.sample_rk_implicit_euler_von_svd,
"rk_implicit_cycloeuler": test_samplers.sample_rk_implicit_cycloeuler,
"rk_salmon": test_samplers.sample_rk_salmon,
"rk_radau_iia_2s_BS": test_samplers.sample_rk_radau_iia_2s_BS,
"rk_radau_ia_2s_lang_full": test_samplers.sample_rk_radau_ia_2s_lang_full,
"rk_radau_iia_2s_lang_full": test_samplers.sample_rk_radau_iia_2s_lang_full,
"rk_radau_iia_2s": test_samplers.sample_rk_radau_iia_2s,
"rk_radau_iia_3s": test_samplers.sample_rk_radau_iia_3s,
"rk_abnorsett4": test_samplers.sample_rk_abnorsett4,
"rk_euler_lowranksvd": test_samplers.sample_rk_euler_lowranksvd,
"rk_randomized_svd": test_samplers.sample_rk_randomized_svd,
"rk_implicit_euler_fd": test_samplers.sample_rk_implicit_euler_fd,
"rk_euler_banana_alphaupdown_test": test_samplers.sample_rk_euler_banana_alphaupdown_test,
"rk_euler_hamberder": test_samplers.sample_rk_euler_hamberder,
"rk_euler_banana": test_samplers.sample_rk_euler_banana,
"rk_res_2s_banana": test_samplers.sample_rk_res_2s_banana,
"rk_res_3s_banana": test_samplers.sample_rk_res_3s_banana,
"rk_euler": test_samplers.sample_rk_euler,
"rk_euler_prenoise": test_samplers.sample_rk_euler_prenoise,
"rk_ddim_test": test_samplers.sample_rk_ddim_test,
"rk_res_denoise_eps": test_samplers.sample_rk_res_denoise_eps,
"rk_exp_euler_denoise_eps": test_samplers.sample_rk_exp_euler_denoise_eps,
"rk_euler_alt_sde": test_samplers.sample_rk_euler_alt_sde,
"rk_implicit_euler": test_samplers.sample_rk_implicit_euler,
"rk_vpsde_trivial": test_samplers.sample_rk_vpsde_trivial,
"zample": test_samplers.sample_zsample,
"zample_paper": test_samplers.sample_zample_paper,
"zample_inversion": test_samplers.sample_zample_inversion,
"sample_zample_edit": test_samplers.sample_zample_edit,
})
if flags["beta_samplers"]:
NODE_CLASS_MAPPINGS.update({
"ClownSamplerAdvanced_Beta": samplers.ClownSamplerAdvanced_Beta,
})
extra_samplers.update({
"rk_beta": rk_sampler_beta.sample_rk_beta,
})
WEB_DIRECTORY = "./web/js"
__all__ = ["NODE_CLASS_MAPPINGS", "WEB_DIRECTORY"]
add_samplers()