File size: 9,971 Bytes
9ca2ae8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "TcLs4cdaLCtB"
      },
      "source": [
        "# 配置项 (修改这里的内容后直接启动就行了 run all 或者save version都可以)\n",
        "\n",
        "---\n",
        "\n",
        "**主要逻辑已经分离出去了,当有更新时也不需要更新这个文件**\n",
        "- 所有的模型列表都支持填文件、文件夹、下载地址\n",
        "- **如果需要在google colab运行**\n",
        "    1. 改好这个文件后下载下来\n",
        "    2. 在cloab新建一个脚本,然后上传这个文件\n",
        "    3. 新建单元格后填入```%run sdwui-before.ipynb```,然后直接执行新建的单元格。注意: sdwui-before.ipynb 需要替换成你上传时的文件名"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "swzyZ1_gLCs_",
        "trusted": true
      },
      "outputs": [],
      "source": [
        "useGooglrDrive = True # 连接到谷歌云盘 在google colab环境才能开启"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "7tTWVxHDLCtB",
        "trusted": true
      },
      "outputs": [],
      "source": [
        "# 模型列表 一行一个 可以填文件 文件夹 和下载地址,如果需要自定义文件名,在url前写上文件名加:\n",
        "模型列表 = '''\n",
        "https://civitai.com/api/download/models/75587\n",
        "https://civitai.com/api/download/models/102222\n",
        "'''\n",
        "# 启动时默认加载的模型名称\n",
        "usedCkpt = 'mg-Tender'\n",
        "VAE列表 = '''\n",
        "https://huggingface.co./stabilityai/sd-vae-ft-ema-original/resolve/main/vae-ft-ema-560000-ema-pruned.safetensors\n",
        "https://huggingface.co./stabilityai/sd-vae-ft-mse-original/resolve/main/vae-ft-mse-840000-ema-pruned.safetensors\n",
        "https://huggingface.co./WarriorMama777/OrangeMixs/resolve/main/VAEs/orangemix.vae.pt\n",
        "'''\n",
        "Lora列表 = '''\n",
        "https://civitai.com/api/download/models/14856\n",
        "https://civitai.com/api/download/models/13169\n",
        "'''\n",
        "LyCORIS列表 = '''\n",
        "https://civitai.com/api/download/models/46821\n",
        "'''\n",
        "hypernetworks列表 = '''\n",
        "\n",
        "'''\n",
        "embeddings列表 = '''\n",
        "https://civitai.com/api/download/models/60938\n",
        "\n",
        "'''\n",
        "controlNet模型列表 = '''\n",
        "https://huggingface.co./webui/ControlNet-modules-safetensors/resolve/main/control_canny-fp16.safetensors\n",
        "https://huggingface.co./webui/ControlNet-modules-safetensors/resolve/main/control_depth-fp16.safetensors\n",
        "https://huggingface.co./webui/ControlNet-modules-safetensors/resolve/main/control_hed-fp16.safetensors\n",
        "https://huggingface.co./webui/ControlNet-modules-safetensors/resolve/main/control_mlsd-fp16.safetensors\n",
        "https://huggingface.co./webui/ControlNet-modules-safetensors/resolve/main/control_normal-fp16.safetensors\n",
        "https://huggingface.co./webui/ControlNet-modules-safetensors/resolve/main/control_openpose-fp16.safetensors\n",
        "https://huggingface.co./webui/ControlNet-modules-safetensors/resolve/main/control_scribble-fp16.safetensors\n",
        "https://huggingface.co./webui/ControlNet-modules-safetensors/resolve/main/control_seg-fp16.safetensors\n",
        "'''\n",
        "# git仓库\n",
        "插件列表='''\n",
        "https://github.com/dtlnor/stable-diffusion-webui-localization-zh_CN.git\n",
        "https://github.com/AlUlkesh/stable-diffusion-webui-images-browser.git\n",
        "https://github.com/DominikDoom/a1111-sd-webui-tagcomplete.git\n",
        "https://github.com/Mikubill/sd-webui-controlnet.git\n",
        "https://github.com/KohakuBlueleaf/a1111-sd-webui-lycoris.git\n",
        "https://github.com/LianZiZhou/sd-webui-pixink-console.git\n",
        "https://github.com/ilian6806/stable-diffusion-webui-state.git\n",
        "https://github.com/pkuliyi2015/multidiffusion-upscaler-for-automatic1111.git\n",
        "https://github.com/Bing-su/adetailer.git\n",
        "https://github.com/viyiviyi/filter-empty-prompts.git\n",
        "https://github.com/civitai/sd_civitai_extension.git\n",
        "https://github.com/zanllp/sd-webui-infinite-image-browsing.git\n",
        "'''\n",
        "#文件或直接填配置\n",
        "ngrok配置或文件地址='''\n",
        "/kaggle/input/configs/ngrok_token.txt\n",
        "'''\n",
        "frp配置文件或配置='''\n",
        "-f **************************:7691619\n",
        "'''\n",
        "frpSSL文件='''\n",
        "\n",
        "'''\n",
        "参数列表='''\n",
        "--disable-safe-unpickle\n",
        "--deepdanbooru\n",
        "--no-hashing\n",
        "--no-download-sd-model\n",
        "--administrator\n",
        "--skip-torch-cuda-test\n",
        "--skip-version-check\n",
        "--disable-nan-check\n",
        "--opt-sdp-attention\n",
        "--opt-sdp-no-mem-attention\n",
        "--xformers-flash-attention\n",
        "--xformers\n",
        "--api\n",
        "--listen\n",
        "--lowram\n",
        "--no-gradio-queue\n",
        "'''\n",
        "# --api-auth=2333:6666 --gradio-auth=2333:6666"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_kg_hide-input": false,
        "id": "r_lBDJdOLCtB",
        "trusted": true
      },
      "outputs": [],
      "source": [
        "# 手机端界面优化 使用了修改过界面布局顺序的webui,不定期同步到官方版本\n",
        "mobileOptimize=True\n",
        "# webui的配置文件\n",
        "webui_settings = 'https://github.com/viyiviyi/sd-configs.git'\n",
        "# 设置文件路径\n",
        "setting_file = '/kaggle/working/configs/config.json'\n",
        "ui_config_file = '/kaggle/working/configs/ui-config.json'\n",
        "\n",
        "# 配置启动参数\n",
        "webuiPort=7860 # webui默认端口\n",
        "disableShared=False # 关闭默认的gradio.live穿透\n",
        "onlyApi=False # 无ui界面,仅提供api服务\n",
        "quickStart=True # 快速启动 使用下载好的python环境 开启后启动到可用需要4分钟,不开启需要8分钟\n",
        "vaeHalf=False # vae开启半精度,关闭效果更好,对速度没啥影响\n",
        "modelHalf=True # 模型开启半精度,关闭效果更好,但生成速度减半\n",
        "consoleProgressbars=False # 控制台显示进度条,关闭可以减少一些输出内容,查看日志时更快一点\n",
        "consolePrompts=False # 同上\n",
        "enableLoadByCopy=False # 是否使用copy的方式加载文件 启动变慢,且测试后没有提高模型切换速度\n",
        "enableThread=True # 启用多线程下载插件 依赖 和 模型\n",
        "#Ngrok\n",
        "useNgrok=True # 非必填 是否使用ngrok作为公网访问地址\n",
        "#Frpc\n",
        "useFrpc=True # 开启frp将不能启动\n",
        "\n",
        "import os\n",
        "INIT_WORK_PATH = os.environ['HOME']\n",
        "if os.getenv('INIT_WORK_PATH',''):\n",
        "    INIT_WORK_PATH = os.getenv('INIT_WORK_PATH','')\n",
        "else:\n",
        "    os.environ['INIT_WORK_PATH'] = os.getcwd()\n",
        "%cd {INIT_WORK_PATH}"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "trusted": true,
        "id": "9aHxnTLGBK5J"
      },
      "outputs": [],
      "source": [
        "reLoad = True\n",
        "# 如果需要重新安装,请注释这一行\n",
        "reLoad = False"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "scrolled": true,
        "trusted": true,
        "id": "BkHAdhudBK5J"
      },
      "outputs": [],
      "source": [
        "!wget https://huggingface.co./viyi/sdwui/resolve/main/sdwui-start.ipynb\n",
        "%run sdwui-start.ipynb"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "ePT_b-s9LCtF",
        "scrolled": true,
        "trusted": true
      },
      "outputs": [],
      "source": [
        "\n",
        "# 打包收藏文件夹 如果需要可以取消下面两行的注释\n",
        "# zipPath('$install_path/stable-diffusion-webui/log','log')\n",
        "# !mv {output_path}/log.tar {output_path}/log.tar.bak\n",
        "# createOrUpdateDataSet(f'{output_path}/log.tar.bak','sd-webui-log-bak')\n",
        "\n",
        "# 打包 这一行的结果是 压缩一个目录,并放在 output_path: /kaggle/working/ 目录下 名字是训练输出.tar\n",
        "# zipPath('$install_path/stable-diffusion-webui/textual_inversion','训练输出')\n",
        "# zipPath('$install_path/stable-diffusion-webui/outputs','outputs')\n",
        "# zipPath('$install_path/stable-diffusion-webui/venv','venv')\n",
        "# !mv {output_path}/venv.tar /kaggle/working/venv.tar.bak\n",
        "# createOrUpdateDataSet('/kaggle/working/venv.tar.bak','sd-webui-venv')\n",
        "# !tar -cf $output_path/webui.tar.bak --exclude=venv --exclude=extensions -C /kaggle/stable-diffusion-webui/ ."
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "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.7.12"
    },
    "colab": {
      "provenance": []
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}