Alex Birch
commited on
update README
Browse files
README.md
CHANGED
@@ -9,16 +9,76 @@ inference: true
|
|
9 |
|
10 |
---
|
11 |
|
12 |
-
This unofficial repository hosts a diffusers-compatible float16 checkpoint of the [WDXL](https://huggingface.co/hakurei/waifu-diffusion-xl) base UNet.
|
13 |
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
```python
|
17 |
import torch
|
18 |
from diffusers import UNet2DConditionModel
|
19 |
|
20 |
base_unet: UNet2DConditionModel = UNet2DConditionModel.from_pretrained(
|
21 |
-
|
22 |
torch_dtype=torch.float16,
|
23 |
use_safetensors=True,
|
24 |
variant='fp16',
|
@@ -26,6 +86,10 @@ base_unet: UNet2DConditionModel = UNet2DConditionModel.from_pretrained(
|
|
26 |
).eval().to(torch.device('cuda'))
|
27 |
```
|
28 |
|
|
|
|
|
|
|
|
|
29 |
### NOTE: The work here is a Work in Progress! Nothing in this repository is final.
|
30 |
|
31 |
# waifu-diffusion-xl - Diffusion for Rich Weebs
|
@@ -59,4 +123,4 @@ This project would not have been possible without the incredible work by Stabili
|
|
59 |
|
60 |
In order to reach us, you can join our [Discord server](https://discord.gg/touhouai).
|
61 |
|
62 |
-
[![Discord Server](https://discordapp.com/api/guilds/930499730843250783/widget.png?style=banner2)](https://discord.gg/touhouai)
|
|
|
9 |
|
10 |
---
|
11 |
|
12 |
+
This unofficial repository hosts a diffusers-compatible float16 checkpoint of the [WDXL](https://huggingface.co/hakurei/waifu-diffusion-xl) base UNet.
|
13 |
|
14 |
+
For convenience (i.e. for use in a StableDiffusionXLPipeline) we include mirrors of other models (please adhere to their terms of usage):
|
15 |
+
|
16 |
+
- [SDXL 0.9](stabilityai/stable-diffusion-xl-base-0.9)
|
17 |
+
- tokenizers
|
18 |
+
- text encoders
|
19 |
+
- scheduler config
|
20 |
+
- [madebyollin's fp16 VAE](https://huggingface.co/madebyollin/sdxl-vae-fp16-fix)
|
21 |
+
|
22 |
+
## Usage (diffusers)
|
23 |
+
|
24 |
+
### StableDiffusionXLPipeline
|
25 |
+
|
26 |
+
Diffusers' StableDiffusionXLPipeline convention handles text encoders + UNet + VAE for you:
|
27 |
+
|
28 |
+
```python
|
29 |
+
from diffusers import StableDiffusionXLPipeline, DPMSolverMultistepScheduler
|
30 |
+
import torch
|
31 |
+
from torch import Generator
|
32 |
+
|
33 |
+
# scheduler args documented here:
|
34 |
+
# https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_dpmsolver_multistep.py#L98
|
35 |
+
scheduler: DPMSolverMultistepScheduler = DPMSolverMultistepScheduler.from_pretrained(
|
36 |
+
'Birchlabs/waifu-diffusion-xl-unofficial',
|
37 |
+
subfolder='scheduler',
|
38 |
+
# sde-dpmsolver++ is very new. if your diffusers version doesn't have it: use 'dpmsolver++' instead.
|
39 |
+
algorithm_type='sde-dpmsolver++',
|
40 |
+
solver_order=2,
|
41 |
+
# solver_type='heun' may give a sharper image. Cheng Lu reckons midpoint is better.
|
42 |
+
solver_type='midpoint',
|
43 |
+
use_karras_sigmas=True,
|
44 |
+
)
|
45 |
+
|
46 |
+
pipe: StableDiffusionXLPipeline = StableDiffusionXLPipeline.from_pretrained(
|
47 |
+
'Birchlabs/waifu-diffusion-xl-unofficial',
|
48 |
+
scheduler=scheduler,
|
49 |
+
torch_dtype=torch.float16,
|
50 |
+
use_safetensors=True,
|
51 |
+
variant='fp16'
|
52 |
+
)
|
53 |
+
pipe.to("cuda")
|
54 |
+
|
55 |
+
prompt = 'masterpiece, best quality, 1girl, green hair, sweater, looking at viewer, upper body, beanie, outdoors, watercolor, night, turtleneck'
|
56 |
+
negative_prompt = 'lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry, artist name'
|
57 |
+
|
58 |
+
images = pipe(
|
59 |
+
prompt=prompt,
|
60 |
+
negative_prompt=negative_prompt,
|
61 |
+
num_inference_steps=25,
|
62 |
+
guidance_scale=12.,
|
63 |
+
original_size=(4096, 4096),
|
64 |
+
target_size=(1024, 1024),
|
65 |
+
height=1024,
|
66 |
+
width=1024,
|
67 |
+
generator=Generator().manual_seed(45),
|
68 |
+
).images[0]
|
69 |
+
|
70 |
+
```
|
71 |
+
|
72 |
+
### UNet2DConditionModel
|
73 |
+
|
74 |
+
If you just want the UNet, you can load it like so:
|
75 |
|
76 |
```python
|
77 |
import torch
|
78 |
from diffusers import UNet2DConditionModel
|
79 |
|
80 |
base_unet: UNet2DConditionModel = UNet2DConditionModel.from_pretrained(
|
81 |
+
'Birchlabs/waifu-diffusion-xl-unofficial',
|
82 |
torch_dtype=torch.float16,
|
83 |
use_safetensors=True,
|
84 |
variant='fp16',
|
|
|
86 |
).eval().to(torch.device('cuda'))
|
87 |
```
|
88 |
|
89 |
+
## How it was converted
|
90 |
+
|
91 |
+
I used Kohya's converter script. See [this commit](https://github.com/Birch-san/diffusers-play/commit/3f16355dd0064932d0bf356ed78676089b9e46ca), and my [previous explanation](https://huggingface.co/Birchlabs/wd-1-5-beta3-unofficial#how-wd15b3-compvis-checkpoint-was-converted) for a bit more detail on how I invoke such scripts.
|
92 |
+
|
93 |
### NOTE: The work here is a Work in Progress! Nothing in this repository is final.
|
94 |
|
95 |
# waifu-diffusion-xl - Diffusion for Rich Weebs
|
|
|
123 |
|
124 |
In order to reach us, you can join our [Discord server](https://discord.gg/touhouai).
|
125 |
|
126 |
+
[![Discord Server](https://discordapp.com/api/guilds/930499730843250783/widget.png?style=banner2)](https://discord.gg/touhouai)
|