Skip to content

Commit

Permalink
karras samplers for img2img?
Browse files Browse the repository at this point in the history
  • Loading branch information
AUTOMATIC1111 committed Oct 6, 2022
1 parent 405c817 commit b34b25b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions modules/sd_samplers.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,11 @@ def sample_img2img(self, p, x, noise, conditioning, unconditional_conditioning,
steps, t_enc = setup_img2img_steps(p, steps)

if p.sampler_noise_scheduler_override:
sigmas = p.sampler_noise_scheduler_override(steps)
sigmas = p.sampler_noise_scheduler_override(steps)
elif self.config is not None and self.config.options.get('scheduler', None) == 'karras':
sigmas = k_diffusion.sampling.get_sigmas_karras(n=steps, sigma_min=0.1, sigma_max=10, device=shared.device)
else:
sigmas = self.model_wrap.get_sigmas(steps)
sigmas = self.model_wrap.get_sigmas(steps)

noise = noise * sigmas[steps - t_enc - 1]
xi = x + noise
Expand Down

3 comments on commit b34b25b

@Birch-san
Copy link

@Birch-san Birch-san commented on b34b25b Oct 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AUTOMATIC1111
SD's sigmas span from 0.0292 to 14.6146.
https://gist.github.com/Birch-san/6cd1574e51871a5e2b88d59f0f3d4fd3

try:

sigma_min=self.model_wrap.sigmas[0],
sigma_max=self.model_wrap.sigmas[-1]

@Birch-san
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

excluding sigmas from the range prevents convergence:
https://github.com/invoke-ai/InvokeAI/discussions/914#discussioncomment-3799516

@Birch-san
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

related:
#4373

Please sign in to comment.