Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when loading HunyuanDiTCLIPTextEncoder: Missing key "embeddings.position_ids" in state_dict #46

Open
hans1996 opened this issue Jun 24, 2024 · 2 comments

Comments

@hans1996
Copy link

Thank you for your help and support!

Issue Description

An error occurred while running ExVideo_svd_test.py. The error happens when loading the HunyuanDiTCLIPTextEncoder model, indicating a missing key "embeddings.position_ids" in the state dictionary.

Execute the following command:

python examples/ExVideo/ExVideo_svd_test.py

output

pytorch_model.bin has been already in models/HunyuanDiT/t2i/clip_text_encoder.
pytorch_model.bin has been already in models/HunyuanDiT/t2i/mt5.
pytorch_model_ema.pt has been already in models/HunyuanDiT/t2i/model.
diffusion_pytorch_model.bin has been already in models/HunyuanDiT/t2i/sdxl-vae-fp16-fix.
Traceback (most recent call last):
File "/home/hans/DiffSynth-Studio/examples/ExVideo/ExVideo_svd_test.py", line 88, in
image = generate_image()
File "/home/hans/DiffSynth-Studio/examples/ExVideo/ExVideo_svd_test.py", line 34, in generate_image
model_manager = ModelManager(torch_dtype=torch.float16, device="cuda", model_id_list=["HunyuanDiT"])
File "/home/hans/DiffSynth-Studio/diffsynth/models/init.py", line 98, in init
self.load_models(downloaded_files + file_path_list)
File "/home/hans/DiffSynth-Studio/diffsynth/models/init.py", line 476, in load_models
self.load_model(file_path, lora_alphas=lora_alphas)
File "/home/hans/DiffSynth-Studio/diffsynth/models/init.py", line 464, in load_model
self.load_hunyuan_dit_clip_text_encoder(state_dict, file_path=file_path)
File "/home/hans/DiffSynth-Studio/diffsynth/models/init.py", line 360, in load_hunyuan_dit_clip_text_encoder
model.load_state_dict(model.state_dict_converter().from_civitai(state_dict))
File "/home/hans/.local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 2189, in load_state_dict
raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
RuntimeError: Error(s) in loading state_dict for HunyuanDiTCLIPTextEncoder:
Missing key(s) in state_dict: "embeddings.position_ids".

@Artiprocher
Copy link
Collaborator

I suspect that the model file encountered an error during the download process. You can delete the file models/HunyuanDiT/t2i/clip_text_encoder/pytorch_model.bin and download it again, or alternatively, you can manually download it using the link provided in the comments of ExVideo_svd_test.py.

@PeterYoungQaQ
Copy link

I updated the version of transformers to the latest version and that solved the problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants