-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathsamplers.py
1280 lines (994 loc) · 69.7 KB
/
samplers.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
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
from .noise_classes import *
from .sigmas import get_sigmas
from .rk_sampler import sample_rk
from .rk_coefficients import RK_SAMPLER_NAMES, IRK_SAMPLER_NAMES
from .rk_coefficients_beta import RK_SAMPLER_NAMES_BETA, IRK_SAMPLER_NAMES_BETA
from .config import MAX_STEPS
import comfy.samplers
import comfy.sample
import comfy.sampler_helpers
import comfy.model_sampling
import comfy.latent_formats
import comfy.sd
from comfy_extras.nodes_model_advanced import ModelSamplingSD3, ModelSamplingFlux, ModelSamplingAuraFlow, ModelSamplingStableCascade
import comfy.supported_models
import latent_preview
import torch
import torch.nn.functional as F
import math
import copy
from .helper import get_extra_options_kv, extra_options_flag, get_res4lyf_scheduler_list
from .latents import initialize_or_scale
from .rk_guide_func import get_orthogonal
from .noise_sigmas_timesteps_scaling import NOISE_MODE_NAMES
def move_to_same_device(*tensors):
if not tensors:
return tensors
device = tensors[0].device
return tuple(tensor.to(device) for tensor in tensors)
#SCHEDULER_NAMES = comfy.samplers.SCHEDULER_NAMES + ["beta57"]
class SharkSampler:
@classmethod
def INPUT_TYPES(s):
return {"required":
{"model": ("MODEL",),
"noise_type_init": (NOISE_GENERATOR_NAMES_SIMPLE, {"default": "gaussian"}),
"noise_stdev": ("FLOAT", {"default": 1.0, "min": -10000.0, "max": 10000.0, "step":0.01, "round": False, }),
"noise_seed": ("INT", {"default": 0, "min": -1, "max": 0xffffffffffffffff}),
"sampler_mode": (['standard', 'unsample', 'resample'],),
"scheduler": (get_res4lyf_scheduler_list(), {"default": "beta57"},),
"steps": ("INT", {"default": 30, "min": 1, "max": 10000}),
"denoise": ("FLOAT", {"default": 1.0, "min": -10000, "max": 10000, "step":0.01}),
"denoise_alt": ("FLOAT", {"default": 1.0, "min": -10000, "max": 10000, "step":0.01}),
"cfg": ("FLOAT", {"default": 3.0, "min": -100.0, "max": 100.0, "step":0.01, "round": False, "tooltip": "Negative values use channelwise CFG." }),
},
"optional":
{
"positive": ("CONDITIONING", ),
"negative": ("CONDITIONING", ),
"sampler": ("SAMPLER", ),
"sigmas": ("SIGMAS", ),
"latent_image": ("LATENT", ),
"options": ("OPTIONS", ),
"extra_options": ("STRING", {"default": "", "multiline": True}),
}
}
RETURN_TYPES = ("LATENT","LATENT", "LATENT",)
RETURN_NAMES = ("output", "denoised","sde_noise",)
FUNCTION = "main"
CATEGORY = "RES4LYF/samplers"
def main(self, model, cfg, scheduler, steps, sampler_mode="standard",denoise=1.0, denoise_alt=1.0,
noise_type_init="gaussian", latent_image=None,
positive=None, negative=None, sampler=None, sigmas=None, latent_noise=None, latent_noise_match=None,
noise_stdev=1.0, noise_mean=0.0, noise_normalize=True,
d_noise=1.0, alpha_init=-1.0, k_init=1.0, cfgpp=0.0, noise_seed=-1,
options=None, sde_noise=None,sde_noise_steps=1,
extra_options="",
):
# blame comfy here
raw_x = latent_image['raw_x'] if 'raw_x' in latent_image else None
last_seed = latent_image['last_seed'] if 'last_seed' in latent_image else None
pos_cond = copy.deepcopy(positive)
neg_cond = copy.deepcopy(negative)
if sampler is None:
raise ValueError("sampler is required")
else:
sampler = copy.deepcopy(sampler)
default_dtype = getattr(torch, get_extra_options_kv("default_dtype", "float64", extra_options), torch.float64)
model = model.clone()
if pos_cond[0][1] is not None:
if "regional_conditioning_weights" in pos_cond[0][1]:
sampler.extra_options['regional_conditioning_weights'] = pos_cond[0][1]['regional_conditioning_weights']
sampler.extra_options['regional_conditioning_floors'] = pos_cond[0][1]['regional_conditioning_floors']
regional_generate_conditionings_and_masks_fn = pos_cond[0][1]['regional_generate_conditionings_and_masks_fn']
regional_conditioning, regional_mask = regional_generate_conditionings_and_masks_fn(latent_image['samples'])
regional_conditioning = copy.deepcopy(regional_conditioning)
regional_mask = copy.deepcopy(regional_mask)
model.set_model_patch(regional_conditioning, 'regional_conditioning_positive')
model.set_model_patch(regional_mask, 'regional_conditioning_mask')
if "noise_seed" in sampler.extra_options:
if sampler.extra_options['noise_seed'] == -1 and noise_seed != -1:
sampler.extra_options['noise_seed'] = noise_seed + 1
#print("Shark: setting clown noise seed to: ", sampler.extra_options['noise_seed'])
if "sampler_mode" in sampler.extra_options:
sampler.extra_options['sampler_mode'] = sampler_mode
if "extra_options" in sampler.extra_options:
extra_options += " "
extra_options += sampler.extra_options['extra_options']
sampler.extra_options['extra_options'] = extra_options
batch_size = int(get_extra_options_kv("batch_size", "1", extra_options))
if batch_size > 1:
latent_image['samples'] = latent_image['samples'].repeat(batch_size, 1, 1, 1)
latent_image_batch = {"samples": latent_image['samples']}
out_samples, out_samples_fp64, out_denoised_samples, out_denoised_samples_fp64 = [], [], [], []
for batch_num in range(latent_image_batch['samples'].shape[0]):
latent_unbatch = copy.deepcopy(latent_image)
latent_unbatch['samples'] = latent_image_batch['samples'][batch_num].clone().unsqueeze(0)
if noise_seed == -1:
seed = torch.initial_seed() + 1 + batch_num
else:
seed = noise_seed + batch_num
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
#torch.cuda.manual_seed_all(seed)
if options is not None:
noise_stdev = options.get('noise_init_stdev', noise_stdev)
noise_mean = options.get('noise_init_mean', noise_mean)
noise_type_init = options.get('noise_type_init', noise_type_init)
d_noise = options.get('d_noise', d_noise)
alpha_init = options.get('alpha_init', alpha_init)
k_init = options.get('k_init', k_init)
sde_noise = options.get('sde_noise', sde_noise)
sde_noise_steps = options.get('sde_noise_steps', sde_noise_steps)
latent_image_dtype = latent_unbatch['samples'].dtype
if isinstance(model.model.model_config, comfy.supported_models.Flux) or isinstance(model.model.model_config, comfy.supported_models.FluxSchnell):
if pos_cond is None:
pos_cond = [[
torch.zeros((1, 256, 4096)),
{'pooled_output': torch.zeros((1, 768))}
]]
if extra_options_flag("uncond_ortho_flux", extra_options):
if neg_cond is None:
print("uncond_ortho_flux: using random negative conditioning...")
neg_cond = [[
torch.randn((1, 256, 4096)),
{'pooled_output': torch.randn((1, 768))}
]]
#neg_cond[0][0] = get_orthogonal(neg_cond[0][0].to(torch.bfloat16), pos_cond[0][0].to(torch.bfloat16))
#neg_cond[0][1]['pooled_output'] = get_orthogonal(neg_cond[0][1]['pooled_output'].to(torch.bfloat16), pos_cond[0][1]['pooled_output'].to(torch.bfloat16))
neg_cond[0][0] = get_orthogonal(neg_cond[0][0], pos_cond[0][0])
neg_cond[0][1]['pooled_output'] = get_orthogonal(neg_cond[0][1]['pooled_output'], pos_cond[0][1]['pooled_output'])
if neg_cond is None:
neg_cond = [[
torch.zeros((1, 256, 4096)),
{'pooled_output': torch.zeros((1, 768))}
]]
else:
if pos_cond is None:
pos_cond = [[
torch.zeros((1, 154, 4096)),
{'pooled_output': torch.zeros((1, 2048))}
]]
if extra_options_flag("uncond_ortho_sd35", extra_options):
if neg_cond is None:
neg_cond = [[
torch.randn((1, 154, 4096)),
{'pooled_output': torch.randn((1, 2048))}
]]
neg_cond[0][0] = get_orthogonal(neg_cond[0][0], pos_cond[0][0])
neg_cond[0][1]['pooled_output'] = get_orthogonal(neg_cond[0][1]['pooled_output'], pos_cond[0][1]['pooled_output'])
if neg_cond is None:
neg_cond = [[
torch.zeros((1, 154, 4096)),
{'pooled_output': torch.zeros((1, 2048))}
]]
if extra_options_flag("zero_uncond_t5", extra_options):
neg_cond[0][0] = torch.zeros_like(neg_cond[0][0])
if extra_options_flag("zero_uncond_pooled_output", extra_options):
neg_cond[0][1]['pooled_output'] = torch.zeros_like(neg_cond[0][1]['pooled_output'])
if extra_options_flag("zero_pooled_output", extra_options):
pos_cond[0][1]['pooled_output'] = torch.zeros_like(pos_cond[0][1]['pooled_output'])
neg_cond[0][1]['pooled_output'] = torch.zeros_like(neg_cond[0][1]['pooled_output'])
if denoise_alt < 0:
d_noise = denoise_alt = -denoise_alt
if options is not None:
d_noise = options.get('d_noise', d_noise)
if sigmas is not None:
sigmas = sigmas.clone().to(default_dtype)
else:
sigmas = get_sigmas(model, scheduler, steps, denoise).to(default_dtype)
sigmas *= denoise_alt
if sampler_mode.startswith("unsample"):
null = torch.tensor([0.0], device=sigmas.device, dtype=sigmas.dtype)
sigmas = torch.flip(sigmas, dims=[0])
sigmas = torch.cat([sigmas, null])
elif sampler_mode.startswith("resample"):
null = torch.tensor([0.0], device=sigmas.device, dtype=sigmas.dtype)
sigmas = torch.cat([null, sigmas])
sigmas = torch.cat([sigmas, null])
x = latent_unbatch["samples"].clone().to(default_dtype)
if latent_unbatch is not None:
if "samples_fp64" in latent_unbatch:
if latent_unbatch['samples'].shape == latent_unbatch['samples_fp64'].shape:
if torch.norm(latent_unbatch['samples'] - latent_unbatch['samples_fp64']) < 0.01:
x = latent_unbatch["samples_fp64"].clone()
if latent_noise is not None:
latent_noise_samples = latent_noise["samples"].clone().to(default_dtype)
if latent_noise_match is not None:
latent_noise_match_samples = latent_noise_match["samples"].clone().to(default_dtype)
truncate_conditioning = extra_options_flag("truncate_conditioning", extra_options)
if truncate_conditioning == "true" or truncate_conditioning == "true_and_zero_neg":
if pos_cond is not None:
pos_cond[0][0] = pos_cond[0][0].clone().to(default_dtype)
pos_cond[0][1]["pooled_output"] = pos_cond[0][1]["pooled_output"].clone().to(default_dtype)
if neg_cond is not None:
neg_cond[0][0] = neg_cond[0][0].clone().to(default_dtype)
neg_cond[0][1]["pooled_output"] = neg_cond[0][1]["pooled_output"].clone().to(default_dtype)
c = []
for t in pos_cond:
d = t[1].copy()
pooled_output = d.get("pooled_output", None)
for t in neg_cond:
d = t[1].copy()
pooled_output = d.get("pooled_output", None)
if pooled_output is not None:
if truncate_conditioning == "true_and_zero_neg":
d["pooled_output"] = torch.zeros((1,2048), dtype=t[0].dtype, device=t[0].device)
n = [torch.zeros((1,154,4096), dtype=t[0].dtype, device=t[0].device), d]
else:
d["pooled_output"] = d["pooled_output"][:, :2048]
n = [t[0][:, :154, :4096], d]
c.append(n)
neg_cond = c
sigmin = model.model.model_sampling.sigma_min
sigmax = model.model.model_sampling.sigma_max
if sde_noise is None and sampler_mode.startswith("unsample"):
total_steps = len(sigmas)+1
sde_noise = []
else:
total_steps = 1
for total_steps_iter in range (sde_noise_steps):
if noise_type_init == "none":
noise = torch.zeros_like(x)
elif latent_noise is None:
print("Initial latent noise seed: ", seed)
noise_sampler_init = NOISE_GENERATOR_CLASSES_SIMPLE.get(noise_type_init)(x=x, seed=seed, sigma_min=sigmin, sigma_max=sigmax)
if noise_type_init == "fractal":
noise_sampler_init.alpha = alpha_init
noise_sampler_init.k = k_init
noise_sampler_init.scale = 0.1
noise = noise_sampler_init(sigma=sigmax, sigma_next=sigmin)
else:
noise = latent_noise_samples
if noise_normalize and noise.std() > 0:
noise = (noise - noise.mean(dim=(-2, -1), keepdim=True)) / noise.std(dim=(-2, -1), keepdim=True)
#noise.sub_(noise.mean()).div_(noise.std())
noise *= noise_stdev
noise = (noise - noise.mean()) + noise_mean
if latent_noise_match is not None:
for i in range(latent_noise_match_samples.shape[1]):
noise[0][i] = (noise[0][i] - noise[0][i].mean())
noise[0][i] = (noise[0][i]) + latent_noise_match_samples[0][i].mean()
noise_mask = latent_unbatch["noise_mask"] if "noise_mask" in latent_unbatch else None
x0_output = {}
if cfg < 0:
sampler.extra_options['cfg_cw'] = -cfg
cfg = 1.0
else:
sampler.extra_options.pop("cfg_cw", None)
if sde_noise is None:
sde_noise = []
else:
sde_noise = copy.deepcopy(sde_noise)
for i in range(len(sde_noise)):
sde_noise[i] = sde_noise[i]
for j in range(sde_noise[i].shape[1]):
sde_noise[i][0][j] = ((sde_noise[i][0][j] - sde_noise[i][0][j].mean()) / sde_noise[i][0][j].std())
callback = latent_preview.prepare_callback(model, sigmas.shape[-1] - 1, x0_output)
disable_pbar = not comfy.utils.PROGRESS_BAR_ENABLED
model.model.diffusion_model.raw_x = raw_x
model.model.diffusion_model.last_seed = last_seed
samples = comfy.sample.sample_custom(model, noise, cfg, sampler, sigmas, pos_cond, neg_cond, x.clone(), noise_mask=noise_mask, callback=callback, disable_pbar=disable_pbar, seed=noise_seed)
out = latent_unbatch.copy()
out["samples"] = samples
if "x0" in x0_output:
out_denoised = latent_unbatch.copy()
out_denoised["samples"] = model.model.process_latent_out(x0_output["x0"].cpu())
else:
out_denoised = out
out["samples_fp64"] = out["samples"].clone()
out["samples"] = out["samples"].to(latent_image_dtype)
out_denoised["samples_fp64"] = out_denoised["samples"].clone()
out_denoised["samples"] = out_denoised["samples"].to(latent_image_dtype)
out_samples. append(out["samples"])
out_samples_fp64.append(out["samples_fp64"])
out_denoised_samples. append(out_denoised["samples"])
out_denoised_samples_fp64.append(out_denoised["samples_fp64"])
seed += 1
torch.manual_seed(seed)
if total_steps_iter > 1:
sde_noise.append(out["samples_fp64"])
out_samples = [tensor.squeeze(0) for tensor in out_samples]
out_samples_fp64 = [tensor.squeeze(0) for tensor in out_samples_fp64]
out_denoised_samples = [tensor.squeeze(0) for tensor in out_denoised_samples]
out_denoised_samples_fp64 = [tensor.squeeze(0) for tensor in out_denoised_samples_fp64]
out['samples'] = torch.stack(out_samples, dim=0)
out['samples_fp64'] = torch.stack(out_samples_fp64, dim=0)
out_denoised['samples'] = torch.stack(out_denoised_samples, dim=0)
out_denoised['samples_fp64'] = torch.stack(out_denoised_samples_fp64, dim=0)
out['raw_x'] = None
if hasattr(model.model.diffusion_model, "raw_x"):
if model.model.diffusion_model.raw_x is not None:
out['raw_x'] = model.model.diffusion_model.raw_x.clone()
del model.model.diffusion_model.raw_x
out['last_seed'] = None
if hasattr(model.model.diffusion_model, "last_seed"):
if model.model.diffusion_model.last_seed is not None:
out['last_seed'] = model.model.diffusion_model.last_seed
del model.model.diffusion_model.last_seed
return ( out, out_denoised, sde_noise,)
class ClownSamplerAdvanced:
@classmethod
def INPUT_TYPES(s):
return {"required":
{
"noise_type_sde": (NOISE_GENERATOR_NAMES_SIMPLE, {"default": "gaussian"}),
"noise_type_sde_substep": (NOISE_GENERATOR_NAMES_SIMPLE, {"default": "gaussian"}),
"noise_mode_sde": (NOISE_MODE_NAMES, {"default": 'hard', "tooltip": "How noise scales with the sigma schedule. Hard is the most aggressive, the others start strong and drop rapidly."}),
"noise_mode_sde_substep": (NOISE_MODE_NAMES, {"default": 'hard', "tooltip": "How noise scales with the sigma schedule. Hard is the most aggressive, the others start strong and drop rapidly."}),
"eta": ("FLOAT", {"default": 0.5, "min": -100.0, "max": 100.0, "step":0.01, "round": False, "tooltip": "Calculated noise amount to be added, then removed, after each step."}),
"eta_substep": ("FLOAT", {"default": 0.5, "min": -100.0, "max": 100.0, "step":0.01, "round": False, "tooltip": "Calculated noise amount to be added, then removed, after each step."}),
"s_noise": ("FLOAT", {"default": 1.0, "min": -10000, "max": 10000, "step":0.01, "tooltip": "Adds extra SDE noise. Values around 1.03-1.07 can lead to a moderate boost in detail and paint textures."}),
"d_noise": ("FLOAT", {"default": 1.0, "min": -10000, "max": 10000, "step":0.01, "tooltip": "Downscales the sigma schedule. Values around 0.98-0.95 can lead to a large boost in detail and paint textures."}),
"noise_seed_sde": ("INT", {"default": -1, "min": -1, "max": 0xffffffffffffffff}),
"sampler_name": (RK_SAMPLER_NAMES, {"default": "res_2m"}),
"implicit_sampler_name": (IRK_SAMPLER_NAMES, {"default": "explicit_diagonal"}),
"implicit_steps": ("INT", {"default": 0, "min": 0, "max": 10000}),
},
"optional":
{
"guides": ("GUIDES", ),
"options": ("OPTIONS", ),
"automation": ("AUTOMATION", ),
"extra_options": ("STRING", {"default": "", "multiline": True}),
}
}
RETURN_TYPES = ("SAMPLER",)
RETURN_NAMES = ("sampler", )
FUNCTION = "main"
CATEGORY = "RES4LYF/samplers"
def main(self,
noise_type_sde="gaussian", noise_type_sde_substep="gaussian", noise_mode_sde="hard",
eta=0.25, eta_var=0.0, d_noise=1.0, s_noise=1.0, alpha_sde=-1.0, k_sde=1.0, cfgpp=0.0, c1=0.0, c2=0.5, c3=1.0, noise_seed_sde=-1, sampler_name="res_2m", implicit_sampler_name="gauss-legendre_2s",
t_fn_formula=None, sigma_fn_formula=None, implicit_steps=0,
latent_guide=None, latent_guide_inv=None, guide_mode="", latent_guide_weights=None, latent_guide_weights_inv=None, latent_guide_mask=None, latent_guide_mask_inv=None, rescale_floor=True, sigmas_override=None,
guides=None, options=None, sde_noise=None,sde_noise_steps=1,
extra_options="", automation=None, etas=None, s_noises=None,unsample_resample_scales=None, regional_conditioning_weights=None,frame_weights_grp=None, eta_substep=0.5, noise_mode_sde_substep="hard",
):
if implicit_sampler_name == "none":
implicit_steps = 0
implicit_sampler_name = "gauss-legendre_2s"
if noise_mode_sde == "none":
eta, eta_var = 0.0, 0.0
noise_mode_sde = "hard"
default_dtype = getattr(torch, get_extra_options_kv("default_dtype", "float64", extra_options), torch.float64)
unsample_resample_scales_override = unsample_resample_scales
if options is not None:
noise_type_sde = options.get('noise_type_sde', noise_type_sde)
noise_mode_sde = options.get('noise_mode_sde', noise_mode_sde)
eta = options.get('eta', eta)
s_noise = options.get('s_noise', s_noise)
d_noise = options.get('d_noise', d_noise)
alpha_sde = options.get('alpha_sde', alpha_sde)
k_sde = options.get('k_sde', k_sde)
c1 = options.get('c1', c1)
c2 = options.get('c2', c2)
c3 = options.get('c3', c3)
t_fn_formula = options.get('t_fn_formula', t_fn_formula)
sigma_fn_formula = options.get('sigma_fn_formula', sigma_fn_formula)
frame_weights_grp = options.get('frame_weights_grp', frame_weights_grp)
sde_noise = options.get('sde_noise', sde_noise)
sde_noise_steps = options.get('sde_noise_steps', sde_noise_steps)
#noise_seed_sde = torch.initial_seed()+1 if noise_seed_sde < 0 else noise_seed_sde
rescale_floor = extra_options_flag("rescale_floor", extra_options)
if automation is not None:
etas = automation['etas'] if 'etas' in automation else None
s_noises = automation['s_noises'] if 's_noises' in automation else None
unsample_resample_scales = automation['unsample_resample_scales'] if 'unsample_resample_scales' in automation else None
frame_weights_grp = automation['frame_weights_grp'] if 'frame_weights_grp' in automation else None
etas = initialize_or_scale(etas, eta, MAX_STEPS).to(default_dtype)
etas = F.pad(etas, (0, MAX_STEPS), value=0.0)
s_noises = initialize_or_scale(s_noises, s_noise, MAX_STEPS).to(default_dtype)
s_noises = F.pad(s_noises, (0, MAX_STEPS), value=0.0)
if sde_noise is None:
sde_noise = []
else:
sde_noise = copy.deepcopy(sde_noise)
for i in range(len(sde_noise)):
sde_noise[i] = sde_noise[i]
for j in range(sde_noise[i].shape[1]):
sde_noise[i][0][j] = ((sde_noise[i][0][j] - sde_noise[i][0][j].mean()) / sde_noise[i][0][j].std())
if unsample_resample_scales_override is not None:
unsample_resample_scales = unsample_resample_scales_override
sampler = comfy.samplers.ksampler("rk", {"eta": eta, "eta_var": eta_var, "s_noise": s_noise, "d_noise": d_noise, "alpha": alpha_sde, "k": k_sde, "c1": c1, "c2": c2, "c3": c3, "cfgpp": cfgpp,
"noise_sampler_type": noise_type_sde, "noise_mode": noise_mode_sde, "noise_seed": noise_seed_sde, "rk_type": sampler_name, "implicit_sampler_name": implicit_sampler_name,
"t_fn_formula": t_fn_formula, "sigma_fn_formula": sigma_fn_formula, "implicit_steps": implicit_steps,
"latent_guide": latent_guide, "latent_guide_inv": latent_guide_inv, "mask": latent_guide_mask, "mask_inv": latent_guide_mask_inv,
"latent_guide_weights": latent_guide_weights, "latent_guide_weights_inv": latent_guide_weights_inv, "guide_mode": guide_mode,
"LGW_MASK_RESCALE_MIN": rescale_floor, "sigmas_override": sigmas_override, "sde_noise": sde_noise,
"extra_options": extra_options,
"etas": etas, "s_noises": s_noises, "unsample_resample_scales": unsample_resample_scales, "regional_conditioning_weights": regional_conditioning_weights,
"guides": guides, "frame_weights_grp": frame_weights_grp, "eta_substep": eta_substep, "noise_mode_sde_substep": noise_mode_sde_substep,
})
return (sampler, )
from .config import IMPLICIT_TYPE_NAMES
class ClownSamplerAdvanced_Beta:
@classmethod
def INPUT_TYPES(s):
return {"required":
{
"noise_type_sde": (NOISE_GENERATOR_NAMES_SIMPLE, {"default": "gaussian"}),
"noise_type_sde_substep": (NOISE_GENERATOR_NAMES_SIMPLE, {"default": "gaussian"}),
"noise_mode_sde": (NOISE_MODE_NAMES, {"default": 'hard', "tooltip": "How noise scales with the sigma schedule. Hard is the most aggressive, the others start strong and drop rapidly."}),
"noise_mode_sde_substep": (NOISE_MODE_NAMES, {"default": 'hard', "tooltip": "How noise scales with the sigma schedule. Hard is the most aggressive, the others start strong and drop rapidly."}),
"overshoot_mode": (NOISE_MODE_NAMES, {"default": 'hard', "tooltip": "How step size overshoot scales with the sigma schedule. Hard is the most aggressive, the others start strong and drop rapidly."}),
"overshoot_mode_substep": (NOISE_MODE_NAMES, {"default": 'hard', "tooltip": "How substep size overshoot scales with the sigma schedule. Hard is the most aggressive, the others start strong and drop rapidly."}),
"eta": ("FLOAT", {"default": 0.5, "min": -100.0, "max": 100.0, "step":0.01, "round": False, "tooltip": "Calculated noise amount to be added, then removed, after each step."}),
"eta_substep": ("FLOAT", {"default": 0.5, "min": -100.0, "max": 100.0, "step":0.01, "round": False, "tooltip": "Calculated noise amount to be added, then removed, after each step."}),
"overshoot": ("FLOAT", {"default": 0.0, "min": -100.0, "max": 100.0, "step":0.01, "round": False, "tooltip": "Boost the size of each denoising step, then rescale to match the original. Has a softening effect."}),
"overshoot_substep": ("FLOAT", {"default": 0.0, "min": -100.0, "max": 100.0, "step":0.01, "round": False, "tooltip": "Boost the size of each denoising substep, then rescale to match the original. Has a softening effect."}),
"noise_boost_step": ("FLOAT", {"default": 0.0, "min": -100.0, "max": 100.0, "step":0.01, "round": False, "tooltip": "Set to positive values to create a sharper, grittier, more detailed image. Set to negative values to soften and deepen the colors."}),
"noise_boost_substep": ("FLOAT", {"default": 0.0, "min": -100.0, "max": 100.0, "step":0.01, "round": False, "tooltip": "Set to positive values to create a sharper, grittier, more detailed image. Set to negative values to soften and deepen the colors."}),
"noise_anchor": ("FLOAT", {"default": 1.0, "min": -100.0, "max": 100.0, "step":0.01, "round": False, "tooltip": "Typically set to between 1.0 and 0.0. Lower values cerate a grittier, more detailed image."}),
"s_noise": ("FLOAT", {"default": 1.0, "min": -10000, "max": 10000, "step":0.01, "tooltip": "Adds extra SDE noise. Values around 1.03-1.07 can lead to a moderate boost in detail and paint textures."}),
"s_noise_substep": ("FLOAT", {"default": 1.0, "min": -10000, "max": 10000, "step":0.01, "tooltip": "Adds extra SDE noise. Values around 1.03-1.07 can lead to a moderate boost in detail and paint textures."}),
"d_noise": ("FLOAT", {"default": 1.0, "min": -10000, "max": 10000, "step":0.01, "tooltip": "Downscales the sigma schedule. Values around 0.98-0.95 can lead to a large boost in detail and paint textures."}),
"noise_seed_sde": ("INT", {"default": -1, "min": -1, "max": 0xffffffffffffffff}),
"sampler_name": (RK_SAMPLER_NAMES_BETA_FOLDERS, {"default": "multistep/res_2m"}),
#"sampler_name": (RK_SAMPLER_NAMES_BETA, {"default": "res_2m"}),
#"implicit_sampler_name": (IRK_SAMPLER_NAMES_BETA, {"default": "use_explicit"}),
"implicit_type": (IMPLICIT_TYPE_NAMES, {"default": "predictor-corrector"}),
"implicit_type_substeps": (IMPLICIT_TYPE_NAMES, {"default": "predictor_corrector"}),
"implicit_steps": ("INT", {"default": 0, "min": 0, "max": 10000}),
"implicit_substeps": ("INT", {"default": 0, "min": 0, "max": 10000}),
"bongmath": ("BOOLEAN", {"default": True}),
},
"optional":
{
"guides": ("GUIDES", ),
"options": ("OPTIONS", ),
"automation": ("AUTOMATION", ),
"extra_options": ("STRING", {"default": "", "multiline": True}),
}
}
RETURN_TYPES = ("SAMPLER",)
RETURN_NAMES = ("sampler", )
FUNCTION = "main"
CATEGORY = "RES4LYF/samplers"
def main(self,
noise_type_sde="gaussian", noise_type_sde_substep="gaussian", noise_mode_sde="hard",overshoot_mode="hard", overshoot_mode_substep="hard",
eta=0.5, eta_substep=0.5, d_noise=1.0, s_noise=1.0, s_noise_substep=1.0, alpha_sde=-1.0, k_sde=1.0, cfgpp=0.0, c1=0.0, c2=0.5, c3=1.0, noise_seed_sde=-1, sampler_name="res_2m", implicit_sampler_name="gauss-legendre_2s",
implicit_substeps=0, implicit_steps=0,
rescale_floor=True, sigmas_override=None,
guides=None, options=None, sde_noise=None,sde_noise_steps=1,
extra_options="", automation=None, etas=None, etas_substep=None, s_noises=None, s_noises_substep=None, epsilon_scales=None, regional_conditioning_weights=None,frame_weights_grp=None, noise_mode_sde_substep="hard",
overshoot=0.0, overshoot_substep=0.0, noise_boost_step=0.0, noise_boost_substep=0.0, bongmath=True, noise_anchor=1.0,
implicit_type="predictor-corrector", implicit_type_substeps="predictor-corrector",
):
sampler_name, implicit_sampler_name = process_sampler_name(sampler_name)
implicit_steps_diag = implicit_substeps
implicit_steps_full = implicit_steps
if noise_mode_sde == "none":
eta, eta_var = 0.0, 0.0
noise_mode_sde = "hard"
default_dtype = getattr(torch, get_extra_options_kv("default_dtype", "float64", extra_options), torch.float64)
if options is not None:
noise_type_sde = options.get('noise_type_sde', noise_type_sde)
noise_mode_sde = options.get('noise_mode_sde', noise_mode_sde)
eta = options.get('eta', eta)
s_noise = options.get('s_noise', s_noise)
d_noise = options.get('d_noise', d_noise)
alpha_sde = options.get('alpha_sde', alpha_sde)
k_sde = options.get('k_sde', k_sde)
c1 = options.get('c1', c1)
c2 = options.get('c2', c2)
c3 = options.get('c3', c3)
frame_weights_grp = options.get('frame_weights_grp', frame_weights_grp)
sde_noise = options.get('sde_noise', sde_noise)
sde_noise_steps = options.get('sde_noise_steps', sde_noise_steps)
rescale_floor = extra_options_flag("rescale_floor", extra_options)
if automation is not None:
etas = automation['etas'] if 'etas' in automation else None
etas_substep = automation['etas_substep'] if 'etas_substep' in automation else None
s_noises = automation['s_noises'] if 's_noises' in automation else None
s_noises_substep = automation['s_noise_substep'] if 's_noise_substep' in automation else None
epsilon_scales = automation['epsilon_scales'] if 'epsilon_scales' in automation else None
frame_weights_grp = automation['frame_weights_grp'] if 'frame_weights_grp' in automation else None
etas = initialize_or_scale(etas, eta, MAX_STEPS).to(default_dtype)
etas_substep = initialize_or_scale(etas_substep, eta_substep, MAX_STEPS).to(default_dtype)
s_noises = initialize_or_scale(s_noises, s_noise, MAX_STEPS).to(default_dtype)
s_noises_substep = initialize_or_scale(s_noises_substep, s_noise_substep, MAX_STEPS).to(default_dtype)
etas = F.pad(etas, (0, MAX_STEPS), value=0.0)
etas_substep = F.pad(etas_substep, (0, MAX_STEPS), value=0.0)
s_noises = F.pad(s_noises, (0, MAX_STEPS), value=1.0)
s_noises_substep = F.pad(s_noises_substep, (0, MAX_STEPS), value=1.0)
if sde_noise is None:
sde_noise = []
else:
sde_noise = copy.deepcopy(sde_noise)
for i in range(len(sde_noise)):
sde_noise[i] = sde_noise[i]
for j in range(sde_noise[i].shape[1]):
sde_noise[i][0][j] = ((sde_noise[i][0][j] - sde_noise[i][0][j].mean()) / sde_noise[i][0][j].std())
sampler = comfy.samplers.ksampler("rk_beta", {"eta": eta, "s_noise": s_noise, "s_noise_substep": s_noise_substep, "d_noise": d_noise, "alpha": alpha_sde, "k": k_sde, "c1": c1, "c2": c2, "c3": c3, "cfgpp": cfgpp,
"noise_sampler_type": noise_type_sde, "noise_sampler_type_substep": noise_type_sde_substep, "noise_mode_sde": noise_mode_sde, "noise_seed": noise_seed_sde, "rk_type": sampler_name, "implicit_sampler_name": implicit_sampler_name,
"implicit_steps_diag": implicit_steps_diag, "implicit_steps_full": implicit_steps_full,
"LGW_MASK_RESCALE_MIN": rescale_floor, "sigmas_override": sigmas_override, "sde_noise": sde_noise,
"extra_options": extra_options, "sampler_mode": "standard",
"etas": etas, "etas_substep": etas_substep, "s_noises": s_noises, "s_noises_substep": s_noises_substep, "epsilon_scales": epsilon_scales, "regional_conditioning_weights": regional_conditioning_weights,
"guides": guides, "frame_weights_grp": frame_weights_grp, "eta_substep": eta_substep, "noise_mode_sde_substep": noise_mode_sde_substep, "noise_boost_step": noise_boost_step, "noise_boost_substep": noise_boost_substep,
"overshoot_mode": overshoot_mode, "overshoot_mode_substep": overshoot_mode_substep, "overshoot": overshoot, "overshoot_substep": overshoot_substep, "BONGMATH": bongmath, "noise_anchor": noise_anchor,
"implicit_type": implicit_type, "implicit_type_substeps": implicit_type_substeps,
})
return (sampler, )
class ClownSampler:
@classmethod
def INPUT_TYPES(s):
return {"required":
{
"noise_type_sde": (NOISE_GENERATOR_NAMES_SIMPLE, {"default": "gaussian"}),
"noise_mode_sde": (NOISE_MODE_NAMES, {"default": 'hard', "tooltip": "How noise scales with the sigma schedule. Hard is the most aggressive, the others start strong and drop rapidly."}),
"eta": ("FLOAT", {"default": 0.5, "min": -100.0, "max": 100.0, "step":0.01, "round": False, "tooltip": "Calculated noise amount to be added, then removed, after each step."}),
"s_noise": ("FLOAT", {"default": 1.0, "min": -10000, "max": 10000, "step":0.01}),
"d_noise": ("FLOAT", {"default": 1.0, "min": -10000, "max": 10000, "step":0.01}),
"noise_seed_sde": ("INT", {"default": -1, "min": -1, "max": 0xffffffffffffffff}),
"sampler_name": (RK_SAMPLER_NAMES, {"default": "res_2m"}),
"implicit_sampler_name": (IRK_SAMPLER_NAMES, {"default": "explicit_diagonal"}),
"implicit_steps": ("INT", {"default": 0, "min": 0, "max": 10000}),
},
"optional":
{
"guides": ("GUIDES", ),
"options": ("OPTIONS", ),
"automation": ("AUTOMATION", ),
"extra_options": ("STRING", {"default": "", "multiline": True}),
}
}
RETURN_TYPES = ("SAMPLER",)
RETURN_NAMES = ("sampler", )
FUNCTION = "main"
CATEGORY = "RES4LYF/samplers"
def main(self,
noise_type_sde="gaussian", noise_type_sde_substep="gaussian", noise_mode_sde="hard",
eta=0.25, eta_var=0.0, d_noise=1.0, s_noise=1.0, alpha_sde=-1.0, k_sde=1.0, cfgpp=0.0, c1=0.0, c2=0.5, c3=1.0, noise_seed_sde=-1, sampler_name="res_2m", implicit_sampler_name="gauss-legendre_2s",
t_fn_formula=None, sigma_fn_formula=None, implicit_steps=0,
latent_guide=None, latent_guide_inv=None, guide_mode="", latent_guide_weights=None, latent_guide_weights_inv=None, latent_guide_mask=None, latent_guide_mask_inv=None, rescale_floor=True, sigmas_override=None,
guides=None, options=None, sde_noise=None,sde_noise_steps=1,
extra_options="", automation=None, etas=None, s_noises=None,unsample_resample_scales=None, regional_conditioning_weights=None,frame_weights_grp=None,eta_substep=0.0, noise_mode_sde_substep="hard",
):
eta_substep = eta
noise_mode_sde_substep = noise_mode_sde
noise_type_sde_substep = noise_type_sde
sampler = ClownSamplerAdvanced().main(
noise_type_sde=noise_type_sde, noise_type_sde_substep=noise_type_sde_substep, noise_mode_sde=noise_mode_sde,
eta=eta, eta_var=eta_var, d_noise=d_noise, s_noise=s_noise, alpha_sde=alpha_sde, k_sde=k_sde, cfgpp=cfgpp, c1=c1, c2=c2, c3=c3, noise_seed_sde=noise_seed_sde, sampler_name=sampler_name, implicit_sampler_name=implicit_sampler_name,
t_fn_formula=t_fn_formula, sigma_fn_formula=sigma_fn_formula, implicit_steps=implicit_steps,
latent_guide=latent_guide, latent_guide_inv=latent_guide_inv, guide_mode=guide_mode, latent_guide_weights=latent_guide_weights, latent_guide_weights_inv=latent_guide_weights_inv, latent_guide_mask=latent_guide_mask, latent_guide_mask_inv=latent_guide_mask_inv, rescale_floor=rescale_floor, sigmas_override=sigmas_override,
guides=guides, options=options, sde_noise=sde_noise,sde_noise_steps=sde_noise_steps,
extra_options=extra_options, automation=automation, etas=etas, s_noises=s_noises,unsample_resample_scales=unsample_resample_scales, regional_conditioning_weights=regional_conditioning_weights,frame_weights_grp=frame_weights_grp, eta_substep=eta_substep, noise_mode_sde_substep=noise_mode_sde_substep,
)
return sampler
from .rk_coefficients_beta import RK_SAMPLER_NAMES_BETA_FOLDERS
def process_sampler_name(selected_value):
processed_name = selected_value.split("/")[-1]
if selected_value.startswith("fully_implicit") or selected_value.startswith("diag_implicit"):
implicit_sampler_name = processed_name
sampler_name = "euler"
else:
sampler_name = processed_name
implicit_sampler_name = "use_explicit"
return sampler_name, implicit_sampler_name
class ClownsharKSamplerSimple_Beta:
@classmethod
def INPUT_TYPES(s):
return {"required":
{"model": ("MODEL",),
"eta": ("FLOAT", {"default": 0.5, "min": -100.0, "max": 100.0, "step":0.01, "round": False, "tooltip": "Calculated noise amount to be added, then removed, after each step."}),
"sampler_name": (RK_SAMPLER_NAMES_BETA_FOLDERS, {"default": "multistep/res_2m"}),
"scheduler": (get_res4lyf_scheduler_list(), {"default": "beta57"},),
"steps": ("INT", {"default": 30, "min": 1, "max": 10000}),
"denoise": ("FLOAT", {"default": 1.0, "min": -10000, "max": 10000, "step":0.01}),
"cfg": ("FLOAT", {"default": 5.5, "min": -100.0, "max": 100.0, "step":0.01, "round": False, }),
"seed": ("INT", {"default": 0, "min": -1, "max": 0xffffffffffffffff}),
"bongmath": ("BOOLEAN", {"default": True}),
},
"optional":
{
"positive": ("CONDITIONING", ),
"negative": ("CONDITIONING", ),
"latent_image": ("LATENT", ),
"guides": ("GUIDES",),
"options": ("OPTIONS", ),
}
}
RETURN_TYPES = ("LATENT","LATENT",)
RETURN_NAMES = ("output", "denoised",)
FUNCTION = "main"
CATEGORY = "RES4LYF/samplers"
def main(self,
model=None,
denoise=1.0,
scheduler="beta57",
cfg=1.0,
seed=42,
positive=None,
negative=None,
latent_image=None,
steps=30,
bongmath=True,
noise_type_sde = "gaussian",
noise_type_sde_substep = "gaussian",
noise_mode_sde = "hard",
noise_mode_sde_substep = "hard",
overshoot_mode = "hard",
overshoot_mode_substep = "hard",
overshoot=0.0,
overshoot_substep=0.0,
eta=0.5,
eta_substep=0.5,
d_noise=1.0,
s_noise=1.0,
s_noise_substep=1.0,
alpha_sde=-1.0,
k_sde=1.0,
cfgpp=0.0,
c1=0.0,
c2=0.5,
c3=1.0,
noise_seed_sde=-1,
sampler_name="res_2m",
implicit_sampler_name="use_explicit",
implicit_type="bongmath",
implicit_type_substeps="bongmath",
implicit_steps=0,
implicit_substeps=0,
sigmas_override=None,
guides=None,
options=None,
sde_noise=None,
sde_noise_steps=1,
extra_options="",
automation=None,
epsilon_scales=None,
regional_conditioning_weights=None,
frame_weights_grp=None,
noise_boost_step=0.0,
noise_boost_substep=0.0,
noise_anchor=1.0,
rescale_floor=True,
):
noise_seed_sde = seed+1
# defaults for ClownSampler
eta_substep = eta
# defaults for SharkSampler
noise_type_init = "gaussian"
noise_stdev = 1.0
sampler_mode = "standard"
denoise_alt = 1.0
channelwise_cfg = 1.0
if options is not None:
noise_type_sde = options.get('noise_type_sde', noise_type_sde)
noise_type_sde_substep = options.get('noise_type_sde_substep', noise_type_sde_substep)
noise_mode_sde = options.get('noise_mode_sde', noise_mode_sde)
noise_mode_sde_substep = options.get('noise_mode_sde_substep', noise_mode_sde_substep)
overshoot_mode = options.get('overshoot_mode', overshoot_mode)
overshoot_mode_substep = options.get('overshoot_mode_substep', overshoot_mode_substep)
eta = options.get('eta', eta)
eta_substep = options.get('eta_substep', eta_substep)
overshoot = options.get('overshoot', overshoot)
overshoot_substep = options.get('overshoot_substep', overshoot_substep)
noise_boost_step = options.get('noise_boost_step', noise_boost_step)
noise_boost_substep = options.get('noise_boost_substep', noise_boost_substep)
noise_anchor = options.get('noise_anchor', noise_anchor)
s_noise = options.get('s_noise', s_noise)
s_noise_substep = options.get('s_noise_substep', s_noise_substep)
d_noise = options.get('d_noise', d_noise)
implicit_type = options.get('implicit_type', implicit_type)
implicit_type_substeps = options.get('implicit_type_substeps', implicit_type_substeps)
implicit_steps = options.get('implicit_steps', implicit_steps)
implicit_substeps = options.get('implicit_substeps', implicit_substeps)
alpha_sde = options.get('alpha_sde', alpha_sde)
k_sde = options.get('k_sde', k_sde)
c1 = options.get('c1', c1)
c2 = options.get('c2', c2)
c3 = options.get('c3', c3)
frame_weights_grp = options.get('frame_weights_grp', frame_weights_grp)
sde_noise = options.get('sde_noise', sde_noise)
sde_noise_steps = options.get('sde_noise_steps', sde_noise_steps)
extra_options = options.get('extra_options', extra_options)
automation = options.get('automation', automation)
# SharkSampler Options
noise_type_init = options.get('noise_type_init', noise_type_init)
noise_stdev = options.get('noise_stdev', noise_stdev)
sampler_mode = options.get('sampler_mode', sampler_mode)
denoise_alt = options.get('denoise_alt', denoise_alt)
channelwise_cfg = options.get('channelwise_cfg', channelwise_cfg)
if channelwise_cfg:
cfg = -abs(cfg) # set cfg negative for shark, to flag as cfg_cw
sampler = ClownSamplerAdvanced_Beta().main(
noise_type_sde = noise_type_sde,
noise_type_sde_substep = noise_type_sde_substep,
noise_mode_sde = noise_mode_sde,
noise_mode_sde_substep = noise_mode_sde_substep,
eta = eta,
eta_substep = eta_substep,
s_noise = s_noise,
s_noise_substep = s_noise_substep,
overshoot = overshoot,
overshoot_substep = overshoot_substep,
overshoot_mode = overshoot_mode,
overshoot_mode_substep = overshoot_mode_substep,
d_noise = d_noise,
alpha_sde = alpha_sde,
k_sde = k_sde,
cfgpp = cfgpp,
c1 = c1,
c2 = c2,
c3 = c3,
sampler_name = sampler_name,
implicit_sampler_name = implicit_sampler_name,
implicit_type = implicit_type,
implicit_type_substeps = implicit_type_substeps,
implicit_steps = implicit_steps,
implicit_substeps = implicit_substeps,
rescale_floor = rescale_floor,
sigmas_override = sigmas_override,
noise_seed_sde = noise_seed_sde,
guides = guides,
options = options,
extra_options = extra_options,
automation = automation,
noise_boost_step = noise_boost_step,
noise_boost_substep = noise_boost_substep,
epsilon_scales = epsilon_scales,
regional_conditioning_weights = regional_conditioning_weights,
frame_weights_grp = frame_weights_grp,
sde_noise = sde_noise,
sde_noise_steps = sde_noise_steps,
bongmath = bongmath,
)
output, denoised, sde_noise = SharkSampler().main(
model=model, cfg=cfg, scheduler=scheduler, steps=steps,
denoise=denoise,
latent_image=latent_image, positive=positive, negative=negative, sampler=sampler[0],
cfgpp=cfgpp, noise_seed=seed,
options=options, sde_noise=sde_noise, sde_noise_steps=sde_noise_steps,
noise_type_init=noise_type_init,
noise_stdev=noise_stdev,
sampler_mode=sampler_mode,
denoise_alt=denoise_alt,
extra_options=extra_options)
return (output, denoised,)
class ClownsharkUnsampler:
@classmethod
def INPUT_TYPES(s):
return {"required":
{"model": ("MODEL",),
"noise_type_init": (NOISE_GENERATOR_NAMES_SIMPLE, {"default": "gaussian"}),
"noise_type_sde": (NOISE_GENERATOR_NAMES_SIMPLE, {"default": "gaussian"}),
"noise_mode_sde": (NOISE_MODE_NAMES, {"default": 'hard', "tooltip": "How noise scales with the sigma schedule. Hard is the most aggressive, the others start strong and drop rapidly."}),
"eta": ("FLOAT", {"default": 0.5, "min": -100.0, "max": 100.0, "step":0.01, "round": False, "tooltip": "Calculated noise amount to be added, then removed, after each step."}),
"noise_seed": ("INT", {"default": 0, "min": -1, "max": 0xffffffffffffffff}),
"sampler_mode": (['standard', 'unsample', 'resample'],),
"sampler_name": (RK_SAMPLER_NAMES, {"default": "res_2m"}),
"implicit_sampler_name": (IRK_SAMPLER_NAMES, {"default": "explicit_diagonal"}),