Skip to content

Commit 9e910c4

Browse files
TeriksDN6
andauthored
Fix SD2.X clip single file load projection_dim (huggingface#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 <[email protected]> Co-authored-by: Dhruv Nair <[email protected]>
1 parent 5e3b7d2 commit 9e910c4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/diffusers/loaders/single_file_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,8 +1448,8 @@ def convert_open_clip_checkpoint(
14481448

14491449
if text_proj_key in checkpoint:
14501450
text_proj_dim = int(checkpoint[text_proj_key].shape[0])
1451-
elif hasattr(text_model.config, "projection_dim"):
1452-
text_proj_dim = text_model.config.projection_dim
1451+
elif hasattr(text_model.config, "hidden_size"):
1452+
text_proj_dim = text_model.config.hidden_size
14531453
else:
14541454
text_proj_dim = LDM_OPEN_CLIP_TEXT_PROJECTION_DIM
14551455

0 commit comments

Comments
 (0)