-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
AnimateDiff #5296
AnimateDiff #5296
Conversation
If this implementation is good to go, I will work on the rest of the tasks mentioned in the Tasks/TODO section. |
Cc: @DN6 |
Hello, take a look at my pipeline, I already implemented a lot of things from your todo. May be you could pick something from it.
|
This is really good, can you open PR? |
@tumurzakov Thanks for sharing your work π. My current PR includes the following,
Since I've used the existing diffusers components, LoRA support for Unet is already available. The one in my TODO refers to the support for the new Motion LoRAs in AnimateDiff. The prompt walk and CN support in your repo looks like good features to have. I've seen some good community showcases of the same. I will add the support for those in my PR. |
@DN6 should I wait for the review of the existing commits or can I merge new commits here. Currently I've the Image2Video/Video2Video pipeline ready for merge. |
Hi @itsadarshms. Nice work putting this together. After taking a look into the original implementation and how AnimateDiff works, I think it might be better to introduce a dedicated model class for the AnimateDiff UNet. I've opened this PR with a proposed design. Since AnimateDiff behaves a bit like a ControlNet/Adapter (modifying the intermediate states of a 2D UNet) and allows saving/loading the motion modules separately, I think it would be better to try and follow a similar design paradigm. You've already brought up the challenges related to fusing the motion weights and 2D UNet weights. A Controlnet/Adapter Here's what I'm thinking for the API # Loading motion module into Pipeline
from diffusers import MotionAdapter, AnimateDiffPipeline
motion_adapter = MotionAdapter.from_pretrained("<path to saved motion modules>")
pipe = AnimateDiffPipeline.from_pretrained("runwayml/stable-diffusion-v1-5", motion_adapter=motion_adapter)
# Calling pipe.unet should return an UNetMotionModel object
# Create brand new UNetMotionModel with all random weights
unet = UNetMotionModel()
# Load from an existing 2D UNet and MotionAdapter
unet2D = UNet2DConditionModel.from_pretrained("...")
motion_adapter = MotionAdapter.from_pretrained("...")
unet_motion = UNetMotionModel.from_unet2d(unet2D, motion_adapter: Optional = None)
# Or load motion module after init
unet_motion.load_motion_modules(motion_adapter)
# Save only motion modules
unet_motion.save_motion_module(<path to save model>, push_to_hub=True)
# Save all weights to a single model repo (Including UNet weights)
unet_motion.save_pretrained()
# Load fused models (Where the motion weights are saved along with the UNet weights in a single repo)
unet_motion = UNetMotionModel.from_pretrained("<path to model>") |
@DN6 I agree, this design is clean and reduce modifications on the existing modules (that are mostly redundant). Implementing motion LoRAs in this design will be neat as well. Let me know if you are looking for contributions, I would be happy to collaborate. |
@itsadarshms Of course. Once we finalize the pipeline, there's a lot of additional functionality that can be added (ControlNets, LoRAs etc). |
Hi @itsadarshms thanks for the great work! Can you please share how you created the unet safetensors?
I'm hoping to convert other base models such as RcnzCartoon |
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread. Please note that issues that do not follow the contributing guidelines are likely to be ignored. |
What does this PR do?
This PR implements AnimateDiff as discussed in #4524
Status -> π§βπ» WIP
Model/Pipeline Description
Tasks/TODO
Usage Examples
itsadarshms/animatediff-v1-stable-diffusion-1.5
variant
parameter of theUNet3DConditionModel
tovariant="v14"
orvariant="v14.realistic_vision_v1.4"
Check the below HF model repos for the available weights
Design Thinking
Since AnimeDiff only require modifications in the Unet, the above HF repos hosts only Unet3D weights that are merged with the temporal module weights from AnimateDiff. While this approach works, I observed a few challenges and would greatly appreciate any suggestions or insights to address them.
from_pretrained
method.Β
Who can review?
@patrickvonplaten @sayakpaul