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

UnetMotionModel ignores important parameters #6125

Closed
jon-chuang opened this issue Dec 10, 2023 · 13 comments
Closed

UnetMotionModel ignores important parameters #6125

jon-chuang opened this issue Dec 10, 2023 · 13 comments
Assignees
Labels
bug Something isn't working contributions-welcome stale Issues that haven't received updates

Comments

@jon-chuang
Copy link

Describe the bug

{'center_input_sample': False, 'flip_sin_to_cos': True, 'freq_shift': 0, 'mid_block_type': 'UNetMidBlock2DCrossAttn', 'only_cross_attention': False, 'dropout': 0.0, 'transformer_layers_per_block': 1, 'attention_head_dim': 8, 'dual_cross_attention': False, 'class_embed_type': None, 'addition_embed_type': None, 'addition_time_embed_dim': None, 'num_class_embeds': None, 'upcast_attention': None, 'resnet_time_scale_shift': 'default', 'resnet_skip_time_act': False, 'resnet_out_scale_factor': 1.0, 'time_embedding_type': 'positional', 'time_embedding_dim': None, 'time_embedding_act_fn': None, 'timestep_post_act': None, 'time_cond_proj_dim': 256, 'conv_in_kernel': 3, 'conv_out_kernel': 3, 'projection_class_embeddings_input_dim': None, 'attention_type': 'default', 'class_embeddings_concat': False, 'mid_block_only_cross_attention': None, 'cross_attention_norm': None, 'addition_embed_type_num_heads': 64}

In particular, it does not initialize time_embedding with 'cond_proj_dim': 256

Reproduction

DreamshaperV7 + MotionAdapter in AnimateDiff pipeline

Logs

No response

System Info

  • diffusers version: 0.24.0
  • Platform: Linux-6.2.0-37-generic-x86_64-with-glibc2.35
  • Python version: 3.10.12
  • PyTorch version (GPU?): 2.2.0a0+git177a1a6 (True)
  • Huggingface_hub version: 0.16.4
  • Transformers version: 4.35.2
  • Accelerate version: 0.25.0
  • xFormers version: 0.0.22.post7
  • Using GPU in script?:
  • Using distributed or parallel set-up in script?:

Who can help?

@DN6 @sayakpaul @patrickvonplaten

@jon-chuang jon-chuang added the bug Something isn't working label Dec 10, 2023
@DN6
Copy link
Collaborator

DN6 commented Dec 12, 2023

Hi @jon-chuang I don't think the original implementation used cond_proj_dim in its UNet. Hence it was omitted. Would you be able to open a PR to add it to the current motion UNet?

@jon-chuang
Copy link
Author

Sure, this is used for example in some non-standard models like DreamshaperV7

@DN6
Copy link
Collaborator

DN6 commented Dec 12, 2023

Hmm actually. Would you be able to provide a snippet to reproduce? I think the UNet is being initialised with the right weights, but the warning is being raised because of how the config is loaded.

@jon-chuang
Copy link
Author

jon-chuang commented Dec 12, 2023

Well, long story short, it throws an error, saying the parameter in question is unexpected. That's because the TimeEmbedding state dict has not been initialized from the JSON config properly, so it does not have a cond.proj field/attr.

By contrast, the Dreamshaper unet timeembedding has a cond.proj field.

@jon-chuang
Copy link
Author

jon-chuang commented Dec 12, 2023

Repro:

import torch
from diffusers import MotionAdapter, AnimateDiffPipeline

adapter = MotionAdapter.from_pretrained("guoyww/animatediff-motion-adapter-v1-5-2").to('cuda', dtype=torch.float16)
pipe = AnimateDiffPipeline.from_pretrained(
    "SimianLuo/LCM_Dreamshaper_v7", use_safetensors=True, motion_adapter=adapter
).to('cuda', dtype=torch.float16)

@DN6
Copy link
Collaborator

DN6 commented Dec 12, 2023

Ah yes. You're right. Would you mind opening a PR with a fix?

Copy link

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.

@github-actions github-actions bot added the stale Issues that haven't received updates label Jan 10, 2024
@DN6 DN6 reopened this Jan 22, 2024
@DN6 DN6 reopened this Jan 30, 2024
@github-actions github-actions bot closed this as completed Feb 8, 2024
@yiyixuxu yiyixuxu added contributions-welcome and removed stale Issues that haven't received updates labels Feb 8, 2024
@yiyixuxu yiyixuxu reopened this Feb 8, 2024
@DN6 DN6 reopened this Feb 19, 2024
@patrickvonplaten
Copy link
Contributor

@DN6 feel free to tackle it if the author of the issue doesn't answer

@stephen-iezzi
Copy link
Contributor

I worked on an issue with the UNetMotionModel yesterday, I'd be happy to go for this one as well!

@sayakpaul
Copy link
Member

Feel free to submit your PR :)

@DN6
Copy link
Collaborator

DN6 commented Feb 21, 2024

@Stepheni12 You can add both changes to your PR: #7035

Copy link

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.

@github-actions github-actions bot added the stale Issues that haven't received updates label Mar 16, 2024
@sayakpaul
Copy link
Member

I guess we can close this now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working contributions-welcome stale Issues that haven't received updates
Projects
None yet
Development

No branches or pull requests

6 participants