poipiii commited on
Commit
14ff830
·
1 Parent(s): dabc83d

test latent fix

Browse files
Files changed (1) hide show
  1. pipeline.py +8 -3
pipeline.py CHANGED
@@ -617,7 +617,7 @@ class StableDiffusionLongPromptWeightingPipeline(StableDiffusionPipeline):
617
  extra_step_kwargs["generator"] = generator
618
  return extra_step_kwargs
619
 
620
- def prepare_latents(self, image, timestep, batch_size, height, width, dtype, device, generator, latents=None):
621
  if image is None:
622
  shape = (
623
  batch_size,
@@ -637,9 +637,11 @@ class StableDiffusionLongPromptWeightingPipeline(StableDiffusionPipeline):
637
  raise ValueError(f"Unexpected latents shape, got {latents.shape}, expected {shape}")
638
  latents = latents.to(device)
639
 
 
 
640
  # scale the initial noise by the standard deviation required by the scheduler
641
- latents = latents * self.scheduler.init_noise_sigma
642
- return latents, None, None
643
  else:
644
  init_latent_dist = self.vae.encode(image).latent_dist
645
  init_latents = init_latent_dist.sample(generator=generator)
@@ -673,6 +675,7 @@ class StableDiffusionLongPromptWeightingPipeline(StableDiffusionPipeline):
673
  eta: float = 0.0,
674
  generator: Optional[torch.Generator] = None,
675
  latents: Optional[torch.FloatTensor] = None,
 
676
  return_latents: bool = False,
677
  max_embeddings_multiples: Optional[int] = 3,
678
  output_type: Optional[str] = "pil",
@@ -1023,6 +1026,7 @@ class StableDiffusionLongPromptWeightingPipeline(StableDiffusionPipeline):
1023
  generator=generator,
1024
  latents=latents,
1025
  return_latents=True,
 
1026
  max_embeddings_multiples=max_embeddings_multiples,
1027
  output_type=output_type,
1028
  return_dict=return_dict,
@@ -1046,6 +1050,7 @@ class StableDiffusionLongPromptWeightingPipeline(StableDiffusionPipeline):
1046
  generator=generator,
1047
  latents=latents,
1048
  return_latents=False,
 
1049
  max_embeddings_multiples=max_embeddings_multiples,
1050
  output_type=output_type,
1051
  return_dict=return_dict,
 
617
  extra_step_kwargs["generator"] = generator
618
  return extra_step_kwargs
619
 
620
+ def prepare_latents(self, image, timestep, batch_size, height, width, dtype, device, generator,upscale=False, latents=None):
621
  if image is None:
622
  shape = (
623
  batch_size,
 
637
  raise ValueError(f"Unexpected latents shape, got {latents.shape}, expected {shape}")
638
  latents = latents.to(device)
639
 
640
+ if upscale:
641
+ return latents, None, None
642
  # scale the initial noise by the standard deviation required by the scheduler
643
+ latents = latents * self.scheduler.init_noise_sigma
644
+ return latents, None, None
645
  else:
646
  init_latent_dist = self.vae.encode(image).latent_dist
647
  init_latents = init_latent_dist.sample(generator=generator)
 
675
  eta: float = 0.0,
676
  generator: Optional[torch.Generator] = None,
677
  latents: Optional[torch.FloatTensor] = None,
678
+ upscale: bool = False,
679
  return_latents: bool = False,
680
  max_embeddings_multiples: Optional[int] = 3,
681
  output_type: Optional[str] = "pil",
 
1026
  generator=generator,
1027
  latents=latents,
1028
  return_latents=True,
1029
+ upscale=False,
1030
  max_embeddings_multiples=max_embeddings_multiples,
1031
  output_type=output_type,
1032
  return_dict=return_dict,
 
1050
  generator=generator,
1051
  latents=latents,
1052
  return_latents=False,
1053
+ upscale=True,
1054
  max_embeddings_multiples=max_embeddings_multiples,
1055
  output_type=output_type,
1056
  return_dict=return_dict,