Table of Contents

Diffusers from_single_file()

Use from_single_file() to load a diffusion model from a single file instead of from_pretrained().

import torch
from diffusers import StableDiffusionPipeline

model_id = "./my-model.safetensors"

pipe = StableDiffusionPipeline.from_single_file(
    model_id,
    torch_dtype=torch.float16)
pipe.to("cuda")

prompt = "a prompt for the model"
image = pipe(prompt).images[0]

Reference