mirror of
https://github.com/huggingface/diffusers.git
synced 2025-12-23 12:54:48 +08:00
Compare commits
2 Commits
remove-unn
...
fix-sdxl-i
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
22062b1cf5 | ||
|
|
5b6851e594 |
@@ -81,7 +81,7 @@ def rescale_noise_cfg(noise_cfg, noise_pred_text, guidance_rescale=0.0):
|
|||||||
|
|
||||||
class StableDiffusionXLImg2ImgPipeline(DiffusionPipeline, FromSingleFileMixin, LoraLoaderMixin):
|
class StableDiffusionXLImg2ImgPipeline(DiffusionPipeline, FromSingleFileMixin, LoraLoaderMixin):
|
||||||
r"""
|
r"""
|
||||||
Pipeline for text-to-image generation using Stable Diffusion XL.
|
Pipeline for image-to-image generation using Stable Diffusion XL.
|
||||||
|
|
||||||
This model inherits from [`DiffusionPipeline`]. Check the superclass documentation for the generic methods the
|
This model inherits from [`DiffusionPipeline`]. Check the superclass documentation for the generic methods the
|
||||||
library implements for all the pipelines (such as downloading or saving, running on a particular device, etc.)
|
library implements for all the pipelines (such as downloading or saving, running on a particular device, etc.)
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ class StableDiffusionXLInpaintPipeline(
|
|||||||
DiffusionPipeline, TextualInversionLoaderMixin, LoraLoaderMixin, FromSingleFileMixin
|
DiffusionPipeline, TextualInversionLoaderMixin, LoraLoaderMixin, FromSingleFileMixin
|
||||||
):
|
):
|
||||||
r"""
|
r"""
|
||||||
Pipeline for text-to-image generation using Stable Diffusion XL.
|
Pipeline for text-guided image inpainting using Stable Diffusion XL.
|
||||||
|
|
||||||
This model inherits from [`DiffusionPipeline`]. Check the superclass documentation for the generic methods the
|
This model inherits from [`DiffusionPipeline`]. Check the superclass documentation for the generic methods the
|
||||||
library implements for all the pipelines (such as downloading or saving, running on a particular device, etc.)
|
library implements for all the pipelines (such as downloading or saving, running on a particular device, etc.)
|
||||||
@@ -948,32 +948,28 @@ class StableDiffusionXLInpaintPipeline(
|
|||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
```py
|
```py
|
||||||
>>> import PIL
|
|
||||||
>>> import requests
|
|
||||||
>>> import torch
|
>>> import torch
|
||||||
>>> from io import BytesIO
|
>>> from diffusers import StableDiffusionXLInpaintPipeline
|
||||||
|
>>> from diffusers.utils import load_image
|
||||||
>>> from diffusers import StableDiffusionInpaintPipeline
|
|
||||||
|
|
||||||
|
|
||||||
>>> def download_image(url):
|
|
||||||
... response = requests.get(url)
|
|
||||||
... return PIL.Image.open(BytesIO(response.content)).convert("RGB")
|
|
||||||
|
|
||||||
|
>>> pipe = StableDiffusionXLInpaintPipeline.from_pretrained(
|
||||||
|
... "stabilityai/stable-diffusion-xl-base-0.9",
|
||||||
|
... torch_dtype=torch.float16,
|
||||||
|
... variant="fp16",
|
||||||
|
... use_safetensors=True,
|
||||||
|
... )
|
||||||
|
>>> pipe.to("cuda")
|
||||||
|
|
||||||
>>> img_url = "https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo.png"
|
>>> img_url = "https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo.png"
|
||||||
>>> mask_url = "https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo_mask.png"
|
>>> mask_url = "https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo_mask.png"
|
||||||
|
|
||||||
>>> init_image = download_image(img_url).resize((512, 512))
|
>>> init_image = load_image(img_url).convert("RGB")
|
||||||
>>> mask_image = download_image(mask_url).resize((512, 512))
|
>>> mask_image = load_image(mask_url).convert("RGB")
|
||||||
|
|
||||||
>>> pipe = StableDiffusionInpaintPipeline.from_pretrained(
|
>>> prompt = "A majestic tiger sitting on a bench"
|
||||||
... "runwayml/stable-diffusion-inpainting", torch_dtype=torch.float16
|
>>> image = pipe(
|
||||||
... )
|
... prompt=prompt, image=init_image, mask_image=mask_image, num_inference_steps=50, strength=0.80
|
||||||
>>> pipe = pipe.to("cuda")
|
... ).images[0]
|
||||||
|
|
||||||
>>> prompt = "Face of a yellow cat, high resolution, sitting on a park bench"
|
|
||||||
>>> image = pipe(prompt=prompt, image=init_image, mask_image=mask_image).images[0]
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|||||||
Reference in New Issue
Block a user