ACCA225 commited on
Commit
b0f9315
1 Parent(s): 11dcbfd

Upload sd-webui土星部署v1.1.ipynb

Browse files
Saturn云端部署/sd-webui土星部署v1.1.ipynb CHANGED
@@ -1,582 +1 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "markdown",
5
- "metadata": {},
6
- "source": [
7
- "## NovelAi Stable Diffusion - webui AI绘画项目 \n",
8
- "**torch: 2.0.0+cu118  •  xformers: 0.0.20**\n",
9
- "​\n",
10
- "## <span style=\"color:red; font-weight:bold;\">有问题请加qq群632428790 (1081/2000)</span>\n",
11
- "or contact me on Discord: Loading#7871\n",
12
- "## <span style=\"color:red; font-weight:bold;\"> 希望有能力的大佬可以做视频宣传本项目!</span>\n",
13
- "## BiliBili:Nyan9 \n",
14
- "## \n",
15
- "<!--- \n",
16
- "这里是作者的署名和群号码,未经同意请勿删除,删一句家里人少一个\n",
17
- "--->\n",
18
- "<!--- \n",
19
- "倒卖狗全家死光\n",
20
- "--->\n"
21
- ]
22
- },
23
- {
24
- "cell_type": "markdown",
25
- "metadata": {},
26
- "source": [
27
- "## 未经同意禁止将源代码用于出售,一经发现严肃追究\n",
28
- "<!--- \n",
29
- "这里是作者的署名和群号码,未经同意请勿删除,删一句家里人少一个\n",
30
- "--->\n",
31
- "<!--- \n",
32
- "倒卖狗全家死光\n",
33
- "--->\n"
34
- ]
35
- },
36
- {
37
- "cell_type": "markdown",
38
- "metadata": {},
39
- "source": [
40
- "分三个代码块:依赖安装,启动sd-webui,下载模型\n",
41
- "第一次开机请先运行依赖安装一遍"
42
- ]
43
- },
44
- {
45
- "cell_type": "markdown",
46
- "metadata": {},
47
- "source": [
48
- "----------"
49
- ]
50
- },
51
- {
52
- "cell_type": "markdown",
53
- "metadata": {},
54
- "source": [
55
- "# 安装依赖,首次使用需要执行"
56
- ]
57
- },
58
- {
59
- "cell_type": "code",
60
- "execution_count": 1,
61
- "metadata": {
62
- "execution": {
63
- "iopub.execute_input": "2023-08-18T04:10:35.764899Z",
64
- "iopub.status.busy": "2023-08-18T04:10:35.764479Z",
65
- "iopub.status.idle": "2023-08-18T04:12:11.276390Z",
66
- "shell.execute_reply": "2023-08-18T04:12:11.275499Z",
67
- "shell.execute_reply.started": "2023-08-18T04:10:35.764866Z"
68
- },
69
- "tags": []
70
- },
71
- "outputs": [
72
- {
73
- "name": "stdout",
74
- "output_type": "stream",
75
- "text": [
76
- "/home/jovyan/workspace\n",
77
- "--2023-08-18 04:10:48-- https://huggingface.co/datasets/sukaka/sd_configs/resolve/main/start.sh\n",
78
- "Resolving huggingface.co (huggingface.co)... 3.160.5.109, 3.160.5.102, 3.160.5.25, ...\n",
79
- "Connecting to huggingface.co (huggingface.co)|3.160.5.109|:443... connected.\n",
80
- "HTTP request sent, awaiting response... 200 OK\n",
81
- "Length: 1019 [text/plain]\n",
82
- "Saving to: ‘start.sh’\n",
83
- "\n",
84
- "start.sh 100%[===================>] 1019 --.-KB/s in 0s \n",
85
- "\n",
86
- "2023-08-18 04:10:48 (792 MB/s) - ‘start.sh’ saved [1019/1019]\n",
87
- "\n",
88
- "/home/jovyan/workspace\n",
89
- "内存优化已安装\n",
90
- "/home/jovyan/workspace\n",
91
- "stable-diffusion-webui安装中\n",
92
- "Cloning into 'stable-diffusion-webui'...\n",
93
- "remote: Enumerating objects: 26020, done.\u001b[K\n",
94
- "remote: Counting objects: 100% (407/407), done.\u001b[K\n",
95
- "remote: Compressing objects: 100% (179/179), done.\u001b[K\n",
96
- "remote: Total 26020 (delta 262), reused 342 (delta 224), pack-reused 25613\u001b[K\n",
97
- "Receiving objects: 100% (26020/26020), 31.82 MiB | 42.49 MiB/s, done.\n",
98
- "Resolving deltas: 100% (18220/18220), done.\n",
99
- "/home/jovyan/workspace\n",
100
- "/home/jovyan/workspace\n",
101
- "环境包下载中\n",
102
- "环境包已下载\n",
103
- "/home/jovyan/workspace/venv\n",
104
- "环境安装中\n",
105
- "环境安装完毕\n"
106
- ]
107
- }
108
- ],
109
- "source": [
110
- "#依赖安装,每次开机请运行此单元格\n",
111
- "#***0是关闭,1是开启***\n",
112
- "\n",
113
- "install_path='/home/jovyan/workspace' ##安装目录\n",
114
- "\n",
115
- "venv_link = \"https://huggingface.co/datasets/sukaka/venv_ai_drow/resolve/main/sd_webui/torch201_cu118_xf20.tar.gz\" #环境包链接\n",
116
- "\n",
117
- "updata = 0 #更新webui\n",
118
- "\n",
119
- "#-----------------------------------------------------------\n",
120
- "\n",
121
- "import os\n",
122
- "import re\n",
123
- "from pathlib import Path\n",
124
- "\n",
125
- "!sudo apt-get update > /dev/null 2>&1\n",
126
- "!sudo apt -y install -qq aria2 > /dev/null 2>&1\n",
127
- "!sudo apt -y install -qq pigz > /dev/null 2>&1\n",
128
- "!sudo apt-get install libglib2.0-0 -y > /dev/null 2>&1\n",
129
- "\n",
130
- "%cd $install_path\n",
131
- "if not os.path.exists(\"start.sh\"):\n",
132
- " !wget https://huggingface.co/datasets/sukaka/sd_configs/resolve/main/start.sh -O start.sh\n",
133
- " !chmod +x start.sh\n",
134
- " \n",
135
- "#内存优化\n",
136
- "if os.path.exists(f\"{install_path}/libtcmalloc/\"):\n",
137
- " print('内存优化已安装')\n",
138
- "else:\n",
139
- " %cd $install_path\n",
140
- " !mkdir libtcmalloc\n",
141
- " !wget https://github.com/camenduru/gperftools/releases/download/v1.0/libtcmalloc_minimal.so.4 -O libtcmalloc/libtcmalloc_minimal.so.4 > /dev/null 2>&1\n",
142
- " print('内存优化已安装')\n",
143
- "\n",
144
- "%cd $install_path\n",
145
- "print('stable-diffusion-webui安装中')\n",
146
- "#Download Automatic1111's Stable Diffusion Web UI\n",
147
- "if os.path.exists('stable-diffusion-webui'):\n",
148
- " if updata == 1:\n",
149
- " %cd $install_path/stable-diffusion-webui/\n",
150
- " !git pull https://github.com/KaggleSD/stable-diffusion-webui master\n",
151
- " !sed -i -e '''/from modules import launch_utils/a\\import os''' /home/jovyan/workspace/stable-diffusion-webui/launch.py\n",
152
- " !sed -i -e '''/ prepare_environment()/a\\ os.system\\(f\\\"\"\"sed -i -e ''\\\"s/dict()))/dict())).cuda()/g\\\"'' /home/jovyan/workspace/stable-diffusion-webui/repositories/stable-diffusion-stability-ai/ldm/util.py\"\"\")''' /home/jovyan/workspace/stable-diffusion-webui/launch.py\n",
153
- " !sed -i -e 's/\\[\"sd_model_checkpoint\"\\]/\\[\"sd_model_checkpoint\",\"sd_vae\",\"CLIP_stop_at_last_layers\"\\]/g' /home/jovyan/workspace/stable-diffusion-webui/modules/shared.py\n",
154
- " print('stable-diffusion-webui已安装')\n",
155
- "else:\n",
156
- " !git clone https://github.com/KaggleSD/stable-diffusion-webui\n",
157
- " !sed -i -e '''/from modules import launch_utils/a\\import os''' /home/jovyan/workspace/stable-diffusion-webui/launch.py\n",
158
- " !sed -i -e '''/ prepare_environment()/a\\ os.system\\(f\\\"\"\"sed -i -e ''\\\"s/dict()))/dict())).cuda()/g\\\"'' /home/jovyan/workspace/stable-diffusion-webui/repositories/stable-diffusion-stability-ai/ldm/util.py\"\"\")''' /home/jovyan/workspace/stable-diffusion-webui/launch.py\n",
159
- " !sed -i -e 's/\\[\"sd_model_checkpoint\"\\]/\\[\"sd_model_checkpoint\",\"sd_vae\",\"CLIP_stop_at_last_layers\"\\]/g' /home/jovyan/workspace/stable-diffusion-webui/modules/shared.py\n",
160
- "\n",
161
- "%cd $install_path\n",
162
- "python_path = f\"{install_path}/venv/bin/python3\"\n",
163
- "if os.path.exists('venv'):\n",
164
- " print('环境已安装')\n",
165
- "else:\n",
166
- " %cd $install_path\n",
167
- " if not os.path.exists('venv.tar.gz'):\n",
168
- " print('环境包下载中')\n",
169
- " os.system(f\"aria2c --console-log-level=error -q -c -x 16 -s 16 -k 1M -o venv.tar.gz {venv_link}\")\n",
170
- " print('环境包已下载')\n",
171
- " !mkdir venv\n",
172
- " %cd venv\n",
173
- " print('环境安装中')\n",
174
- " os.system(f'pigz -dc -p 4 {install_path}/venv.tar.gz | tar xf -')\n",
175
- " !rm -rf $install_path/venv.tar.gz\n",
176
- " # 定位 serializing.py 文件\n",
177
- " serializing_file = os.path.join(install_path, \"venv\", \"lib\", \"python3.10\", \"site-packages\", \"gradio_client\", \"serializing.py\")\n",
178
- "\n",
179
- " # 读取文件内容\n",
180
- " with open(serializing_file, \"r\") as f:\n",
181
- " lines = f.readlines()\n",
182
- "\n",
183
- " # 在 COMPONENT_MAPPING 字典中添加一行\n",
184
- " for i, line in enumerate(lines):\n",
185
- " if \"COMPONENT_MAPPING = {\" in line:\n",
186
- " lines.insert(i + 1, ' \"dataset\": StringSerializable,\\n')\n",
187
- " break\n",
188
- "\n",
189
- " # 写回文件\n",
190
- " with open(serializing_file, \"w\") as f:\n",
191
- " f.writelines(lines)\n",
192
- "\n",
193
- "print('环境安装完毕')"
194
- ]
195
- },
196
- {
197
- "cell_type": "markdown",
198
- "metadata": {},
199
- "source": [
200
- "# 安装插件,模型"
201
- ]
202
- },
203
- {
204
- "cell_type": "code",
205
- "execution_count": 2,
206
- "metadata": {
207
- "execution": {
208
- "iopub.execute_input": "2023-08-18T04:12:37.330898Z",
209
- "iopub.status.busy": "2023-08-18T04:12:37.330524Z",
210
- "iopub.status.idle": "2023-08-18T04:13:56.278444Z",
211
- "shell.execute_reply": "2023-08-18T04:13:56.277657Z",
212
- "shell.execute_reply.started": "2023-08-18T04:12:37.330871Z"
213
- },
214
- "tags": []
215
- },
216
- "outputs": [
217
- {
218
- "name": "stdout",
219
- "output_type": "stream",
220
- "text": [
221
- "/home/jovyan/workspace/stable-diffusion-webui\n",
222
- "安装插件中\n"
223
- ]
224
- },
225
- {
226
- "name": "stderr",
227
- "output_type": "stream",
228
- "text": [
229
- "Cloning into 'loopback_scaler'...\n",
230
- "Cloning into 'sd-webui-controlnet'...\n",
231
- "Cloning into 'sd-civitai-browser'...\n",
232
- "Cloning into 'sd-webui-depth-lib'...\n",
233
- "Cloning into 'sd-webui-3d-open-pose-editor'...\n",
234
- "Cloning into 'stable-diffusion-webui-localization-zh_CN'...\n",
235
- "Cloning into 'stable-diffusion-webui-two-shot'...\n",
236
- "Cloning into 'a1111-sd-webui-tagcomplete'...\n",
237
- "Cloning into 'multidiffusion-upscaler-for-automatic1111'...\n",
238
- "Cloning into 'sd-webui-cutoff'...\n",
239
- "Cloning into 'sd-webui-lora-block-weight'...\n",
240
- "Cloning into 'Stable-Diffusion-Webui-Civitai-Helper'...\n",
241
- "Cloning into 'stable-diffusion-webui'...\n",
242
- "Cloning into 'sd-webui-mov2mov'...\n",
243
- "Cloning into 'stable-diffusion-webui-wd14-tagger'...\n",
244
- "Cloning into 'sd-webui-prompt-all-in-one'...\n",
245
- "Cloning into 'sd-webui-infinite-image-browsing'...\n",
246
- "Cloning into 'sd-webui-segment-anything'...\n"
247
- ]
248
- },
249
- {
250
- "name": "stdout",
251
- "output_type": "stream",
252
- "text": [
253
- "下载模型中\n",
254
- "下载完毕\n"
255
- ]
256
- }
257
- ],
258
- "source": [
259
- "#运行这个单元格下载模型和插件\n",
260
- "#***出现下载完毕才是下载完****\n",
261
- "\n",
262
- "# 插件列表: git仓库地址\n",
263
- "# 不需要的插件在前面加 # 插件地址之间需要用英语逗号隔开\n",
264
- "extensions = [\n",
265
- " 'https://github.com/Elldreth/loopback_scaler',\n",
266
- " 'https://github.com/jexom/sd-webui-depth-lib',\n",
267
- " #'https://github.com/AlUlkesh/stable-diffusion-webui-images-browser',\n",
268
- " 'https://github.com/camenduru/sd-civitai-browser',\n",
269
- " 'https://github.com/Mikubill/sd-webui-controlnet',\n",
270
- " 'https://github.com/nonnonstop/sd-webui-3d-open-pose-editor',\n",
271
- " 'https://github.com/2575044704/stable-diffusion-webui-localization-zh_CN2',\n",
272
- " 'https://github.com/opparco/stable-diffusion-webui-two-shot',\n",
273
- " #'https://github.com/minicacas/stable-diffusion-webui-composable-lora',\n",
274
- " 'https://github.com/DominikDoom/a1111-sd-webui-tagcomplete',\n",
275
- " 'https://github.com/pkuliyi2015/multidiffusion-upscaler-for-automatic1111',\n",
276
- " #'https://github.com/KohakuBlueleaf/a1111-sd-webui-locon',\n",
277
- " 'https://github.com/hnmr293/sd-webui-cutoff',\n",
278
- " 'https://github.com/hako-mikan/sd-webui-lora-block-weight',\n",
279
- " 'https://github.com/butaixianran/Stable-Diffusion-Webui-Civitai-Helper',\n",
280
- " 'https://github.com/catppuccin/stable-diffusion-webui',\n",
281
- " #'https://github.com/Nevysha/Cozy-Nest',\n",
282
- " 'https://github.com/Scholar01/sd-webui-mov2mov',\n",
283
- " 'https://github.com/toriato/stable-diffusion-webui-wd14-tagger',\n",
284
- " 'https://github.com/Physton/sd-webui-prompt-all-in-one',\n",
285
- " #'https://github.com/KohakuBlueleaf/a1111-sd-webui-lycoris',\n",
286
- " #'https://github.com/deforum-art/sd-webui-deforum',\n",
287
- " 'https://github.com/Scholar01/sd-webui-mov2mov',\n",
288
- " 'https://github.com/zanllp/sd-webui-infinite-image-browsing',\n",
289
- " 'https://github.com/continue-revolution/sd-webui-segment-anything',\n",
290
- "]\n",
291
- "\n",
292
- "# Stable Diffusion模型下载链接放这里\n",
293
- "sd_model_urls=[\n",
294
- "#'https://huggingface.co/datasets/sukaka/sd_models_fp16/resolve/main/GhostMix2.safetensors',\n",
295
- "#sdxl\n",
296
- "\"https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0.safetensors\",\n",
297
- "#'https://huggingface.co/ptx0/sdxl-refiner/resolve/main/sd_xl_refiner_1.0.safetensors',\n",
298
- "]\n",
299
- "#VAE模型下载链接放这里\n",
300
- "vae_model_urls=[\n",
301
- "#'https://huggingface.co/datasets/sukaka/sd_models_fp16/resolve/main/clearvae.vae.pt',\n",
302
- "#'https://huggingface.co/datasets/sukaka/sd_models_fp16/resolve/main/klF8Anime2.vae.pt',\n",
303
- "'https://huggingface.co/madebyollin/sdxl-vae-fp16-fix/resolve/main/sdxl_vae.safetensors',\n",
304
- "]\n",
305
- "# Lora模型下载链接放这里\n",
306
- "lora_model_urls=[\n",
307
- "#墨心\n",
308
- "#'https://civitai.com/api/download/models/14856',\n",
309
- "]\n",
310
- "\n",
311
- "# controlnet模型下载链接放这里\n",
312
- "cn_model_urls = [\n",
313
- "#'https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11e_sd15_ip2p_fp16.safetensors',\n",
314
- "#'https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11e_sd15_shuffle_fp16.safetensors',\n",
315
- "#'https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11f1p_sd15_depth_fp16.safetensors',\n",
316
- "#'https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_canny_fp16.safetensors',\n",
317
- "#'https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_inpaint_fp16.safetensors',\n",
318
- "#'https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_lineart_fp16.safetensors',\n",
319
- "#'https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_mlsd_fp16.safetensors',\n",
320
- "#'https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_normalbae_fp16.safetensors',\n",
321
- "#'https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_openpose_fp16.safetensors',\n",
322
- "#'https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_scribble_fp16.safetensors',\n",
323
- "#'https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_softedge_fp16.safetensors',\n",
324
- "#'https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15s2_lineart_anime_fp16.safetensors',\n",
325
- "#'https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11u_sd15_tile_fp16.safetensors',\n",
326
- "]\n",
327
- "\n",
328
- "#Hypernetworks超网络模型下载链接请放在这里\n",
329
- "hypernetworks_model_urls = []\n",
330
- "\n",
331
- "#放大算法路径请放在这里\n",
332
- "ESRGAN = []\n",
333
- "#放大算法链接请放在这里\n",
334
- "ESRGAN_urls = [\n",
335
- "'https://huggingface.co/FacehugmanIII/4x_foolhardy_Remacri/resolve/main/4x_foolhardy_Remacri.pth',\n",
336
- "'https://huggingface.co/konohashinobi4/4xAnimesharp/resolve/main/4x-AnimeSharp.pth',\n",
337
- "'https://huggingface.co/lokCX/4x-Ultrasharp/resolve/main/4x-UltraSharp.pth',\n",
338
- "]\n",
339
- "\n",
340
- "# embeddings(pt文件)下载链接请放在这里:\n",
341
- "embeddings_model_urls=[\n",
342
- "#'https://huggingface.co/datasets/sukaka/sd_configs/resolve/main/%E4%BA%BA%E4%BD%93%E4%BF%AE%E6%AD%A3/EasyNegative.pt',\n",
343
- "#'https://huggingface.co/datasets/sukaka/sd_configs/resolve/main/%E4%BA%BA%E4%BD%93%E4%BF%AE%E6%AD%A3/bad-artist-anime.pt',\n",
344
- "#'https://huggingface.co/datasets/sukaka/sd_configs/resolve/main/%E4%BA%BA%E4%BD%93%E4%BF%AE%E6%AD%A3/bad-hands-5.pt',\n",
345
- "#'https://huggingface.co/datasets/sukaka/sd_configs/resolve/main/%E4%BA%BA%E4%BD%93%E4%BF%AE%E6%AD%A3/bad_prompt_version2.pt',\n",
346
- "#'https://huggingface.co/datasets/sukaka/sd_configs/resolve/main/%E4%BA%BA%E4%BD%93%E4%BF%AE%E6%AD%A3/bad-image-v2-39000.pt',\n",
347
- "]\n",
348
- "\n",
349
- "#script文件下载链接导入\n",
350
- "scripts_urls = []\n",
351
- "\n",
352
- "#tag词库文件下载链接导入\n",
353
- "tags_file_urls=[\n",
354
- "\"https://huggingface.co/datasets/sukaka/sd_configs/resolve/main/danbooru.zh_CN.csv\",\n",
355
- "]\n",
356
- "\n",
357
- "#sd-webui-segment-anything插件的模型导入\n",
358
- "sam_model = []\n",
359
- "#sd-webui-segment-anything插件的模型下载链接导入\n",
360
- "sam_model_urls = [\n",
361
- " #'https://huggingface.co/lkeab/hq-sam/resolve/main/sam_hq_vit_h.pth',\n",
362
- " 'https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth',\n",
363
- "]\n",
364
- "\n",
365
- "#---------------------------------------------------------------------------------------------------------------------\n",
366
- "\n",
367
- "from concurrent.futures import ThreadPoolExecutor\n",
368
- "# 安装插件,下载和同步模型\n",
369
- "def install_extensions(install_path, extensions):\n",
370
- " print('安装插件中')\n",
371
- " os.chdir(os.path.join(install_path, 'stable-diffusion-webui'))\n",
372
- " os.makedirs('extensions', exist_ok=True)\n",
373
- " os.chdir('extensions')\n",
374
- "\n",
375
- " def clone_repo(ex):\n",
376
- " repo_name = ex.split('/')[-1]\n",
377
- " if not os.path.exists(repo_name):\n",
378
- " os.system('git clone ' + ex)\n",
379
- "\n",
380
- " with ThreadPoolExecutor(max_workers=4) as executor:\n",
381
- " executor.map(clone_repo, extensions)\n",
382
- " \n",
383
- "def download_link(link, target_folder):\n",
384
- " if link.startswith('https://huggingface.co/' or 'https://dl.fbaipublicfiles.com'):\n",
385
- " filename = re.search(r'[^/]+$', link).group(0)\n",
386
- " return f'aria2c --console-log-level=error -q -c -x 16 -s 16 -k 1M -d \"{target_folder}\" -o \"{filename}\" \"{link}\"'\n",
387
- " else:\n",
388
- " return f'aria2c --console-log-level=error -q -c -x 16 -s 16 -k 1M --remote-time -d \"{target_folder}\" \"{link}\"'\n",
389
- "\n",
390
- "def download_links(links, target_folder):\n",
391
- " tasks = []\n",
392
- " for link in links:\n",
393
- " tasks.append(download_link(link, target_folder))\n",
394
- " return tasks\n",
395
- "\n",
396
- "def download_links_all(tasks):\n",
397
- " with ThreadPoolExecutor(max_workers=4) as executor:\n",
398
- " for task in tasks:\n",
399
- " executor.submit(os.system, task)\n",
400
- "\n",
401
- "%cd $install_path/stable-diffusion-webui\n",
402
- "install_extensions(install_path, extensions)\n",
403
- "print('下载模型中')\n",
404
- "tasks = []\n",
405
- "tasks.extend(download_links(vae_model_urls, f'{install_path}/stable-diffusion-webui/models/VAE'))\n",
406
- "tasks.extend(download_links(sd_model_urls, f'{install_path}/stable-diffusion-webui/models/Stable-diffusion'))\n",
407
- "tasks.extend(download_links(lora_model_urls, f'{install_path}/stable-diffusion-webui/models/Lora'))\n",
408
- "tasks.extend(download_links(cn_model_urls, f'{install_path}/stable-diffusion-webui/extensions/sd-webui-controlnet/models'))\n",
409
- "tasks.extend(download_links(hypernetworks_model_urls, f'{install_path}/stable-diffusion-webui/models/hypernetworks'))\n",
410
- "tasks.extend(download_links(ESRGAN_urls, f'{install_path}/stable-diffusion-webui/models/ESRGAN'))\n",
411
- "tasks.extend(download_links(embeddings_model_urls, f'{install_path}/stable-diffusion-webui/embeddings'))\n",
412
- "tasks.extend(download_links(scripts_urls, f'{install_path}/stable-diffusion-webui/scripts'))\n",
413
- "tasks.extend(download_links(tags_file_urls, f'{install_path}/stable-diffusion-webui/extensions/a1111-sd-webui-tagcomplete/tags'))\n",
414
- "tasks.extend(download_links(sam_model_urls, f'{install_path}/stable-diffusion-webui/extensions/sd-webui-segment-anything/models/sam'))\n",
415
- "download_links_all(tasks)\n",
416
- "print('下载完毕')"
417
- ]
418
- },
419
- {
420
- "cell_type": "markdown",
421
- "metadata": {},
422
- "source": [
423
- "# 启动SD-webui"
424
- ]
425
- },
426
- {
427
- "cell_type": "code",
428
- "execution_count": null,
429
- "metadata": {
430
- "execution": {
431
- "iopub.execute_input": "2023-08-18T04:20:05.735646Z",
432
- "iopub.status.busy": "2023-08-18T04:20:05.735130Z"
433
- },
434
- "tags": []
435
- },
436
- "outputs": [
437
- {
438
- "name": "stdout",
439
- "output_type": "stream",
440
- "text": [
441
- "/home/jovyan\n",
442
- "/home/jovyan/workspace\n",
443
- "Python 3.10.11 (main, May 16 2023, 00:28:57) [GCC 11.2.0]\n",
444
- "Version: v1.5.1\n",
445
- "Commit hash: 68f336bd994bed5442ad95bad6b6ad5564a5409a\n",
446
- "Installing clip\n",
447
- "Cloning Stable Diffusion into /home/jovyan/workspace/stable-diffusion-webui/repositories/stable-diffusion-stability-ai...\n",
448
- "Cloning into '/home/jovyan/workspace/stable-diffusion-webui/repositories/stable-diffusion-stability-ai'...\n",
449
- "remote: Enumerating objects: 574, done.\u001b[K\n",
450
- "remote: Counting objects: 100% (304/304), done.\u001b[K\n",
451
- "remote: Compressing objects: 100% (88/88), done.\u001b[K\n",
452
- "remote: Total 574 (delta 244), reused 216 (delta 216), pack-reused 270\u001b[K\n",
453
- "Receiving objects: 100% (574/574), 73.43 MiB | 44.92 MiB/s, done.\n",
454
- "Resolving deltas: 100% (276/276), done.\n",
455
- "Cloning Stable Diffusion XL into /home/jovyan/workspace/stable-diffusion-webui/repositories/generative-models...\n",
456
- "Cloning into '/home/jovyan/workspace/stable-diffusion-webui/repositories/generative-models'...\n",
457
- "remote: Enumerating objects: 740, done.\u001b[K\n",
458
- "remote: Counting objects: 100% (563/563), done.\u001b[K\n",
459
- "remote: Compressing objects: 100% (283/283), done.\u001b[K\n",
460
- "remote: Total 740 (delta 340), reused 425 (delta 266), pack-reused 177\u001b[K\n",
461
- "Receiving objects: 100% (740/740), 22.31 MiB | 28.38 MiB/s, done.\n",
462
- "Resolving deltas: 100% (378/378), done.\n",
463
- "Cloning K-diffusion into /home/jovyan/workspace/stable-diffusion-webui/repositories/k-diffusion...\n",
464
- "Cloning into '/home/jovyan/workspace/stable-diffusion-webui/repositories/k-diffusion'...\n",
465
- "remote: Enumerating objects: 770, done.\u001b[K\n",
466
- "remote: Counting objects: 100% (46/46), done.\u001b[K\n",
467
- "remote: Compressing objects: 100% (25/25), done.\u001b[K\n",
468
- "remote: Total 770 (delta 25), reused 34 (delta 21), pack-reused 724\u001b[K\n",
469
- "Receiving objects: 100% (770/770), 157.76 KiB | 4.78 MiB/s, done.\n",
470
- "Resolving deltas: 100% (503/503), done.\n",
471
- "Cloning CodeFormer into /home/jovyan/workspace/stable-diffusion-webui/repositories/CodeFormer...\n",
472
- "Cloning into '/home/jovyan/workspace/stable-diffusion-webui/repositories/CodeFormer'...\n",
473
- "remote: Enumerating objects: 594, done.\u001b[K\n",
474
- "remote: Counting objects: 100% (245/245), done.\u001b[K\n",
475
- "remote: Compressing objects: 100% (98/98), done.\u001b[K\n",
476
- "remote: Total 594 (delta 176), reused 167 (delta 147), pack-reused 349\u001b[K\n",
477
- "Receiving objects: 100% (594/594), 17.31 MiB | 26.69 MiB/s, done.\n",
478
- "Resolving deltas: 100% (287/287), done.\n",
479
- "Cloning BLIP into /home/jovyan/workspace/stable-diffusion-webui/repositories/BLIP...\n",
480
- "Cloning into '/home/jovyan/workspace/stable-diffusion-webui/repositories/BLIP'...\n",
481
- "remote: Enumerating objects: 277, done.\u001b[K\n",
482
- "remote: Counting objects: 100% (165/165), done.\u001b[K\n",
483
- "remote: Compressing objects: 100% (30/30), done.\u001b[K\n",
484
- "remote: Total 277 (delta 137), reused 136 (delta 135), pack-reused 112\u001b[K\n",
485
- "Receiving objects: 100% (277/277), 7.03 MiB | 40.70 MiB/s, done.\n",
486
- "Resolving deltas: 100% (152/152), done.\n",
487
- "Installing requirements for CodeFormer\n",
488
- "Installing sd-webui-segment-anything requirement: segment_anything\n",
489
- "Installing sd-webui-segment-anything requirement: supervision\n",
490
- "\n",
491
- "Installing requirements for Mov2mov\n",
492
- "Installing requirements for ffmpeg\n",
493
- "\n",
494
- "Installing sd-webui-infinite-image-browsing requirement: python-dotenv\n",
495
- "Installing sd-webui-infinite-image-browsing requirement: pyfunctional\n",
496
- "\n",
497
- "Installing sd-webui-prompt-all-in-one: chardet\n",
498
- "Installing sd-webui-prompt-all-in-one: execjs\n",
499
- "Installing sd-webui-prompt-all-in-one: lxml\n",
500
- "Installing sd-webui-prompt-all-in-one: pathos\n",
501
- "Installing sd-webui-prompt-all-in-one: cryptography\n",
502
- "Installing sd-webui-prompt-all-in-one: openai\n",
503
- "Installing sd-webui-prompt-all-in-one: boto3\n",
504
- "Installing sd-webui-prompt-all-in-one: aliyunsdkcore\n",
505
- "Installing sd-webui-prompt-all-in-one: aliyunsdkalimt\n",
506
- "\n",
507
- "Downloading pose_landmark_full.tflite...\n",
508
- "Downloading pose_web.binarypb...\n",
509
- "Downloading pose_solution_packed_assets.data...\n",
510
- "Downloading pose_solution_simd_wasm_bin.wasm...\n",
511
- "Downloading pose_solution_packed_assets_loader.js...\n",
512
- "Downloading pose_solution_simd_wasm_bin.js...\n",
513
- "\n",
514
- "Installing sd-webui-controlnet requirement: mediapipe\n",
515
- "Installing sd-webui-controlnet requirement: svglib\n",
516
- "Installing sd-webui-controlnet requirement: fvcore\n",
517
- "\n",
518
- "Installing requirements for CivitAI Browser\n",
519
- "\n",
520
- "Launching Web UI with arguments: --listen --xformers --no-hashing --enable-insecure-extension-access --gradio-queue --administrator --disable-safe-unpickle --ckpt=models/Stable-diffusion/sd_xl_base_1.0.safetensors --port=8000\n",
521
- "Civitai Helper: Get Custom Model Folder\n",
522
- "Civitai Helper: Load setting from: /home/jovyan/workspace/stable-diffusion-webui/extensions/Stable-Diffusion-Webui-Civitai-Helper/setting.json\n",
523
- "Civitai Helper: No setting file, use default\n",
524
- "Tag Autocomplete: Could not locate model-keyword extension, Lora trigger word completion will be limited to those added through the extra networks menu.\n",
525
- "2023-08-18 04:21:27,963 - ControlNet - \u001b[0;32mINFO\u001b[0m - ControlNet v1.1.238\n",
526
- "ControlNet preprocessor location: /home/jovyan/workspace/stable-diffusion-webui/extensions/sd-webui-controlnet/annotator/downloads\n",
527
- "2023-08-18 04:21:28,071 - ControlNet - \u001b[0;32mINFO\u001b[0m - ControlNet v1.1.238\n",
528
- "sd-webui-prompt-all-in-one background API service started successfully.\n",
529
- "Loading weights [None] from /home/jovyan/workspace/stable-diffusion-webui/models/Stable-diffusion/sd_xl_base_1.0.safetensors\n",
530
- "Creating model from config: /home/jovyan/workspace/stable-diffusion-webui/repositories/generative-models/configs/inference/sd_xl_base.yaml\n",
531
- "Downloading (…)olve/main/vocab.json: 100%|███| 961k/961k [00:00<00:00, 23.2MB/s]\n",
532
- "Downloading (…)olve/main/merges.txt: 100%|███| 525k/525k [00:00<00:00, 26.4MB/s]\n",
533
- "Downloading (…)cial_tokens_map.json: 100%|█████| 389/389 [00:00<00:00, 3.80MB/s]\n",
534
- "Downloading (…)okenizer_config.json: 100%|█████| 905/905 [00:00<00:00, 11.1MB/s]\n",
535
- "Downloading (…)lve/main/config.json: 100%|█| 4.52k/4.52k [00:00<00:00, 35.7MB/s]\n",
536
- "Applying attention optimization: xformers... done.\n",
537
- "Model loaded in 18.8s (load weights from disk: 2.1s, load config: 0.2s, create model: 8.2s, apply weights to model: 6.7s, calculate empty prompt: 1.4s).\n",
538
- "Running on local URL: http://0.0.0.0:8000\n",
539
- "\n",
540
- "To create a public link, set `share=True` in `launch()`.\n",
541
- "Startup time: 102.2s (launcher: 69.7s, import torch: 3.9s, import gradio: 1.2s, setup paths: 2.4s, other imports: 1.2s, load scripts: 1.9s, create ui: 19.1s, gradio launch: 2.6s).\n"
542
- ]
543
- }
544
- ],
545
- "source": [
546
- "#sd-webui启动\n",
547
- "#启动参数在start.sh修改\n",
548
- "%cd \n",
549
- "%cd workspace\n",
550
- "!./start.sh\n"
551
- ]
552
- },
553
- {
554
- "cell_type": "code",
555
- "execution_count": null,
556
- "metadata": {},
557
- "outputs": [],
558
- "source": []
559
- }
560
- ],
561
- "metadata": {
562
- "kernelspec": {
563
- "display_name": "saturn (Python 3)",
564
- "language": "python",
565
- "name": "python3"
566
- },
567
- "language_info": {
568
- "codemirror_mode": {
569
- "name": "ipython",
570
- "version": 3
571
- },
572
- "file_extension": ".py",
573
- "mimetype": "text/x-python",
574
- "name": "python",
575
- "nbconvert_exporter": "python",
576
- "pygments_lexer": "ipython3",
577
- "version": "3.9.15"
578
- }
579
- },
580
- "nbformat": 4,
581
- "nbformat_minor": 4
582
- }
 
