CompVis / stable-diffusion

A latent text-to-image diffusion model
https://ommer-lab.com/research/latent-diffusion-models/
Other
66.54k stars 9.97k forks source link

KeyError: 'time_embed.0.weight' #764

Open moo611 opened 11 months ago

moo611 commented 11 months ago

diffusers version : 0.18.2 code :

from torch import autocast
from diffusers import StableDiffusionPipeline
pipeline = StableDiffusionPipeline.from_single_file("https://huggingface.co/xiaolxl/GuoFeng3/blob/main/GuoFeng3.2_Lora.safetensors")
pipeline.to("cuda")
with autocast("cuda"):
  image = pipeline("best quality,masterpiece,highres,1girl,blush,(seductive smile:0.8),star-shaped pupils,red china hanfu,hanfu,chinese clothes,hair ornament,necklace,jewelry,Beautiful face,upon_body,tyndall effect,photorealistic,dark studio,rim lighting,two tone lighting,(high detailed skin:1.2),8k uhd,dslr,soft lighting,high quality,volumetric lighting,candid,Photograph,high resolution,4k,8k,Bokeh,").images[0]
image.save("test.png")

I run this on the google colab, but I got the error: KeyError: 'time_embed.0.weight'. I will give the whole error message below:

`

KeyError Traceback (most recent call last) in <cell line: 3>() 1 from torch import autocast 2 from diffusers import StableDiffusionPipeline ----> 3 pipeline = StableDiffusionPipeline.from_single_file("https://huggingface.co/xiaolxl/GuoFeng3/blob/main/GuoFeng3.2_Lora.safetensors") 4 pipeline.to("cuda") 5 with autocast("cuda"):

2 frames /usr/local/lib/python3.10/dist-packages/diffusers/pipelines/stable_diffusion/convert_from_ckpt.py in convert_ldm_unet_checkpoint(checkpoint, config, path, extract_ema, controlnet, skip_extract_state_dict) 419 new_checkpoint = {} 420 --> 421 new_checkpoint["time_embedding.linear_1.weight"] = unet_state_dict["time_embed.0.weight"] 422 new_checkpoint["time_embedding.linear_1.bias"] = unet_state_dict["time_embed.0.bias"] 423 new_checkpoint["time_embedding.linear_2.weight"] = unet_state_dict["time_embed.2.weight"]

KeyError: 'time_embed.0.weight' `

Hrushi11 commented 10 months ago

Any Idea on how you fixed it ?

suruguru5 commented 10 months ago

i changed base model and it worked

jonathanrstern commented 9 months ago

Also running into this... any fix?

iaverypadberg commented 9 months ago

Just ran into this issue while loading a UNet2DModel I fine-tuned. pipe = StableDiffusionPipeline.from_single_file("/train3/unet/diffusion_pytorch_model.safetensors") is causing issue.