KEMBAR78
support StableDiffusionAdapterPipeline.from_single_file by Teriks · Pull Request #10552 · huggingface/diffusers · GitHub
Skip to content

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.

@Teriks
Copy link
Contributor Author

Teriks commented Jan 28, 2025

@yiyixuxu

@yiyixuxu yiyixuxu merged commit 33f9361 into huggingface:main Jan 29, 2025
12 checks passed
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