Open whydna opened 1 month ago
It says you can change weights_only
to False
at diffusers/models/model_loading_utils.py:107
; but be careful because it is not a .safetensors
file, it might run malicious codes. If the .safetensors
equivalent works fine; then I would prefer it. For more info about safetensors
.
doesn't look like there is a way to set that from the pipeline class.
it's so rare nowadays that someone wants to load a ckpt
on purpose that probably no one noticed this.
This is a safety feature in the code because a generative model shouldn't need to execute arbitrary code with diffusers:
If you still want to load it, you can change it to False
in the code but we probably won't do it as a library because of the risk. You can also downgrade your torch version.
I did it as a test and now it's asking my to install torch lighting which is weird, never loaded a ckpt
with diffusers before so I don't know if that was a requirement or not.
cc: @DN6 for awareness
I think the bug is the fact that it's not able to load the weights using weights_only=True
from the .ckpt checkpoint (https://huggingface.co/runwayml/stable-diffusion-v1-5/blob/main/v1-5-pruned.ckpt).
If weights_only
is set to False
then it will try to load the model modules as well, which depending on the implementation may require pytorch lightning.
The expected behavior for the ckpt
should just be the same as loading the .safetensors
- which seems to be working fine.
If you consider that a bug then you probably should report it in the model repo, probably it was saved with some weird call to pytorch lighting because of the training.
which depending on the implementation may require pytorch lightning
The safetensors alternative works because it doesn't store any library requirement/implementation and it's a fact that you don't need to install pytorch lighting to load any stable diffusion checkpoints.
But yeah, you're right. You can easily reproduce this error with this code:
import torch
state_dict = torch.load("models/checkpoints/v1-5-pruned-emaonly.ckpt", weights_only=True)
but this is not a diffusers
issue then.
It's a change they made. 0.27.2 this worked
pipe.vae = AutoencoderKL.from_single_file(
path.join("./assets/vae/orangemix.vae.pt"),
local_files_only=True,
torch_dtype=torch.bfloat16
)
But now in 0.28.0+ it is broken. Can we stop making changes that completely breaks functionality without noting it? @sayakpaul many of us still use pickle files.
Also how can I make sure all weights are loaded?
Some weights of the model checkpoint were not used when initializing CLIPTextModel
I'm now receiving this message. It's annoying.
we started to add weights_only=True
for safety concern https://github.com/huggingface/diffusers/pull/7393
I wonder if we would allow the user to explicitly set weights_only=False
when they need it cc @DN6
Describe the bug
Trying to load local CKPT file using the "from_single_file()" method fails. Works fine with .safetensors file from same repo (Runway ML SD).
Reproduction
Logs
System Info
Who can help?
@yiyixuxu @asomoza @DN