Phasmanta commited on
Commit
01079e3
1 Parent(s): 3cceb43

Upload message.txt

Browse files
Files changed (1) hide show
  1. message.txt +702 -0
message.txt ADDED
@@ -0,0 +1,702 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #@title - Instant (Simple)
2
+ import requests
3
+ import os
4
+ import subprocess
5
+ cek = subprocess.getoutput('nvidia-smi')
6
+ from google.colab.output import eval_js
7
+ os.environ['colab_url'] = eval_js("google.colab.kernel.proxyPort(7860, {'cache': false})")
8
+
9
+ if not 'T4' in cek:
10
+ print("[1;32m-----Your colab session is over. Use other google account or wait 12-24 hours-----")
11
+ print("-----Sesi colab elu udah habis bro. Saran gw tunggu 12-24 jam atau bikin/pake akun google lain-----")
12
+ raise KeyboardInterrupt
13
+
14
+
15
+ #thanks to https://github.com/camenduru for the fork
16
+ print('[1;32mInstalling dependencies...')
17
+ print('[1;32m(This process will only happen once per session)')
18
+ print('[0m')
19
+ %cd /content
20
+ #!if ! [ -f xformers ]; then pip install -q https://github.com/camenduru/stable-diffusion-webui-colab/releases/download/0.0.16/xformers-0.0.16+814314d.d20230118-cp38-cp38-linux_x86_64.whl; pip install -q --pre triton; touch xformers; fi
21
+ if not os.path.isfile('dependencies'):
22
+ !gdown http://launchpadlibrarian.net/367274644/libgoogle-perftools-dev_2.5-2.2ubuntu3_amd64.deb
23
+ !gdown https://launchpad.net/ubuntu/+source/google-perftools/2.5-2.2ubuntu3/+build/14795286/+files/google-perftools_2.5-2.2ubuntu3_all.deb
24
+ !gdown https://launchpad.net/ubuntu/+source/google-perftools/2.5-2.2ubuntu3/+build/14795286/+files/libtcmalloc-minimal4_2.5-2.2ubuntu3_amd64.deb
25
+ !gdown https://launchpad.net/ubuntu/+source/google-perftools/2.5-2.2ubuntu3/+build/14795286/+files/libgoogle-perftools4_2.5-2.2ubuntu3_amd64.deb
26
+ !apt install -qq libunwind8-dev
27
+ !dpkg -i *.deb
28
+ %env LD_PRELOAD=libtcmalloc.so
29
+ !rm *.deb
30
+ # print("Grabbing pre-built xformers from camenduru's repo")
31
+ # url = 'https://api.github.com/repos/camenduru/stable-diffusion-webui-colab/releases/latest'
32
+ # response = requests.get(url)
33
+ # print("Status code: " + str(response.status_code))
34
+ # if response.status_code == 200:
35
+ # data = response.json()
36
+ # templink = [link for link in [asset['browser_download_url'] for asset in data['assets'] if 'cp39' in asset['name']]]
37
+ # xformerlink = templink[0]
38
+ # else:
39
+ # print("Request failed, loading last updated xformers instead")
40
+ # xformerlink = 'https://github.com/camenduru/stable-diffusion-webui-colab/releases/download/0.0.17/xformers-0.0.17+b6be33a.d20230315-cp39-cp39-linux_x86_64.whl'
41
+ # !pip install -q --pre xformers
42
+ !pip install torch==1.13.1+cu116 torchvision==0.14.1+cu116 torchaudio==0.13.1 torchtext==0.14.1 torchdata==0.5.1 --extra-index-url https://download.pytorch.org/whl/cu116 -U
43
+ !pip install -q xformers==0.0.16 triton==2.0.0 -U
44
+ # !pip install -q --pre xformers==0.0.17.dev476 -U
45
+ # !pip install -q --pre triton
46
+ !touch dependencies
47
+
48
+ print('[1;32mInstalling webui...')
49
+ print('[0m')
50
+ !if ! [ -d stable-diffusion-webui ]; then git clone -b v2.1 https://github.com/camenduru/stable-diffusion-webui; touch forkedwebui; fi
51
+ %cd stable-diffusion-webui
52
+
53
+ #AnythingV3 Model & Vae
54
+ print('[1;32mDownloading AnythingV3 model...')
55
+ print('[0m')
56
+ %cd /content/stable-diffusion-webui/models/Stable-diffusion/
57
+ !if ! [ -f Anything-V3.0.safetensors ]; then gdown https://huggingface.co/Linaqruf/anything-v3.0/resolve/main/anything-v3-fp32-pruned.safetensors -O /content/stable-diffusion-webui/models/Stable-diffusion/Anything-V3.0.safetensors; fi
58
+ !if ! [ -f Anything-V3.0.vae.pt ]; then gdown https://huggingface.co/WarriorMama777/OrangeMixs/resolve/main/VAEs/orangemix.vae.pt -O /content/stable-diffusion-webui/models/Stable-diffusion/Anything-V3.0.vae.pt; fi
59
+
60
+ #webui setup for nai
61
+ print('[1;32mSetting UI configs...')
62
+ print('[0m')
63
+ %cd /content/stable-diffusion-webui
64
+ !if [ -f configinstan ]; then rm configinstan; fi
65
+ !if ! [ -f configinstanlite ]; then gdown https://pastebin.com/raw/fmN0i5Sd -O /content/stable-diffusion-webui/ui-config.json && gdown https://pastebin.com/raw/amVtB1NW -O /content/stable-diffusion-webui/config.json; fi
66
+ !if ! [ -f configinstanlite ]; then mv /content/stable-diffusion-webui/modules/ui.py /content/stable-diffusion-webui/modules/ui_backup.py && gdown https://pastebin.com/raw/pKFWUfLM -O /content/stable-diffusion-webui/modules/ui.py; fi
67
+ !touch configinstanlite
68
+
69
+ #notification bell
70
+ !gdown https://github.com/etherealxx/etherportal-webui-colab/raw/master/notification.mp3 -O /content/stable-diffusion-webui/notification.mp3
71
+
72
+ #foolhardy remacri
73
+ ! [ ! -d models/ESRGAN ] && mkdir -p models/ESRGAN; [ ! -f models/ESRGAN/4x_foolhardy_Remacri.pth ] && gdown https://huggingface.co/etherealxx/whoseisthis/resolve/main/4x_foolhardy_Remacri.pth -O /content/stable-diffusion-webui/models/ESRGAN/4x_foolhardy_Remacri.pth
74
+
75
+ #extensions
76
+ print('[1;32mInstalling extensions...')
77
+ print('[0m')
78
+ %cd /content/stable-diffusion-webui/extensions
79
+ !bash -c 'for repo in camenduru/stable-diffusion-webui-images-browser Extraltodeus/depthmap2mask ddPn08/kohya-sd-scripts-webui arenatemp/stable-diffusion-webui-model-toolkit; do if [ ! -d "repo" && true; fi; done' #DominikDoom/a1111-sd-webui-tagcomplete
80
+ !bash -c 'for repo in sd-civitai-browser kohya-sd-scripts-webui stable-diffusion-webui-model-toolkit batchlinks-webui; do if [ -d "
81
+ repo && true; fi; done'
82
+ #%cd /content/stable-diffusion-webui/extensions/UnivAICharGen
83
+ #!git checkout c56b5146049b91cfcd645c62bd356bd0631c4131 .
84
+ !git clone -b pre-embedding --single-branch https://github.com/etherealxx/Umi-AI
85
+
86
+ #badprompt & badartist
87
+ %cd /content/stable-diffusion-webui/embeddings/
88
+ !if ! [ -f bad_prompt.pt ]; then gdown https://huggingface.co/datasets/Nerfgun3/bad_prompt/resolve/main/bad_prompt_version2.pt -O /content/stable-diffusion-webui/embeddings/bad_prompt.pt; fi
89
+ !if ! [ -f bad_artist.pt ]; then gdown https://huggingface.co/etherealxx/whoseisthis/resolve/main/bad_artist.pt -O /content/stable-diffusion-webui/embeddings/bad_artist.pt; fi
90
+ !if ! [ -f bad_hands.pt ]; then gdown https://huggingface.co/etherealxx/whoseisthis/resolve/main/bad-hands-5.pt -O /content/stable-diffusion-webui/embeddings/bad_hands.pt; fi
91
+
92
+ #some fix
93
+ !sed -i -e '''/ prepare_environment()/a\ os.system\(f\"""sed -i -e ''\"s/dict()))/dict())).cuda()/g\"'' /content/stable-diffusion-webui/repositories/stable-diffusion-stability-ai/ldm/util.py""")''' /content/stable-diffusion-webui/launch.py
94
+ !sed -i -e 's/fastapi==0.90.1/fastapi==0.89.1/g' /content/stable-diffusion-webui/requirements_versions.txt
95
+
96
+ print('[1;32mInstallation Success!')
97
+ print('[1;32mLaunching the webui...')
98
+ print('[0m')
99
+ %cd /content/stable-diffusion-webui
100
+ !python launch.py --ckpt /content/stable-diffusion-webui/models/Stable-diffusion/Anything-V3.0.safetensors --vae-path /content/stable-diffusion-webui/models/Stable-diffusion/Anything-V3.0.vae.pt --share --xformers --enable-insecure-extension-access --gradio-queue
101
+
102
+
103
+ #@title - Instant (Advanced)
104
+ import requests
105
+ import os
106
+ import subprocess
107
+ cek = subprocess.getoutput('nvidia-smi')
108
+ if not 'T4' in cek:
109
+ print("[1;32m-----Your colab session is over. Use other google account or wait 12-24 hours-----")
110
+ print("-----Sesi colab elu udah habis bro. Saran gw tunggu 12-24 jam atau bikin/pake akun google lain-----")
111
+ raise KeyboardInterrupt
112
+ from google.colab.output import eval_js
113
+ os.environ['colab_url'] = eval_js("google.colab.kernel.proxyPort(7860, {'cache': false})")
114
+
115
+ #thanks to https://github.com/camenduru for the fork
116
+ print('[1;32mInstalling dependencies...')
117
+ print('[1;32m(This process will only happen once per session)')
118
+ print('[0m')
119
+ %cd /content
120
+ #!if ! [ -f xformers ]; then pip install -q https://github.com/camenduru/stable-diffusion-webui-colab/releases/download/0.0.16/xformers-0.0.16+814314d.d20230118-cp38-cp38-linux_x86_64.whl; pip install -q --pre triton; touch xformers; fi
121
+ if not os.path.isfile('dependencies'):
122
+ !gdown http://launchpadlibrarian.net/367274644/libgoogle-perftools-dev_2.5-2.2ubuntu3_amd64.deb
123
+ !gdown https://launchpad.net/ubuntu/+source/google-perftools/2.5-2.2ubuntu3/+build/14795286/+files/google-perftools_2.5-2.2ubuntu3_all.deb
124
+ !gdown https://launchpad.net/ubuntu/+source/google-perftools/2.5-2.2ubuntu3/+build/14795286/+files/libtcmalloc-minimal4_2.5-2.2ubuntu3_amd64.deb
125
+ !gdown https://launchpad.net/ubuntu/+source/google-perftools/2.5-2.2ubuntu3/+build/14795286/+files/libgoogle-perftools4_2.5-2.2ubuntu3_amd64.deb
126
+ !apt install -qq libunwind8-dev
127
+ !dpkg -i *.deb
128
+ %env LD_PRELOAD=libtcmalloc.so
129
+ !rm *.deb
130
+ # print("Grabbing pre-built xformers from camenduru's repo")
131
+ # url = 'https://api.github.com/repos/camenduru/stable-diffusion-webui-colab/releases/latest'
132
+ # response = requests.get(url)
133
+ # print("Status code: " + str(response.status_code))
134
+ # if response.status_code == 200:
135
+ # data = response.json()
136
+ # templink = [link for link in [asset['browser_download_url'] for asset in data['assets'] if 'cp39' in asset['name']]]
137
+ # xformerlink = templink[0]
138
+ # else:
139
+ # print("Request failed, loading last updated xformers instead")
140
+ # xformerlink = 'https://github.com/camenduru/stable-diffusion-webui-colab/releases/download/0.0.17/xformers-0.0.17+b6be33a.d20230315-cp39-cp39-linux_x86_64.whl'
141
+ # !pip install -q --pre xformers
142
+ !pip install torch==1.13.1+cu116 torchvision==0.14.1+cu116 torchaudio==0.13.1 torchtext==0.14.1 torchdata==0.5.1 --extra-index-url https://download.pytorch.org/whl/cu116 -U
143
+ !pip install -q xformers==0.0.16 triton==2.0.0 -U
144
+ # !pip install -q --pre xformers==0.0.17.dev476 -U
145
+ # !pip install -q --pre triton
146
+ !touch dependencies
147
+
148
+ print('[1;32mInstalling webui...')
149
+ print('[0m')
150
+ !if ! [ -d stable-diffusion-webui ]; then git clone -b v2.1 https://github.com/camenduru/stable-diffusion-webui; touch forkedwebui; fi
151
+ %cd stable-diffusion-webui
152
+
153
+ #AnythingV3 Model & Vae
154
+ print('[1;32mDownloading AnythingV3 model...')
155
+ print('[0m')
156
+ %cd /content/stable-diffusion-webui/models/Stable-diffusion/
157
+ !if ! [ -f Anything-V3.0.safetensors ]; then gdown https://huggingface.co/Linaqruf/anything-v3.0/resolve/main/anything-v3-fp32-pruned.safetensors -O /content/stable-diffusion-webui/models/Stable-diffusion/Anything-V3.0.safetensors; fi
158
+ !if ! [ -f Anything-V3.0.vae.pt ]; then gdown https://huggingface.co/WarriorMama777/OrangeMixs/resolve/main/VAEs/orangemix.vae.pt -O /content/stable-diffusion-webui/models/Stable-diffusion/Anything-V3.0.vae.pt; fi
159
+
160
+ #webui setup for nai
161
+ print('[1;32mSetting UI configs...')
162
+ print('[0m')
163
+ %cd /content/stable-diffusion-webui
164
+ !if [ -f configinstanlite ]; then rm configinstanlite && rm /content/stable-diffusion-webui/modules/ui.py && mv /content/stable-diffusion-webui/modules/ui_backup.py /content/stable-diffusion-webui/modules/ui.py; fi
165
+ !if ! [ -f configinstan ]; then gdown https://pastebin.com/raw/gMTvTUUZ -O /content/stable-diffusion-webui/ui-config.json && gdown https://pastebin.com/raw/VviKmfiQ -O /content/stable-diffusion-webui/config.json; fi
166
+ !touch configinstan
167
+
168
+ #notification bell
169
+ !gdown https://github.com/etherealxx/etherportal-webui-colab/raw/master/notification.mp3 -O /content/stable-diffusion-webui/notification.mp3
170
+
171
+ #foolhardy remacri
172
+ ! [ ! -d models/ESRGAN ] && mkdir -p models/ESRGAN; [ ! -f models/ESRGAN/4x_foolhardy_Remacri.pth ] && gdown https://huggingface.co/etherealxx/whoseisthis/resolve/main/4x_foolhardy_Remacri.pth -O /content/stable-diffusion-webui/models/ESRGAN/4x_foolhardy_Remacri.pth
173
+
174
+ #extensions
175
+ print('[1;32mInstalling extensions...')
176
+ print('[0m')
177
+ %cd /content/stable-diffusion-webui/extensions
178
+ !bash -c 'for repo in camenduru/stable-diffusion-webui-images-browser camenduru/sd-civitai-browser Extraltodeus/depthmap2mask ddPn08/kohya-sd-scripts-webui arenatemp/stable-diffusion-webui-model-toolkit etherealxx/batchlinks-webui; do if [ ! -d "
179
+ repo" && true; fi; done' #DominikDoom/a1111-sd-webui-tagcomplete
180
+ # !git clone -b lora --single-branch https://github.com/etherealxx/sd-civitai-browser
181
+ !git clone -b pre-embedding --single-branch https://github.com/etherealxx/Umi-AI
182
+ #%cd /content/stable-diffusion-webui/extensions/UnivAICharGen
183
+ #!git checkout c56b5146049b91cfcd645c62bd356bd0631c4131 .
184
+
185
+ #badprompt & badartist
186
+ %cd /content/stable-diffusion-webui/embeddings/
187
+ !if ! [ -f bad_prompt.pt ]; then gdown https://huggingface.co/datasets/Nerfgun3/bad_prompt/resolve/main/bad_prompt_version2.pt -O /content/stable-diffusion-webui/embeddings/bad_prompt.pt; fi
188
+ !if ! [ -f bad_artist.pt ]; then gdown https://huggingface.co/etherealxx/whoseisthis/resolve/main/bad_artist.pt -O /content/stable-diffusion-webui/embeddings/bad_artist.pt; fi
189
+ !if ! [ -f bad_hands.pt ]; then gdown https://huggingface.co/etherealxx/whoseisthis/resolve/main/bad-hands-5.pt -O /content/stable-diffusion-webui/embeddings/bad_hands.pt; fi
190
+
191
+ #some fix
192
+ !sed -i -e '''/ prepare_environment()/a\ os.system\(f\"""sed -i -e ''\"s/dict()))/dict())).cuda()/g\"'' /content/stable-diffusion-webui/repositories/stable-diffusion-stability-ai/ldm/util.py""")''' /content/stable-diffusion-webui/launch.py
193
+ !sed -i -e 's/fastapi==0.90.1/fastapi==0.89.1/g' /content/stable-diffusion-webui/requirements_versions.txt
194
+
195
+ print('[1;32mInstallation Success!')
196
+ print('[1;32mLaunching the webui...')
197
+ print('[0m')
198
+ %cd /content/stable-diffusion-webui
199
+ !python launch.py --ckpt /content/stable-diffusion-webui/models/Stable-diffusion/Anything-V3.0.safetensors --vae-path /content/stable-diffusion-webui/models/Stable-diffusion/Anything-V3.0.vae.pt --share --xformers --enable-insecure-extension-access --gradio-queue
200
+
201
+
202
+ #@title (for mobile/android user, run this first before Instant/Manual)
203
+
204
+ %%html
205
+ Press play on the music player to keep the tab alive (Uses only 13MB of data)
206
+
207
+ Untuk pengguna mobile, tekan play di musik di bawah
208
+ Fungsinya agar bisa make Colabnya lebih lama (make kuota 13MB)
209
+ - Manual (Open Dropdown👇)
210
+
211
+ Run the 1. installation cell
212
+ Choose your desired model, then run the 2. Download Model cell (you can repeat this step to download several model before you launch the webui)
213
+ Open the dropdown of 3. Run (Choose one👇), then choose one of the two available methods (doesn't matter which one)
214
+
215
+
216
+ #@title 1. Installation
217
+ webui_version = "camenduru's fork (stable)" #@param ["camenduru's fork (stable)", "original automatic1111 repo (latest feature, might be buggy)"]
218
+ import shutil
219
+ import os
220
+ import requests
221
+ import subprocess
222
+ cek = subprocess.getoutput('nvidia-smi')
223
+ if not 'T4' in cek:
224
+ print("[1;32m-----Your colab session is over. Use other google account or wait 12-24 hours-----")
225
+ print("-----Sesi colab elu udah habis bro. Saran gw tunggu 12-24 jam atau bikin/pake akun google lain-----")
226
+ raise KeyboardInterrupt
227
+ from google.colab.output import eval_js
228
+ os.environ['colab_url'] = eval_js("google.colab.kernel.proxyPort(7860, {'cache': false})")
229
+
230
+
231
+ print('[1;32mInstalling dependencies...')
232
+ print('[1;32m(This process will only happen once per session)')
233
+ print('[0m')
234
+ %cd /content
235
+ #!if ! [ -f xformers ]; then pip install -q https://github.com/camenduru/stable-diffusion-webui-colab/releases/download/0.0.16/xformers-0.0.16+814314d.d20230118-cp38-cp38-linux_x86_64.whl; pip install -q --pre triton; touch xformers; fi
236
+ if not os.path.isfile('dependencies'):
237
+ !gdown http://launchpadlibrarian.net/367274644/libgoogle-perftools-dev_2.5-2.2ubuntu3_amd64.deb
238
+ !gdown https://launchpad.net/ubuntu/+source/google-perftools/2.5-2.2ubuntu3/+build/14795286/+files/google-perftools_2.5-2.2ubuntu3_all.deb
239
+ !gdown https://launchpad.net/ubuntu/+source/google-perftools/2.5-2.2ubuntu3/+build/14795286/+files/libtcmalloc-minimal4_2.5-2.2ubuntu3_amd64.deb
240
+ !gdown https://launchpad.net/ubuntu/+source/google-perftools/2.5-2.2ubuntu3/+build/14795286/+files/libgoogle-perftools4_2.5-2.2ubuntu3_amd64.deb
241
+ !apt install -qq libunwind8-dev
242
+ !dpkg -i *.deb
243
+ %env LD_PRELOAD=libtcmalloc.so
244
+ !rm *.deb
245
+ # print("Grabbing pre-built xformers from camenduru's repo")
246
+ # url = 'https://api.github.com/repos/camenduru/stable-diffusion-webui-colab/releases/latest'
247
+ # response = requests.get(url)
248
+ # print("Status code: " + str(response.status_code))
249
+ # if response.status_code == 200:
250
+ # data = response.json()
251
+ # templink = [link for link in [asset['browser_download_url'] for asset in data['assets'] if 'cp39' in asset['name']]]
252
+ # xformerlink = templink[0]
253
+ # else:
254
+ # print("Request failed, loading last updated xformers instead")
255
+ # xformerlink = 'https://github.com/camenduru/stable-diffusion-webui-colab/releases/download/0.0.17/xformers-0.0.17+b6be33a.d20230315-cp39-cp39-linux_x86_64.whl'
256
+ # !pip install -q --pre xformers
257
+ !pip install torch==1.13.1+cu116 torchvision==0.14.1+cu116 torchaudio==0.13.1 torchtext==0.14.1 torchdata==0.5.1 --extra-index-url https://download.pytorch.org/whl/cu116 -U
258
+ !pip install -q xformers==0.0.16 triton==2.0.0 -U
259
+ # !pip install -q --pre xformers==0.0.17.dev476 -U
260
+ # !pip install -q --pre triton
261
+ !touch dependencies
262
+
263
+ print('[1;32mInstalling webui...')
264
+ print('[0m')
265
+ if webui_version=="camenduru's fork (stable)":
266
+ !if ! [ -f forkedwebui ]; then echo "cloning from camenduru's fork"; rm -rf stable-diffusion-webui; git clone -b v2.1 https://github.com/camenduru/stable-diffusion-webui; sed -i -e '''/ prepare_environment()/a\ os.system\(f\"""sed -i -e ''\"s/dict()))/dict())).cuda()/g\"'' /content/stable-diffusion-webui/repositories/stable-diffusion-stability-ai/ldm/util.py""")''' /content/stable-diffusion-webui/launch.py; sed -i -e 's/fastapi==0.90.1/fastapi==0.89.1/g' /content/stable-diffusion-webui/requirements_versions.txt; touch forkedwebui; fi
267
+ else:
268
+ !if [ -f forkedwebui ]; then rm forkedwebui; mv '/content/stable-diffusion-webui/models/Stable-diffusion' '/content/temp'; rm -rf stable-diffusion-webui; fi
269
+ !if ! [ -d stable-diffusion-webui ]; then echo "cloning from official repo"; git clone https://github.com/automatic1111/stable-diffusion-webui; cp -rf '/content/temp'/* '/content/stable-diffusion-webui/models/Stable-diffusion'; rm -rf '/content/temp'; fi
270
+ %cd stable-diffusion-webui
271
+
272
+ #webui setup for nai
273
+ print('[1;32mSetting UI configs...')
274
+ print('[0m')
275
+ %cd /content/stable-diffusion-webui
276
+ !if [ -f configinstanlite ]; then rm configinstanlite && rm /content/stable-diffusion-webui/modules/ui.py && mv /content/stable-diffusion-webui/modules/ui_backup.py /content/stable-diffusion-webui/modules/ui.py; fi
277
+ !if ! [ -f configinstan ]; then gdown https://pastebin.com/raw/gMTvTUUZ -O /content/stable-diffusion-webui/ui-config.json && gdown https://pastebin.com/raw/VviKmfiQ -O /content/stable-diffusion-webui/config.json; fi
278
+ !touch configinstan
279
+
280
+ #notification bell
281
+ !gdown https://github.com/etherealxx/etherportal-webui-colab/raw/master/notification.mp3 -O /content/stable-diffusion-webui/notification.mp3
282
+
283
+ #foolhardy remacri
284
+ ! [ ! -d models/ESRGAN ] && mkdir -p models/ESRGAN; [ ! -f models/ESRGAN/4x_foolhardy_Remacri.pth ] && gdown https://huggingface.co/etherealxx/whoseisthis/resolve/main/4x_foolhardy_Remacri.pth -O /content/stable-diffusion-webui/models/ESRGAN/4x_foolhardy_Remacri.pth
285
+
286
+ #temporaryfix
287
+
288
+ #extensions
289
+ print('[1;32mInstalling extensions...')
290
+ print('[0m')
291
+ %cd /content/stable-diffusion-webui/extensions
292
+ !bash -c 'for repo in camenduru/stable-diffusion-webui-images-browser camenduru/sd-civitai-browser Extraltodeus/depthmap2mask kohya-ss/sd-webui-additional-networks etherealxx/batchlinks-webui; do if [ ! -d "
293
+ repo" && true; fi; done' #DominikDoom/a1111-sd-webui-tagcomplete
294
+ !git clone -b pre-embedding --single-branch https://github.com/etherealxx/Umi-AI
295
+ #%cd /content/stable-diffusion-webui/extensions/UnivAICharGen
296
+ #!if [ -f forkedwebui ]; then git checkout c56b5146049b91cfcd645c62bd356bd0631c4131 .; fi
297
+ # !git clone -b lora --single-branch https://github.com/etherealxx/sd-civitai-browser
298
+
299
+ #badprompt & badartist
300
+ %cd /content/stable-diffusion-webui/embeddings/
301
+ !if ! [ -f bad_prompt.pt ]; then gdown https://huggingface.co/datasets/Nerfgun3/bad_prompt/resolve/main/bad_prompt_version2.pt -O /content/stable-diffusion-webui/embeddings/bad_prompt.pt; fi
302
+ !if ! [ -f bad_artist.pt ]; then gdown https://huggingface.co/etherealxx/whoseisthis/resolve/main/bad_artist.pt -O /content/stable-diffusion-webui/embeddings/bad_artist.pt; fi
303
+ !if ! [ -f bad_hands.pt ]; then gdown https://huggingface.co/etherealxx/whoseisthis/resolve/main/bad-hands-5.pt -O /content/stable-diffusion-webui/embeddings/bad_hands.pt; fi
304
+
305
+ print('[1;32mInstallation Success!')
306
+ print('[0m')
307
+
308
+
309
+ #@title 2. Download Model
310
+ Model_to_download="Anythingv3" #@param [ "Anythingv3", "WaifuDiffusion-Vae", "Eimis", "EvtV3", "ACertain", "ElysiumV3", "Wlop-any", "LeafMix", "Abyss7thLayer", "Healys", "LigneClaire", "KriboMix", "InizioSkinjob", "PantyStocking", "WaifuBodyBlenderMix", "StuffyMix", "AbyssOrangeMix2", "AbyssOrangeMix3", "8528", "AmbrosiaFusion", "AniMeth", "AnythingV4.0", "ArchonInstagram", "CounterveitV2.5", "CounterveitV2.2", "CounterveitV2.2", "HD-17", "HDDreamGape", "MomochaMix", "Mozarella", "PadoruDiffusion", "PastelMix", "Protothing", "Shirayuki", "NutMegMix", "KaniAnime", "EverythingMix", "BlossomExtract", "HentaiElysium", "BerryMix", "Systemy-CSR", "ElyOrangeMix", "AnyTwamMix", "DarkberryMix", "Grapefruit", "Mitsudoue"]
311
+ #@markdown Confused on what model to choose? Look for examples and comparison [here](https://github.com/etherealxx/etherportal-webui-colab/blob/master/ModelComparison.md).
312
+ #@markdown If the download speed is slow (Below 10MiB/s), press the stop button then re-run the cell)
313
+ #@markdown If the model you wanted isn't listed, and you have the direct link, paste it to the form below. (Supported link: Huggingface, MEGA)
314
+ optional_direct_link='' #@param {type:"string"}
315
+
316
+ import os
317
+ import urllib.request, subprocess, contextlib #these handle mega.nz
318
+ from IPython.display import clear_output #this also handle mega.nz
319
+ from IPython.utils import capture
320
+ import requests
321
+ from tqdm import tqdm
322
+
323
+ folder = '/content/stable-diffusion-webui/models/Stable-diffusion/'
324
+
325
+ def checkdownloaded(pathx):
326
+ if os.path.exists(pathx) or (os.path.exists(os.path.join(folder, 'Anything-V3.0.safetensors')) and Model_to_download=="Anythingv3"):
327
+
328
+ if pathx.endswith("tmp"):
329
+ os.remove(pathx)
330
+ else:
331
+ print(f'[1;32mThat model is already downloaded.')
332
+ print('[0m')
333
+ return 2
334
+
335
+ #civitstuff
336
+ checkerpath = os.path.join(folder, 'civitmodel.txt')
337
+ alreadythere = False
338
+
339
+ def checkearlycivit():
340
+ alreadythere = False
341
+ lines = []
342
+ if not os.path.exists(checkerpath):
343
+ !touch {checkerpath}
344
+ #check for unavailable model first
345
+ if os.stat(checkerpath).st_size != 0:
346
+ with open(checkerpath, "r") as file:
347
+ for line in file:
348
+ key, value = line.strip().split(" = ")
349
+ modelfile = os.path.join(folder, value)
350
+ if os.path.exists(modelfile):
351
+ lines.append(line)
352
+ if key == Model_to_download:
353
+ alreadythere = True
354
+ else:
355
+ print(f"Seems like {key} model is not found on the model folder.")
356
+ print()
357
+
358
+ with open(checkerpath, "w") as file:
359
+ file.writelines(lines)
360
+
361
+ if alreadythere == True: return 2
362
+
363
+ def civitgetpath(modelname):
364
+ with open(checkerpath, "r") as file:
365
+ for line in file:
366
+ key, value = line.strip().split(" = ")
367
+ if key == modelname:
368
+ return os.path.join(folder, value)
369
+
370
+ def civitwrite(modelname):
371
+ towrite = f"{Model_to_download} = {modelname}"
372
+ with open(checkerpath, "a") as file:
373
+ file.write(towrite + "\n")
374
+ #civitstuffend
375
+
376
+ def download_hf(link):
377
+ filename = link.rsplit('/', 1)[-1]
378
+ if Model_to_download == 'WaifuDiffusion-Vae':
379
+ filename = 'WD-vae.vae.pt'
380
+ elif Model_to_download == 'Anythingv3':
381
+ filename = 'Anything-V3.0.safetensors'
382
+
383
+ hfpath = os.path.join(folder, filename)
384
+ check = checkdownloaded(hfpath)
385
+ if check == 2:
386
+ if Model_to_download=='Anythingv3' and not os.path.exists(os.path.join(folder, 'Anything-V3.0.vae.pt')):
387
+ !gdown https://huggingface.co/WarriorMama777/OrangeMixs/resolve/main/VAEs/orangemix.vae.pt -O /content/stable-diffusion-webui/models/Stable-diffusion/Anything-V3.0.vae.pt
388
+ return
389
+
390
+ print(f'\033[1;32mDownloading {Model_to_download} Model...\033[0m')
391
+ !gdown {link} -O /content/stable-diffusion-webui/models/Stable-diffusion/{filename}
392
+ if Model_to_download=='Anythingv3':
393
+ !gdown https://huggingface.co/WarriorMama777/OrangeMixs/resolve/main/VAEs/orangemix.vae.pt -O /content/stable-diffusion-webui/models/Stable-diffusion/Anything-V3.0.vae.pt
394
+ print(f'\033[1;32mModel Downloaded.\033[0m')
395
+
396
+ def download_civit(url):
397
+ print(f'\033[1;32mDownloading {Model_to_download} Model...\033[0m')
398
+
399
+ head_response = requests.head(url)
400
+ total = int(head_response.headers.get('Content-Length', 0))
401
+ civitcheck = checkearlycivit()
402
+ if civitcheck == 2: #model exist
403
+ civitpath = civitgetpath(Model_to_download)
404
+ downloaded_size = os.path.getsize(civitpath)
405
+ if total != 0 and downloaded_size != total:
406
+ os.remove(civitpath)
407
+ checkearlycivit()
408
+ print(f'Removed incomplete download: {Model_to_download}')
409
+ else:
410
+ print(f'[1;32mThat model is already downloaded.')
411
+ print('[0m')
412
+ return
413
+
414
+ downloaded_size = 0
415
+
416
+ if not civitcheck == 2:
417
+ pathtemp = os.path.join(folder, Model_to_download + ".bdgh")
418
+ print(f'The model "{Model_to_download}" will be renamed correctly after downloading')
419
+ with open(pathtemp, 'wb') as file, tqdm(
420
+ desc=pathtemp,
421
+ total=total,
422
+ unit='iB',
423
+ unit_scale=True,
424
+ unit_divisor=1024,
425
+ initial=downloaded_size,
426
+ ) as bar:
427
+ resp = requests.get(url, stream=True)
428
+
429
+ for data in resp.iter_content(chunk_size=1024):
430
+ size = file.write(data)
431
+ bar.update(size)
432
+ # Check if the file has been downloaded successfully
433
+ downloaded_size = os.path.getsize(pathtemp)
434
+ if (total != 0 and downloaded_size != total) or (downloaded_size < 1000):
435
+ # Remove the file if it has not been downloaded successfully
436
+ os.remove(pathtemp)
437
+ print()
438
+ if downloaded_size < 1000:
439
+ print(f'The model "{Model_to_download}" is probably had the link changed. Contact the owner of this repo.')
440
+ else:
441
+ print(f'Removed incomplete download: {Model_to_download}')
442
+ return
443
+ actualfilename = resp.headers['Content-Disposition'].split("filename=")[1].strip('"')
444
+ #%cd {folder}
445
+ os.rename(pathtemp, os.path.join(folder, actualfilename))
446
+ print (f'Model "{Model_to_download}.bdgh" renamed to "{actualfilename}"')
447
+ civitwrite(actualfilename)
448
+ print(f'\033[1;32mModel Downloaded.\033[0m')
449
+
450
+
451
+ print('[1;32mInstalling webui...')
452
+ with capture.capture_output() as cap:
453
+ %cd /content
454
+ !if ! [ -d stable-diffusion-webui ]; then git clone -b v1.6 https://github.com/camenduru/stable-diffusion-webui; touch forkedwebui; fi
455
+ print('[0m')
456
+ !if [ -f {folder}'Put Stable Diffusion checkpoints here.txt' ]; then rm {folder}'Put Stable Diffusion checkpoints here.txt'; fi
457
+
458
+ %cd {folder}
459
+ #sfw
460
+ if Model_to_download=='Anythingv3':
461
+ download_hf('https://huggingface.co/Linaqruf/anything-v3.0/resolve/main/anything-v3-fp32-pruned.safetensors')
462
+ if Model_to_download=='WaifuDiffusion-Vae':
463
+ download_hf('https://huggingface.co/hakurei/waifu-diffusion-v1-4/resolve/main/vae/kl-f8-anime2.ckpt')
464
+ if Model_to_download=='Eimis':
465
+ download_hf('https://huggingface.co/eimiss/EimisAnimeDiffusion_1.0v/resolve/main/EimisAnimeDiffusion_1-0v.ckpt')
466
+ if Model_to_download=='EvtV3':
467
+ download_hf('https://huggingface.co/haor/Evt_V3/resolve/main/Evt_V3_ema.ckpt')
468
+ if Model_to_download=='ACertain':
469
+ download_hf('https://huggingface.co/JosephusCheung/ACertainModel/resolve/main/ACertainModel.ckpt')
470
+ if Model_to_download=='ElysiumV3':
471
+ download_hf('https://huggingface.co/hesw23168/SD-Elysium-Model/resolve/main/Elysium_Anime_V3.safetensors')
472
+ if Model_to_download=='Wlop-any':
473
+ download_hf('https://huggingface.co/SirVeggie/wlop/resolve/main/wlop-any.ckpt')
474
+ if Model_to_download=='LeafMix':
475
+ download_hf('https://huggingface.co/etherealxx/anyleaf-temp/resolve/main/Leaf-pruned.safetensors')
476
+ if Model_to_download=='Abyss7thLayer':
477
+ download_hf('https://huggingface.co/syaimu/7th_Layer/resolve/main/7th_layer/Abyss_7th_layer.ckpt')
478
+ if Model_to_download=='Healys':
479
+ download_civit('https://civitai.com/api/download/models/1498')
480
+ if Model_to_download=='LigneClaire':
481
+ download_hf('https://huggingface.co/breakcore2/ligne_claire_anime_diffusion/resolve/main/ligne_claire_anime_diffusion_v1.safetensors')
482
+ if Model_to_download=='KriboMix':
483
+ download_civit('https://civitai.com/api/download/models/1289')
484
+ if Model_to_download=='InizioSkinjob':
485
+ download_hf('https://huggingface.co/Cinnamomo/inizio/resolve/main/safetensor/inizio_skinjob.safetensors')
486
+ if Model_to_download=='PantyStocking':
487
+ download_civit('https://civitai.com/api/download/models/1560')
488
+ if Model_to_download=='WaifuBodyBlenderMix':
489
+ download_civit('https://civitai.com/api/download/models/1838')
490
+ if Model_to_download=='StuffyMix':
491
+ download_civit('https://civitai.com/api/download/models/3376')
492
+ if Model_to_download=='AbyssOrangeMix2':
493
+ download_hf('https://huggingface.co/WarriorMama777/OrangeMixs/resolve/main/Models/AbyssOrangeMix2/AbyssOrangeMix2_hard.safetensors')
494
+ if Model_to_download=='AbyssOrangeMix3':
495
+ download_hf('https://huggingface.co/WarriorMama777/OrangeMixs/resolve/main/Models/AbyssOrangeMix3/AOM3
496
+ .safetensors')
497
+ if Model_to_download=='8528':
498
+ download_hf('https://huggingface.co/ckpt/8528-diffusion/resolve/main/8528d-final.ckpt')
499
+ if Model_to_download=='AmbrosiaFusion':
500
+ download_hf('https://huggingface.co/NiteStormz/ProtoThing_200/resolve/main/AmbrosiaFusion.ckpt')
501
+ if Model_to_download=='AniMeth':
502
+ download_hf('https://huggingface.co/Rasgeath/self_made_sauce/resolve/main/AniMeth.safetensors')
503
+ if Model_to_download=='AnythingV4.0':
504
+ download_hf('https://huggingface.co/andite/anything-v4.0/resolve/main/anything-v4.0-pruned.safetensors')
505
+ if Model_to_download=='ArchonInstagram':
506
+ download_hf('https://huggingface.co/misobarisic/playground/resolve/main/ArchonInstagram-fp16.ckpt')
507
+ if Model_to_download=='CounterveitV2.5':
508
+ download_hf('https://huggingface.co/gsdf/Counterfeit-V2.5/resolve/main/Counterfeit-V2.5_pruned.safetensors')
509
+ if Model_to_download=='CounterveitV2.2':
510
+ download_hf('https://huggingface.co/gsdf/Counterfeit-V2.5/resolve/main/Counterfeit-V2.2.safetensors')
511
+ if Model_to_download=='CounterveitV2.2':
512
+ download_hf('https://huggingface.co/gsdf/Counterfeit-V2.5/resolve/main/Counterfeit-V2.2.safetensors')
513
+ if Model_to_download=='HD-17':
514
+ download_hf('https://huggingface.co/Deltaadams/HentaiDiffusion/resolve/main/HD-17.ckpt')
515
+ if Model_to_download=='HDDreamGape':
516
+ download_hf('https://huggingface.co/Horsebird/HDDream-G/resolve/main/HDDream-Gape.safetensors')
517
+ if Model_to_download=='MomochaMix':
518
+ download_hf('https://huggingface.co/NoCrypt/momocha-mix/resolve/main/momocha-6E7-0.315-AD-E7-0.15-WS.ckpt')
519
+ if Model_to_download=='Mozarella':
520
+ download_hf('https://huggingface.co/Rasgeath/self_made_sauce/resolve/main/Mozzarella-pruned.safetensors')
521
+ if Model_to_download=='PadoruDiffusion':
522
+ download_hf('https://huggingface.co/misobarisic/playground/resolve/main/padoruDiffusion_1.ckpt')
523
+ if Model_to_download=='PastelMix':
524
+ download_hf('https://huggingface.co/andite/pastel-mix/resolve/main/pastelmix-fp32.safetensors')
525
+ if Model_to_download=='Protothing':
526
+ download_hf('https://huggingface.co/NiteStormz/ProtoThing_200/resolve/main/ProtoThing_200.ckpt')
527
+ if Model_to_download=='Shirayuki':
528
+ download_hf('https://huggingface.co/hesw23168/SD_Shirayuki_Model/resolve/main/Shirayuki_Anime_V1-fp16.safetensors')
529
+ if Model_to_download=='NutMegMix':
530
+ download_hf('https://huggingface.co/acheong08/nutmegmix/resolve/main/nutmegmix.safetensors')
531
+ if Model_to_download=='KaniAnime':
532
+ download_hf('https://huggingface.co/Rasgeath/self_made_sauce/resolve/main/Kani-anime-pruned.ckpt')
533
+ if Model_to_download=='EverythingMix':
534
+ download_hf('https://huggingface.co/DrBob2142/Everything/resolve/main/Everything%20V1B.safetensors')
535
+ if Model_to_download=='BlossomExtract':
536
+ download_hf('https://huggingface.co/NUROISEA/anything-mix/resolve/main/blossom-extract.safetensors')
537
+ if Model_to_download=='HentaiElysium':
538
+ download_hf('https://huggingface.co/NUROISEA/anything-mix/resolve/main/hentai-elysium-50.safetensors')
539
+
540
+ #nsfw
541
+ if Model_to_download=='BerryMix':
542
+ download_hf('https://huggingface.co/misobarisic/berry-mix/resolve/main/berry_mix.ckpt')
543
+ if Model_to_download=='Systemy-CSR':
544
+ download_hf('https://huggingface.co/etherealxx/systemy-csrmodel-cutesexyrobutts/resolve/main/CSRmodel_1-CSRmodel_0-Weighted_sum-merged.ckpt')
545
+ if Model_to_download=='ElyOrangeMix':
546
+ download_hf('https://huggingface.co/WarriorMama777/OrangeMixs/resolve/main/Models/ElyOrangeMix/ElyOrangeMix.ckpt')
547
+ if Model_to_download=='AnyTwamMix':
548
+ download_civit('https://civitai.com/api/download/models/4527')
549
+ if Model_to_download=='DarkberryMix':
550
+ download_civit('https://civitai.com/api/download/models/1992')
551
+ if Model_to_download=='Grapefruit':
552
+ download_civit('https://civitai.com/api/download/models/6360')
553
+ if Model_to_download=='Mitsudoue':
554
+ download_civit('https://civitai.com/api/download/models/1454')
555
+
556
+ #these code below handle mega.nz
557
+ def unbuffered(proc, stream='stdout'):
558
+ stream = getattr(proc, stream)
559
+ with contextlib.closing(stream):
560
+ while True:
561
+ out = []
562
+ last = stream.read(1)
563
+ # Don't loop forever
564
+ if last == '' and proc.poll() is not None:
565
+ break
566
+ while last not in newlines:
567
+ # Don't loop forever
568
+ if last == '' and proc.poll() is not None:
569
+ break
570
+ out.append(last)
571
+ last = stream.read(1)
572
+ out = ''.join(out)
573
+ yield out
574
+
575
+ def transfare():
576
+ import codecs
577
+ decoder = codecs.getincrementaldecoder("UTF-8")()
578
+ cmd = ["mega-get", optional_direct_link, folder]
579
+ proc = subprocess.Popen(
580
+ cmd,
581
+ stdout=subprocess.PIPE,
582
+ stderr=subprocess.STDOUT,
583
+ universal_newlines=True,
584
+ )
585
+ for line in unbuffered(proc):
586
+ if not line.startswith("Download"):
587
+ print(f"\r{line}", end="")
588
+ else:
589
+ print(f"\n{line}")
590
+
591
+
592
+ def installmega():
593
+ HOME = os.path.expanduser("~")
594
+ if not os.path.exists(f"{HOME}/.ipython/ocr.py"):
595
+ hCode = "https://raw.githubusercontent.com/biplobsd/" \
596
+ "OneClickRun/master/res/ocr.py"
597
+ urllib.request.urlretrieve(hCode, f"{HOME}/.ipython/ocr.py")
598
+
599
+ from ocr import (
600
+ runSh,
601
+ loadingAn,
602
+ )
603
+
604
+ if not os.path.exists("/usr/bin/mega-cmd"):
605
+ loadingAn()
606
+ print("Installing MEGA ...")
607
+ runSh('sudo apt-get -y update')
608
+ runSh('sudo apt-get -y install libmms0 libc-ares2 libc6 libcrypto++6 libgcc1 libmediainfo0v5 libpcre3 libpcrecpp0v5 libssl1.1 libstdc++6 libzen0v5 zlib1g apt-transport-https')
609
+ runSh('sudo curl -sL -o /var/cache/apt/archives/MEGAcmd.deb https://mega.nz/linux/MEGAsync/Debian_9.0/amd64/megacmd-Debian_9.0_amd64.deb', output=True)
610
+ runSh('sudo dpkg -i /var/cache/apt/archives/MEGAcmd.deb', output=True)
611
+ print("MEGA is installed.")
612
+ clear_output()
613
+ #these code above handle mega.nz
614
+
615
+ if optional_direct_link!='':
616
+ if optional_direct_link.startswith("https://huggingface.co/"):
617
+ custom_download = os.path.basename(optional_direct_link)
618
+ custom_path = os.path.join(folder,custom_download)
619
+ if not os.path.isfile(custom_path):
620
+ print(f'[1;32mDownloading {custom_download}')
621
+ print('[0m')
622
+ !gdown {optional_direct_link} -O {custom_path}
623
+ else:
624
+ print(f'[1;32mThat custom model is already downloaded.')
625
+ print('[0m')
626
+ elif optional_direct_link.startswith("https://mega.nz/"):
627
+ print(f'[1;32mDownloading from a Mega link')
628
+ print('[0m')
629
+ installmega()
630
+ newlines = ['\n', '\r\n', '\r']
631
+ transfare()
632
+
633
+ files = os.listdir(folder)
634
+ for file in files:
635
+ if file.endswith('tmp') or file.endswith('bdgh'):
636
+ file_path = os.path.join(folder, file)
637
+ print(f"Removed incomplete download: {file_path}")
638
+ os.remove(file_path)
639
+
640
+ for root, dirs, files in os.walk(folder):
641
+ for file in files:
642
+ if file.endswith('.ckpt') or file.endswith('.safetensors'):
643
+ checksizepath = os.path.join(root, file)
644
+ MB = 1000000 # 1 megabyte = 1000000 bytes
645
+ lorapath = '/content/stable-diffusion-webui/models/Lora'
646
+ if os.path.getsize(checksizepath) < 200 * MB:
647
+ if os.path.getsize(checksizepath) < MB:
648
+ os.remove(checksizepath)
649
+ print()
650
+ print(f'The model {checksizepath} is probably had the link changed. Contact the owner of this repo.')
651
+ else:
652
+ if not os.path.exists(lorapath):
653
+ os.makedirs(lorapath)
654
+ os.rename(checksizepath, os.path.join(lorapath, file))
655
+ print()
656
+ print(f'The model {checksizepath} is probably a Lora, so it is moved to lora folder')
657
+
658
+ print()
659
+ print('[1;32mList of installed models:')
660
+ print('[0m')
661
+ !ls *.{ckpt,safetensors,pt} {folder} 2>/dev/null
662
+
663
+ 3. Run (Choose one👇)
664
+
665
+ #@title Run with Gradio
666
+ #@markdown ![](https://raw.githubusercontent.com/etherealxx/etherportal-webui-colab/master/images/launchwebui2.jpg)
667
+
668
+ import subprocess
669
+ cek = subprocess.getoutput('nvidia-smi')
670
+ if not 'T4' in cek:
671
+ print("[1;32m-----Your colab session is over. Use other google account or wait 12-24 hours-----")
672
+ print("-----Sesi colab elu udah habis bro. Saran gw tunggu 12-24 jam atau bikin/pake akun google lain-----")
673
+ raise KeyboardInterrupt
674
+
675
+
676
+ %cd /content/stable-diffusion-webui/
677
+ !python launch.py --share --xformers --enable-insecure-extension-access --gradio-queue --no-half-vae
678
+
679
+
680
+ #@title Run with Localtunnel
681
+ #@markdown ![](https://raw.githubusercontent.com/etherealxx/etherportal-webui-colab/master/images/launchwebui3.jpg)
682
+
683
+ import subprocess
684
+ import time
685
+ !npm install -g localtunnel
686
+
687
+ cek = subprocess.getoutput('nvidia-smi')
688
+ if not 'T4' in cek:
689
+ print("[1;32m-----Your colab session is over. Use other google account or wait 12-24 hours-----")
690
+ print("-----Sesi colab elu udah habis bro. Saran gw tunggu 12-24 jam atau bikin/pake akun google lain-----")
691
+ raise KeyboardInterrupt
692
+
693
+
694
+ %cd /content/stable-diffusion-webui/
695
+ !nohup lt -p 7860 > lt.log 2>&1 &
696
+ time.sleep(2)
697
+ with open('/content/stable-diffusion-webui/lt.log', 'r') as testwritefile:
698
+ print("\033[92m" + "Wait for the model to load and follow this link")
699
+ print(testwritefile.read())
700
+ print("\033[95m")
701
+ !python launch.py --xformers --enable-insecure-extension-access
702
+