mirror of
https://github.com/huggingface/diffusers.git
synced 2026-01-27 17:22:53 +03:00
Fix SD2.X clip single file load projection_dim (#10770)
* Fix SD2.X clip single file load projection_dim Infer projection_dim from the checkpoint before loading from pretrained, override any incorrect hub config. Hub configuration for SD2.X specifies projection_dim=512 which is incorrect for SD2.X checkpoints loaded from civitai and similar. Exception was previously thrown upon attempting to load_model_dict_into_meta for SD2.X single file checkpoints. Such LDM models usually require projection_dim=1024 * convert_open_clip_checkpoint use hidden_size for text_proj_dim * convert_open_clip_checkpoint, revert checkpoint[text_proj_key].shape[1] -> [0] values are identical --------- Co-authored-by: Teriks <Teriks@users.noreply.github.com> Co-authored-by: Dhruv Nair <dhruv.nair@gmail.com>
This commit is contained in:
@@ -1448,8 +1448,8 @@ def convert_open_clip_checkpoint(
|
||||
|
||||
if text_proj_key in checkpoint:
|
||||
text_proj_dim = int(checkpoint[text_proj_key].shape[0])
|
||||
elif hasattr(text_model.config, "projection_dim"):
|
||||
text_proj_dim = text_model.config.projection_dim
|
||||
elif hasattr(text_model.config, "hidden_size"):
|
||||
text_proj_dim = text_model.config.hidden_size
|
||||
else:
|
||||
text_proj_dim = LDM_OPEN_CLIP_TEXT_PROJECTION_DIM
|
||||
|
||||
|
||||
Reference in New Issue
Block a user