Skip to content

Commit

Permalink
Update pipeline_animatediff_video2video.py (huggingface#7457)
Browse files Browse the repository at this point in the history
* Update pipeline_animatediff_video2video.py

* commit with test for whether latent input can be passed into animatediffvid2vid
  • Loading branch information
AbhinavGopal authored Apr 3, 2024
1 parent ad55ce6 commit 35db2fd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ def prepare_latents(
# video must be a list of list of images
# the outer list denotes having multiple videos as input, whereas inner list means the frames of the video
# as a list of images
if not isinstance(video[0], list):
if video and not isinstance(video[0], list):
video = [video]
if latents is None:
video = torch.cat(
Expand Down
11 changes: 11 additions & 0 deletions tests/pipelines/animatediff/test_animatediff_video2video.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,17 @@ def test_prompt_embeds(self):
inputs["prompt_embeds"] = torch.randn((1, 4, 32), device=torch_device)
pipe(**inputs)

def test_latent_inputs(self):
components = self.get_dummy_components()
pipe = self.pipeline_class(**components)
pipe.set_progress_bar_config(disable=None)
pipe.to(torch_device)

inputs = self.get_dummy_inputs(torch_device)
inputs["latents"] = torch.randn((1, 4, 1, 32, 32), device=torch_device)
inputs.pop("video")
pipe(**inputs)

@unittest.skipIf(
torch_device != "cuda" or not is_xformers_available(),
reason="XFormers attention is only available with CUDA and `xformers` installed",
Expand Down

0 comments on commit 35db2fd

Please sign in to comment.