@@ -1268,8 +1268,6 @@ def convert_open_clip_checkpoint(
1268
1268
else :
1269
1269
text_proj_dim = LDM_OPEN_CLIP_TEXT_PROJECTION_DIM
1270
1270
1271
- text_model_dict ["text_model.embeddings.position_ids" ] = text_model .text_model .embeddings .get_buffer ("position_ids" )
1272
-
1273
1271
keys = list (checkpoint .keys ())
1274
1272
keys_to_ignore = SD_2_TEXT_ENCODER_KEYS_TO_IGNORE
1275
1273
@@ -1318,9 +1316,6 @@ def convert_open_clip_checkpoint(
1318
1316
else :
1319
1317
text_model_dict [diffusers_key ] = checkpoint .get (key )
1320
1318
1321
- if not (hasattr (text_model , "embeddings" ) and hasattr (text_model .embeddings .position_ids )):
1322
- text_model_dict .pop ("text_model.embeddings.position_ids" , None )
1323
-
1324
1319
return text_model_dict
1325
1320
1326
1321
@@ -1414,17 +1409,17 @@ def create_diffusers_clip_model_from_ldm(
1414
1409
1415
1410
if is_accelerate_available ():
1416
1411
unexpected_keys = load_model_dict_into_meta (model , diffusers_format_checkpoint , dtype = torch_dtype )
1417
- if model ._keys_to_ignore_on_load_unexpected is not None :
1418
- for pat in model ._keys_to_ignore_on_load_unexpected :
1419
- unexpected_keys = [k for k in unexpected_keys if re .search (pat , k ) is None ]
1412
+ else :
1413
+ _ , unexpected_keys = model .load_state_dict (diffusers_format_checkpoint , strict = False )
1420
1414
1421
- if len (unexpected_keys ) > 0 :
1422
- logger .warning (
1423
- f"Some weights of the model checkpoint were not used when initializing { cls .__name__ } : \n { [', ' .join (unexpected_keys )]} "
1424
- )
1415
+ if model ._keys_to_ignore_on_load_unexpected is not None :
1416
+ for pat in model ._keys_to_ignore_on_load_unexpected :
1417
+ unexpected_keys = [k for k in unexpected_keys if re .search (pat , k ) is None ]
1425
1418
1426
- else :
1427
- model .load_state_dict (diffusers_format_checkpoint )
1419
+ if len (unexpected_keys ) > 0 :
1420
+ logger .warning (
1421
+ f"Some weights of the model checkpoint were not used when initializing { cls .__name__ } : \n { [', ' .join (unexpected_keys )]} "
1422
+ )
1428
1423
1429
1424
if torch_dtype is not None :
1430
1425
model .to (torch_dtype )
0 commit comments