Skip to content
New issue

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

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

Already on GitHub? # to your account

Motion Model / Adapter versatility #8301

Merged
merged 3 commits into from
Jun 27, 2024

Conversation

Arlaz
Copy link
Contributor

@Arlaz Arlaz commented May 28, 2024

In the MotionModel and MotionAdapter for AnimateDiff pipeline :

  • allow to use a different number of layers per block
  • allow to use a different number of transformer per layers per block
  • allow a different number of motion attention head per block
  • allow to pass the dropout argument

These modifications are needed for some custom trained model that follow the SDXL architecture more closely (less down block) and more Transformer block per layers.

New arguments / tuple instead of int can now be used, as in the following example :

adapter = MotionAdapter(
    block_out_channels=(320, 640, 1280),  # to be checked with the base model unet for compatibility
    motion_layers_per_block=2,  # to be checked with the base model unet for compatibility
    motion_transformer_per_layers=(1, 2, 6),  # free to choose
    motion_mid_block_layers_per_block=1,
    motion_transformer_per_mid_layers=10,
    motion_num_attention_heads=(5, 8, 10), # free to choose
    motion_norm_num_groups=32,
    motion_max_seq_length=32,
    use_motion_mid_block=True,
    conv_in_channels=None,
)

Important : this PR does not break any existing code

Before submitting

Who can review?

@sayakpaul @yiyixuxu @DN6

@DN6 DN6 self-requested a review May 28, 2024 16:14
@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.

- allow to use a different number of layers per block
- allow to use a different number of transformer per layers per block
- allow a different number of motion attention head per block
- use dropout argument in get_down/up_block in 3d blocks
@Arlaz Arlaz force-pushed the motionmodel_improvements branch from c3525f9 to 4678f9c Compare June 3, 2024 08:43
@Arlaz
Copy link
Contributor Author

Arlaz commented Jun 5, 2024

The suggested changes have been made, thanks

@DN6
Copy link
Collaborator

DN6 commented Jun 10, 2024

Could we add a fast test for the model here:
https://github.com/huggingface/diffusers/blob/main/tests/models/unets/test_models_unet_motion.py

I think we we should test creating an asymmetric UNetMotionModel. I'd just like to confirm that the updated parameters aren't breaking anything.

@Arlaz
Copy link
Contributor Author

Arlaz commented Jun 10, 2024

Of course, a forward test for the most asymmetrical UnetMotionModel possible is added 😃
It's passing on my side.

@Arlaz
Copy link
Contributor Author

Arlaz commented Jun 17, 2024

Are some of the tests failing because of my commits ?
After log inspection I don't think so, but if that's the case can you please give me some hints on how to solve it ?

@DN6
Copy link
Collaborator

DN6 commented Jun 27, 2024

Failing tests are unrelated @Arlaz. Merging this.

@DN6 DN6 merged commit 3e0d128 into huggingface:main Jun 27, 2024
13 of 15 checks passed
@Arlaz Arlaz deleted the motionmodel_improvements branch June 27, 2024 13:32
sayakpaul pushed a commit that referenced this pull request Dec 23, 2024
* Motion Model / Adapter versatility

- allow to use a different number of layers per block
- allow to use a different number of transformer per layers per block
- allow a different number of motion attention head per block
- use dropout argument in get_down/up_block in 3d blocks

* Motion Model added arguments renamed & refactoring

* Add test for asymmetric UNetMotionModel
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants