使用stable diffusionv1-5 pipeline的时候报错如下safetensors_rust.SafetensorError: Error while deserializing header: MetadataIncompleteBuffer,具体日志为:
Traceback (most recent call last):
File "/root/Faster-Diffusion-main/sd_demo.py", line 8, in <module>
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
File "/root/miniconda3/envs/fastersd/lib/python3.9/site-packages/diffusers/pipelines/pipeline_utils.py", line 1253, in from_pretrained
loaded_sub_model = load_sub_model(
File "/root/miniconda3/envs/fastersd/lib/python3.9/site-packages/diffusers/pipelines/pipeline_utils.py", line 506, in load_sub_model
loaded_sub_model = load_method(os.path.join(cached_folder, name), **loading_kwargs)
File "/root/miniconda3/envs/fastersd/lib/python3.9/site-packages/transformers/modeling_utils.py", line 2604, in from_pretrained
state_dict = load_state_dict(resolved_archive_file)
File "/root/miniconda3/envs/fastersd/lib/python3.9/site-packages/transformers/modeling_utils.py", line 450, in load_state_dict
with safe_open(checkpoint_file, framework="pt") as f:
safetensors_rust.SafetensorError: Error while deserializing header: MetadataIncompleteBuffer
模型文件不完整,解决办法:
https://huggingface.co/runwayml/stable-diffusion-v1-5/blob/main/v1-5-pruned-emaonly.safetensors
下载这个文件,然后替换掉,等待上传成功后再执行就可以解决了。