stable-diffusion-webui/modules/sd_samplers.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

68 lines
1.9 KiB
Python
Raw Normal View History

2024-03-20 06:17:11 +00:00
from __future__ import annotations
from modules import sd_samplers_kdiffusion, sd_samplers_timesteps, sd_samplers_lcm, shared, sd_samplers_common
# imports for functions that previously were here and are used by other modules
2024-03-20 06:17:11 +00:00
samples_to_image_grid = sd_samplers_common.samples_to_image_grid
sample_to_image = sd_samplers_common.sample_to_image
2022-09-03 14:21:15 +00:00
all_samplers = [
*sd_samplers_kdiffusion.samplers_data_k_diffusion,
*sd_samplers_timesteps.samplers_data_timesteps,
2024-01-08 12:43:39 +00:00
*sd_samplers_lcm.samplers_data_lcm,
]
all_samplers_map = {x.name: x for x in all_samplers}
2024-03-20 06:17:11 +00:00
samplers: list[sd_samplers_common.SamplerData] = []
samplers_for_img2img: list[sd_samplers_common.SamplerData] = []
samplers_map = {}
samplers_hidden = {}
def find_sampler_config(name):
if name is not None:
config = all_samplers_map.get(name, None)
else:
config = all_samplers[0]
return config
def create_sampler(name, model):
config = find_sampler_config(name)
assert config is not None, f'bad sampler name: {name}'
if model.is_sdxl and config.options.get("no_sdxl", False):
raise Exception(f"Sampler {config.name} is not supported for SDXL")
2022-10-06 11:12:52 +00:00
sampler = config.constructor(model)
sampler.config = config
2022-10-06 11:12:52 +00:00
return sampler
def set_samplers():
global samplers, samplers_for_img2img, samplers_hidden
samplers_hidden = set(shared.opts.hide_samplers)
samplers = all_samplers
samplers_for_img2img = all_samplers
samplers_map.clear()
for sampler in all_samplers:
samplers_map[sampler.name.lower()] = sampler.name
for alias in sampler.aliases:
samplers_map[alias.lower()] = sampler.name
def visible_sampler_names():
return [x.name for x in samplers if x.name not in samplers_hidden]
2024-03-20 06:17:11 +00:00
def visible_samplers():
return [x for x in samplers if x.name not in samplers_hidden]
set_samplers()