LaurentMazare / diffusers-rs

An implementation of the diffusers api in Rust
Apache License 2.0
521 stars 54 forks source link

Support load from safe tensors #54

Closed oovm closed 1 year ago

oovm commented 1 year ago

Solve #53

It can also work with official safetensors without convert weights now!

https://huggingface.co/runwayml/stable-diffusion-v1-5/blob/main/unet/diffusion_pytorch_model.safetensors

cargo run --example stable-diffusion --features clap -- --prompt "A rusty robot holding a fire torch." --sd-version=v1-5 --intermediary-images --unet-weights="data/diffusion_pytorch_model.safetensors"

Wrap function can be removed when https://github.com/LaurentMazare/tch-rs/pull/633 merged.

vlad20012 commented 1 year ago

Also, with this PR it's now possible to load only unet weights, but not vue or clip weights. Is it expected? :thinking:

LaurentMazare commented 1 year ago

I don't think this PR is useful anymore now that supports for safetensors has been included in the tch crate (tch#636) - loading from safetensors file should work for all models. So I'll close this PR but let me know if I'm missing something.