| 2 | from .presets_to_add import extra_samplers |
| 3 | |
| 4 | def add_samplers(): |
| 5 | from comfy.samplers import KSampler, k_diffusion_sampling |
| 6 | added = 0 |
| 7 | samplers_names = [n for n in extra_samplers][::-1] |
| 8 | for sampler in samplers_names: |
| 9 | if sampler not in KSampler.SAMPLERS: |
| 10 | try: |
| 11 | idx = KSampler.SAMPLERS.index("uni_pc_bh2") # Last item in the samplers list |
| 12 | KSampler.SAMPLERS.insert(idx+1, sampler) # Add our custom samplers |
| 13 | setattr(k_diffusion_sampling, "sample_{}".format(sampler), extra_samplers[sampler]) |
| 14 | added += 1 |
| 15 | except ValueError as _err: |
| 16 | pass |
| 17 | if added > 0: |
| 18 | import importlib |
| 19 | importlib.reload(k_diffusion_sampling) |
| 20 | |
| 21 | add_samplers() |
| 22 | |