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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"nbformat": 4,
|
3 |
+
"nbformat_minor": 0,
|
4 |
+
"metadata": {
|
5 |
+
"colab": {
|
6 |
+
"provenance": []
|
7 |
+
},
|
8 |
+
"kernelspec": {
|
9 |
+
"name": "python3",
|
10 |
+
"display_name": "Python 3"
|
11 |
+
},
|
12 |
+
"language_info": {
|
13 |
+
"name": "python"
|
14 |
+
},
|
15 |
+
"accelerator": "GPU",
|
16 |
+
"gpuClass": "standard"
|
17 |
+
},
|
18 |
+
"cells": [
|
19 |
+
{
|
20 |
+
"cell_type": "markdown",
|
21 |
+
"source": [
|
22 |
+
"### Setup/Troubleshooting\n",
|
23 |
+
"Click thingy below to keep colab tab alive while running SD"
|
24 |
+
],
|
25 |
+
"metadata": {
|
26 |
+
"id": "DBRMp3KyeXQm"
|
27 |
+
}
|
28 |
+
},
|
29 |
+
{
|
30 |
+
"cell_type": "code",
|
31 |
+
"execution_count": null,
|
32 |
+
"metadata": {
|
33 |
+
"colab": {
|
34 |
+
"base_uri": "https://localhost:8080/",
|
35 |
+
"height": 91
|
36 |
+
},
|
37 |
+
"id": "7tv-3cGvQiQm",
|
38 |
+
"outputId": "f429240b-4daf-4456-dfb6-82492fefffc3"
|
39 |
+
},
|
40 |
+
"outputs": [
|
41 |
+
{
|
42 |
+
"output_type": "display_data",
|
43 |
+
"data": {
|
44 |
+
"text/plain": [
|
45 |
+
"<IPython.core.display.HTML object>"
|
46 |
+
],
|
47 |
+
"text/html": [
|
48 |
+
"<b>Press play on the music player(Uses only 13MB of data)</b><br/>\n",
|
49 |
+
"<audio src=\"https://henk.tech/colabkobold/silence.m4a\" controls>\n"
|
50 |
+
]
|
51 |
+
},
|
52 |
+
"metadata": {}
|
53 |
+
}
|
54 |
+
],
|
55 |
+
"source": [
|
56 |
+
"%%html\n",
|
57 |
+
"<b>Press play on the music player(Uses only 13MB of data)</b><br/>\n",
|
58 |
+
"<audio src=\"https://henk.tech/colabkobold/silence.m4a\" controls>"
|
59 |
+
]
|
60 |
+
},
|
61 |
+
{
|
62 |
+
"cell_type": "markdown",
|
63 |
+
"source": [
|
64 |
+
"<b>Pytorch/Torchvision fix</b><br>\n",
|
65 |
+
"If running the WebUI tunnel and it promots a torchvision error on versions, run this."
|
66 |
+
],
|
67 |
+
"metadata": {
|
68 |
+
"id": "ME6TR7D6L3ua"
|
69 |
+
}
|
70 |
+
},
|
71 |
+
{
|
72 |
+
"cell_type": "code",
|
73 |
+
"source": [
|
74 |
+
"%pip install torch==1.13.1+cu117 torchvision==0.14.1+cu117 torchtext==0.14.1 torchaudio==0.13.1 torchdata==0.5.1 --extra-index-url https://download.pytorch.org/whl/cu117"
|
75 |
+
],
|
76 |
+
"metadata": {
|
77 |
+
"id": "iEqBEJHvRCFs"
|
78 |
+
},
|
79 |
+
"execution_count": null,
|
80 |
+
"outputs": []
|
81 |
+
},
|
82 |
+
{
|
83 |
+
"cell_type": "markdown",
|
84 |
+
"source": [
|
85 |
+
"**Drive Mount** \n",
|
86 |
+
"<br> Mounts Google Drive onto the colab."
|
87 |
+
],
|
88 |
+
"metadata": {
|
89 |
+
"id": "iwUkS06KWEHJ"
|
90 |
+
}
|
91 |
+
},
|
92 |
+
{
|
93 |
+
"cell_type": "code",
|
94 |
+
"source": [
|
95 |
+
"from google.colab import drive\n",
|
96 |
+
"drive.mount('/content/drive')"
|
97 |
+
],
|
98 |
+
"metadata": {
|
99 |
+
"id": "vx7U5dg2QmzH"
|
100 |
+
},
|
101 |
+
"execution_count": null,
|
102 |
+
"outputs": []
|
103 |
+
},
|
104 |
+
{
|
105 |
+
"cell_type": "markdown",
|
106 |
+
"source": [
|
107 |
+
"<b>Stable Diffusion Download</b><br>\n",
|
108 |
+
"Downloads stable diffusion onto the colab. Comes with some plugins already."
|
109 |
+
],
|
110 |
+
"metadata": {
|
111 |
+
"id": "baj9ryDKMzMq"
|
112 |
+
}
|
113 |
+
},
|
114 |
+
{
|
115 |
+
"cell_type": "code",
|
116 |
+
"source": [
|
117 |
+
"!curl -Lo memfix.zip https://github.com/nolanaatama/sd-webui/raw/main/memfix.zip\n",
|
118 |
+
"!unzip /content/memfix.zip\n",
|
119 |
+
"!apt install -qq libunwind8-dev\n",
|
120 |
+
"!dpkg -i *.deb\n",
|
121 |
+
"%env LD_PRELOAD=libtcmalloc.so\n",
|
122 |
+
"!rm *\n",
|
123 |
+
"!pip install --upgrade fastapi==0.90.1\n",
|
124 |
+
"!git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui\n",
|
125 |
+
"!git clone https://github.com/nolanaatama/sd-webui-tunnels /content/stable-diffusion-webui/extensions/sd-webui-tunnels\n",
|
126 |
+
"!git clone https://github.com/Mikubill/sd-webui-controlnet /content/stable-diffusion-webui/extensions/sd-webui-controlnet\n",
|
127 |
+
"!git clone https://github.com/fkunn1326/openpose-editor /content/stable-diffusion-webui/extensions/openpose-editor\n",
|
128 |
+
"!git clone https://github.com/yfszzx/stable-diffusion-webui-images-browser /content/stable-diffusion-webui/extensions/stable-diffusion-webui-images-browser\n",
|
129 |
+
"!git clone https://github.com/DominikDoom/a1111-sd-webui-tagcomplete /content/stable-diffusion-webui/extensions/a1111-sd-webui-tagcomplete\n",
|
130 |
+
"!git clone https://github.com/KohakuBlueleaf/a1111-sd-webui-locon /contrnt/stable-diffusion-webui/extensions/a1111-sd-webui-locon\n",
|
131 |
+
"# Model(s) setup\n",
|
132 |
+
"# Below are model code for ChilloutMix, we always could change it to our desired model (how-to: https://youtu.be/vj-QrS_mWQI or https://youtu.be/MwyfwPFezvY)\n",
|
133 |
+
"!curl -Lo /content/stable-diffusion-webui/models/Stable-diffusion/chilloutmixni.safetensors https://huggingface.co/nolanaatama/chomni/resolve/main/chomni.safetensors\n",
|
134 |
+
"\n",
|
135 |
+
"# ControlNet\n",
|
136 |
+
"!curl -Lo /content/stable-diffusion-webui/extensions/sd-webui-controlnet/models/control_canny.safetensors https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_canny-fp16.safetensors\n",
|
137 |
+
"!curl -Lo /content/stable-diffusion-webui/extensions/sd-webui-controlnet/models/control_depth.safetensors https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_depth-fp16.safetensors\n",
|
138 |
+
"!curl -Lo /content/stable-diffusion-webui/extensions/sd-webui-controlnet/models/control_hed-fp16.safetensors https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_hed-fp16.safetensors\n",
|
139 |
+
"!curl -Lo /content/stable-diffusion-webui/extensions/sd-webui-controlnet/models/control_mlsd-fp16.safetensors https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_mlsd-fp16.safetensors\n",
|
140 |
+
"!curl -Lo /content/stable-diffusion-webui/extensions/sd-webui-controlnet/models/control_normal-fp16.safetensors https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_normal-fp16.safetensors\n",
|
141 |
+
"!curl -Lo /content/stable-diffusion-webui/extensions/sd-webui-controlnet/models/control_openpose-fp16.safetensors https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_openpose-fp16.safetensors\n",
|
142 |
+
"!curl -Lo /content/stable-diffusion-webui/extensions/sd-webui-controlnet/models/control_scribble-fp16.safetensors https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_scribble-fp16.safetensors\n",
|
143 |
+
"!curl -Lo /content/stable-diffusion-webui/extensions/sd-webui-controlnet/models/control_seg-fp16.safetensors https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_seg-fp16.safetensors\n",
|
144 |
+
"!curl -Lo /content/stable-diffusion-webui/extensions/sd-webui-controlnet/models/t2iadapter_canny_sd14v1.pth https://huggingface.co/TencentARC/T2I-Adapter/resolve/main/models/t2iadapter_canny_sd14v1.pth\n",
|
145 |
+
"!curl -Lo /content/stable-diffusion-webui/extensions/sd-webui-controlnet/models/t2iadapter_color_sd14v1.pth https://huggingface.co/TencentARC/T2I-Adapter/resolve/main/models/t2iadapter_color_sd14v1.pth\n",
|
146 |
+
"!curl -Lo /content/stable-diffusion-webui/extensions/sd-webui-controlnet/models/t2iadapter_depth_sd14v1.pth https://huggingface.co/TencentARC/T2I-Adapter/resolve/main/models/t2iadapter_depth_sd14v1.pth\n",
|
147 |
+
"!curl -Lo /content/stable-diffusion-webui/extensions/sd-webui-controlnet/models/t2iadapter_keypose_sd14v1.pth https://huggingface.co/TencentARC/T2I-Adapter/resolve/main/models/t2iadapter_keypose_sd14v1.pth\n",
|
148 |
+
"!curl -Lo /content/stable-diffusion-webui/extensions/sd-webui-controlnet/models/t2iadapter_openpose_sd14v1.pth https://huggingface.co/TencentARC/T2I-Adapter/resolve/main/models/t2iadapter_openpose_sd14v1.pth\n",
|
149 |
+
"!curl -Lo /content/stable-diffusion-webui/extensions/sd-webui-controlnet/models/t2iadapter_seg_sd14v1.pth https://huggingface.co/TencentARC/T2I-Adapter/resolve/main/models/t2iadapter_seg_sd14v1.pth\n",
|
150 |
+
"!curl -Lo /content/stable-diffusion-webui/extensions/sd-webui-controlnet/models/t2iadapter_sketch_sd14v1.pth https://huggingface.co/TencentARC/T2I-Adapter/resolve/main/models/t2iadapter_sketch_sd14v1.pth\n",
|
151 |
+
"!curl -Lo /content/stable-diffusion-webui/extensions/sd-webui-controlnet/models/t2iadapter_style_sd14v1.pth https://huggingface.co/TencentARC/T2I-Adapter/resolve/main/models/t2iadapter_style_sd14v1.pth\n",
|
152 |
+
"import shutil\n",
|
153 |
+
"shutil.rmtree('/content/stable-diffusion-webui/embeddings')\n",
|
154 |
+
"%cd /content/stable-diffusion-webui\n",
|
155 |
+
"!git checkout 0cc0ee1\n",
|
156 |
+
"!git clone https://huggingface.co/nolanaatama/embeddings\n",
|
157 |
+
"# Web UI tunnel\n",
|
158 |
+
"!COMMANDLINE_ARGS=\"--share --disable-safe-unpickle --no-half-vae --xformers --reinstall-xformers --enable-insecure-extension- --gradio-queue --remotemoe\" REQS_FILE=\"requirements.txt\" python launch.py\n",
|
159 |
+
"# If remotemoe failed to start, change '--remotemoe' to '--cloudflared' on the COMMANDLINE_ARGS line above to use cloudflare tunnel"
|
160 |
+
],
|
161 |
+
"metadata": {
|
162 |
+
"id": "dqA3z5bwQkvq"
|
163 |
+
},
|
164 |
+
"execution_count": null,
|
165 |
+
"outputs": []
|
166 |
+
},
|
167 |
+
{
|
168 |
+
"cell_type": "markdown",
|
169 |
+
"source": [
|
170 |
+
"**Web UI Startup**\n",
|
171 |
+
"<br>Click start on this note to begin stable diffusion. \n",
|
172 |
+
"<br>Make sure all wanted models are loaded on the models folder."
|
173 |
+
],
|
174 |
+
"metadata": {
|
175 |
+
"id": "ESVbs6GeVtyp"
|
176 |
+
}
|
177 |
+
},
|
178 |
+
{
|
179 |
+
"cell_type": "code",
|
180 |
+
"source": [
|
181 |
+
"# Web UI tunnel\n",
|
182 |
+
"!COMMANDLINE_ARGS=\"--share --disable-safe-unpickle --no-half-vae --xformers --reinstall-xformers --enable-insecure-extension- --gradio-queue --remotemoe\" REQS_FILE=\"requirements.txt\" python launch.py"
|
183 |
+
],
|
184 |
+
"metadata": {
|
185 |
+
"id": "XIjrjhmFVGxq"
|
186 |
+
},
|
187 |
+
"execution_count": null,
|
188 |
+
"outputs": []
|
189 |
+
},
|
190 |
+
{
|
191 |
+
"cell_type": "markdown",
|
192 |
+
"source": [
|
193 |
+
"###Installing Models\n",
|
194 |
+
"Methods of installing models such as LoRA into SD web-ui."
|
195 |
+
],
|
196 |
+
"metadata": {
|
197 |
+
"id": "dVYNKa2bNUAq"
|
198 |
+
}
|
199 |
+
},
|
200 |
+
{
|
201 |
+
"cell_type": "markdown",
|
202 |
+
"source": [
|
203 |
+
"**Hugging Face Download**\n",
|
204 |
+
"<br> Downloads the huggingface repo.\n",
|
205 |
+
"\n",
|
206 |
+
"Login possibly required, use a read API token."
|
207 |
+
],
|
208 |
+
"metadata": {
|
209 |
+
"id": "TicK8AEjWaSk"
|
210 |
+
}
|
211 |
+
},
|
212 |
+
{
|
213 |
+
"cell_type": "code",
|
214 |
+
"source": [
|
215 |
+
"!pip install huggingface_hub\n",
|
216 |
+
"import huggingface_hub\n",
|
217 |
+
"huggingface_hub.login(\"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\")\n",
|
218 |
+
"!git clone https://huggingface.co/Solarium/personal-lora.git /content/huggingface\n",
|
219 |
+
"%cd personal-lora\n",
|
220 |
+
"!git-lfs install\n",
|
221 |
+
"!git lfs pull"
|
222 |
+
],
|
223 |
+
"metadata": {
|
224 |
+
"id": "5LBEaujTQnLh"
|
225 |
+
},
|
226 |
+
"execution_count": null,
|
227 |
+
"outputs": []
|
228 |
+
},
|
229 |
+
{
|
230 |
+
"cell_type": "markdown",
|
231 |
+
"source": [
|
232 |
+
"**LoRA sets**\n",
|
233 |
+
"\n",
|
234 |
+
"Downloads specific sets of models from the huggingface repo."
|
235 |
+
],
|
236 |
+
"metadata": {
|
237 |
+
"id": "7W6yfgk0WtDq"
|
238 |
+
}
|
239 |
+
},
|
240 |
+
{
|
241 |
+
"cell_type": "code",
|
242 |
+
"source": [
|
243 |
+
"\n",
|
244 |
+
"# Azur Lane characters\n",
|
245 |
+
"!cp -r '/content/huggingface/Anime/azur-lane/.' '/content/stable-diffusion-webui/models/Lora'\n",
|
246 |
+
"\n",
|
247 |
+
"# Blue Archive Characters\n",
|
248 |
+
"!cp -r '/content/huggingface/Anime/blue-archive/.' '/content/stable-diffusion-webui/models/Lora'\n",
|
249 |
+
"\n",
|
250 |
+
"# Genshin Impact Models\n",
|
251 |
+
"!cp -r '/content/huggingface/Anime/Genshin/.' '/content/stable-diffusion-webui/models/Lora'\n",
|
252 |
+
"\n",
|
253 |
+
"# Characters from other stuff\n",
|
254 |
+
"!cp -r '/content/huggingface/Anime/other/.' '/content/stable-diffusion-webui/models/Lora'"
|
255 |
+
],
|
256 |
+
"metadata": {
|
257 |
+
"id": "66nYE2NCQoaW"
|
258 |
+
},
|
259 |
+
"execution_count": null,
|
260 |
+
"outputs": []
|
261 |
+
},
|
262 |
+
{
|
263 |
+
"cell_type": "markdown",
|
264 |
+
"source": [
|
265 |
+
"**Doll Likenesses**\n",
|
266 |
+
"\n",
|
267 |
+
"Will be mounted on the huggingface repo eventually."
|
268 |
+
],
|
269 |
+
"metadata": {
|
270 |
+
"id": "ypHUF_LYXZSK"
|
271 |
+
}
|
272 |
+
},
|
273 |
+
{
|
274 |
+
"cell_type": "code",
|
275 |
+
"source": [
|
276 |
+
"# Japanese Doll Likeness\n",
|
277 |
+
"!curl -Lo /content/stable-diffusion-webui/models/Lora/japaneseDollLikeness_v10.safetensors https://huggingface.co/nolanaatama/jdllora/resolve/main/jdllora.safetensors\n",
|
278 |
+
"\n",
|
279 |
+
"# Korean Doll Likeness\n",
|
280 |
+
"!curl -Lo /content/stable-diffusion-webui/models/Lora/koreanDollLikeness_v15.safetensors https://huggingface.co/nolanaatama/kdllora/resolve/main/kdllorav15.safetensors\n",
|
281 |
+
"\n",
|
282 |
+
"# Taiwan Doll Likeness\n",
|
283 |
+
"!curl -Lo /content/stable-diffusion-webui/models/Lora/taiwanDollLikeness_v10.safetensors https://huggingface.co/nolanaatama/tdllora/resolve/main/tdllora.safetensors\n",
|
284 |
+
"\n",
|
285 |
+
"#!cp -r '/content/drive/MyDrive/AI/Models/.' '/content/stable-diffusion-webui/models/Loras' to '--cloudflared' on the COMMANDLINE_ARGS line above to use cloudflare tunnel"
|
286 |
+
],
|
287 |
+
"metadata": {
|
288 |
+
"id": "bw3ke8PKQpDk",
|
289 |
+
"colab": {
|
290 |
+
"base_uri": "https://localhost:8080/"
|
291 |
+
},
|
292 |
+
"outputId": "ba854a89-71cf-44c8-d81f-028108315321"
|
293 |
+
},
|
294 |
+
"execution_count": null,
|
295 |
+
"outputs": [
|
296 |
+
{
|
297 |
+
"output_type": "stream",
|
298 |
+
"name": "stdout",
|
299 |
+
"text": [
|
300 |
+
" % Total % Received % Xferd Average Speed Time Time Time Current\n",
|
301 |
+
" Dload Upload Total Spent Left Speed\n",
|
302 |
+
"100 1129 100 1129 0 0 8007 0 --:--:-- --:--:-- --:--:-- 8007\n",
|
303 |
+
"100 144M 100 144M 0 0 176M 0 --:--:-- --:--:-- --:--:-- 176M\n",
|
304 |
+
" % Total % Received % Xferd Average Speed Time Time Time Current\n",
|
305 |
+
" Dload Upload Total Spent Left Speed\n",
|
306 |
+
"100 1139 100 1139 0 0 8761 0 --:--:-- --:--:-- --:--:-- 8694\n",
|
307 |
+
"100 144M 100 144M 0 0 174M 0 --:--:-- --:--:-- --:--:-- 174M\n",
|
308 |
+
" % Total % Received % Xferd Average Speed Time Time Time Current\n",
|
309 |
+
" Dload Upload Total Spent Left Speed\n",
|
310 |
+
"100 1137 100 1137 0 0 8548 0 --:--:-- --:--:-- --:--:-- 8485\n",
|
311 |
+
"100 144M 100 144M 0 0 161M 0 --:--:-- --:--:-- --:--:-- 161M\n"
|
312 |
+
]
|
313 |
+
}
|
314 |
+
]
|
315 |
+
}
|
316 |
+
]
|
317 |
+
}
|