1
+ {"metadata":{"kernelspec":{"display_name":"saturn (Python 3)","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.9.15"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"## NovelAi Stable Diffusion - webui AI绘画项目 \n**torch: 2.0.0+cu118  •  xformers: 0.0.20**\n​\n## <span style=\"color:red; font-weight:bold;\">有问题请加qq群632428790 (1081/2000)</span>\nor contact me on Discord: Loading#7871\n## <span style=\"color:red; font-weight:bold;\"> 希望有能力的大佬可以做视频宣传本项目!</span>\n## BiliBili:Nyan9 \n### 发布地址:HF: https://huggingface.co/datasets/ACCA225/Kaggle-Stable-Diffusion & Gihub: https://github.com/2575044704/Saturn-SD-Webui\n<!--- \n这里是作者的署名和群号码,未经同意请勿删除,删一句家里人少一个\n--->\n<!--- \n倒卖狗全家死光\n--->\n","metadata":{}},{"cell_type":"markdown","source":"## 未经同意禁止将源代码用于出售,一经发现���肃追究\n<!--- \n这里是作者的署名和群号码,未经同意请勿删除,删一句家里人少一个\n--->\n<!--- \n倒卖狗全家死光\n--->\n","metadata":{}},{"cell_type":"markdown","source":"分三个代码块:依赖安装,启动sd-webui,下载模型\n第一次开机请先运行依赖安装一遍","metadata":{}},{"cell_type":"markdown","source":"----------","metadata":{}},{"cell_type":"markdown","source":"# 安装依赖,首次使用需要执行","metadata":{}},{"cell_type":"code","source":"#依赖安装,每次开机请运行此单元格\n#***0是关闭,1是开启***\n\ninstall_path='/home/jovyan/workspace' ##安装目录\n\nvenv_link = \"https://huggingface.co/datasets/sukaka/venv_ai_drow/resolve/main/sd_webui/torch201_cu118_xf20.tar.gz\" #环境包链接\n\nupdata = 0 #更新webui\n\n#-----------------------------------------------------------\n\nimport os\nimport re\nfrom pathlib import Path\n\n!sudo apt-get update > /dev/null 2>&1\n!sudo apt -y install -qq aria2 > /dev/null 2>&1\n!sudo apt -y install -qq pigz > /dev/null 2>&1\n!sudo apt-get install libglib2.0-0 -y > /dev/null 2>&1\n\n%cd $install_path\nif not os.path.exists(\"start.sh\"):\n !wget https://huggingface.co/datasets/sukaka/sd_configs/resolve/main/start.sh -O start.sh\n !chmod +x start.sh\n \n#内存优化\nif os.path.exists(f\"{install_path}/libtcmalloc/\"):\n print('内存优化已安装')\nelse:\n %cd $install_path\n !mkdir libtcmalloc\n !wget https://github.com/camenduru/gperftools/releases/download/v1.0/libtcmalloc_minimal.so.4 -O libtcmalloc/libtcmalloc_minimal.so.4 > /dev/null 2>&1\n print('内存优化已安装')\n\n%cd $install_path\nprint('stable-diffusion-webui安装中')\n#Download Automatic1111's Stable Diffusion Web UI\nif os.path.exists('stable-diffusion-webui'):\n if updata == 1:\n %cd $install_path/stable-diffusion-webui/\n !git pull https://github.com/KaggleSD/stable-diffusion-webui master\n !sed -i -e '''/from modules import launch_utils/a\\import os''' /home/jovyan/workspace/stable-diffusion-webui/launch.py\n !sed -i -e '''/ prepare_environment()/a\\ os.system\\(f\\\"\"\"sed -i -e ''\\\"s/dict()))/dict())).cuda()/g\\\"'' /home/jovyan/workspace/stable-diffusion-webui/repositories/stable-diffusion-stability-ai/ldm/util.py\"\"\")''' /home/jovyan/workspace/stable-diffusion-webui/launch.py\n !sed -i -e 's/\\[\"sd_model_checkpoint\"\\]/\\[\"sd_model_checkpoint\",\"sd_vae\",\"CLIP_stop_at_last_layers\"\\]/g' /home/jovyan/workspace/stable-diffusion-webui/modules/shared.py\n print('stable-diffusion-webui已安装')\nelse:\n !git clone https://github.com/KaggleSD/stable-diffusion-webui\n !sed -i -e '''/from modules import launch_utils/a\\import os''' /home/jovyan/workspace/stable-diffusion-webui/launch.py\n !sed -i -e '''/ prepare_environment()/a\\ os.system\\(f\\\"\"\"sed -i -e ''\\\"s/dict()))/dict())).cuda()/g\\\"'' /home/jovyan/workspace/stable-diffusion-webui/repositories/stable-diffusion-stability-ai/ldm/util.py\"\"\")''' /home/jovyan/workspace/stable-diffusion-webui/launch.py\n !sed -i -e 's/\\[\"sd_model_checkpoint\"\\]/\\[\"sd_model_checkpoint\",\"sd_vae\",\"CLIP_stop_at_last_layers\"\\]/g' /home/jovyan/workspace/stable-diffusion-webui/modules/shared.py\n\n%cd $install_path\npython_path = f\"{install_path}/venv/bin/python3\"\nif os.path.exists('venv'):\n print('环境已安装')\nelse:\n %cd $install_path\n if not os.path.exists('venv.tar.gz'):\n print('环境包下载中')\n os.system(f\"aria2c --console-log-level=error -q -c -x 16 -s 16 -k 1M -o venv.tar.gz {venv_link}\")\n print('环境包已下载')\n !mkdir venv\n %cd venv\n print('环境安装中')\n os.system(f'pigz -dc -p 4 {install_path}/venv.tar.gz | tar xf -')\n !rm -rf $install_path/venv.tar.gz\n # 定位 serializing.py 文件\n serializing_file = os.path.join(install_path, \"venv\", \"lib\", \"python3.10\", \"site-packages\", \"gradio_client\", \"serializing.py\")\n\n # 读取文件内容\n with open(serializing_file, \"r\") as f:\n lines = f.readlines()\n\n # 在 COMPONENT_MAPPING 字典中添加一行\n for i, line in enumerate(lines):\n if \"COMPONENT_MAPPING = {\" in line:\n lines.insert(i + 1, ' \"dataset\": StringSerializable,\\n')\n break\n\n # 写回文件\n with open(serializing_file, \"w\") as f:\n f.writelines(lines)\n\nprint('环境安装完毕')","metadata":{"execution":{"iopub.execute_input":"2023-08-18T04:10:35.764899Z","iopub.status.busy":"2023-08-18T04:10:35.764479Z","iopub.status.idle":"2023-08-18T04:12:11.276390Z","shell.execute_reply":"2023-08-18T04:12:11.275499Z","shell.execute_reply.started":"2023-08-18T04:10:35.764866Z"},"tags":[]},"execution_count":1,"outputs":[{"name":"stdout","output_type":"stream","text":"/home/jovyan/workspace\n\n--2023-08-18 04:10:48-- https://huggingface.co/datasets/sukaka/sd_configs/resolve/main/start.sh\n\nResolving huggingface.co (huggingface.co)... 3.160.5.109, 3.160.5.102, 3.160.5.25, ...\n\nConnecting to huggingface.co (huggingface.co)|3.160.5.109|:443... connected.\n\nHTTP request sent, awaiting response... 200 OK\n\nLength: 1019 [text/plain]\n\nSaving to: ‘start.sh’\n\n\n\nstart.sh 100%[===================>] 1019 --.-KB/s in 0s \n\n\n\n2023-08-18 04:10:48 (792 MB/s) - ‘start.sh’ saved [1019/1019]\n\n\n\n/home/jovyan/workspace\n\n内存优化已安装\n\n/home/jovyan/workspace\n\nstable-diffusion-webui安装中\n\nCloning into 'stable-diffusion-webui'...\n\nremote: Enumerating objects: 26020, done.\u001b[K\n\nremote: Counting objects: 100% (407/407), done.\u001b[K\n\nremote: Compressing objects: 100% (179/179), done.\u001b[K\n\nremote: Total 26020 (delta 262), reused 342 (delta 224), pack-reused 25613\u001b[K\n\nReceiving objects: 100% (26020/26020), 31.82 MiB | 42.49 MiB/s, done.\n\nResolving deltas: 100% (18220/18220), done.\n\n/home/jovyan/workspace\n\n/home/jovyan/workspace\n\n环境包下载中\n\n环境包已下载\n\n/home/jovyan/workspace/venv\n\n环境安装中\n\n环境安装完毕\n"}]},{"cell_type":"markdown","source":"# 安装插件,模型","metadata":{}},{"cell_type":"code","source":"#运行这个单元格下载模型和插件\n#***出现下载完毕才是下载完****\n\n# 插件列表: git仓库地址\n# 不需要的插件在前面加 # 插件地址之间需要用英语逗号隔开\nextensions = [\n 'https://github.com/Elldreth/loopback_scaler',\n 'https://github.com/jexom/sd-webui-depth-lib',\n #'https://github.com/AlUlkesh/stable-diffusion-webui-images-browser',\n 'https://github.com/camenduru/sd-civitai-browser',\n 'https://github.com/Mikubill/sd-webui-controlnet',\n 'https://github.com/nonnonstop/sd-webui-3d-open-pose-editor',\n 'https://github.com/2575044704/stable-diffusion-webui-localization-zh_CN2',\n 'https://github.com/opparco/stable-diffusion-webui-two-shot',\n #'https://github.com/minicacas/stable-diffusion-webui-composable-lora',\n 'https://github.com/DominikDoom/a1111-sd-webui-tagcomplete',\n 'https://github.com/pkuliyi2015/multidiffusion-upscaler-for-automatic1111',\n #'https://github.com/KohakuBlueleaf/a1111-sd-webui-locon',\n 'https://github.com/hnmr293/sd-webui-cutoff',\n 'https://github.com/hako-mikan/sd-webui-lora-block-weight',\n 'https://github.com/butaixianran/Stable-Diffusion-Webui-Civitai-Helper',\n 'https://github.com/catppuccin/stable-diffusion-webui',\n #'https://github.com/Nevysha/Cozy-Nest',\n 'https://github.com/Scholar01/sd-webui-mov2mov',\n 'https://github.com/toriato/stable-diffusion-webui-wd14-tagger',\n 'https://github.com/Physton/sd-webui-prompt-all-in-one',\n #'https://github.com/KohakuBlueleaf/a1111-sd-webui-lycoris',\n #'https://github.com/deforum-art/sd-webui-deforum',\n 'https://github.com/Scholar01/sd-webui-mov2mov',\n 'https://github.com/zanllp/sd-webui-infinite-image-browsing',\n 'https://github.com/continue-revolution/sd-webui-segment-anything',\n]\n\n# Stable Diffusion模型下载链接放这里\nsd_model_urls=[\n#'https://huggingface.co/datasets/sukaka/sd_models_fp16/resolve/main/GhostMix2.safetensors',\n#sdxl\n\"https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0.safetensors\",\n#'https://huggingface.co/ptx0/sdxl-refiner/resolve/main/sd_xl_refiner_1.0.safetensors',\n]\n#VAE模型下载链接放这里\nvae_model_urls=[\n#'https://huggingface.co/datasets/sukaka/sd_models_fp16/resolve/main/clearvae.vae.pt',\n#'https://huggingface.co/datasets/sukaka/sd_models_fp16/resolve/main/klF8Anime2.vae.pt',\n'https://huggingface.co/madebyollin/sdxl-vae-fp16-fix/resolve/main/sdxl_vae.safetensors',\n]\n# Lora模型下载链接放这里\nlora_model_urls=[\n#墨心\n#'https://civitai.com/api/download/models/14856',\n]\n\n# controlnet模型下载链接放这里\ncn_model_urls = [\n#'https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11e_sd15_ip2p_fp16.safetensors',\n#'https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11e_sd15_shuffle_fp16.safetensors',\n#'https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11f1p_sd15_depth_fp16.safetensors',\n#'https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_canny_fp16.safetensors',\n#'https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_inpaint_fp16.safetensors',\n#'https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_lineart_fp16.safetensors',\n#'https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_mlsd_fp16.safetensors',\n#'https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_normalbae_fp16.safetensors',\n#'https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_openpose_fp16.safetensors',\n#'https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_scribble_fp16.safetensors',\n#'https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_softedge_fp16.safetensors',\n#'https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15s2_lineart_anime_fp16.safetensors',\n#'https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11u_sd15_tile_fp16.safetensors',\n]\n\n#Hypernetworks超网络模型下载链接请放在这里\nhypernetworks_model_urls = []\n\n#放大算法路径请放在这里\nESRGAN = []\n#放大算法链接请放在这里\nESRGAN_urls = [\n'https://huggingface.co/FacehugmanIII/4x_foolhardy_Remacri/resolve/main/4x_foolhardy_Remacri.pth',\n'https://huggingface.co/konohashinobi4/4xAnimesharp/resolve/main/4x-AnimeSharp.pth',\n'https://huggingface.co/lokCX/4x-Ultrasharp/resolve/main/4x-UltraSharp.pth',\n]\n\n# embeddings(pt文件)下载链接请放在这里:\nembeddings_model_urls=[\n#'https://huggingface.co/datasets/sukaka/sd_configs/resolve/main/%E4%BA%BA%E4%BD%93%E4%BF%AE%E6%AD%A3/EasyNegative.pt',\n#'https://huggingface.co/datasets/sukaka/sd_configs/resolve/main/%E4%BA%BA%E4%BD%93%E4%BF%AE%E6%AD%A3/bad-artist-anime.pt',\n#'https://huggingface.co/datasets/sukaka/sd_configs/resolve/main/%E4%BA%BA%E4%BD%93%E4%BF%AE%E6%AD%A3/bad-hands-5.pt',\n#'https://huggingface.co/datasets/sukaka/sd_configs/resolve/main/%E4%BA%BA%E4%BD%93%E4%BF%AE%E6%AD%A3/bad_prompt_version2.pt',\n#'https://huggingface.co/datasets/sukaka/sd_configs/resolve/main/%E4%BA%BA%E4%BD%93%E4%BF%AE%E6%AD%A3/bad-image-v2-39000.pt',\n]\n\n#script文件下载链接导入\nscripts_urls = []\n\n#tag词库文件下载链接导入\ntags_file_urls=[\n\"https://huggingface.co/datasets/sukaka/sd_configs/resolve/main/danbooru.zh_CN.csv\",\n]\n\n#sd-webui-segment-anything插件的模型导入\nsam_model = []\n#sd-webui-segment-anything插件的模型下载链接导入\nsam_model_urls = [\n #'https://huggingface.co/lkeab/hq-sam/resolve/main/sam_hq_vit_h.pth',\n 'https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth',\n]\n\n#---------------------------------------------------------------------------------------------------------------------\n\nfrom concurrent.futures import ThreadPoolExecutor\n# 安装插件,下载和同步模型\ndef install_extensions(install_path, extensions):\n print('安装插件中')\n os.chdir(os.path.join(install_path, 'stable-diffusion-webui'))\n os.makedirs('extensions', exist_ok=True)\n os.chdir('extensions')\n\n def clone_repo(ex):\n repo_name = ex.split('/')[-1]\n if not os.path.exists(repo_name):\n os.system('git clone ' + ex)\n\n with ThreadPoolExecutor(max_workers=4) as executor:\n executor.map(clone_repo, extensions)\n \ndef download_link(link, target_folder):\n if link.startswith('https://huggingface.co/' or 'https://dl.fbaipublicfiles.com'):\n filename = re.search(r'[^/]+$', link).group(0)\n return f'aria2c --console-log-level=error -q -c -x 16 -s 16 -k 1M -d \"{target_folder}\" -o \"{filename}\" \"{link}\"'\n else:\n return f'aria2c --console-log-level=error -q -c -x 16 -s 16 -k 1M --remote-time -d \"{target_folder}\" \"{link}\"'\n\ndef download_links(links, target_folder):\n tasks = []\n for link in links:\n tasks.append(download_link(link, target_folder))\n return tasks\n\ndef download_links_all(tasks):\n with ThreadPoolExecutor(max_workers=4) as executor:\n for task in tasks:\n executor.submit(os.system, task)\n\n%cd $install_path/stable-diffusion-webui\ninstall_extensions(install_path, extensions)\nprint('下载模型中')\ntasks = []\ntasks.extend(download_links(vae_model_urls, f'{install_path}/stable-diffusion-webui/models/VAE'))\ntasks.extend(download_links(sd_model_urls, f'{install_path}/stable-diffusion-webui/models/Stable-diffusion'))\ntasks.extend(download_links(lora_model_urls, f'{install_path}/stable-diffusion-webui/models/Lora'))\ntasks.extend(download_links(cn_model_urls, f'{install_path}/stable-diffusion-webui/extensions/sd-webui-controlnet/models'))\ntasks.extend(download_links(hypernetworks_model_urls, f'{install_path}/stable-diffusion-webui/models/hypernetworks'))\ntasks.extend(download_links(ESRGAN_urls, f'{install_path}/stable-diffusion-webui/models/ESRGAN'))\ntasks.extend(download_links(embeddings_model_urls, f'{install_path}/stable-diffusion-webui/embeddings'))\ntasks.extend(download_links(scripts_urls, f'{install_path}/stable-diffusion-webui/scripts'))\ntasks.extend(download_links(tags_file_urls, f'{install_path}/stable-diffusion-webui/extensions/a1111-sd-webui-tagcomplete/tags'))\ntasks.extend(download_links(sam_model_urls, f'{install_path}/stable-diffusion-webui/extensions/sd-webui-segment-anything/models/sam'))\ndownload_links_all(tasks)\nprint('下载完毕')","metadata":{"execution":{"iopub.execute_input":"2023-08-18T04:12:37.330898Z","iopub.status.busy":"2023-08-18T04:12:37.330524Z","iopub.status.idle":"2023-08-18T04:13:56.278444Z","shell.execute_reply":"2023-08-18T04:13:56.277657Z","shell.execute_reply.started":"2023-08-18T04:12:37.330871Z"},"tags":[]},"execution_count":2,"outputs":[{"name":"stdout","output_type":"stream","text":"/home/jovyan/workspace/stable-diffusion-webui\n\n安装插件中\n"},{"name":"stderr","output_type":"stream","text":"Cloning into 'loopback_scaler'...\n\nCloning into 'sd-webui-controlnet'...\n\nCloning into 'sd-civitai-browser'...\n\nCloning into 'sd-webui-depth-lib'...\n\nCloning into 'sd-webui-3d-open-pose-editor'...\n\nCloning into 'stable-diffusion-webui-localization-zh_CN'...\n\nCloning into 'stable-diffusion-webui-two-shot'...\n\nCloning into 'a1111-sd-webui-tagcomplete'...\n\nCloning into 'multidiffusion-upscaler-for-automatic1111'...\n\nCloning into 'sd-webui-cutoff'...\n\nCloning into 'sd-webui-lora-block-weight'...\n\nCloning into 'Stable-Diffusion-Webui-Civitai-Helper'...\n\nCloning into 'stable-diffusion-webui'...\n\nCloning into 'sd-webui-mov2mov'...\n\nCloning into 'stable-diffusion-webui-wd14-tagger'...\n\nCloning into 'sd-webui-prompt-all-in-one'...\n\nCloning into 'sd-webui-infinite-image-browsing'...\n\nCloning into 'sd-webui-segment-anything'...\n"},{"name":"stdout","output_type":"stream","text":"下载模型中\n\n下载完毕\n"}]},{"cell_type":"markdown","source":"# 启动SD-webui","metadata":{}},{"cell_type":"code","source":"#sd-webui启动\n#启动参数在start.sh修改\n%cd \n%cd workspace\n!./start.sh\n","metadata":{"execution":{"iopub.execute_input":"2023-08-18T04:20:05.735646Z","iopub.status.busy":"2023-08-18T04:20:05.735130Z"},"tags":[]},"execution_count":null,"outputs":[{"name":"stdout","output_type":"stream","text":"/home/jovyan\n\n/home/jovyan/workspace\n\nPython 3.10.11 (main, May 16 2023, 00:28:57) [GCC 11.2.0]\n\nVersion: v1.5.1\n\nCommit hash: 68f336bd994bed5442ad95bad6b6ad5564a5409a\n\nInstalling clip\n\nCloning Stable Diffusion into /home/jovyan/workspace/stable-diffusion-webui/repositories/stable-diffusion-stability-ai...\n\nCloning into '/home/jovyan/workspace/stable-diffusion-webui/repositories/stable-diffusion-stability-ai'...\n\nremote: Enumerating objects: 574, done.\u001b[K\n\nremote: Counting objects: 100% (304/304), done.\u001b[K\n\nremote: Compressing objects: 100% (88/88), done.\u001b[K\n\nremote: Total 574 (delta 244), reused 216 (delta 216), pack-reused 270\u001b[K\n\nReceiving objects: 100% (574/574), 73.43 MiB | 44.92 MiB/s, done.\n\nResolving deltas: 100% (276/276), done.\n\nCloning Stable Diffusion XL into /home/jovyan/workspace/stable-diffusion-webui/repositories/generative-models...\n\nCloning into '/home/jovyan/workspace/stable-diffusion-webui/repositories/generative-models'...\n\nremote: Enumerating objects: 740, done.\u001b[K\n\nremote: Counting objects: 100% (563/563), done.\u001b[K\n\nremote: Compressing objects: 100% (283/283), done.\u001b[K\n\nremote: Total 740 (delta 340), reused 425 (delta 266), pack-reused 177\u001b[K\n\nReceiving objects: 100% (740/740), 22.31 MiB | 28.38 MiB/s, done.\n\nResolving deltas: 100% (378/378), done.\n\nCloning K-diffusion into /home/jovyan/workspace/stable-diffusion-webui/repositories/k-diffusion...\n\nCloning into '/home/jovyan/workspace/stable-diffusion-webui/repositories/k-diffusion'...\n\nremote: Enumerating objects: 770, done.\u001b[K\n\nremote: Counting objects: 100% (46/46), done.\u001b[K\n\nremote: Compressing objects: 100% (25/25), done.\u001b[K\n\nremote: Total 770 (delta 25), reused 34 (delta 21), pack-reused 724\u001b[K\n\nReceiving objects: 100% (770/770), 157.76 KiB | 4.78 MiB/s, done.\n\nResolving deltas: 100% (503/503), done.\n\nCloning CodeFormer into /home/jovyan/workspace/stable-diffusion-webui/repositories/CodeFormer...\n\nCloning into '/home/jovyan/workspace/stable-diffusion-webui/repositories/CodeFormer'...\n\nremote: Enumerating objects: 594, done.\u001b[K\n\nremote: Counting objects: 100% (245/245), done.\u001b[K\n\nremote: Compressing objects: 100% (98/98), done.\u001b[K\n\nremote: Total 594 (delta 176), reused 167 (delta 147), pack-reused 349\u001b[K\n\nReceiving objects: 100% (594/594), 17.31 MiB | 26.69 MiB/s, done.\n\nResolving deltas: 100% (287/287), done.\n\nCloning BLIP into /home/jovyan/workspace/stable-diffusion-webui/repositories/BLIP...\n\nCloning into '/home/jovyan/workspace/stable-diffusion-webui/repositories/BLIP'...\n\nremote: Enumerating objects: 277, done.\u001b[K\n\nremote: Counting objects: 100% (165/165), done.\u001b[K\n\nremote: Compressing objects: 100% (30/30), done.\u001b[K\n\nremote: Total 277 (delta 137), reused 136 (delta 135), pack-reused 112\u001b[K\n\nReceiving objects: 100% (277/277), 7.03 MiB | 40.70 MiB/s, done.\n\nResolving deltas: 100% (152/152), done.\n\nInstalling requirements for CodeFormer\n\nInstalling sd-webui-segment-anything requirement: segment_anything\n\nInstalling sd-webui-segment-anything requirement: supervision\n\n\n\nInstalling requirements for Mov2mov\n\nInstalling requirements for ffmpeg\n\n\n\nInstalling sd-webui-infinite-image-browsing requirement: python-dotenv\n\nInstalling sd-webui-infinite-image-browsing requirement: pyfunctional\n\n\n\nInstalling sd-webui-prompt-all-in-one: chardet\n\nInstalling sd-webui-prompt-all-in-one: execjs\n\nInstalling sd-webui-prompt-all-in-one: lxml\n\nInstalling sd-webui-prompt-all-in-one: pathos\n\nInstalling sd-webui-prompt-all-in-one: cryptography\n\nInstalling sd-webui-prompt-all-in-one: openai\n\nInstalling sd-webui-prompt-all-in-one: boto3\n\nInstalling sd-webui-prompt-all-in-one: aliyunsdkcore\n\nInstalling sd-webui-prompt-all-in-one: aliyunsdkalimt\n\n\n\nDownloading pose_landmark_full.tflite...\n\nDownloading pose_web.binarypb...\n\nDownloading pose_solution_packed_assets.data...\n\nDownloading pose_solution_simd_wasm_bin.wasm...\n\nDownloading pose_solution_packed_assets_loader.js...\n\nDownloading pose_solution_simd_wasm_bin.js...\n\n\n\nInstalling sd-webui-controlnet requirement: mediapipe\n\nInstalling sd-webui-controlnet requirement: svglib\n\nInstalling sd-webui-controlnet requirement: fvcore\n\n\n\nInstalling requirements for CivitAI Browser\n\n\n\nLaunching Web UI with arguments: --listen --xformers --no-hashing --enable-insecure-extension-access --gradio-queue --administrator --disable-safe-unpickle --ckpt=models/Stable-diffusion/sd_xl_base_1.0.safetensors --port=8000\n\nCivitai Helper: Get Custom Model Folder\n\nCivitai Helper: Load setting from: /home/jovyan/workspace/stable-diffusion-webui/extensions/Stable-Diffusion-Webui-Civitai-Helper/setting.json\n\nCivitai Helper: No setting file, use default\n\nTag Autocomplete: Could not locate model-keyword extension, Lora trigger word completion will be limited to those added through the extra networks menu.\n\n2023-08-18 04:21:27,963 - ControlNet - \u001b[0;32mINFO\u001b[0m - ControlNet v1.1.238\n\nControlNet preprocessor location: /home/jovyan/workspace/stable-diffusion-webui/extensions/sd-webui-controlnet/annotator/downloads\n\n2023-08-18 04:21:28,071 - ControlNet - \u001b[0;32mINFO\u001b[0m - ControlNet v1.1.238\n\nsd-webui-prompt-all-in-one background API service started successfully.\n\nLoading weights [None] from /home/jovyan/workspace/stable-diffusion-webui/models/Stable-diffusion/sd_xl_base_1.0.safetensors\n\nCreating model from config: /home/jovyan/workspace/stable-diffusion-webui/repositories/generative-models/configs/inference/sd_xl_base.yaml\n\nDownloading (…)olve/main/vocab.json: 100%|███| 961k/961k [00:00<00:00, 23.2MB/s]\n\nDownloading (…)olve/main/merges.txt: 100%|███| 525k/525k [00:00<00:00, 26.4MB/s]\n\nDownloading (…)cial_tokens_map.json: 100%|█████| 389/389 [00:00<00:00, 3.80MB/s]\n\nDownloading (…)okenizer_config.json: 100%|█████| 905/905 [00:00<00:00, 11.1MB/s]\n\nDownloading (…)lve/main/config.json: 100%|█| 4.52k/4.52k [00:00<00:00, 35.7MB/s]\n\nApplying attention optimization: xformers... done.\n\nModel loaded in 18.8s (load weights from disk: 2.1s, load config: 0.2s, create model: 8.2s, apply weights to model: 6.7s, calculate empty prompt: 1.4s).\n\nRunning on local URL: http://0.0.0.0:8000\n\n\n\nTo create a public link, set `share=True` in `launch()`.\n\nStartup time: 102.2s (launcher: 69.7s, import torch: 3.9s, import gradio: 1.2s, setup paths: 2.4s, other imports: 1.2s, load scripts: 1.9s, create ui: 19.1s, gradio launch: 2.6s).\n"}]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}