mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 01:04:32 +02:00
maybe fix slerp
This commit is contained in:
+4
-10
@@ -17,8 +17,7 @@ class Script(scripts.Script):
|
||||
def get_latents(p):
|
||||
generator_device = devices.cpu if shared.opts.diffusers_generator_device == "CPU" else shared.device
|
||||
generator = [torch.Generator(generator_device).manual_seed(s) for s in p.seeds]
|
||||
shape = (len(generator), shared.sd_model.unet.config.in_channels, p.height // shared.sd_model.vae_scale_factor,
|
||||
p.width // shared.sd_model.vae_scale_factor)
|
||||
shape = (len(generator), shared.sd_model.unet.config.in_channels, p.height // shared.sd_model.vae_scale_factor, p.width // shared.sd_model.vae_scale_factor)
|
||||
latents = randn_tensor(shape, generator=generator, device=shared.sd_model._execution_device, dtype=shared.sd_model.unet.dtype) # pylint: disable=protected-access
|
||||
var_generator = [torch.Generator(generator_device).manual_seed(ss) for ss in p.subseeds]
|
||||
var_latents = randn_tensor(shape, generator=var_generator, device=shared.sd_model._execution_device, dtype=shared.sd_model.unet.dtype) # pylint: disable=protected-access
|
||||
@@ -26,14 +25,8 @@ class Script(scripts.Script):
|
||||
|
||||
@staticmethod
|
||||
def set_slerp(p, latents, var_latents, generator, var_generator):
|
||||
if p.subseed_strength < 1:
|
||||
p.init_latent = slerp(p.subseed_strength, latents, var_latents)
|
||||
if p.subseed_strength == 1:
|
||||
p.init_latent = var_latents
|
||||
if 0 < p.subseed_strength <= 0.5:
|
||||
p.generator = generator
|
||||
if 0.5 < p.subseed_strength <= 1:
|
||||
p.generator = var_generator
|
||||
p.init_latent = slerp(p.subseed_strength, latents, var_latents) if p.subseed_strength < 1 else var_latents
|
||||
p.generator = generator if p.subseed_strength <= 0.5 else var_generator
|
||||
|
||||
|
||||
def process_batch(self, p: processing.StableDiffusionProcessing, *args, **kwargs): # pylint: disable=arguments-differ
|
||||
@@ -43,3 +36,4 @@ class Script(scripts.Script):
|
||||
if p.subseed_strength != 0 and getattr(shared.sd_model, '_execution_device', None) is not None:
|
||||
latents, var_latents, generator, var_generator = self.get_latents(p)
|
||||
self.set_slerp(p, latents, var_latents, generator, var_generator)
|
||||
# shared.log.warning(f'Init latents: start={torch.aminmax(latents)} end={torch.aminmax(var_latents)} strength={p.subseed_strength} res={torch.aminmax(p.init_latent)}')
|
||||
|
||||
Reference in New Issue
Block a user