diff --git a/invokeai/backend/stable_diffusion/diffusion_backend.py b/invokeai/backend/stable_diffusion/diffusion_backend.py index 806deb5e03..60a21bdc02 100644 --- a/invokeai/backend/stable_diffusion/diffusion_backend.py +++ b/invokeai/backend/stable_diffusion/diffusion_backend.py @@ -100,8 +100,10 @@ class StableDiffusionBackend: if isinstance(guidance_scale, list): guidance_scale = guidance_scale[ctx.step_index] - return torch.lerp(ctx.negative_noise_pred, ctx.positive_noise_pred, guidance_scale) - # return ctx.negative_noise_pred + guidance_scale * (ctx.positive_noise_pred - ctx.negative_noise_pred) + # Note: Although logically it same, it seams that precision errors differs. + # This sometimes results in slightly different output. + # return torch.lerp(ctx.negative_noise_pred, ctx.positive_noise_pred, guidance_scale) + return ctx.negative_noise_pred + guidance_scale * (ctx.positive_noise_pred - ctx.negative_noise_pred) def run_unet(self, ctx: DenoiseContext, ext_manager: ExtensionsManager, conditioning_mode: ConditioningMode): sample = ctx.latent_model_input