Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Community] Experimental AnimateDiff Image to Video (open to improvements) #6509

Merged
merged 8 commits into from
Jan 19, 2024

Conversation

a-r-r-o-w
Copy link
Contributor

@a-r-r-o-w a-r-r-o-w commented Jan 9, 2024

What does this PR do?

Experimental img2vid support for AnimateDiff. Moved it here from #6328 due to the other being a core addition and it should make it easier to review vid2vid.

Colab

Fixes #6123.

Before submitting

Who can review?

@DN6

@a-r-r-o-w a-r-r-o-w mentioned this pull request Jan 9, 2024
6 tasks
@a-r-r-o-w a-r-r-o-w changed the title [Community] AnimateDiff Image to Video [Community] Experimental AnimateDiff Image to Video (open to improvements) Jan 9, 2024
@a-r-r-o-w
Copy link
Contributor Author

Some results can be found here: #6328 (comment)

Copy link
Collaborator

@DN6 DN6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent 👍🏽

examples/community/README.md Outdated Show resolved Hide resolved
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Collaborator

@DN6 DN6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@a-r-r-o-w
Copy link
Contributor Author

a-r-r-o-w commented Jan 17, 2024

image

Looks like the IP Adapter FaceID PR would require fixing in the community README. @DN6 Should I fix it here?

Edit: There's a few things that we could refactor in the community README. I think I'll take it up in a separate PR after this.

@DN6
Copy link
Collaborator

DN6 commented Jan 17, 2024

@a-r-r-o-w I think separate PR for the README works.

@patrickvonplaten patrickvonplaten merged commit 6382663 into huggingface:main Jan 19, 2024
14 checks passed
@a-r-r-o-w a-r-r-o-w mentioned this pull request Jan 19, 2024
6 tasks
@Skquark
Copy link

Skquark commented Feb 22, 2024

I ran into an issue using pipeline_animatediff_img2video worth reporting.. Getting this import error:

File "/root/.cache/huggingface/modules/diffusers_modules/git/pipeline_animatediff_img2video.py", line 28, in <module>
    from diffusers.models.unet_motion_model import MotionAdapter
ModuleNotFoundError: No module named 'diffusers.models.unet_motion_model'

To fix it, you'd change that line to:
from diffusers.models.unets.unet_motion_model import MotionAdapter
Looks like it was missing the .unets part as I see in animatediff_controlnet.py.. Tested in my custom at "AlanB/pipeline_animatediff_img2video_mod" and got it working in DiffusionDeluxe.com app. I also notice the output was grainy, thinking the DDIM scheduler code in the example may be incorrect too, gonna play with that some more to make sure. Thanks.

@DN6
Copy link
Collaborator

DN6 commented Feb 23, 2024

cc: @a-r-r-o-w

@a-r-r-o-w
Copy link
Contributor Author

@Skquark Thanks for reporting the error! I believe this PR overlapped with the refactoring of the UNet modules and so this broke. If you'd like to, you can submit a PR fixing it otherwise I'll take it up sometime soon. Regarding the quality, AnimateDiff motion checkpoints are sensitive to the beta_schedule="linear" parameter so make sure that you set it when initializing the scheduler. The output quality here is not that great because of how the latents are created from an image (it is a method that the community figured out that produces ~handwavy results). If you're looking into it more deeply to improve result quality, maybe this comment can provide some useful information. I'd love if you can figure out how generation quality could be improved, and congrats on building what you have! But, I do not think much can be done to improve generation quality with a hacky trick like how the latents are created here, or atleast don't know of any such technique (maybe @jon-chuang could share his thoughts), and so I'd recommend using a model geared towards img2vid such as Personalized Image Animator or MotionCtrl SVD.

@Skquark
Copy link

Skquark commented Feb 23, 2024

Thanks, simple enough fix for an understandable refactoring break. I'd prefer it if you or someone else does that PR since it's an easy one-liner and my git fork is a mess, but I can try if preferred.. I also changed the way I loaded the scheduler to be the same as the video2video example using .from_pretrained, and it worked much better without the defective graininess, so may want to change that too in the usage example.. Worked right with this setting:
pipe.scheduler = DDIMScheduler.from_pretrained(model_id, subfolder="scheduler", clip_sample=False, timestep_spacing="linspace", beta_schedule="linear", steps_offset=1)
instead of DDIMScheduler(beta_schedule="linear".... Another easy fix, got some pretty fun test results so far, looking forward to see what we can do with it next. I've got a nice collection of most of the good opensource Video AIs in my app, including PIA, I2VGen-XL, Video-to-Video, Controlnet Vid2Vid, SVD, Enhanced AnimateDiff from cli mod instead of HF, and all the others I could find. Will add MotionCtrl SVD when it's merged, and more as they come, they're all fun to play with... Now I'm anxious to see what SD3 will do for videos in the next leap. Anyways, here's my screenshots of this pipeline's implementation..
SDD_AnimateDiff_Img2Vid-1
SDD_AnimateDiff_Img2Vid-2

@a-r-r-o-w a-r-r-o-w deleted the re-animatediff-img2video branch February 25, 2024 11:44
AmericanPresidentJimmyCarter pushed a commit to AmericanPresidentJimmyCarter/diffusers that referenced this pull request Apr 26, 2024
…ents) (huggingface#6509)

* add animatediff img2vid

* fix

* Update examples/community/README.md

Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>

* fix code snippet between ip adapter face id and animatediff img2vid

---------

Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AnimateDiffPipeline: add ImageToVideo and VideoToVideo
5 participants