Merge pull request #273 from wkpark/strict-fix

load_state_dict() with strict=False option to fix #271
ver17
hako-mikan 2023-11-04 00:41:39 +09:00 committed by GitHub
commit 64a6064e25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -855,11 +855,11 @@ def load_models_from_stable_diffusion_checkpoint(v2, ckpt_path, dtype=None):
transformers_version="4.25.0.dev0",
)
text_model = CLIPTextModel._from_config(cfg)
info = text_model.load_state_dict(converted_text_encoder_checkpoint)
info = text_model.load_state_dict(converted_text_encoder_checkpoint, strict=False)
else:
converted_text_encoder_checkpoint = convert_ldm_clip_checkpoint_v1(state_dict)
text_model = CLIPTextModel.from_pretrained("openai/clip-vit-large-patch14")
info = text_model.load_state_dict(converted_text_encoder_checkpoint)
info = text_model.load_state_dict(converted_text_encoder_checkpoint, strict=False)
print("loading text encoder:", info)
return text_model, vae, unet, info