samplers add custom sigma

Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
Vladimir Mandic
2024-12-03 08:52:53 -05:00
parent bd192d2991
commit e3f06734d0
3 changed files with 17 additions and 1 deletions
+15
View File
@@ -186,6 +186,21 @@ def set_pipeline_args(p, model, prompts: list, negative_prompts: list, prompts_2
shared.log.error(f'Sampler timesteps: {e}')
else:
shared.log.warning(f'Sampler: sampler={model.scheduler.__class__.__name__} timesteps not supported')
if 'sigmas' in possible:
sigmas = re.split(',| ', shared.opts.schedulers_timesteps)
sigmas = [float(x)/1000.0 for x in sigmas if x.isdigit()]
if len(sigmas) > 0:
if hasattr(model.scheduler, 'set_timesteps') and "sigmas" in set(inspect.signature(model.scheduler.set_timesteps).parameters.keys()):
try:
args['sigmas'] = sigmas
p.steps = len(sigmas)
p.timesteps = sigmas
steps = p.steps
shared.log.debug(f'Sampler: steps={len(sigmas)} sigmas={sigmas}')
except Exception as e:
shared.log.error(f'Sampler sigmas: {e}')
else:
shared.log.warning(f'Sampler: sampler={model.scheduler.__class__.__name__} sigmas not supported')
if hasattr(model, 'scheduler') and hasattr(model.scheduler, 'noise_sampler_seed') and hasattr(model.scheduler, 'noise_sampler'):
model.scheduler.noise_sampler = None # noise needs to be reset instead of using cached values