Waifu-Inpaint-XL / README.md
ShinoharaHare's picture
Update README.md
419a84a verified
---
library_name: diffusers
license: openrail++
datasets:
- ShinoharaHare/Danbooru-2024-Filtered-1M
language:
- en
base_model:
- ShinoharaHare/WAI-NSFW-illustrious-SDXL-V14.0-V-Prediction
pipeline_tag: image-to-image
tags:
- anime
- art
- inpaint
- inpainting
- stable-diffusion
- stable-diffusion-xl
---
# Waifu-Inpaint-XL
![image/png](https://cdn-uploads.huggingface.co/production/uploads/630ed69a31970d1cd4fd575d/H3Zmkcm4v2_i--5djR8LP.png)
**Waifu-Inpaint-XL** is an SDXL-based model specifically designed for inpainting anime-themed images.
| Task | Model |
|:----------:|:---------------------------------------------------------------------------------------------------------------------------------:|
| Generation | [WAI-NSFW-illustrious-SDXL-V14.0-V-Prediction](https://huggingface.co/ShinoharaHare/WAI-NSFW-illustrious-SDXL-V14.0-V-Prediction) |
| Inpainting | [Waifu-Inpaint-XL](https://huggingface.co/ShinoharaHare/Waifu-Inpaint-XL) |
| Colorizing | [Waifu-Colorize-XL](https://huggingface.co/ShinoharaHare/Waifu-Colorize-XL) |
## Overview
**Waifu-Inpaint-XL** is initialized from [WAI-NSFW-illustrious-SDXL-V14.0-V-Prediction](https://huggingface.co/ShinoharaHare/WAI-NSFW-illustrious-SDXL-V14.0-V-Prediction), with its input channels expanded from 4 to 9. Among these, 1 additional channel is dedicated to the mask, and 4 extra channels are used for masked latents.
## Model Details
- **Developed by:** ShinoharaHare
- **Model type:** Diffusion based text-to-image/image-to-image generative model for inpainting
- **Language(s) (NLP):** English
- **License:** [CreativeML Open RAIL++-M](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/blob/main/LICENSE.md)
- **Finetuned from:** [WAI-NSFW-illustrious-SDXL-V14.0-V-Prediction](https://huggingface.co/ShinoharaHare/WAI-NSFW-illustrious-SDXL-V14.0-V-Prediction)
## 🧨 Diffusers
<style>
.image-viewer {
position: relative;
width: 100%;
margin: 0 auto;
display: flex;
flex-flow: wrap;
align-items: center;
justify-content: center;
}
.image-viewer input[type="radio"] {
display: none;
}
.image-viewer label {
width: 120px;
border-radius: 12px;
margin: 8px;
padding: 20px;
cursor: pointer;
text-align: center;
border: 2px solid transparent;
}
.image-viewer label:hover {
border: 2px solid var(--color-blue-400);
}
.image-viewer input[type="radio"]:checked + label {
background-color: var(--color-blue-400);
color: white;
}
.image-container {
position: relative;
width: 100%;
height: 50vh;
}
.inner-container {
position: absolute;
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.inner-container img {
border-radius: 10px;
max-height: 100%;
max-width: 100%;
height: 0;
width: 0;
opacity: 0;
margin: 0;
transition: opacity 0.5s ease, height 0.25s ease, width 0.25s ease;
}
#image1:checked ~ .image-container img:nth-child(1),
#image2:checked ~ .image-container img:nth-child(2),
#image3:checked ~ .image-container img:nth-child(3) {
height: auto;
width: auto;
opacity: 1.0;
}
</style>
<div class="image-viewer">
<input type="radio" id="image1" name="image-switcher" checked>
<label for="image1" id="image1l">Image</label>
<input type="radio" id="image2" name="image-switcher">
<label for="image2" id="image2l">Mask</label>
<input type="radio" id="image3" name="image-switcher">
<label for="image3" id="image3l">Inpainted</label>
<div class="image-container">
<div class="inner-container">
<img src="https://cdn-uploads.huggingface.co/production/uploads/630ed69a31970d1cd4fd575d/tPo5oPJQpxWamM-tGIYqj.png" alt="image1" />
<img src="https://cdn-uploads.huggingface.co/production/uploads/630ed69a31970d1cd4fd575d/QpmzmgROUM0eP53Cxx2Ih.png" alt="image2" />
<img src="https://cdn-uploads.huggingface.co/production/uploads/630ed69a31970d1cd4fd575d/zfvAO3xJhhcuuvyvy_pmX.png" alt="image3" />
</div>
</div>
</div>
```python
import torch
from diffusers import StableDiffusionXLInpaintPipeline
from diffusers.utils import load_image
pipeline = StableDiffusionXLInpaintPipeline.from_pretrained(
'ShinoharaHare/Waifu-Inpaint-XL',
torch_dtype=torch.half
)
pipeline.to('cuda')
image = load_image('https://cdn-uploads.huggingface.co/production/uploads/630ed69a31970d1cd4fd575d/tPo5oPJQpxWamM-tGIYqj.png')
mask_image = load_image('https://cdn-uploads.huggingface.co/production/uploads/630ed69a31970d1cd4fd575d/QpmzmgROUM0eP53Cxx2Ih.png', lambda x: x.convert('L'))
inpainted_image = pipeline(
prompt='blue eyes, holding red spider lily in hand',
image=image,
mask_image=mask_image,
num_inference_steps=28,
guidance_scale=5.0,
height=image.height,
width=image.width,
generator=torch.Generator(pipeline.device).manual_seed(5)
).images[0]
inpainted_image.show()
```