Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use diffusers with custom ckpt file

Currently I have the current code which runs a prompt on a model which it downloads from huggingface.

from diffusers import StableDiffusionPipeline, EulerDiscreteScheduler

model_id = "stabilityai/stable-diffusion-2"

# Use the Euler scheduler here instead
scheduler = EulerDiscreteScheduler.from_pretrained(model_id, subfolder="scheduler")
pipe = StableDiffusionPipeline.from_pretrained(model_id, scheduler=scheduler)
pipe = pipe.to("mps")
pipe.enable_attention_slicing()


prompt = "a photo of an astronaut riding a horse on mars"
pipe(prompt).images[0]

I wanted to know how can I feed a custom ckpt file to this script instead of it downloading it from stabilityAi repo?

like image 783
Mohammad Razeghi Avatar asked Oct 22 '25 07:10

Mohammad Razeghi


1 Answers

You cannot use a ckpt file with diffusers out of the box. The ckpt file has to be converted to a diffusers friendly format.

You can do that with a tool named StableTuner. Or this utility script on HuggingFace https://huggingface.co/spaces/anzorq/sd-to-diffusers

like image 166
Alexis.Rolland Avatar answered Oct 23 '25 21:10

Alexis.Rolland



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!