Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
### AUTOMATIC1111 WebUI Stable Diffusion
|
2 |
+
`WebUIStableDiffusionPipeline` 是与 [AUTOMATIC1111/stable-diffusion-webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui) 基本对齐的一个pipeline。
|
3 |
+
|
4 |
+
该自定义Pipeline支持如下的功能:
|
5 |
+
* 输入的 token 没有长度限制,可以超过77;
|
6 |
+
* 支持clip_skip,即可以使用不同层text_encoder的输出;
|
7 |
+
* 支持直接加载webui中的textual_inversion权重;
|
8 |
+
|
9 |
+
|
10 |
+
```python
|
11 |
+
import paddle
|
12 |
+
from ppdiffusers.utils import image_grid
|
13 |
+
from ppdiffusers import DiffusionPipeline
|
14 |
+
from pathlib import Path
|
15 |
+
|
16 |
+
pipe = DiffusionPipeline.from_pretrained("TASUKU2023/Chilloutmix", paddle_dtype=paddle.float16, custom_pipeline="junnyu/webui_ppdiffusers")
|
17 |
+
|
18 |
+
# 自动下载civitai的lora及ti文件(请注意自己的网络。)
|
19 |
+
# 介绍网页,程序将自动搜索介绍网页的下载链接
|
20 |
+
pipe.download_civitai_lora_file('https://civitai.com/models/15365/hanfu')
|
21 |
+
pipe.download_civitai_lora_file('https://civitai.com/models/12597/moxin')
|
22 |
+
pipe.download_civitai_ti_file('https://civitai.com/models/1998/autumn-style')
|
23 |
+
pipe.download_civitai_ti_file('https://civitai.com/models/21131/daisy-ridley-embedding')
|
24 |
+
# 纯下载链接
|
25 |
+
pipe.download_civitai_lora_file('https://civitai.com/api/download/models/21656')
|
26 |
+
|
27 |
+
print("Supported Lora: " + "、 ".join([p.stem for p in Path(pipe.LORA_DIR).glob("*.safetensors")]))
|
28 |
+
|
29 |
+
# 我们需要安装develop版的paddle才可以使用xformers
|
30 |
+
# pipe.enable_xformers_memory_efficient_attention()
|
31 |
+
scheduler_name = ["ddim", "pndm", "euler", "dpm-multi"]
|
32 |
+
for enable_lora in [True, False]:
|
33 |
+
images = []
|
34 |
+
for sc in scheduler_name:
|
35 |
+
# 切换scheduler
|
36 |
+
pipe.switch_scheduler(sc)
|
37 |
+
# 指定clip_skip
|
38 |
+
clip_skip = 1
|
39 |
+
# 指定seed
|
40 |
+
generator = paddle.Generator().manual_seed(0)
|
41 |
+
# guidance_scale
|
42 |
+
guidance_scale = 3.5
|
43 |
+
prompt = "# shukezouma, negative space, , shuimobysim , portrait of a woman standing , willow branches, (masterpiece, best quality:1.2), traditional chinese ink painting, <lora:Moxin_10:1.0>, modelshoot style, peaceful, (smile), looking at viewer, wearing long hanfu, hanfu, song, willow tree in background, wuchangshuo,"
|
44 |
+
negative_prompt = "(worst quality:2), (low quality:2), (normal quality:2), lowres, normal quality, skin spots, acnes, skin blemishes, age spot, glans, (watermark:2),"
|
45 |
+
img = pipe(prompt, negative_prompt=negative_prompt, num_inference_steps=50, height=768, width=512, clip_skip=clip_skip, guidance_scale=guidance_scale, generator=generator, enable_lora=enable_lora).images[0]
|
46 |
+
images.append(img)
|
47 |
+
if enable_lora:
|
48 |
+
image_grid(images, 2, 2).save(f"lora_enable.png")
|
49 |
+
else:
|
50 |
+
image_grid(images, 2, 2).save(f"lora_disable.png")
|
51 |
+
```
|
52 |
+
生成的图片如下所示:
|
53 |
+
|
54 |
+
| lora_disable.png | lora_enable.png |
|
55 |
+
|:----------:|:--------------:|
|
56 |
+
|<center class="half"><img src="https://user-images.githubusercontent.com/50394665/230832029-c06a1367-1f2c-4206-9666-99854fcee240.png" width=50%></center> | <center class="half"><img src="https://user-images.githubusercontent.com/50394665/230832028-730ce442-dd34-4e36-afd0-81d40843359a.png" width=50%></center> |
|