Nekos4Lyfe commited on
Commit
dbfdeaf
·
1 Parent(s): 3fa8d08

Upload Neko_sd.ipynb

Browse files
Files changed (1) hide show
  1. Neko_sd.ipynb +294 -0
Neko_sd.ipynb ADDED
@@ -0,0 +1,294 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "source": [
6
+ "#Fetch the .zip file of the UI\n",
7
+ "#Note that extensions are attached within this .zip file\n",
8
+ "#A full list of extensions used can be found under sd/extensions/Extensions download URLs.txt\n",
9
+ "%cd /content\n",
10
+ "!curl -Lo sd.zip https://huggingface.co/Nekos4Lyfe/sd-kit/resolve/main/sd.zip\n",
11
+ "!unzip sd.zip \n",
12
+ "!rm embeddings.zip #remove .zip file"
13
+ ],
14
+ "metadata": {
15
+ "id": "V1X7OSaLJuHa"
16
+ },
17
+ "execution_count": null,
18
+ "outputs": []
19
+ },
20
+ {
21
+ "cell_type": "code",
22
+ "source": [
23
+ "#Download some basic ControlNET models \n",
24
+ "!curl -Lo /content/sd/extensions/controlnet/models/control_v11p_sd15_canny.safetensors https://huggingface.co/nolanaatama/models/resolve/main/control_v11p_sd15_canny_fp16.safetensors\n",
25
+ "!curl -Lo /content/sd/extensions/controlnet/models/t2iadapter_canny_sd14v1.pth https://huggingface.co/nolanaatama/models/resolve/main/t2iadapter_canny_sd14v1.pth\n",
26
+ "!curl -Lo /content/sd/extensions/controlnet/models/control_v11p_sd15_lineart.safetensors https://huggingface.co/nolanaatama/models/resolve/main/control_v11p_sd15_lineart_fp16.safetensors\n",
27
+ "!curl -Lo /content/sd/extensions/controlnet/models/control_v11p_sd15s2_lineart_anime.safetensors https://huggingface.co/nolanaatama/models/resolve/main/control_v11p_sd15s2_lineart_anime_fp16.safetensors\n"
28
+ ],
29
+ "metadata": {
30
+ "id": "3ab7ebbQIP-v"
31
+ },
32
+ "execution_count": null,
33
+ "outputs": []
34
+ },
35
+ {
36
+ "cell_type": "code",
37
+ "source": [
38
+ "from google.colab import drive\n",
39
+ "drive.mount('/content/drive')\n",
40
+ "\n",
41
+ "#Choose a model to store on Drive as backup. Here are some examples\n",
42
+ "#!curl -Lo /content/drive/MyDrive/models/mistoon.safetensors https://civitai.com/api/download/models/28861\n",
43
+ "#!curl -Lo /content/drive/MyDrive/models/ghostmix.safetensors https://civitai.com/api/download/models/64503\n",
44
+ "#!curl -Lo /content/drive/MyDrive/models/darkside.safetensors https://civitai.com/api/download/models/63193\n",
45
+ "#!curl -Lo /content/drive/MyDrive/models/lyriel.safetensors https://civitai.com/api/download/models/72396\n",
46
+ "#!curl -Lo /content/drive/MyDrive/models/beenyou.safetensors https://civitai.com/api/download/models/64889\n",
47
+ "#!curl -Lo /content/drive/MyDrive/models/analogmadness.safetensors https://civitai.com/api/download/models/56498\n",
48
+ "\n",
49
+ "#Store VAE on your drive for easy access in the future \n",
50
+ "#!curl -Lo /content/drive/MyDrive/VAE/mse840000.vae.pt https://huggingface.co/stabilityai/sd-vae-ft-mse-original/resolve/main/vae-ft-mse-840000-ema-pruned.ckpt #<--Commonly used VAE For photoreal models\n",
51
+ "#!curl -Lo /content/drive/MyDrive/VAE/kl-f8-anime2.vae.pt https://civitai.com/api/download/models/28569 #<--Commonly used VAE For anime models\n",
52
+ "\n",
53
+ "#Add a preloaded model from your Google drive (recommended as civitai is slow/offline sometimes)\n",
54
+ "#import shutil\n",
55
+ "#shutil.copy(\"/content/drive/MyDrive/models/analogmadness.safetensors\", \n",
56
+ "# \"/content/sd/models/Stable-diffusion/analogmadness.safetensors\")\n",
57
+ "\n",
58
+ "#Add VAE to model\n",
59
+ "#shutil.copy(\"/content/drive/MyDrive/VAE/mse840000.vae.pt\", \n",
60
+ "# \"/content/sd/models/Stable-diffusion/analogmadness.vae.pt\")"
61
+ ],
62
+ "metadata": {
63
+ "colab": {
64
+ "base_uri": "https://localhost:8080/"
65
+ },
66
+ "id": "pFkOt218iAKp",
67
+ "outputId": "ae13e74f-1822-48e1-9f5d-b03479f8ab41"
68
+ },
69
+ "execution_count": 4,
70
+ "outputs": [
71
+ {
72
+ "output_type": "stream",
73
+ "name": "stdout",
74
+ "text": [
75
+ "Mounted at /content/drive\n"
76
+ ]
77
+ }
78
+ ]
79
+ },
80
+ {
81
+ "cell_type": "code",
82
+ "source": [
83
+ "#--------------Add a model from civitai:-------------------------------#\n",
84
+ "#Baked VAE (No external VAE required)\n",
85
+ "!curl -Lo /content/sd/models/Stable-diffusion/azovya-rpg.safetensors https://civitai.com/api/download/models/87886 #<---baked VAE\n",
86
+ "\n",
87
+ "#Photoreal models\n",
88
+ "#!curl -Lo /content/sd/models/Stable-diffusion/analogmadness.safetensors https://civitai.com/api/download/models/56498\n",
89
+ "\n",
90
+ "#Anime models\n",
91
+ "#!curl -Lo /content/sd/models/Stable-diffusion/mistoon.safetensors https://civitai.com/api/download/models/28861\n",
92
+ "#!curl -Lo /content/sd/models/Stable-diffusion/beenyou.safetensors https://civitai.com/api/download/models/85614\n",
93
+ "\n",
94
+ "#model from Google Drive\n",
95
+ "#import shutil\n",
96
+ "#shutil.copy(\"/content/drive/MyDrive/models/analogmadness.safetensors\", \n",
97
+ " # \"/content/sd/models/Stable-diffusion/analogmadness.safetensors\")\n",
98
+ "\n",
99
+ "#---------------Add VAE stored on drive to model:-----------------------#\n",
100
+ "\n",
101
+ "#Add VAE for anime models:\n",
102
+ "#import shutil\n",
103
+ "#shutil.copy(\"/content/drive/MyDrive/VAE/kl-f8-anime2.vae.pt\", \n",
104
+ "# \"/content/sd/models/Stable-diffusion/mistoon.vae.pt\")\n",
105
+ "\n",
106
+ "#Add VAE for photoreal models:\n",
107
+ "#import shutil\n",
108
+ "#shutil.copy(\"/content/drive/MyDrive/VAE/mse840000.vae.pt\", \n",
109
+ "# \"/content/sd/models/Stable-diffusion/analogmadness.vae.pt\")\n"
110
+ ],
111
+ "metadata": {
112
+ "colab": {
113
+ "base_uri": "https://localhost:8080/",
114
+ "height": 35
115
+ },
116
+ "id": "TtUGrBEN7AsN",
117
+ "outputId": "1b452bfd-6b7c-4fa4-c612-15bf5caff61f"
118
+ },
119
+ "execution_count": 5,
120
+ "outputs": [
121
+ {
122
+ "output_type": "execute_result",
123
+ "data": {
124
+ "text/plain": [
125
+ "'/content/sd/models/Stable-diffusion/analogmadness.vae.pt'"
126
+ ],
127
+ "application/vnd.google.colaboratory.intrinsic+json": {
128
+ "type": "string"
129
+ }
130
+ },
131
+ "metadata": {},
132
+ "execution_count": 5
133
+ }
134
+ ]
135
+ },
136
+ {
137
+ "cell_type": "code",
138
+ "source": [
139
+ "#Install dependencies\n",
140
+ "!pip install --upgrade fastapi==0.90.1\n",
141
+ "!pip install -q torch==2.0.0+cu118 torchvision==0.15.1+cu118 torchaudio==2.0.1+cu118 torchtext==0.15.1 torchdata==0.6.0 --extra-index-url https://download.pytorch.org/whl/cu118 -U\n",
142
+ "!pip install -q xformers==0.0.18 triton==2.0.0 -U\n",
143
+ "\n",
144
+ "#run the webui once \n",
145
+ "#Three blue links will appear to the UI\n",
146
+ "#(This cell will run indefinetely until you press the square shaped \"Stop\" button <---)\n",
147
+ "#\n",
148
+ "%cd /content/sd\n",
149
+ "!COMMANDLINE_ARGS=\"--share --disable-safe-unpickle --no-half-vae --xformers --enable-insecure-extension --gradio-queue --remotemoe\" REQS_FILE=\"requirements.txt\" python launch.py\n",
150
+ "# If remotemoe failed to start, change '--remotemoe' to '--cloudflared' on the COMMANDLINE_ARGS line above to use cloudflare tunnel"
151
+ ],
152
+ "metadata": {
153
+ "id": "XFottHPM31pS"
154
+ },
155
+ "execution_count": null,
156
+ "outputs": []
157
+ },
158
+ {
159
+ "cell_type": "code",
160
+ "source": [
161
+ "#Add some embeddings after running the UI\n",
162
+ "import shutil\n",
163
+ "shutil.rmtree(\"/content/sd/embeddings/embeddings\") #Remove empty folder\n",
164
+ "%cd /content\n",
165
+ "!curl -Lo embeddings.zip https://huggingface.co/Nekos4Lyfe/sd-kit/resolve/main/embeddings.zip \n",
166
+ "%cd /content/sd/embeddings\n",
167
+ "!unzip /content/embeddings.zip #Create new embeddings folder with content\n",
168
+ "%cd /content\n",
169
+ "!rm embeddings.zip #remove .zip file\n",
170
+ "\n",
171
+ "#How to use: \n",
172
+ "#write \"no_Sketch\" in the negative prompt to activate no_Sketch.pt\n",
173
+ "#write angry512 in the prompt to activate angry512.pt"
174
+ ],
175
+ "metadata": {
176
+ "id": "P3MTYF8fmVDY"
177
+ },
178
+ "execution_count": null,
179
+ "outputs": []
180
+ },
181
+ {
182
+ "cell_type": "code",
183
+ "execution_count": null,
184
+ "metadata": {
185
+ "id": "b7FqKKN4tE3m"
186
+ },
187
+ "outputs": [],
188
+ "source": [
189
+ "#Add some LoRa:s after running the UI \n",
190
+ "#Here the LoRa trigger words are the same as the LoRa .safetensor names\n",
191
+ "!curl -Lo /content/sd/models/Lora/epinoise.safetensors https://civitai.com/api/download/models/16576\n",
192
+ "!curl -Lo /content/sd/models/Lora/dieselpunkai.safetensors https://civitai.com/api/download/models/27755\n",
193
+ "!curl -Lo /content/sd/models/Lora/hipoly.safetensors https://civitai.com/api/download/models/44566\n",
194
+ "!curl -Lo /content/sd/models/Lora/1990s\\(style\\).safetensors https://civitai.com/api/download/models/54221\n",
195
+ "!curl -Lo /content/sd/models/Lora/kids_illustration.safetensors https://civitai.com/api/download/models/67980\n",
196
+ "!curl -Lo /content/sd/models/Lora/\\(illumination\\).safetensors https://civitai.com/api/download/models/42981\n",
197
+ "!curl -Lo /content/sd/models/Lora/kusanagi_motoko.safetensors https://civitai.com/api/download/models/7692\n",
198
+ "!curl -Lo /content/sd/models/Lora/WH40K_ork.safetensors https://civitai.com/api/download/models/63475\n",
199
+ "!curl -Lo /content/sd/models/Lora/MSHN.safetensors https://civitai.com/api/download/models/62552\n",
200
+ "!curl -Lo /content/sd/models/Lora/blame.safetensors https://civitai.com/api/download/models/55412\n",
201
+ "!curl -Lo /content/sd/models/Lora/WH40K_Imperial_Guardsman.safetensors https://civitai.com/api/download/models/56778\n",
202
+ "!curl -Lo /content/sd/models/Lora/WH40K_Commissar.safetensors https://civitai.com/api/download/models/56414\n",
203
+ "!curl -Lo /content/sd/models/Lora/Squeezer1.safetensors https://civitai.com/api/download/models/54302\n",
204
+ "!curl -Lo /content/sd/models/Lora/Squeezer2.safetensors https://civitai.com/api/download/models/44493\n",
205
+ "!curl -Lo /content/sd/models/Lora/scared_expression.safetensors https://civitai.com/api/download/models/49924\n",
206
+ "!curl -Lo /content/sd/models/Lora/graphic_novel.safetensors https://civitai.com/api/download/models/39455\n",
207
+ "!curl -Lo /content/sd/models/Lora/>_<-@_@-=_=-X-X-._.-JITOME-:I.safetensors https://civitai.com/api/download/models/30666\n",
208
+ "!curl -Lo /content/sd/models/Lora/emotion.safetensors https://civitai.com/models/11998/emotion-puppeteer-lora\n",
209
+ "!curl -Lo /content/sd/models/Lora/adepta_sororitas.safetensors https://civitai.com/api/download/models/12730\n",
210
+ "!curl -Lo /content/sd/models/Lora/gmod.safetensors https://civitai.com/api/download/models/5988\n",
211
+ "!curl -Lo /content/sd/models/Lora/onoff.safetensors https://civitai.com/api/download/models/55073\n",
212
+ "!curl -Lo /content/sd/models/Lora/mrrpss.safetensors https://civitai.com/api/download/models/52660\n",
213
+ "!curl -Lo /content/sd/models/Lora/eaba.safetensors https://civitai.com/api/download/models/68626\n",
214
+ "\n",
215
+ "#How to use: \n",
216
+ "#write <lora:epinoise:1> epinoise in the prompt to activate the Lora epinoise.safetensors"
217
+ ]
218
+ },
219
+ {
220
+ "cell_type": "code",
221
+ "source": [
222
+ "#Add some Wildcards after running the UI \n",
223
+ "#These are not my own but fetched from here: https://www.sdcompendium.com/doku.php?id=start\n",
224
+ "#(using the dynamic prompts extension baked into sd.zip)\n",
225
+ "%cd /content\n",
226
+ "!curl -Lo wildcards.zip https://huggingface.co/Nekos4Lyfe/sd-kit/resolve/main/wildcards.zip \n",
227
+ "\n",
228
+ "import shutil\n",
229
+ "shutil.rmtree(\"/content/sd/extensions/sd-dynamic-prompts/wildcards\") #Remove empty folder\n",
230
+ "%cd /content/sd/extensions/sd-dynamic-prompts/wildcards\n",
231
+ "!unzip /content/wildcards.zip \n",
232
+ "%cd /content\n",
233
+ "!rm wildcards.zip #remove .zip file\n"
234
+ ],
235
+ "metadata": {
236
+ "id": "3hPt2WCNEy9f"
237
+ },
238
+ "execution_count": null,
239
+ "outputs": []
240
+ },
241
+ {
242
+ "cell_type": "code",
243
+ "source": [
244
+ "#Run the UI again with the LoRa and embeddings\n",
245
+ "#To access the LoRa and embeddings, click one of the buttons beneath the big \"Generate!\" button. \n",
246
+ "#It's the button beneath \"Generate!\" right in the middle with some orange on it. \n",
247
+ "#Scroll up to find the UI links\n",
248
+ "%cd /content/sd\n",
249
+ "!COMMANDLINE_ARGS=\"--share --disable-safe-unpickle --no-half-vae --xformers --enable-insecure-extension --gradio-queue --remotemoe --disable-console-progressbars\" REQS_FILE=\"requirements.txt\" python launch.py\n",
250
+ "# If remotemoe failed to start, change '--remotemoe' to '--cloudflared' on the COMMANDLINE_ARGS line above to use cloudflare tunnel"
251
+ ],
252
+ "metadata": {
253
+ "id": "2jdGVvT19hk2"
254
+ },
255
+ "execution_count": null,
256
+ "outputs": []
257
+ },
258
+ {
259
+ "cell_type": "code",
260
+ "source": [
261
+ "#Use remote storage rather then Drive storage \n",
262
+ "#(note that you will lose all generated images at end of session)\n",
263
+ "%cd /content\n",
264
+ "!curl -Lo memfix.zip https://huggingface.co/Nekos4Lyfe/sd-kit/resolve/main/memfix.zip \n",
265
+ "!unzip memfix.zip\n",
266
+ "!apt install -qq libunwind8-dev\n",
267
+ "!dpkg -i *.deb\n",
268
+ "%env LD_PRELOAD=libtcmalloc.so\n",
269
+ "!rm *"
270
+ ],
271
+ "metadata": {
272
+ "id": "_2T1Tc0uq8bc"
273
+ },
274
+ "execution_count": null,
275
+ "outputs": []
276
+ }
277
+ ],
278
+ "metadata": {
279
+ "colab": {
280
+ "provenance": [],
281
+ "gpuType": "T4"
282
+ },
283
+ "kernelspec": {
284
+ "display_name": "Python 3",
285
+ "name": "python3"
286
+ },
287
+ "language_info": {
288
+ "name": "python"
289
+ },
290
+ "accelerator": "GPU"
291
+ },
292
+ "nbformat": 4,
293
+ "nbformat_minor": 0
294
+ }