Skip to content

Fix mid block checker to fix custom model loading#13

Open
Dango233 wants to merge 1 commit into
showlab:mainfrom
Dango233:dango.fix.midblock_typecheck
Open

Fix mid block checker to fix custom model loading#13
Dango233 wants to merge 1 commit into
showlab:mainfrom
Dango233:dango.fix.midblock_typecheck

Conversation

@Dango233

@Dango233 Dango233 commented Feb 3, 2023

Copy link
Copy Markdown

The from_pretrained_2d runs into ValueError: unknown mid_block_type: UNetMidBlock2DCrossAttn when "mid_block_type": "UNetMidBlock2DCrossAttn" is specified in the config file of pertained unet.

This happens with some custom models (model converters could be a cause) but won't happen with the official models.

This PR fixes the problem by allowing UNetMidBlock2DCrossAttn in the type check.

@Dango233 Dango233 changed the title Fix mid block checker to avoid problem with custom models Fix mid block checker to fix custom model loading Feb 3, 2023
@zhangjiewu

Copy link
Copy Markdown
Collaborator

just wondering what kind of custom models you are using?

@Dango233

Dango233 commented Feb 4, 2023

Copy link
Copy Markdown
Author

I used a model trained under the CompVis/Stable-diffusion format. I got it converted to diffusers format using this conversion script:

https://github.com/huggingface/diffusers/blob/main/scripts/convert_original_stable_diffusion_to_diffusers.py

@Dango233

Dango233 commented Feb 5, 2023

Copy link
Copy Markdown
Author

Seems that the config saved using diffusers' save_pretrained method will have this problem

@kangqiyue

Copy link
Copy Markdown

Thanks! cool !

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.

3 participants