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

animatediff result is worse than origin Repo #5881

Closed
akk-123 opened this issue Nov 21, 2023 · 11 comments
Closed

animatediff result is worse than origin Repo #5881

akk-123 opened this issue Nov 21, 2023 · 11 comments
Assignees
Labels
bug Something isn't working

Comments

@akk-123
Copy link

akk-123 commented Nov 21, 2023

Describe the bug

It's seems that animatediff result is bad, generate image is blur, however when I use the sdwebui or origin animatediff, it can get good result

diffuser result
https://github.com/huggingface/diffusers/assets/98469560/994c50d7-0568-4798-8e33-61251c77cd36

sdwebui or origin repo result
https://github.com/huggingface/diffusers/assets/98469560/dee390c2-7e95-4cee-a041-086d95d03cc8

Reproduction

adapter = MotionAdapter.from_pretrained("xx/animatediff-motion-adapter-v1-5-2")
model_id = "xx/majicmixRealistic_v7" 

animate_pipe = AnimateDiffPipeline.from_pretrained(model_id, motion_adapter=adapter).to('cuda')
scheduler = DDIMScheduler.from_pretrained(
    model_id, subfolder="scheduler", clip_sample=False, timestep_spacing="linspace", steps_offset=1
)
animate_pipe.scheduler = scheduler

prompt="1girl, offshoulder, light smile, shiny skin best quality, masterpiece, photorealistic"
seed = 42
frames = animate_pipe(
    prompt=prompt,
    num_frames=16,
    guidance_scale=7.5,
    num_inference_steps=30,
    generator=torch.Generator("cpu").manual_seed(seed),
).frames[0]

Logs

No response

System Info

  • diffusers version: 0.23.0
  • Platform: Linux-4.9.70-040970-generic-x86_64-with-glibc2.23
  • Python version: 3.10.13
  • PyTorch version (GPU?): 2.0.1+cu118 (True)
  • Huggingface_hub version: 0.17.3
  • Transformers version: 4.30.2
  • Accelerate version: 0.21.0
  • xFormers version: 0.0.20

Who can help?

No response

@akk-123 akk-123 added the bug Something isn't working label Nov 21, 2023
@DN6
Copy link
Collaborator

DN6 commented Nov 21, 2023

@akk-123 Looking into it. Just to confirm, the results used the exact same prompts, seeds and schedulers? I ask because the subjects seem to be different in the two results you shared.

@akk-123
Copy link
Author

akk-123 commented Nov 22, 2023

@DN6 yes, I use the same config
image

@akk-123
Copy link
Author

akk-123 commented Nov 24, 2023

@DN6 Any progress about it?

@cfanyyx
Copy link

cfanyyx commented Nov 28, 2023

@DN6 Hi, Any progress about it? I found the same problem. I think maybe the implementation of animatediff in diffusers has something wrong?

@WuTao-CS
Copy link

I meet the same problem, and the result seemed to be significantly different from the original repo.

@DN6
Copy link
Collaborator

DN6 commented Nov 29, 2023

Hi @akk-123 taking a look into it this week. Do you notice the same quality difference when you use other checkpoints?

@akk-123
Copy link
Author

akk-123 commented Nov 30, 2023

Hi @akk-123 taking a look into it this week. Do you notice the same quality difference when you use other checkpoints?

yes, all checkpoints is worse

@DN6 Hi, Any progress about it? I found the same problem. I think maybe the implementation of animatediff in diffusers has something wrong?

I agree, maybe the implementation of animatediff in diffusers has something wrong

@DN6
Copy link
Collaborator

DN6 commented Dec 4, 2023

Hi @akk-123 I think the issue seems to be with the beta_schedule set by the checkpoint. Changing it to linear removed the artifacts from the generated gif.

import torch
from diffusers import AnimateDiffPipeline, MotionAdapter, DDIMScheduler
from diffusers.utils import export_to_gif

adapter = MotionAdapter.from_pretrained("guoyww/animatediff-motion-adapter-v1-5-2")
model_id = "pagebrain/majicmix-realistic-v7"

pipe = AnimateDiffPipeline.from_pretrained(model_id, motion_adapter=adapter).to('cuda')
scheduler = DDIMScheduler.from_pretrained(
    model_id,
    subfolder="scheduler",
    beta_schedule="linear",
    clip_sample=False,
    timestep_spacing="linspace",
    steps_offset=1
)
pipe.scheduler = scheduler
pipe.to("cuda")
pipe.enable_vae_slicing()

prompt="1girl, offshoulder, light smile, shiny skin best quality, masterpiece, photorealistic"
seed = 42
frames = pipe(
    prompt=prompt,
    num_frames=16,
    guidance_scale=7.5,
    num_inference_steps=30,
    generator=torch.Generator("cpu").manual_seed(seed),
).frames[0]
export_to_gif(frames, "output.gif")

@akk-123
Copy link
Author

akk-123 commented Dec 5, 2023

@DN6 thanks, I try it, It's work, why does this parameter(beta_schedule) have such a big impact on the results?

@DN6
Copy link
Collaborator

DN6 commented Dec 7, 2023

I think the original repository trained the model using the linear schedule with DDIM. It could be that the motion checkpoint is sensitive to it.

@akk-123 akk-123 closed this as completed Dec 7, 2023
@a-r-r-o-w
Copy link
Member

@DN6 Kindly requesting your suggestions to be reflected in blogs like this. The quality change is quite significant and it would help a lot of people like me that were wondering about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants