smoothieAI commited on
Commit
47ecd18
·
verified ·
1 Parent(s): 2c12498

Update pipeline.py

Browse files
Files changed (1) hide show
  1. pipeline.py +42 -38
pipeline.py CHANGED
@@ -777,6 +777,7 @@ class AnimateDiffPipeline(DiffusionPipeline, TextualInversionLoaderMixin, IPAdap
777
  init_image: Optional[PipelineImageInput] = None,
778
  init_image_strength: Optional[float] = 1.0,
779
  init_noise_correlation: Optional[float] = 0.0,
 
780
  ):
781
  r"""
782
  The call function to the pipeline for generation.
@@ -905,44 +906,47 @@ class AnimateDiffPipeline(DiffusionPipeline, TextualInversionLoaderMixin, IPAdap
905
 
906
  # 5. Prepare latent variables
907
  num_channels_latents = self.unet.config.in_channels
908
- # latents = self.prepare_latents(
909
- # batch_size * num_videos_per_prompt,
910
- # num_channels_latents,
911
- # num_frames,
912
- # height,
913
- # width,
914
- # prompt_embeds.dtype,
915
- # device,
916
- # generator,
917
- # latents,
918
- # )
919
- latents = self.prepare_motion_latents(
920
- batch_size * num_videos_per_prompt,
921
- num_channels_latents,
922
- num_frames,
923
- height,
924
- width,
925
- prompt_embeds.dtype,
926
- device,
927
- generator,
928
- latents,
929
- x_velocity=x_velocity,
930
- y_velocity=y_velocity,
931
- scale_velocity=scale_velocity,
932
- )
933
- # latents, init_latents = self.prepare_correlated_latents(
934
- # init_image,
935
- # init_image_strength,
936
- # init_noise_correlation,
937
- # batch_size,
938
- # num_channels_latents,
939
- # num_frames,
940
- # height,
941
- # width,
942
- # prompt_embeds.dtype,
943
- # device,
944
- # generator,
945
- # )
 
 
 
946
 
947
 
948
  # 6. Prepare extra step kwargs. TODO: Logic should ideally just be moved out of the pipeline
 
777
  init_image: Optional[PipelineImageInput] = None,
778
  init_image_strength: Optional[float] = 1.0,
779
  init_noise_correlation: Optional[float] = 0.0,
780
+ latent_mode: Optional[str] = "normal",
781
  ):
782
  r"""
783
  The call function to the pipeline for generation.
 
906
 
907
  # 5. Prepare latent variables
908
  num_channels_latents = self.unet.config.in_channels
909
+ if(latent_mode == "normal"):
910
+ latents = self.prepare_latents(
911
+ batch_size * num_videos_per_prompt,
912
+ num_channels_latents,
913
+ num_frames,
914
+ height,
915
+ width,
916
+ prompt_embeds.dtype,
917
+ device,
918
+ generator,
919
+ latents,
920
+ )
921
+ elif(latent_mode == "motion"):
922
+ latents = self.prepare_motion_latents(
923
+ batch_size * num_videos_per_prompt,
924
+ num_channels_latents,
925
+ num_frames,
926
+ height,
927
+ width,
928
+ prompt_embeds.dtype,
929
+ device,
930
+ generator,
931
+ latents,
932
+ x_velocity=x_velocity,
933
+ y_velocity=y_velocity,
934
+ scale_velocity=scale_velocity,
935
+ )
936
+ elif(latent_mode == "correlated"):
937
+ latents, init_latents = self.prepare_correlated_latents(
938
+ init_image,
939
+ init_image_strength,
940
+ init_noise_correlation,
941
+ batch_size,
942
+ num_channels_latents,
943
+ num_frames,
944
+ height,
945
+ width,
946
+ prompt_embeds.dtype,
947
+ device,
948
+ generator,
949
+ )
950
 
951
 
952
  # 6. Prepare extra step kwargs. TODO: Logic should ideally just be moved out of the pipeline