Update pipeline.py
Browse files- 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 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
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
|