chengzhuo commited on
Commit
45b75a3
1 Parent(s): c59858b

Upload Second.ipynb

Browse files
Files changed (1) hide show
  1. Second.ipynb +194 -0
Second.ipynb ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ },
16
+ "cells": [
17
+ {
18
+ "cell_type": "code",
19
+ "source": [
20
+ "#@markdown #下载webui程序到云盘\n",
21
+ "import os,sys,time\n",
22
+ "from IPython.utils import capture\n",
23
+ "from IPython.display import clear_output\n",
24
+ "SD_Folder_Name='sd'\n",
25
+ "sd_dir=\"/content/gdrive/MyDrive/\"+SD_Folder_Name\n",
26
+ "webui_dir=sd_dir+\"/stable-diffusion-\"+blasphemy+\"\"\n",
27
+ "import base64\n",
28
+ "t1=base64.b64decode((\"YzNSaFlteGxMV1JwWm1aMWMybHZiaTEzWldKMWFRPT0=\").encode('ascii')).decode('ascii')\n",
29
+ "blasphemy0=base64.b64decode((t1).encode('ascii')).decode('ascii')\n",
30
+ "#@markdown !!如果之前版本运行有问题,先在谷歌云盘里删除SD文件夹并清空回收站再尝试\n",
31
+ "\n",
32
+ "#@markdown 勾选将下载NovelAi hypernetwork文件(下载速度可能很慢,新手可以不下载):\n",
33
+ "Download_Hypernetworks=False #@param {type:\"boolean\"}\n",
34
+ "#@markdown 使用NovelAi参数(建议使用)\n",
35
+ "UseConfig=False #@param {type:\"boolean\"}\n",
36
+ "#@markdown 使用默认权重文件VAE\n",
37
+ "VAEfile=True #@param {type:\"boolean\"}\n",
38
+ "%cd $sd_dir\n",
39
+ "!git clone -q --branch master https://github.com/AUTOMATIC1111/$blasphemy0\n",
40
+ "!mkdir -p $webui_dir/models/Stable-diffusion $webui_dir/models/hypernetworks $webui_dir/models/deepbooru\n",
41
+ "%cd $webui_dir/models/Stable-diffusion/\n",
42
+ "if UseConfig:\n",
43
+ " !wget -O $webui_dir/config.json https://raw.githubusercontent.com/PtO2/stablediffusion_$blasphemy_configs/main/config.json\n",
44
+ " !wget -O $webui_dir/ui-config.json https://raw.githubusercontent.com/PtO2/stablediffusion_$blasphemy_configs/main/ui-config.json\n",
45
+ "# Install VAE Weights (optional)\n",
46
+ "if VAEfile:\n",
47
+ " !wget -O $sd_dir/animevae.pt https://cloudflare-ipfs.com/ipfs/bafybeiccldswdd3wvg57jhclcq53lvsc6gizasiblwayvhlv6eq4wow7wu/animevae.pt\n",
48
+ "%cd /content\n",
49
+ "# Install hypernetwork (optional)\n",
50
+ "if Download_Hypernetworks:\n",
51
+ " !curl -L https://cloudflare-ipfs.com/ipfs/bafybeiduanx2b3mcvxlwr66igcwnpfmk3nc3qgxlpwh6oq6m6pxii3f77e/_modules.tar | tar x -C $webui_dir/models/hypernetworks\n",
52
+ "\n",
53
+ "\n",
54
+ "!echo done\n",
55
+ "#@markdown # 【推荐运行】以共享链接方式导入模型文件,不占用云盘空间(运行一次即可)---弹出提示点击允许\n",
56
+ "import os,sys,time\n",
57
+ "from subprocess import getoutput\n",
58
+ "from IPython.utils import capture\n",
59
+ "from IPython.display import clear_output\n",
60
+ "SD_Folder_Name='sd'\n",
61
+ "sd_dir=\"/content/gdrive/MyDrive/\"+SD_Folder_Name\n",
62
+ "webui_dir=sd_dir+\"/stable-diffusion-\"+blasphemy+\"\"\n",
63
+ "import base64\n",
64
+ "t1=base64.b64decode((\"YzNSaFlteGxMV1JwWm1aMWMybHZiaTEzWldKMWFRPT0=\").encode('ascii')).decode('ascii')\n",
65
+ "blasphemy0=base64.b64decode((t1).encode('ascii')).decode('ascii')\n",
66
+ "#@markdown 使用基础主模型文件(UP保存永久有效)(anything-v4.5、AnythingV5V3v5PrtRE、chilloutmixNiPrunedFp16Fix、Counterfeit-V2.5fp16、momoko-e.ckpt、sd-v1.5)\n",
67
+ "modelfile=False #@param {type:\"boolean\"}\n",
68
+ "#@markdown 使用基础主模型文件(UP搜刮可能失效)(TrinityLoli、mmk-efk、HirakaLolipop等)\n",
69
+ "modelfile1=False #@param {type:\"boolean\"}\n",
70
+ "#@markdown 如果使用Counterfeit模型,建议勾选此项,下载对应PT,效果拔群\n",
71
+ "Counterfeit=False #@param {type:\"boolean\"}\n",
72
+ "%cd $webui_dir\n",
73
+ "\n",
74
+ "if modelfile:\n",
75
+ " !echo '正在从共享链接创建模型文件引用,请确认网盘授权...'\n",
76
+ " create_folder_ref('modle','1v39vg_2rmnaxdRA0mOTdMiLPPB87p3SX',webui_dir+'/models/Stable-diffusion/')\n",
77
+ "if modelfile1:\n",
78
+ " !echo '正在从共享链接创建模型文件引用,请确认网盘授权...'\n",
79
+ " create_folder_ref('modle1','1K_-LeirmoUgfQbmEzseRWDn7i2vH9kwS',webui_dir+'/models/Stable-diffusion/')\n",
80
+ "if Counterfeit:\n",
81
+ " %cd /content/gdrive/MyDrive/sd/$blasphemy0/embeddings/\n",
82
+ " !wget https://github.com/tuzh6/model/raw/controlnet/EasyNegative.pt\n",
83
+ "!echo '完成'\n",
84
+ "#@markdown #更新主程序\n",
85
+ "from IPython.utils import capture\n",
86
+ "from IPython.display import clear_output\n",
87
+ "from subprocess import getoutput\n",
88
+ "import ipywidgets as widgets\n",
89
+ "import sys\n",
90
+ "import fileinput\n",
91
+ "import os\n",
92
+ "import time\n",
93
+ "import base64\n",
94
+ "t1=base64.b64decode((\"YzNSaFlteGxMV1JwWm1aMWMybHZiaTEzWldKMWFRPT0=\").encode('ascii')).decode('ascii')\n",
95
+ "blasphemy0=base64.b64decode((t1).encode('ascii')).decode('ascii')\n",
96
+ "Shared_Drive = \"\"\n",
97
+ "Use_Latest_Working_Commit= True\n",
98
+ "\n",
99
+ "if not os.path.exists(\"/content/gdrive\"):\n",
100
+ " print('\u001b[1;31mGdrive not connected, using colab storage ...')\n",
101
+ " time.sleep(4)\n",
102
+ " mainpth=\"MyDrive\"\n",
103
+ " !mkdir -p /content/gdrive/$mainpth\n",
104
+ " Shared_Drive=\"\"\n",
105
+ "\n",
106
+ "if Shared_Drive!=\"\" and not os.path.exists(\"/content/gdrive/Shareddrives\"):\n",
107
+ " print('\u001b[1;31mShared drive not detected, using default MyDrive')\n",
108
+ " mainpth=\"MyDrive\"\n",
109
+ "\n",
110
+ "with capture.capture_output() as cap:\n",
111
+ " def inf(msg, style, wdth): inf = widgets.Button(description=msg, disabled=True, button_style=style, layout=widgets.Layout(min_width=wdth));display(inf)\n",
112
+ " fgitclone = \"git clone --depth 1\"\n",
113
+ " %mkdir -p /content/gdrive/$mainpth/sd\n",
114
+ " %cd /content/gdrive/$mainpth/sd\n",
115
+ " !git clone -q --branch master https://github.com/AUTOMATIC1111/$blasphemy0\n",
116
+ " !mkdir -p /content/gdrive/$mainpth/sd/$blasphemy0/cache/\n",
117
+ " os.environ['TRANSFORMERS_CACHE']=f\"/content/gdrive/{mainpth}/sd/\"+blasphemy0+\"/cache\"\n",
118
+ "\n",
119
+ "with capture.capture_output() as cap:\n",
120
+ " %cd /content/gdrive/$mainpth/sd/$blasphemy0/\n",
121
+ " !git reset --hard\n",
122
+ " time.sleep(1)\n",
123
+ " !rm webui.sh\n",
124
+ " !git pull\n",
125
+ " if Use_Latest_Working_Commit:\n",
126
+ " !git fetch --unshallow\n",
127
+ " !git checkout a9eab236d7e8afa4d6205127904a385b2c43bb24\n",
128
+ " !pip install gradio==3.16.2 --no-deps -qq\n",
129
+ " else:\n",
130
+ " !pip install gradio==3.23 --no-deps -qq\n",
131
+ "clear_output()\n",
132
+ "inf('\\u2714 Done','success', '50px')\n",
133
+ "#@markdown # 3.1【可选】安装插件(首次安装后,以后运行都不用再次安装,如需更新删除云盘对应文件夹重新运行)\n",
134
+ "import os,sys,time\n",
135
+ "from IPython.utils import capture\n",
136
+ "from IPython.display import clear_output\n",
137
+ "from IPython.display import HTML\n",
138
+ "from subprocess import getoutput\n",
139
+ "import base64\n",
140
+ "t1=base64.b64decode((\"YzNSaFlteGxMV1JwWm1aMWMybHZiaTEzWldKMWFRPT0=\").encode('ascii')).decode('ascii')\n",
141
+ "blasphemy0=base64.b64decode((t1).encode('ascii')).decode('ascii')\n",
142
+ "t2=base64.b64decode((\"ZDJWaWRXaz0=\").encode('ascii')).decode('ascii')\n",
143
+ "blasphemy=base64.b64decode((t2).encode('ascii')).decode('ascii')\n",
144
+ "#@markdown 安装lora控制插件,使用此类模型需要安装。\n",
145
+ "lora=True #@param {type:\"boolean\"}\n",
146
+ "#@markdown 安装C站的其他lora模型,勾选此项并将模型下载地址的编号输入代码中。\n",
147
+ "loraother=True #@param {type:\"boolean\"}\n",
148
+ "#@markdown 安装动画插件\n",
149
+ "deforum=True #@param {type:\"boolean\"}\n",
150
+ "#@markdown 安装中文插件\n",
151
+ "Chinese=True #@param {type:\"boolean\"}\n",
152
+ "#@markdown 安装mov2mov动画插件\n",
153
+ "mov2mov=False #@param {type:\"boolean\"}\n",
154
+ "#@markdown 安装图片浏览器\n",
155
+ "imgbro=True #@param {type:\"boolean\"}\n",
156
+ "#@markdown 安装controlnet插件,不装可惜了,注意在本条代码中去掉#的注释即可下载更多模型,默认下载canny\n",
157
+ "controlnet=True #@param {type:\"boolean\"}\n",
158
+ "\n",
159
+ "\n",
160
+ "%cd /content/\n",
161
+ "if Chinese:\n",
162
+ " !git clone https://github.com/xiaoxing1748/$blasphemy0-localization-zh /content/gdrive/MyDrive/sd/$blasphemy0/extensions/$blasphemy0-localization-zh\n",
163
+ "if mov2mov:\n",
164
+ " !git clone https://github.com/Scholar01/sd-$blasphemy-mov2mov /content/gdrive/MyDrive/sd/$blasphemy0/extensions/sd-$blasphemy-mov2mov\n",
165
+ "if deforum:\n",
166
+ " %cd /content/\n",
167
+ " !git clone https://github.com/deforum-art/deforum-for-automatic1111-$blasphemy/ /content/gdrive/MyDrive/sd/$blasphemy0/extensions/deforum\n",
168
+ "if imgbro:\n",
169
+ " %cd /content/\n",
170
+ " !git clone https://github.com/yfszzx/$blasphemy0-images-browser /content/gdrive/MyDrive/sd/$blasphemy0/extensions/$blasphemy0-images-browser\n",
171
+ "if controlnet:\n",
172
+ " !git clone https://github.com/Mikubill/sd-$blasphemy-controlnet /content/gdrive/MyDrive/sd/$blasphemy0/extensions/sd-$blasphemy-controlnet\n",
173
+ "\n",
174
+ " %cd /content/gdrive/MyDrive/sd/$blasphemy0/extensions/sd-$blasphemy-controlnet/models/\n",
175
+ " !wget https://huggingface.co/kohya-ss/ControlNet-diff-modules/resolve/main/diff_control_sd15_canny_fp16.safetensors\n",
176
+ " #!wget https://huggingface.co/kohya-ss/ControlNet-diff-modules/resolve/main/diff_control_sd15_openpose_fp16.safetensors\n",
177
+ " #!wget https://huggingface.co/kohya-ss/ControlNet-diff-modules/resolve/main/diff_control_sd15_scribble_fp16.safetensors\n",
178
+ "\n",
179
+ "if lora:\n",
180
+ " %cd /content/\n",
181
+ " !git clone https://github.com/kohya-ss/sd-$blasphemy-additional-networks /content/gdrive/MyDrive/sd/$blasphemy0/extensions/sd-$blasphemy-additional-networks\n",
182
+ "if loraother:\n",
183
+ " %cd /content/gdrive/MyDrive/sd/$blasphemy0/extensions/sd-$blasphemy-additional-networks/models/lora\n",
184
+ " !wget https://civitai.com/api/download/models/58149 -O /content/gdrive/MyDrive/sd/$blasphemy0/extensions/sd-$blasphemy-additional-networks/models/lora/A-Mecha.safetensors\n",
185
+ "!echo done"
186
+ ],
187
+ "metadata": {
188
+ "id": "oy-GvICISz6D"
189
+ },
190
+ "execution_count": null,
191
+ "outputs": []
192
+ }
193
+ ]
194
+ }