lllyasviel / ControlNet

Let us control diffusion models!
Apache License 2.0
30.33k stars 2.73k forks source link

RuntimeError: The shape of the 2D attn_mask is torch.Size([77, 77]), but should be (4, 4) #708

Closed JaspinXu closed 1 month ago

JaspinXu commented 1 month ago

I encountered the problem “RuntimeError: The shape of the 2D attn_mask is torch.Size([77, 77]), but should be (4, 4)”, which wasted half a day of my time, but I solved it, so I'm showing it here for the benefit of others who encounter the same problem.

JaspinXu commented 1 month ago

This should be caused by open-clip-torch to 2.26.1, note that it's - not _ here, in 2.26.1, you need to set clip_model.transformer.batch_first = False, or you can just downgrade to version 2.24.0, pip install open- clip-torch==2.24.0.