mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
restore ability of ksamplers to process -v variation options
- supersedes PR #977 - works with both img2img and txt2img
This commit is contained in:
parent
3d7bc074cf
commit
7a701506a4
@ -49,6 +49,7 @@ class Img2Img(Generator):
|
|||||||
img_callback = step_callback,
|
img_callback = step_callback,
|
||||||
unconditional_guidance_scale=cfg_scale,
|
unconditional_guidance_scale=cfg_scale,
|
||||||
unconditional_conditioning=uc,
|
unconditional_conditioning=uc,
|
||||||
|
init_latent = self.init_latent, # changes how noising is performed in ksampler
|
||||||
)
|
)
|
||||||
|
|
||||||
return self.sample_to_image(samples)
|
return self.sample_to_image(samples)
|
||||||
|
@ -175,8 +175,13 @@ class KSampler(Sampler):
|
|||||||
total_steps = len(self.sigmas)
|
total_steps = len(self.sigmas)
|
||||||
sigmas = self.sigmas[-S-1:]
|
sigmas = self.sigmas[-S-1:]
|
||||||
|
|
||||||
|
# x_T is variation noise. When an init image is provided (in x0) we need to add
|
||||||
|
# more randomness to the starting image.
|
||||||
if x_T is not None:
|
if x_T is not None:
|
||||||
x = x_T + torch.randn([batch_size, *shape], device=self.device) * sigmas[0]
|
if x0 is not None:
|
||||||
|
x = x_T + torch.randn_like(x0, device=self.device) * sigmas[0]
|
||||||
|
else:
|
||||||
|
x = x_T * sigmas[0]
|
||||||
else:
|
else:
|
||||||
x = torch.randn([batch_size, *shape], device=self.device) * sigmas[0]
|
x = torch.randn([batch_size, *shape], device=self.device) * sigmas[0]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user