Skip to content

Commit 35db2fd

Browse files
authored
Update pipeline_animatediff_video2video.py (#7457)
* Update pipeline_animatediff_video2video.py * commit with test for whether latent input can be passed into animatediffvid2vid
1 parent ad55ce6 commit 35db2fd

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/diffusers/pipelines/animatediff/pipeline_animatediff_video2video.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ def prepare_latents(
638638
# video must be a list of list of images
639639
# the outer list denotes having multiple videos as input, whereas inner list means the frames of the video
640640
# as a list of images
641-
if not isinstance(video[0], list):
641+
if video and not isinstance(video[0], list):
642642
video = [video]
643643
if latents is None:
644644
video = torch.cat(

tests/pipelines/animatediff/test_animatediff_video2video.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,17 @@ def test_prompt_embeds(self):
269269
inputs["prompt_embeds"] = torch.randn((1, 4, 32), device=torch_device)
270270
pipe(**inputs)
271271

272+
def test_latent_inputs(self):
273+
components = self.get_dummy_components()
274+
pipe = self.pipeline_class(**components)
275+
pipe.set_progress_bar_config(disable=None)
276+
pipe.to(torch_device)
277+
278+
inputs = self.get_dummy_inputs(torch_device)
279+
inputs["latents"] = torch.randn((1, 4, 1, 32, 32), device=torch_device)
280+
inputs.pop("video")
281+
pipe(**inputs)
282+
272283
@unittest.skipIf(
273284
torch_device != "cuda" or not is_xformers_available(),
274285
reason="XFormers attention is only available with CUDA and `xformers` installed",

0 commit comments

Comments
 (0)