Fix diffusers clip_skip math

This commit is contained in:
Disty0
2024-02-09 01:48:17 +03:00
parent 5b76fc3140
commit 0923a98f08
+10 -3
View File
@@ -182,6 +182,13 @@ def process_diffusers(p: processing.StableDiffusionProcessing):
shared.log.error(f'Prompt parser encode: {e}')
if os.environ.get('SD_PROMPT_DEBUG', None) is not None:
errors.display(e, 'Prompt parser encode')
if parser == 'Fixed attention':
clip_skip = kwargs.pop("clip_skip", None)
if clip_skip is not None:
if 'XL' in model.__class__.__name__:
args['clip_skip'] = clip_skip - 2
else:
args['clip_skip'] = clip_skip - 1
if 'prompt' in possible:
if hasattr(model, 'text_encoder') and 'prompt_embeds' in possible and len(p.prompt_embeds) > 0 and p.prompt_embeds[0] is not None:
args['prompt_embeds'] = p.prompt_embeds[0]
@@ -410,7 +417,7 @@ def process_diffusers(p: processing.StableDiffusionProcessing):
denoising_start=0 if use_refiner_start else p.refiner_start if use_denoise_start else None,
denoising_end=p.refiner_start if use_refiner_start else 1 if use_denoise_start else None,
output_type='latent' if hasattr(shared.sd_model, 'vae') else 'np',
clip_skip=p.clip_skip - 1,
clip_skip=p.clip_skip,
desc='Base',
)
update_sampler(shared.sd_model)
@@ -487,7 +494,7 @@ def process_diffusers(p: processing.StableDiffusionProcessing):
guidance_scale=p.image_cfg_scale if p.image_cfg_scale is not None else p.cfg_scale,
guidance_rescale=p.diffusers_guidance_rescale,
output_type='latent' if hasattr(shared.sd_model, 'vae') else 'np',
clip_skip=p.clip_skip - 1,
clip_skip=p.clip_skip,
image=output.images,
strength=p.denoising_strength,
desc='Hires',
@@ -546,7 +553,7 @@ def process_diffusers(p: processing.StableDiffusionProcessing):
denoising_end=1 if p.refiner_start > 0 and p.refiner_start < 1 else None,
image=image,
output_type=output_type,
clip_skip=p.clip_skip - 1,
clip_skip=p.clip_skip,
desc='Refiner',
)
shared.state.sampling_steps = refiner_args['num_inference_steps']