Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support StableDiffusionAdapterPipeline.from_single_file #10552

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Teriks
Copy link
Contributor

@Teriks Teriks commented Jan 13, 2025

What does this PR do?

Adds support for from_single_file to StableDiffusionAdapterPipeline by inheriting FromSingleFileMixin

import diffusers
from PIL import Image
from diffusers.utils import load_image
import torch

# checkpoint: https://civitai.com/api/download/models/74821?type=Model&format=SafeTensor&size=pruned&fp=fp16

image = load_image(
     "https://huggingface.co/datasets/diffusers/docs-images/resolve/main/t2i-adapter/color_ref.png"
)

color_palette = image.resize((8, 8))
color_palette = color_palette.resize((512, 512), resample=Image.Resampling.NEAREST)

adapter = diffusers.T2IAdapter.from_pretrained("TencentARC/t2iadapter_color_sd14v1", torch_dtype=torch.float16)

# single file load
pipe = diffusers.StableDiffusionAdapterPipeline.from_single_file(
    'impressionismOil_sd15.safetensors',
     adapter=adapter, torch_dtype=torch.float16)

pipe.to('cuda')

output = pipe(
    prompt='impressionist oil painting of a sunset', image=color_palette).images[0]

output.save('test.png')

Previously working around this with:

pipe_class = type(
    'StableDiffusionAdapterPipeline',  
    (diffusers.loaders.FromSingleFileMixin, diffusers.StableDiffusionAdapterPipeline), {})

Fixes #9123

Before submitting

Who can review?

@DN6

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(feature) diffusers.StableDiffusionAdapterPipeline could inherit FromSingleFileMixin
5 participants