Closed tienduong-21 closed 7 months ago
Have you solved it? I also encountered the same problem
I solved this problem!! You need to remove this key from dictionary
def load_ckpt(ckpt_path):
saved_ckpt = torch.load(ckpt_path)
config = saved_ckpt["config_dict"]["_content"]
model = instantiate_from_config(config['model']).to(device).eval()
autoencoder = instantiate_from_config(config['autoencoder']).to(device).eval()
text_encoder = instantiate_from_config(config['text_encoder']).to(device).eval()
diffusion = instantiate_from_config(config['diffusion']).to(device)
model_parts = torch.load("gligen_checkpoints/diffusion_pytorch_model.bin")
# donot need to load official_ckpt for self.model here, since we will load from our ckpt
model.load_state_dict( saved_ckpt['model'] )
autoencoder.load_state_dict( model_parts["autoencoder"] )
del model_parts["text_encoder"]['transformer.text_model.embeddings.position_ids'] #add this line
text_encoder.load_state_dict( model_parts["text_encoder"] )
diffusion.load_state_dict( model_parts["diffusion"] )
return model, autoencoder, text_encoder, diffusion, config
Have you solved it? I also encountered the same problem
you can check your packages version, such as transformers and diffusers,
--- i reinstalled these packages and solved it.
I run file gligen_inference.py and this is my error: RuntimeError: Error(s) in loading state_dict for FrozenCLIPEmbedder: Unexpected key(s) in state_dict: "transformer.text_model.embeddings.position_ids". This is my code