Skip to content

Fix diffusers compatibility: handle renamed modules#435

Open
Mr-Neutr0n wants to merge 2 commits intoguoyww:mainfrom
Mr-Neutr0n:fix/diffusers-import-compatibility
Open

Fix diffusers compatibility: handle renamed modules#435
Mr-Neutr0n wants to merge 2 commits intoguoyww:mainfrom
Mr-Neutr0n:fix/diffusers-import-compatibility

Conversation

@Mr-Neutr0n
Copy link

Summary

  • Fixed compatibility with newer diffusers versions (0.21+) where several modules were renamed/moved

Problem

In newer diffusers versions:

  • diffusers.modeling_utils.ModelMixin was moved to diffusers.models.modeling_utils.ModelMixin
  • diffusers.models.attention.CrossAttention was renamed to diffusers.models.attention_processor.Attention

This causes ModuleNotFoundError when using newer diffusers installations.

Solution

Added try/except blocks to handle both old and new import paths:

try:
    from diffusers.modeling_utils import ModelMixin
except ImportError:
    from diffusers.models.modeling_utils import ModelMixin

Files Modified

  • animatediff/models/motion_module.py
  • animatediff/models/unet.py
  • animatediff/models/attention.py
  • animatediff/models/sparse_controlnet.py

Related Issue

Fixes #415

Test Plan

  • Works with older diffusers versions (< 0.21)
  • Works with newer diffusers versions (>= 0.21)

@Mr-Neutr0n
Copy link
Author

hi, following up — this fixes a broken import after diffusers restructured its modules. without it the pipeline can't load. let me know your thoughts

telsav pushed a commit to ai-dashboad/AnimateDiff that referenced this pull request Feb 9, 2026
- Add try/except imports for diffusers >= 0.21 compatibility (PR guoyww#435):
  ModelMixin, CrossAttention->Attention, DiffusionPipeline path changes
- Widen diffusers version range to >=0.16.0 (no upper bound)
- Add --format flag to animate.py for mp4/gif output (PR guoyww#37)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.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.

No module named 'diffusers.modeling_utils' in Macbook Pro with M2 chip

1 participant

Comments