kohya-ss / sd-scripts

Apache License 2.0
5.27k stars 876 forks source link

usage of xformers in gen_img_diffusers.py #321

Open lyb9725 opened 1 year ago

lyb9725 commented 1 year ago

Hi, I appreciate the clever structure of the inference script!

I notice that you only change the forward method in CrossAttention but not in other AttentionBlock when uising the xformers, which is difference from the diffusers. code. And it seems works better than diffusers too.

Why it works better? Thanks a lot!

kohya-ss commented 1 year ago

Thank you!

The reason I am only replacing CrossAttenion is simple: the UNet2DConditionModel uses only CrossAttention and not AttentionBlock.

I'm not sure which is better, Diffusers' method or mine 😅