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_info": {
|
13 |
+
"name": "python"
|
14 |
+
}
|
15 |
+
},
|
16 |
+
"cells": [
|
17 |
+
{
|
18 |
+
"cell_type": "code",
|
19 |
+
"source": [
|
20 |
+
"import os\n",
|
21 |
+
"import re\n",
|
22 |
+
"import sys\n",
|
23 |
+
"import time\n",
|
24 |
+
"import json\n",
|
25 |
+
"import shutil\n",
|
26 |
+
"import subprocess\n",
|
27 |
+
"from datetime import timedelta\n",
|
28 |
+
"from subprocess import getoutput\n",
|
29 |
+
"from urllib.parse import unquote\n",
|
30 |
+
"from IPython.utils import capture\n",
|
31 |
+
"from IPython.display import clear_output\n",
|
32 |
+
"\n",
|
33 |
+
"\n",
|
34 |
+
"# ================= DETECT ENV =================\n",
|
35 |
+
"def detect_environment():\n",
|
36 |
+
" environments = {\n",
|
37 |
+
" 'COLAB_GPU': ('Google Colab', \"/content\"),\n",
|
38 |
+
" 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\"),\n",
|
39 |
+
" 'SAGEMAKER_INTERNAL_IMAGE_URI': ('SageMaker Studio Lab', \"/home/studio-lab-user/content\")\n",
|
40 |
+
" }\n",
|
41 |
+
"\n",
|
42 |
+
" for env_var, (environment, path) in environments.items():\n",
|
43 |
+
" if env_var in os.environ:\n",
|
44 |
+
" return environment, path\n",
|
45 |
+
"\n",
|
46 |
+
" sys.exit(\"\\033[31mError: an unsupported runtime environment was detected.\\n\\033[34mSupported environments:\\033[0m Google Colab, Kaggle, Sagemaker Studio Lab\")\n",
|
47 |
+
"\n",
|
48 |
+
"env, root_path = detect_environment()\n",
|
49 |
+
"webui_path = f\"{root_path}/sdw\"\n",
|
50 |
+
"# ----------------------------------------------\n",
|
51 |
+
"\n",
|
52 |
+
"\n",
|
53 |
+
"# ================ LIBRARIES ================\n",
|
54 |
+
"flag_file = f\"{root_path}/libraries_installed.txt\"\n",
|
55 |
+
"\n",
|
56 |
+
"if not os.path.exists(flag_file):\n",
|
57 |
+
" xformers = \"xformers==0.0.20 triton==2.0.0\"\n",
|
58 |
+
" torch = \"torch==2.0.1+cu118 torchvision==0.15.2+cu118 torchaudio==2.0.2+cu118 torchtext==0.15.2 torchdata==0.6.1 --extra-index-url https://download.pytorch.org/whl/cu118\"\n",
|
59 |
+
"\n",
|
60 |
+
" print(\"Installing the libraries, it's going to take a while....\", end='')\n",
|
61 |
+
" with capture.capture_output() as cap:\n",
|
62 |
+
" !apt -y install -qq aria2 &> /dev/null\n",
|
63 |
+
" !npm install -g localtunnel &> /dev/null\n",
|
64 |
+
" !curl -s -OL https://github.com/DEX-1101/sd-webui-notebook/raw/main/res/new_tunnel --output-dir {root_path}\n",
|
65 |
+
" !curl -s -Lo /usr/bin/cl https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 && chmod +x /usr/bin/cl\n",
|
66 |
+
" !pip install insightface\n",
|
67 |
+
"\n",
|
68 |
+
" if env == \"Google Colab\":\n",
|
69 |
+
" !pip install -q xformers==0.0.22.post7\n",
|
70 |
+
" else:\n",
|
71 |
+
" !pip install -q {torch} -U\n",
|
72 |
+
" !pip install -q {xformers} -U\n",
|
73 |
+
"\n",
|
74 |
+
" with open(flag_file, \"w\") as f:\n",
|
75 |
+
" f.write(\"hey ;3\")\n",
|
76 |
+
" del cap\n",
|
77 |
+
" print(\"\\rLibraries are installed!\" + \" \"*35)\n",
|
78 |
+
" time.sleep(2)\n",
|
79 |
+
" clear_output()\n",
|
80 |
+
"\n",
|
81 |
+
"\n",
|
82 |
+
"# ================= loading settings V4 =================\n",
|
83 |
+
"def load_settings(path):\n",
|
84 |
+
" if os.path.exists(path):\n",
|
85 |
+
" with open(path, 'r') as file:\n",
|
86 |
+
" return json.load(file)\n",
|
87 |
+
" return {}\n",
|
88 |
+
"\n",
|
89 |
+
"settings = load_settings(f'{root_path}/settings.json')\n",
|
90 |
+
"\n",
|
91 |
+
"variables = [\n",
|
92 |
+
" 'Model', 'Model_Num', 'Inpainting_Model',\n",
|
93 |
+
" 'Vae', 'Vae_Num',\n",
|
94 |
+
" 'latest_webui', 'latest_exstensions', 'detailed_download',\n",
|
95 |
+
" 'controlnet', 'controlnet_Num', 'commit_hash', 'optional_huggingface_token',\n",
|
96 |
+
" 'ngrok_token' 'commandline_arguments',\n",
|
97 |
+
" 'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url', 'Extensions_url'\n",
|
98 |
+
"]\n",
|
99 |
+
"\n",
|
100 |
+
"locals().update({key: settings.get(key) for key in variables})\n",
|
101 |
+
"\n",
|
102 |
+
"\n",
|
103 |
+
"# ================= OTHER =================\n",
|
104 |
+
"try:\n",
|
105 |
+
" start_colab\n",
|
106 |
+
"except:\n",
|
107 |
+
" start_colab = int(time.time())-5\n",
|
108 |
+
"\n",
|
109 |
+
"# CONFIG DIR\n",
|
110 |
+
"models_dir = f\"{webui_path}/models/Stable-diffusion\"\n",
|
111 |
+
"vaes_dir = f\"{webui_path}/models/VAE\"\n",
|
112 |
+
"embeddings_dir = f\"{webui_path}/embeddings\"\n",
|
113 |
+
"loras_dir = f\"{webui_path}/models/Lora\"\n",
|
114 |
+
"extensions_dir = f\"{webui_path}/extensions\"\n",
|
115 |
+
"control_dir = f\"{webui_path}/models/ControlNet\"\n",
|
116 |
+
"\n",
|
117 |
+
"\n",
|
118 |
+
"# ================= MAIN CODE =================\n",
|
119 |
+
"if not os.path.exists(webui_path):\n",
|
120 |
+
" start_install = int(time.time())\n",
|
121 |
+
" print(\"⌚ Unpacking Stable Diffusion...\", end='')\n",
|
122 |
+
" with capture.capture_output() as cap:\n",
|
123 |
+
" !aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO.zip -o repo.zip\n",
|
124 |
+
" !unzip -q -o repo.zip -d {webui_path}\n",
|
125 |
+
" !rm -rf repo.zip\n",
|
126 |
+
"\n",
|
127 |
+
" %cd {root_path}\n",
|
128 |
+
" os.environ[\"SAFETENSORS_FAST_GPU\"]='1'\n",
|
129 |
+
" os.environ[\"CUDA_MODULE_LOADING\"]=\"LAZY\"\n",
|
130 |
+
" os.environ[\"TF_CPP_MIN_LOG_LEVEL\"] = \"3\"\n",
|
131 |
+
" os.environ[\"PYTHONWARNINGS\"] = \"ignore\"\n",
|
132 |
+
"\n",
|
133 |
+
" !echo -n {start_colab} > {webui_path}/static/colabTimer.txt\n",
|
134 |
+
" del cap\n",
|
135 |
+
" install_time = timedelta(seconds=time.time()-start_install)\n",
|
136 |
+
" print(\"\\r🚀 Unpacking is complete! For\",\"%02d:%02d:%02d ⚡\\n\" % (install_time.seconds / 3600, (install_time.seconds / 60) % 60, install_time.seconds % 60), end='', flush=True)\n",
|
137 |
+
"else:\n",
|
138 |
+
" !echo -n {start_colab} > {webui_path}/static/colabTimer.txt\n",
|
139 |
+
" print(\"🚀 All unpacked... Skip. ⚡\")\n",
|
140 |
+
" start_colab = float(open(f'{webui_path}/static/colabTimer.txt', 'r').read())\n",
|
141 |
+
" time_since_start = str(timedelta(seconds=time.time()-start_colab)).split('.')[0]\n",
|
142 |
+
" print(f\"⌚️ You have been conducting this session for - \\033[33m{time_since_start}\\033[0m\")\n",
|
143 |
+
"\n",
|
144 |
+
"\n",
|
145 |
+
"## Changes extensions and WebUi\n",
|
146 |
+
"if latest_webui or latest_exstensions:\n",
|
147 |
+
" action = \"Updating WebUI and Extensions\" if latest_webui and latest_exstensions else (\"WebUI Update\" if latest_webui else \"Update Extensions\")\n",
|
148 |
+
" print(f\"⌚️ {action}...\", end='', flush=True)\n",
|
149 |
+
" with capture.capture_output() as cap:\n",
|
150 |
+
" !git config --global user.email \"you@example.com\"\n",
|
151 |
+
" !git config --global user.name \"Your Name\"\n",
|
152 |
+
"\n",
|
153 |
+
" ## Update Webui\n",
|
154 |
+
" if latest_webui:\n",
|
155 |
+
" %cd {webui_path}\n",
|
156 |
+
" !git restore .\n",
|
157 |
+
" !git pull -X theirs --rebase --autostash\n",
|
158 |
+
"\n",
|
159 |
+
" ## Update extensions\n",
|
160 |
+
" if latest_exstensions:\n",
|
161 |
+
" !find {webui_path}/extensions/ -mindepth 1 -maxdepth 1 -type d -exec sh -c 'cd \"$0\" && git reset --hard && git pull' {} \\;\n",
|
162 |
+
"\n",
|
163 |
+
" !cd {webui_path}/repositories/stable-diffusion-stability-ai && git restore .\n",
|
164 |
+
" del cap\n",
|
165 |
+
" print(f\"\\r✨ {action} Completed!\")\n",
|
166 |
+
"\n",
|
167 |
+
"\n",
|
168 |
+
"## Version switching\n",
|
169 |
+
"if commit_hash:\n",
|
170 |
+
" print('⏳ Time machine activation...', end=\"\", flush=True)\n",
|
171 |
+
" with capture.capture_output() as cap:\n",
|
172 |
+
" %cd {webui_path}\n",
|
173 |
+
" !git config --global user.email \"you@example.com\"\n",
|
174 |
+
" !git config --global user.name \"Your Name\"\n",
|
175 |
+
" !git reset --hard {commit_hash}\n",
|
176 |
+
" del cap\n",
|
177 |
+
" print(f\"\\r⌛️ The time machine has been activated! Current commit: \\033[34m{commit_hash}\\033[0m\")\n",
|
178 |
+
"\n",
|
179 |
+
"\n",
|
180 |
+
"## Downloading model and stuff | oh yeah~ I'm starting to misunderstand my own code ( almost my own ;3 )\n",
|
181 |
+
"print(\"📦 Downloading models and stuff...\", end='')\n",
|
182 |
+
"model_list = {\n",
|
183 |
+
" \"1.Anime (by Xpuct) + INP\": [\n",
|
184 |
+
" {\"url\": \"https://huggingface.co/XpucT/Anime/resolve/main/Anime_v1.safetensors\", \"name\": \"Anime.safetensors\"},\n",
|
185 |
+
" {\"url\": \"https://huggingface.co/XpucT/Anime/resolve/main/Anime_v1-inpainting.safetensors\", \"name\": \"Anime-inpainting.safetensors\"}\n",
|
186 |
+
" ],\n",
|
187 |
+
" \"2.Cetus-Mix [Anime] [V4] + INP\": [\n",
|
188 |
+
" {\"url\": \"https://civitai.com/api/download/models/130298\", \"name\": \"CetusMix_V4.safetensors\"},\n",
|
189 |
+
" {\"url\": \"https://civitai.com/api/download/models/139882\", \"name\": \"CetusMix_V4-inpainting.safetensors\"}\n",
|
190 |
+
" ],\n",
|
191 |
+
" \"3.Counterfeit [Anime] [V3] + INP\": [\n",
|
192 |
+
" {\"url\": \"https://civitai.com/api/download/models/125050\", \"name\": \"Counterfeit_V3.safetensors\"},\n",
|
193 |
+
" {\"url\": \"https://civitai.com/api/download/models/137911\", \"name\": \"Counterfeit_V3-inpainting.safetensors\"}\n",
|
194 |
+
" ],\n",
|
195 |
+
" \"4.CuteColor [Anime] [V3]\": [\n",
|
196 |
+
" {\"url\": \"https://civitai.com/api/download/models/138754\", \"name\": \"CuteColor_V3.safetensors\"}\n",
|
197 |
+
" ],\n",
|
198 |
+
" \"5.Dark-Sushi-Mix [Anime]\": [\n",
|
199 |
+
" {\"url\": \"https://civitai.com/api/download/models/101640\", \"name\": \"DarkSushiMix_2_5D.safetensors\"},\n",
|
200 |
+
" {\"url\": \"https://civitai.com/api/download/models/56071\", \"name\": \"DarkSushiMix_colorful.safetensors\"}\n",
|
201 |
+
" ],\n",
|
202 |
+
" \"6.Meina-Mix [Anime] [V11] + INP\": [\n",
|
203 |
+
" {\"url\": \"https://civitai.com/api/download/models/119057\", \"name\": \"MeinaMix_V11.safetensors\"},\n",
|
204 |
+
" {\"url\": \"https://civitai.com/api/download/models/120702\", \"name\": \"MeinaMix_V11-inpainting.safetensors\"}\n",
|
205 |
+
" ],\n",
|
206 |
+
" \"7.Mix-Pro [Anime] [V4] + INP\": [\n",
|
207 |
+
" {\"url\": \"https://civitai.com/api/download/models/125668\", \"name\": \"MixPro_V4.safetensors\"},\n",
|
208 |
+
" {\"url\": \"https://civitai.com/api/download/models/139878\", \"name\": \"MixPro_V4-inpainting.safetensors\"}\n",
|
209 |
+
" ],\n",
|
210 |
+
" \"8.Vela-Mix [Anime] [V2] [6GB]\": [ # 6GB - why so much...?\n",
|
211 |
+
" {\"url\": \"https://civitai.com/api/download/models/83548\", \"name\": \"VelaMix_2.safetensors\"}\n",
|
212 |
+
" ]\n",
|
213 |
+
"}\n",
|
214 |
+
"\n",
|
215 |
+
"vae_list = {\n",
|
216 |
+
" \"1.Anime.vae\": [{\"url\": \"https://civitai.com/api/download/models/131654\", \"name\": \"Anime.vae.safetensors\"}],\n",
|
217 |
+
" \"2.Anything.vae\": [{\"url\": \"https://huggingface.co/NoCrypt/resources/resolve/main/VAE/any.vae.safetensors\", \"name\": \"Anything.vae.safetensors\"}],\n",
|
218 |
+
" \"3.blessed2.vae\": [{\"url\": \"https://huggingface.co/NoCrypt/resources/resolve/main/VAE/blessed2.vae.safetensors\", \"name\": \"Blessed2.vae.safetensors\"}],\n",
|
219 |
+
" \"4.WD.vae\": [{\"url\": \"https://huggingface.co/NoCrypt/resources/resolve/main/VAE/wd.vae.safetensors\", \"name\": \"WD.vae.safetensors\"}]\n",
|
220 |
+
"}\n",
|
221 |
+
"\n",
|
222 |
+
"controlnet_list = {\n",
|
223 |
+
" \"1.canny\": [\n",
|
224 |
+
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_canny_fp16.safetensors\", \"name\": \"control_v11p_sd15_canny_fp16.safetensors\"},\n",
|
225 |
+
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_canny_fp16.yaml\", \"name\": \"control_v11p_sd15_canny_fp16.yaml\"}\n",
|
226 |
+
" ],\n",
|
227 |
+
" \"2.openpose\": [\n",
|
228 |
+
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_openpose_fp16.safetensors\", \"name\": \"control_v11p_sd15_openpose_fp16.safetensors\"},\n",
|
229 |
+
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_openpose_fp16.yaml\", \"name\": \"control_v11p_sd15_openpose_fp16.yaml\"}\n",
|
230 |
+
" ],\n",
|
231 |
+
" \"3.depth\": [\n",
|
232 |
+
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11f1p_sd15_depth_fp16.safetensors\", \"name\": \"control_v11f1p_sd15_depth_fp16.safetensors\"},\n",
|
233 |
+
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11f1p_sd15_depth_fp16.yaml\", \"name\": \"control_v11f1p_sd15_depth_fp16.yaml\"},\n",
|
234 |
+
" {\"url\": \"https://huggingface.co/NagisaNao/models/resolve/main/ControlNet_v11/control_v11p_sd15_depth_anything_fp16.safetensors\", \"name\": \"control_v11p_sd15_depth_anything_fp16.safetensors\"}\n",
|
235 |
+
" ],\n",
|
236 |
+
" \"4.normal_map\": [\n",
|
237 |
+
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_normalbae_fp16.safetensors\", \"name\": \"control_v11p_sd15_normalbae_fp16.safetensors\"},\n",
|
238 |
+
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_normalbae_fp16.yaml\", \"name\": \"control_v11p_sd15_normalbae_fp16.yaml\"}\n",
|
239 |
+
" ],\n",
|
240 |
+
" \"5.mlsd\": [\n",
|
241 |
+
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_mlsd_fp16.safetensors\", \"name\": \"control_v11p_sd15_mlsd_fp16.safetensors\"},\n",
|
242 |
+
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_mlsd_fp16.yaml\", \"name\": \"control_v11p_sd15_mlsd_fp16.yaml\"}\n",
|
243 |
+
" ],\n",
|
244 |
+
" \"6.lineart\": [\n",
|
245 |
+
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_lineart_fp16.safetensors\", \"name\": \"control_v11p_sd15_lineart_fp16.safetensors\"},\n",
|
246 |
+
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15s2_lineart_anime_fp16.safetensors\", \"name\": \"control_v11p_sd15s2_lineart_anime_fp16.safetensors\"},\n",
|
247 |
+
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_lineart_fp16.yaml\", \"name\": \"control_v11p_sd15_lineart_fp16.yaml\"},\n",
|
248 |
+
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15s2_lineart_anime_fp16.yaml\", \"name\": \"control_v11p_sd15s2_lineart_anime_fp16.yaml\"}\n",
|
249 |
+
" ],\n",
|
250 |
+
" \"7.soft_edge\": [\n",
|
251 |
+
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_softedge_fp16.safetensors\", \"name\": \"control_v11p_sd15_softedge_fp16.safetensors\"},\n",
|
252 |
+
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_softedge_fp16.yaml\", \"name\": \"control_v11p_sd15_softedge_fp16.yaml\"}\n",
|
253 |
+
" ],\n",
|
254 |
+
" \"8.scribble\": [\n",
|
255 |
+
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_scribble_fp16.safetensors\", \"name\": \"control_v11p_sd15_scribble_fp16.safetensors\"},\n",
|
256 |
+
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_scribble_fp16.yaml\", \"name\": \"control_v11p_sd15_scribble_fp16.yaml\"}\n",
|
257 |
+
" ],\n",
|
258 |
+
" \"9.segmentation\": [\n",
|
259 |
+
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_seg_fp16.safetensors\", \"name\": \"control_v11p_sd15_seg_fp16.safetensors\"},\n",
|
260 |
+
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_seg_fp16.yaml\", \"name\": \"control_v11p_sd15_seg_fp16.yaml\"}\n",
|
261 |
+
" ],\n",
|
262 |
+
" \"10.shuffle\": [\n",
|
263 |
+
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11e_sd15_shuffle_fp16.safetensors\", \"name\": \"control_v11e_sd15_shuffle_fp16.safetensors\"},\n",
|
264 |
+
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11e_sd15_shuffle_fp16.yaml\", \"name\": \"control_v11e_sd15_shuffle_fp16.yaml\"}\n",
|
265 |
+
" ],\n",
|
266 |
+
" \"11.tile\": [\n",
|
267 |
+
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11f1e_sd15_tile_fp16.safetensors\", \"name\": \"control_v11f1e_sd15_tile_fp16.safetensors\"},\n",
|
268 |
+
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11f1e_sd15_tile_fp16.yaml\", \"name\": \"control_v11f1e_sd15_tile_fp16.yaml\"}\n",
|
269 |
+
" ],\n",
|
270 |
+
" \"12.inpaint\": [\n",
|
271 |
+
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_inpaint_fp16.safetensors\", \"name\": \"control_v11p_sd15_inpaint_fp16.safetensors\"},\n",
|
272 |
+
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_inpaint_fp16.yaml\", \"name\": \"control_v11p_sd15_inpaint_fp16.yaml\"}\n",
|
273 |
+
" ],\n",
|
274 |
+
" \"13.instruct_p2p\": [\n",
|
275 |
+
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11e_sd15_ip2p_fp16.safetensors\", \"name\": \"control_v11e_sd15_ip2p_fp16.safetensors\"},\n",
|
276 |
+
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11e_sd15_ip2p_fp16.yaml\", \"name\": \"control_v11e_sd15_ip2p_fp16.yaml\"}\n",
|
277 |
+
" ]\n",
|
278 |
+
"}\n",
|
279 |
+
"\n",
|
280 |
+
"extension_repo = []\n",
|
281 |
+
"prefixes = [\n",
|
282 |
+
" \"model:\",\n",
|
283 |
+
" \"vae:\",\n",
|
284 |
+
" \"lora:\",\n",
|
285 |
+
" \"embeddings:\",\n",
|
286 |
+
" \"extensions:\"\n",
|
287 |
+
"]\n",
|
288 |
+
"\n",
|
289 |
+
"url = \"\"\n",
|
290 |
+
"hf_token = optional_huggingface_token if optional_huggingface_token else \"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\"\n",
|
291 |
+
"user_header = f\"\\\"Authorization: Bearer {hf_token}\\\"\"\n",
|
292 |
+
"\n",
|
293 |
+
"def handle_manual(url):\n",
|
294 |
+
" original_url = url\n",
|
295 |
+
" url = url.split(':', 1)[1]\n",
|
296 |
+
" file_name = re.search(r'\\[(.*?)\\]', url)\n",
|
297 |
+
" file_name = file_name.group(1) if file_name else None\n",
|
298 |
+
" if file_name:\n",
|
299 |
+
" url = re.sub(r'\\[.*?\\]', '', url)\n",
|
300 |
+
"\n",
|
301 |
+
" dir_mapping = {\"model\": models_dir, \"vae\": vaes_dir, \"lora\": loras_dir, \"embeddings\": embeddings_dir, \"extensions\": None}\n",
|
302 |
+
"\n",
|
303 |
+
" for prefix, dir in dir_mapping.items():\n",
|
304 |
+
" if original_url.startswith(f\"{prefix}:\"):\n",
|
305 |
+
" if prefix != \"extensions\":\n",
|
306 |
+
" manual_download(url, dir, file_name=file_name)\n",
|
307 |
+
" else:\n",
|
308 |
+
" extension_repo.append((url, file_name))\n",
|
309 |
+
"\n",
|
310 |
+
"def manual_download(url, dst_dir, file_name):\n",
|
311 |
+
" basename = url.split(\"/\")[-1] if file_name is None else file_name\n",
|
312 |
+
"\n",
|
313 |
+
" # -- GDrive --\n",
|
314 |
+
" if 'drive.google' in url:\n",
|
315 |
+
" if 'folders' in url:\n",
|
316 |
+
" !gdown --folder \"{url}\" -O {dst_dir} --fuzzy -c\n",
|
317 |
+
" else:\n",
|
318 |
+
" !gdown \"{url}\" -O {dst_dir} --fuzzy -c\n",
|
319 |
+
" # -- Huggin Face --\n",
|
320 |
+
" elif 'huggingface' in url:\n",
|
321 |
+
" if '/blob/' in url:\n",
|
322 |
+
" url = url.replace('/blob/', '/resolve/')\n",
|
323 |
+
" if file_name:\n",
|
324 |
+
" !aria2c --optimize-concurrent-downloads --console-log-level=error --summary-interval=10 --header={user_header} -c -j5 -x16 -s16 -k1M -d {dst_dir} -o {basename} {url}\n",
|
325 |
+
" else:\n",
|
326 |
+
" parsed_link = '\\n{}\\n\\tout={}'.format(url, unquote(url.split('/')[-1]))\n",
|
327 |
+
" !echo -e \"{parsed_link}\" | aria2c --header={user_header} --console-log-level=error --summary-interval=10 -i- -j5 -x16 -s16 -k1M -c -d \"{dst_dir}\" -o {basename}\n",
|
328 |
+
" # -- Other --\n",
|
329 |
+
" elif 'http' in url or 'magnet' in url:\n",
|
330 |
+
" if file_name:\n",
|
331 |
+
" !aria2c --optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -j5 -x16 -s16 -k1M -c -d {dst_dir} -o {file_name} {url}\n",
|
332 |
+
" else:\n",
|
333 |
+
" parsed_link = '\"{}\"'.format(url)\n",
|
334 |
+
" !aria2c --optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -j5 -x16 -s16 -k1M -c -d {dst_dir} -Z {parsed_link}\n",
|
335 |
+
"\n",
|
336 |
+
"def download(url):\n",
|
337 |
+
" links_and_paths = url.split(',')\n",
|
338 |
+
" !mkdir -p {models_dir} {vaes_dir} {embeddings_dir} {loras_dir} {control_dir}\n",
|
339 |
+
"\n",
|
340 |
+
" for link_or_path in links_and_paths:\n",
|
341 |
+
" link_or_path = link_or_path.strip()\n",
|
342 |
+
" if not link_or_path:\n",
|
343 |
+
" continue\n",
|
344 |
+
"\n",
|
345 |
+
" if any(link_or_path.startswith(prefix.lower()) for prefix in prefixes):\n",
|
346 |
+
" handle_manual(link_or_path)\n",
|
347 |
+
" continue\n",
|
348 |
+
"\n",
|
349 |
+
" url, dst_dir, file_name = link_or_path.split()\n",
|
350 |
+
" manual_download(url, dst_dir, file_name)\n",
|
351 |
+
"\n",
|
352 |
+
"submodels = []\n",
|
353 |
+
"\n",
|
354 |
+
"def add_submodels(selection, num_selection, model_dict, dst_dir):\n",
|
355 |
+
" if selection == \"none\":\n",
|
356 |
+
" return []\n",
|
357 |
+
" if selection == \"ALL\":\n",
|
358 |
+
" all_models = []\n",
|
359 |
+
" for models in model_dict.values():\n",
|
360 |
+
" all_models.extend(models)\n",
|
361 |
+
" selected_models = all_models\n",
|
362 |
+
" else:\n",
|
363 |
+
" selected_models = model_dict[selection]\n",
|
364 |
+
" selected_nums = map(int, num_selection.replace(',', '').split())\n",
|
365 |
+
"\n",
|
366 |
+
" for num in selected_nums:\n",
|
367 |
+
" if 1 <= num <= len(model_dict):\n",
|
368 |
+
" name = list(model_dict)[num - 1]\n",
|
369 |
+
" selected_models.extend(model_dict[name])\n",
|
370 |
+
"\n",
|
371 |
+
" unique_models = list({model['name']: model for model in selected_models}.values())\n",
|
372 |
+
"\n",
|
373 |
+
" for model in unique_models:\n",
|
374 |
+
" model['dst_dir'] = dst_dir\n",
|
375 |
+
"\n",
|
376 |
+
" return unique_models\n",
|
377 |
+
"\n",
|
378 |
+
"submodels += add_submodels(Model, Model_Num, model_list, models_dir) # model\n",
|
379 |
+
"submodels += add_submodels(Vae, Vae_Num, vae_list, vaes_dir) # vae\n",
|
380 |
+
"submodels += add_submodels(controlnet, \"\" if controlnet == \"ALL\" else controlnet_Num, controlnet_list, control_dir) # controlnet\n",
|
381 |
+
"\n",
|
382 |
+
"for submodel in submodels:\n",
|
383 |
+
" if not Inpainting_Model and \"inpainting\" in submodel['name']:\n",
|
384 |
+
" continue\n",
|
385 |
+
"\n",
|
386 |
+
" url += f\"{submodel['url']} {submodel['dst_dir']} {submodel['name']}, \"\n",
|
387 |
+
"\n",
|
388 |
+
"urls = [Model_url, Vae_url, LoRA_url, Embedding_url, Extensions_url]\n",
|
389 |
+
"\n",
|
390 |
+
"for i, prefix in enumerate(prefixes):\n",
|
391 |
+
" if urls[i]:\n",
|
392 |
+
" prefixed_urls = [f\"{prefix}{u}\" for u in urls[i].replace(',', '').split()]\n",
|
393 |
+
" if prefixed_urls:\n",
|
394 |
+
" url += \", \".join(prefixed_urls) + \", \"\n",
|
395 |
+
"\n",
|
396 |
+
"if detailed_download == \"on\":\n",
|
397 |
+
" print(\"\\n\\n\\033[33m# ====== Detailed Download ====== #\\n\\033[0m\")\n",
|
398 |
+
" download(url)\n",
|
399 |
+
" print(\"\\n\\033[33m# =============================== #\\n\\033[0m\")\n",
|
400 |
+
"else:\n",
|
401 |
+
" with capture.capture_output() as cap:\n",
|
402 |
+
" download(url)\n",
|
403 |
+
" del cap\n",
|
404 |
+
"\n",
|
405 |
+
"print(\"\\r🏁 Download Complete!\" + \" \"*15)\n",
|
406 |
+
"\n",
|
407 |
+
"\n",
|
408 |
+
"# Cleaning shit after downloading...\n",
|
409 |
+
"!find \\( -name \".ipynb_checkpoints\" -o -name \".aria2\" \\) -type d -exec rm -r {} \\; >/dev/null 2>&1\n",
|
410 |
+
"\n",
|
411 |
+
"\n",
|
412 |
+
"## Install of Custom extensions\n",
|
413 |
+
"if len(extension_repo) > 0:\n",
|
414 |
+
" print(\"✨ Installing custom extensions...\", end='', flush=True)\n",
|
415 |
+
" with capture.capture_output() as cap:\n",
|
416 |
+
" for repo, repo_name in extension_repo:\n",
|
417 |
+
" if not repo_name:\n",
|
418 |
+
" repo_name = repo.split('/')[-1]\n",
|
419 |
+
" !cd {extensions_dir} \\\n",
|
420 |
+
" && git clone {repo} {repo_name} \\\n",
|
421 |
+
" && cd {repo_name} \\\n",
|
422 |
+
" && git fetch\n",
|
423 |
+
" del cap\n",
|
424 |
+
" print(f\"\\r📦 Installed '{len(extension_repo)}', Custom extensions!\")\n",
|
425 |
+
"\n",
|
426 |
+
"\n",
|
427 |
+
"## List Models and stuff\n",
|
428 |
+
"if detailed_download == \"off\":\n",
|
429 |
+
" print(\"\\n\\n\\033[33mIf you don't see any downloaded files, enable the 'Detailed Downloads' feature in the widget.\")\n",
|
430 |
+
"\n",
|
431 |
+
"if any(not file.endswith('.txt') for file in os.listdir(models_dir)):\n",
|
432 |
+
" print(\"\\n\\033[33m➤ Models\\033[0m\")\n",
|
433 |
+
" !find {models_dir}/ -mindepth 1 ! -name '*.txt' -printf '%f\\n'\n",
|
434 |
+
"if any(not file.endswith('.txt') for file in os.listdir(vaes_dir)):\n",
|
435 |
+
" print(\"\\n\\033[33m➤ VAEs\\033[0m\")\n",
|
436 |
+
" !find {vaes_dir}/ -mindepth 1 ! -name '*.txt' -printf '%f\\n'\n",
|
437 |
+
"if any(not file.endswith('.txt') and not os.path.isdir(os.path.join(embeddings_dir, file)) for file in os.listdir(embeddings_dir)):\n",
|
438 |
+
" print(\"\\n\\033[33m➤ Embeddings\\033[0m\")\n",
|
439 |
+
" !find {embeddings_dir}/ -mindepth 1 -maxdepth 1 \\( -name '*.pt' -or -name '*.safetensors' \\) -printf '%f\\n'\n",
|
440 |
+
"if any(not file.endswith('.txt') for file in os.listdir(loras_dir)):\n",
|
441 |
+
" print(\"\\n\\033[33m➤ LoRAs\\033[0m\")\n",
|
442 |
+
" !find {loras_dir}/ -mindepth 1 ! -name '*.keep' -printf '%f\\n'\n",
|
443 |
+
"print(f\"\\n\\033[33m➤ Extensions\\033[0m\")\n",
|
444 |
+
"!find {extensions_dir}/ -mindepth 1 -maxdepth 1 ! -name '*.txt' -printf '%f\\n'\n",
|
445 |
+
"if any(not file.endswith(('.txt', '.yaml')) for file in os.listdir(control_dir)):\n",
|
446 |
+
" print(\"\\n\\033[33m➤ ControlNet\\033[0m\")\n",
|
447 |
+
" !find {control_dir}/ -mindepth 1 ! -name '*.yaml' -printf '%f\\n' | sed 's/^[^_]*_[^_]*_[^_]*_\\(.*\\)_fp16\\.safetensors$/\\1/'"
|
448 |
+
],
|
449 |
+
"metadata": {
|
450 |
+
"id": "2lJmbqrs3Mu8"
|
451 |
+
},
|
452 |
+
"execution_count": null,
|
453 |
+
"outputs": []
|
454 |
+
}
|
455 |
+
]
|
456 |
+
}
|
files_cells/notebooks/en/launch_en.ipynb
ADDED
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
"execution_count": null,
|
20 |
+
"metadata": {
|
21 |
+
"id": "JKTCrY9LU7Oq"
|
22 |
+
},
|
23 |
+
"outputs": [],
|
24 |
+
"source": [
|
25 |
+
"import os\n",
|
26 |
+
"import re\n",
|
27 |
+
"import sys\n",
|
28 |
+
"import time\n",
|
29 |
+
"import json\n",
|
30 |
+
"import requests\n",
|
31 |
+
"import cloudpickle as pickle\n",
|
32 |
+
"from datetime import timedelta\n",
|
33 |
+
"\n",
|
34 |
+
"# ================= DETECT ENV =================\n",
|
35 |
+
"def detect_environment():\n",
|
36 |
+
" environments = {\n",
|
37 |
+
" 'COLAB_GPU': ('Google Colab', \"/content\"),\n",
|
38 |
+
" 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\"),\n",
|
39 |
+
" 'SAGEMAKER_INTERNAL_IMAGE_URI': ('SageMaker Studio Lab', \"/home/studio-lab-user/content\")\n",
|
40 |
+
" }\n",
|
41 |
+
"\n",
|
42 |
+
" for env_var, (environment, path) in environments.items():\n",
|
43 |
+
" if env_var in os.environ:\n",
|
44 |
+
" return environment, path\n",
|
45 |
+
"\n",
|
46 |
+
" sys.exit(\"\\033[31mError: an unsupported runtime environment was detected.\\n\\033[34mSupported environments:\\033[0m Google Colab, Kaggle, Sagemaker Studio Lab\")\n",
|
47 |
+
"\n",
|
48 |
+
"env, root_path = detect_environment()\n",
|
49 |
+
"webui_path = f\"{root_path}/sdw\"\n",
|
50 |
+
"# ----------------------------------------------\n",
|
51 |
+
"\n",
|
52 |
+
"def load_settings():\n",
|
53 |
+
" SETTINGS_FILE = f'{root_path}/settings.json'\n",
|
54 |
+
" if os.path.exists(SETTINGS_FILE):\n",
|
55 |
+
" with open(SETTINGS_FILE, 'r') as f:\n",
|
56 |
+
" settings = json.load(f)\n",
|
57 |
+
" return settings\n",
|
58 |
+
"\n",
|
59 |
+
"settings = load_settings()\n",
|
60 |
+
"ngrok_token = settings['ngrok_token']\n",
|
61 |
+
"commandline_arguments = settings['commandline_arguments']\n",
|
62 |
+
"\n",
|
63 |
+
"# ======================== TUNNEL ========================\n",
|
64 |
+
"password = \"x1101\"\n",
|
65 |
+
"def get_public_ip(version='ipv4'):\n",
|
66 |
+
" try:\n",
|
67 |
+
" url = f'https://api64.ipify.org?format=json&{version}=true'\n",
|
68 |
+
" response = requests.get(url)\n",
|
69 |
+
" data = response.json()\n",
|
70 |
+
" public_ip = data['ip']\n",
|
71 |
+
" return public_ip\n",
|
72 |
+
" except Exception as e:\n",
|
73 |
+
" print(f\"Error getting public {version} address:\", e)\n",
|
74 |
+
"\n",
|
75 |
+
"public_ipv4 = get_public_ip(version='ipv4')\n",
|
76 |
+
"\n",
|
77 |
+
"tunnel_class = pickle.load(open(f\"{root_path}/new_tunnel\", \"rb\"), encoding=\"utf-8\")\n",
|
78 |
+
"tunnel_port= 1101\n",
|
79 |
+
"tunnel = tunnel_class(tunnel_port)\n",
|
80 |
+
"tunnel.add_tunnel(command=\"cl tunnel --url localhost:{port}\", name=\"cl\", pattern=re.compile(r\"[\\w-]+\\.trycloudflare\\.com\"))\n",
|
81 |
+
"tunnel.add_tunnel(command=\"lt --port {port}\", name=\"lt\", pattern=re.compile(r\"[\\w-]+\\.loca\\.lt\"), note=\"Password : \" + \"\\033[32m\" + public_ipv4 + \"\\033[0m\" + \" rerun cell if 404 error.\")\n",
|
82 |
+
"\n",
|
83 |
+
"# ======================== TUNNEL ========================\n",
|
84 |
+
"\n",
|
85 |
+
"# fixing path...\n",
|
86 |
+
"!sed -i 's#\\/home\\/studio-lab-user\\/content#{root_path}#g' {webui_path}/config.json\n",
|
87 |
+
"\n",
|
88 |
+
"with tunnel:\n",
|
89 |
+
" !#python -m http.server 1101\n",
|
90 |
+
" %cd {webui_path}\n",
|
91 |
+
"\n",
|
92 |
+
" if ngrok_token:\n",
|
93 |
+
" commandline_arguments += ' --ngrok ' + ngrok_token\n",
|
94 |
+
" commandline_arguments += f\" --port=1101 \" # --encrypt-pass={password}\n",
|
95 |
+
"\n",
|
96 |
+
" !COMMANDLINE_ARGS=\"{commandline_arguments}\" python launch.py\n",
|
97 |
+
"\n",
|
98 |
+
" start_colab = float(open(f'{webui_path}/static/colabTimer.txt', 'r').read())\n",
|
99 |
+
" time_since_start = str(timedelta(seconds=time.time()-start_colab)).split('.')[0]\n",
|
100 |
+
" print(f\"\\n⌚️ \\033[0mYou have been conducting this session for - \\033[33m{time_since_start}\\033[0m\\n\\n\")"
|
101 |
+
]
|
102 |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
},
|
16 |
+
"cells": [
|
17 |
+
{
|
18 |
+
"cell_type": "code",
|
19 |
+
"source": [
|
20 |
+
"import os\n",
|
21 |
+
"import sys\n",
|
22 |
+
"import json\n",
|
23 |
+
"import ipywidgets as widgets\n",
|
24 |
+
"from ipywidgets import widgets, Layout, Label, Button, VBox, HBox\n",
|
25 |
+
"from IPython.display import display, HTML, Javascript, clear_output\n",
|
26 |
+
"\n",
|
27 |
+
"\n",
|
28 |
+
"# ================= DETECT ENV =================\n",
|
29 |
+
"def detect_environment():\n",
|
30 |
+
" environments = {\n",
|
31 |
+
" 'COLAB_GPU': ('Google Colab', \"/content\"),\n",
|
32 |
+
" 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\"),\n",
|
33 |
+
" 'SAGEMAKER_INTERNAL_IMAGE_URI': ('SageMaker Studio Lab', \"/home/studio-lab-user/content\")\n",
|
34 |
+
" }\n",
|
35 |
+
"\n",
|
36 |
+
" for env_var, (environment, path) in environments.items():\n",
|
37 |
+
" if env_var in os.environ:\n",
|
38 |
+
" return environment, path\n",
|
39 |
+
"\n",
|
40 |
+
" sys.exit(\"\\033[31mError: an unsupported runtime environment was detected.\\n\\033[34mSupported environments:\\033[0m Google Colab, Kaggle, Sagemaker Studio Lab\")\n",
|
41 |
+
"\n",
|
42 |
+
"env, root_path = detect_environment()\n",
|
43 |
+
"webui_path = f\"{root_path}/sdw\"\n",
|
44 |
+
"# ----------------------------------------------\n",
|
45 |
+
"\n",
|
46 |
+
"!mkdir -p {root_path}\n",
|
47 |
+
"\n",
|
48 |
+
"\n",
|
49 |
+
"style = {'description_width': 'initial'}\n",
|
50 |
+
"layout = widgets.Layout(min_width='1047px')\n",
|
51 |
+
"SETTINGS_FILE = f'{root_path}/settings.json'\n",
|
52 |
+
"\n",
|
53 |
+
"\n",
|
54 |
+
"# ==================== CSS JS ====================\n",
|
55 |
+
"# --- CSS ---\n",
|
56 |
+
"CSS = '''\n",
|
57 |
+
"<style>\n",
|
58 |
+
"/* General Styles */\n",
|
59 |
+
".header {\n",
|
60 |
+
" font-family: cursive;\n",
|
61 |
+
" font-size: 20px;\n",
|
62 |
+
" font-weight: bold;\n",
|
63 |
+
" color: #ff8cee;\n",
|
64 |
+
" margin-bottom: 15px;\n",
|
65 |
+
" user-select: none;\n",
|
66 |
+
" cursor: default;\n",
|
67 |
+
" display: inline-block;\n",
|
68 |
+
"}\n",
|
69 |
+
"\n",
|
70 |
+
"hr {\n",
|
71 |
+
" border-color: grey;\n",
|
72 |
+
" background-color: grey;\n",
|
73 |
+
" opacity: 0.25;\n",
|
74 |
+
"}\n",
|
75 |
+
"\n",
|
76 |
+
"\n",
|
77 |
+
"/* Container style */\n",
|
78 |
+
"\n",
|
79 |
+
".container {\n",
|
80 |
+
" position: relative;\n",
|
81 |
+
" background-color: #232323;\n",
|
82 |
+
" width: 1080px;\n",
|
83 |
+
" padding: 10px 15px;\n",
|
84 |
+
" border-radius: 15px;\n",
|
85 |
+
" box-shadow: 0 0 50px rgba(0, 0, 0, 0.3);\n",
|
86 |
+
" margin-bottom: 5px;\n",
|
87 |
+
" overflow: visible;\n",
|
88 |
+
"}\n",
|
89 |
+
"\n",
|
90 |
+
".container::after {\n",
|
91 |
+
" position: absolute;\n",
|
92 |
+
" top: 5px;\n",
|
93 |
+
" right: 10px;\n",
|
94 |
+
" content: \"ANXETY\";\n",
|
95 |
+
" font-weight: bold;\n",
|
96 |
+
" font-size: 24px;\n",
|
97 |
+
" color: rgba(0, 0, 0, 0.15);\n",
|
98 |
+
"}\n",
|
99 |
+
"\n",
|
100 |
+
".container_custom_downlad {\n",
|
101 |
+
" height: 55px;\n",
|
102 |
+
" overflow: hidden;\n",
|
103 |
+
" transition: all 0.5s;\n",
|
104 |
+
"}\n",
|
105 |
+
"\n",
|
106 |
+
".container_custom_downlad.expanded {\n",
|
107 |
+
" height: 240px;\n",
|
108 |
+
"}\n",
|
109 |
+
"\n",
|
110 |
+
"\n",
|
111 |
+
"/* Element text style */\n",
|
112 |
+
"\n",
|
113 |
+
".widget-html,\n",
|
114 |
+
".widget-button,\n",
|
115 |
+
".widget-text label,\n",
|
116 |
+
".widget-checkbox label,\n",
|
117 |
+
".widget-dropdown label,\n",
|
118 |
+
".widget-dropdown select,\n",
|
119 |
+
".widget-text input[type=\"text\"] {\n",
|
120 |
+
" font-family: cursive;\n",
|
121 |
+
" font-size: 14px;\n",
|
122 |
+
" color: white !important;\n",
|
123 |
+
" user-select: none;\n",
|
124 |
+
"}\n",
|
125 |
+
"\n",
|
126 |
+
".widget-text input[type=\"text\"]::placeholder {\n",
|
127 |
+
" color: grey;\n",
|
128 |
+
"}\n",
|
129 |
+
"\n",
|
130 |
+
"\n",
|
131 |
+
"/* Input field styles */\n",
|
132 |
+
"\n",
|
133 |
+
".widget-dropdown select,\n",
|
134 |
+
".widget-text input[type=\"text\"] {\n",
|
135 |
+
" height: 30px;\n",
|
136 |
+
" background-color: #1c1c1c;\n",
|
137 |
+
" border: 1px solid #262626;\n",
|
138 |
+
" border-radius: 10px;\n",
|
139 |
+
" box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);\n",
|
140 |
+
" transition: all 0.3s ease-in-out;\n",
|
141 |
+
"}\n",
|
142 |
+
"\n",
|
143 |
+
".widget-dropdown select:focus,\n",
|
144 |
+
".widget-text input[type=\"text\"]:focus {\n",
|
145 |
+
" border-color: #006ee5;\n",
|
146 |
+
"}\n",
|
147 |
+
"\n",
|
148 |
+
".widget-dropdown select:hover,\n",
|
149 |
+
".widget-text input[type=\"text\"]:hover {\n",
|
150 |
+
" transform: scale(1.003);\n",
|
151 |
+
" background-color: #262626;\n",
|
152 |
+
" box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);\n",
|
153 |
+
"}\n",
|
154 |
+
"\n",
|
155 |
+
"\n",
|
156 |
+
"/* Button styles */\n",
|
157 |
+
"\n",
|
158 |
+
".button_save {\n",
|
159 |
+
" font-size: 15px;\n",
|
160 |
+
" font-weight: bold;\n",
|
161 |
+
" width: 120px;\n",
|
162 |
+
" height: 35px;\n",
|
163 |
+
" border-radius: 15px;\n",
|
164 |
+
" background-image: radial-gradient(circle at top left, purple 10%, violet 90%);\n",
|
165 |
+
" background-size: 200% 200%;\n",
|
166 |
+
" background-position: left bottom;\n",
|
167 |
+
" transition: background 0.5s ease-in-out, transform 0.3s ease;\n",
|
168 |
+
"}\n",
|
169 |
+
"\n",
|
170 |
+
".button_save:hover {\n",
|
171 |
+
" cursor: pointer;\n",
|
172 |
+
" background-image: radial-gradient(circle at top left, purple 10%, #93ac47 90%);\n",
|
173 |
+
" background-size: 200% 200%;\n",
|
174 |
+
" background-position: right bottom;\n",
|
175 |
+
" transform: translateY(1px);\n",
|
176 |
+
"}\n",
|
177 |
+
"\n",
|
178 |
+
".button_ngrok {\n",
|
179 |
+
" font-size: 12px;\n",
|
180 |
+
" height: 30px;\n",
|
181 |
+
" border-radius: 10px;\n",
|
182 |
+
" padding: 1px 12px;\n",
|
183 |
+
" background-image: radial-gradient(circle at top left, purple 10%, violet 90%);\n",
|
184 |
+
" background-size: 200% 200%;\n",
|
185 |
+
" background-position: left bottom;\n",
|
186 |
+
" transition: background 0.5s ease-in-out, transform 0.3s ease;\n",
|
187 |
+
" white-space: nowrap;\n",
|
188 |
+
"}\n",
|
189 |
+
"\n",
|
190 |
+
".button_ngrok:hover {\n",
|
191 |
+
" cursor: pointer;\n",
|
192 |
+
" background-image: radial-gradient(circle at top left, purple 10%, #e2a9a8 90%);\n",
|
193 |
+
" background-size: 200% 200%;\n",
|
194 |
+
" background-position: right bottom;\n",
|
195 |
+
" transform: translateY(1px);\n",
|
196 |
+
"}\n",
|
197 |
+
"\n",
|
198 |
+
".button_save:active,\n",
|
199 |
+
".button_ngrok:active {\n",
|
200 |
+
" filter: brightness(0.75);\n",
|
201 |
+
"}\n",
|
202 |
+
"\n",
|
203 |
+
"\n",
|
204 |
+
"/* Popup style of `FAQ` window */\n",
|
205 |
+
"\n",
|
206 |
+
".info {\n",
|
207 |
+
" position: absolute;\n",
|
208 |
+
" top: -5px;\n",
|
209 |
+
" right: 95px;\n",
|
210 |
+
" color: grey;\n",
|
211 |
+
" font-family: cursive;\n",
|
212 |
+
" font-size: 14px;\n",
|
213 |
+
" font-weight: normal;\n",
|
214 |
+
" user-select: none;\n",
|
215 |
+
" pointer-events: none;\n",
|
216 |
+
" opacity: 0;\n",
|
217 |
+
" transition: opacity 0.3s ease-in-out;\n",
|
218 |
+
" display: inline-block;\n",
|
219 |
+
"}\n",
|
220 |
+
"\n",
|
221 |
+
".popup {\n",
|
222 |
+
" position: absolute;\n",
|
223 |
+
" top: 120px;\n",
|
224 |
+
" z-index: 999;\n",
|
225 |
+
" width: auto;\n",
|
226 |
+
" padding: 10px;\n",
|
227 |
+
" text-align: center;\n",
|
228 |
+
" background-color: rgba(255, 255, 255, 0.05);\n",
|
229 |
+
" backdrop-filter: blur(20px);\n",
|
230 |
+
" border: 1px solid rgba(255, 255, 255, 0.45);\n",
|
231 |
+
" border-radius: 8px;\n",
|
232 |
+
" box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);\n",
|
233 |
+
" opacity: 0;\n",
|
234 |
+
" color: #fff;\n",
|
235 |
+
" font-size: 16px;\n",
|
236 |
+
" font-family: cursive;\n",
|
237 |
+
" user-select: none;\n",
|
238 |
+
" cursor: default;\n",
|
239 |
+
" pointer-events: none;\n",
|
240 |
+
" transform: rotate(-5deg);\n",
|
241 |
+
" transition: top 0.3s ease-in-out, opacity 0.3s ease-in-out, transform 0.3s ease-in-out;\n",
|
242 |
+
"}\n",
|
243 |
+
"\n",
|
244 |
+
".sample {\n",
|
245 |
+
" display: inline-block;\n",
|
246 |
+
" margin-top: 25px;\n",
|
247 |
+
" padding: 10px 100px;\n",
|
248 |
+
" background-color: rgba(255, 255, 255, 0.2);\n",
|
249 |
+
" color: #c6e2ff;\n",
|
250 |
+
" border: 2px solid rgba(255, 255, 255, 0.2);\n",
|
251 |
+
" border-radius: 8px;\n",
|
252 |
+
" box-shadow: 0 0 10px rgba(255, 255, 255, 0.2), inset 0 0 25px rgba(255, 255, 255, 0.2);\n",
|
253 |
+
"}\n",
|
254 |
+
"\n",
|
255 |
+
".info.showed {\n",
|
256 |
+
" opacity: 1;\n",
|
257 |
+
" pointer-events: auto;\n",
|
258 |
+
"}\n",
|
259 |
+
"\n",
|
260 |
+
".info:hover + .popup {\n",
|
261 |
+
" top: 35px;\n",
|
262 |
+
" opacity: 1;\n",
|
263 |
+
" pointer-events: initial;\n",
|
264 |
+
" transform: rotate(0deg);\n",
|
265 |
+
"}\n",
|
266 |
+
"\n",
|
267 |
+
"\n",
|
268 |
+
"/* Animation of elements */\n",
|
269 |
+
"\n",
|
270 |
+
".container,\n",
|
271 |
+
".button_save {\n",
|
272 |
+
" animation-name: showedWidgets;\n",
|
273 |
+
" animation-duration: 1s;\n",
|
274 |
+
"}\n",
|
275 |
+
"\n",
|
276 |
+
"@keyframes showedWidgets {\n",
|
277 |
+
" 0% {\n",
|
278 |
+
" transform: translate3d(-65%, 15%, 0) scale(0) rotate(15deg);\n",
|
279 |
+
" filter: blur(25px) grayscale(1) brightness(0.3);\n",
|
280 |
+
" opacity: 0;\n",
|
281 |
+
" }\n",
|
282 |
+
" 100% {\n",
|
283 |
+
" transform: translate3d(0, 0, 0) scale(1) rotate(0deg);\n",
|
284 |
+
" filter: blur(0) grayscale(0) brightness(1);\n",
|
285 |
+
" opacity: 1;\n",
|
286 |
+
" }\n",
|
287 |
+
"}\n",
|
288 |
+
"</style>\n",
|
289 |
+
"\n",
|
290 |
+
"<!-- TOGGLE 'CustomDL' SCRIPT -->\n",
|
291 |
+
"<script>\n",
|
292 |
+
"function toggleContainer() {\n",
|
293 |
+
" let downloadContainer = document.querySelector('.container_custom_downlad');\n",
|
294 |
+
" let info = document.querySelector('.info');\n",
|
295 |
+
"\n",
|
296 |
+
" downloadContainer.classList.toggle('expanded');\n",
|
297 |
+
" info.classList.toggle('showed');\n",
|
298 |
+
"}\n",
|
299 |
+
"</script>\n",
|
300 |
+
"'''\n",
|
301 |
+
"\n",
|
302 |
+
"display(HTML(CSS))\n",
|
303 |
+
"# ==================== CSS JS ====================\n",
|
304 |
+
"\n",
|
305 |
+
"\n",
|
306 |
+
"# ==================== WIDGETS ====================\n",
|
307 |
+
"# --- MODEL ---\n",
|
308 |
+
"model_header = widgets.HTML('<div class=\"header\">Model Selection<div>')\n",
|
309 |
+
"model_options = ['none',\n",
|
310 |
+
" '1.Anime (by Xpuct) + INP',\n",
|
311 |
+
" '2.Cetus-Mix [Anime] [V4] + INP',\n",
|
312 |
+
" '3.Counterfeit [Anime] [V3] + INP',\n",
|
313 |
+
" '4.CuteColor [Anime] [V3]',\n",
|
314 |
+
" '5.Dark-Sushi-Mix [Anime]',\n",
|
315 |
+
" '6.Meina-Mix [Anime] [V11] + INP',\n",
|
316 |
+
" '7.Mix-Pro [Anime] [V4] + INP',\n",
|
317 |
+
" '8.Vela-Mix [Anime] [V2] [6GB]']\n",
|
318 |
+
"# ---\n",
|
319 |
+
"Model_widget = widgets.Dropdown(options=model_options, value='3.Counterfeit [Anime] [V3] + INP', description='Model:', style=style, layout=layout)\n",
|
320 |
+
"Model_Num_widget = widgets.Text(description='Model Number:', placeholder='Enter the model numbers to be downloaded using comma/space.', style=style, layout=layout)\n",
|
321 |
+
"Inpainting_Model_widget = widgets.Checkbox(value=False, description='Inpainting Models', style=style)\n",
|
322 |
+
"\n",
|
323 |
+
"display(widgets.VBox([model_header, Model_widget, Model_Num_widget, Inpainting_Model_widget]).add_class(\"container\"))\n",
|
324 |
+
"\n",
|
325 |
+
"# --- VAE ---\n",
|
326 |
+
"vae_header = widgets.HTML('<div class=\"header\" >VAE Selection</div>')\n",
|
327 |
+
"vae_options = ['none',\n",
|
328 |
+
" '1.Anime.vae',\n",
|
329 |
+
" '2.Anything.vae',\n",
|
330 |
+
" '3.blessed2.vae',\n",
|
331 |
+
" '4.WD.vae']\n",
|
332 |
+
"Vae_widget = widgets.Dropdown(options=vae_options, value='1.Anime.vae', description='Vae:', style=style, layout=layout)\n",
|
333 |
+
"Vae_Num_widget = widgets.Text(description='Vae number:', placeholder='Enter the vae numbers to be downloaded using comma/space.', style=style, layout=layout)\n",
|
334 |
+
"\n",
|
335 |
+
"display(widgets.VBox([vae_header, Vae_widget, Vae_Num_widget]).add_class(\"container\"))\n",
|
336 |
+
"\n",
|
337 |
+
"# --- ADDITIONAL ---\n",
|
338 |
+
"additional_header = widgets.HTML('<div class=\"header\">Additional</div>')\n",
|
339 |
+
"latest_webui_widget = widgets.Checkbox(value=True, description='Update WebUI', style=style)\n",
|
340 |
+
"latest_exstensions_widget = widgets.Checkbox(value=True, description='Update Extensions', style=style)\n",
|
341 |
+
"detailed_download_widget = widgets.Dropdown(options=['off', 'on'], value='off', description='Detailed Download:', style=style)\n",
|
342 |
+
"latest_changes_widget = HBox([latest_webui_widget, latest_exstensions_widget, detailed_download_widget], layout=widgets.Layout(justify_content='space-between'))\n",
|
343 |
+
"controlnet_options = ['none', 'ALL', '1.canny',\n",
|
344 |
+
" '2.openpose', '3.depth',\n",
|
345 |
+
" '4.normal_map', '5.mlsd',\n",
|
346 |
+
" '6.lineart', '7.soft_edge',\n",
|
347 |
+
" '8.scribble', '9.segmentation',\n",
|
348 |
+
" '10.shuffle', '11.tile',\n",
|
349 |
+
" '12.inpaint', '13.instruct_p2p']\n",
|
350 |
+
"# ---\n",
|
351 |
+
"controlnet_widget = widgets.Dropdown(options=controlnet_options, value='none', description='ControlNet:', style=style, layout=layout)\n",
|
352 |
+
"controlnet_Num_widget = widgets.Text(description='ControlNet Number:', placeholder='Enter the ControlNet model numbers to be downloaded using comma/space.', style=style, layout=layout)\n",
|
353 |
+
"commit_hash_widget = widgets.Text(description='Commit Hash:', style=style, layout=layout)\n",
|
354 |
+
"optional_huggingface_token_widget = widgets.Text(description='Huggingface token:', style=style, layout=layout)\n",
|
355 |
+
"ngrok_token_widget = widgets.Text(description='Ngrok token:', style=style, layout=widgets.Layout(width='1047px'))\n",
|
356 |
+
"ngrock_button = widgets.HTML('<a href=\"https://dashboard.ngrok.com/get-started/your-authtoken\" target=\"_blank\">Get Ngrok Token</a>').add_class(\"button_ngrok\")\n",
|
357 |
+
"ngrok_widget = widgets.HBox([ngrok_token_widget, ngrock_button], style=style, layout=layout)\n",
|
358 |
+
"# ---\n",
|
359 |
+
"commandline_arguments_options = \"--listen --enable-insecure-extension-access --theme dark --no-half-vae --disable-console-progressbars --xformers\"\n",
|
360 |
+
"commandline_arguments_widget = widgets.Text(description='Arguments:', value=commandline_arguments_options, style=style, layout=layout)\n",
|
361 |
+
"\n",
|
362 |
+
"display(widgets.VBox([additional_header, latest_changes_widget, widgets.HTML('<hr>'), controlnet_widget, controlnet_Num_widget, commit_hash_widget, optional_huggingface_token_widget, ngrok_widget, widgets.HTML('<hr>'), commandline_arguments_widget]).add_class(\"container\"))\n",
|
363 |
+
"\n",
|
364 |
+
"# --- CUSTOM DOWNLOAD ---\n",
|
365 |
+
"custom_download_header_popup = widgets.HTML('''\n",
|
366 |
+
"<style>\n",
|
367 |
+
"/* Term Colors */\n",
|
368 |
+
".sample_label {color: #dbafff;}\n",
|
369 |
+
".braces {color: #ffff00;}\n",
|
370 |
+
".extension {color: #eb934b;}\n",
|
371 |
+
".file_name {color: #ffffd8;}\n",
|
372 |
+
"</style>\n",
|
373 |
+
"\n",
|
374 |
+
"<div class=\"header\" style=\"cursor: pointer;\" onclick=\"toggleContainer()\">Custom Download</div>\n",
|
375 |
+
"<!-- PopUp Window -->\n",
|
376 |
+
"<div class=\"info\">FAQ?</div>\n",
|
377 |
+
"<div class=\"popup\">\n",
|
378 |
+
" Separate multiple URLs with a comma/space. For a <span class=\"file_name\">custom name</span> file/extension, specify it with <span class=\"braces\">[]</span>\n",
|
379 |
+
" after the URL without spaces.\n",
|
380 |
+
" <span style=\"color: #ff9999\">For files, be sure to specify</span> - <span class=\"extension\">Filename Extension.</span>\n",
|
381 |
+
" <div class=\"sample\">\n",
|
382 |
+
" <span class=\"sample_label\">Example for File:</span>\n",
|
383 |
+
" https://civitai.com/api/download/models/229782<span class=\"braces\">[</span><span class=\"file_name\">Detailer</span><span class=\"extension\">.safetensors</span><span class=\"braces\">]</span>\n",
|
384 |
+
" <br>\n",
|
385 |
+
" <span class=\"sample_label\">Example for Extension:</span>\n",
|
386 |
+
" https://github.com/hako-mikan/sd-webui-regional-prompter<span class=\"braces\">[</span><span class=\"file_name\">Regional-Prompter</span><span class=\"braces\">]</span>\n",
|
387 |
+
" </div>\n",
|
388 |
+
"</div>\n",
|
389 |
+
"''')\n",
|
390 |
+
"# ---\n",
|
391 |
+
"Model_url_widget = widgets.Text(description='Model:', style=style, layout=layout)\n",
|
392 |
+
"Vae_url_widget = widgets.Text(description='Vae:', style=style, layout=layout)\n",
|
393 |
+
"LoRA_url_widget = widgets.Text(description='LoRa:', style=style, layout=layout)\n",
|
394 |
+
"Embedding_url_widget = widgets.Text(description='Embedding:', style=style, layout=layout)\n",
|
395 |
+
"Extensions_url_widget = widgets.Text(description='Extensions:', style=style, layout=layout)\n",
|
396 |
+
"\n",
|
397 |
+
"display(widgets.VBox([custom_download_header_popup, Model_url_widget, Vae_url_widget, LoRA_url_widget, Embedding_url_widget, Extensions_url_widget]).add_class(\"container\").add_class(\"container_custom_downlad\"))\n",
|
398 |
+
"\n",
|
399 |
+
"# --- Save Button ---\n",
|
400 |
+
"save_button = widgets.Button(description='Save').add_class(\"button_save\")\n",
|
401 |
+
"display(save_button)\n",
|
402 |
+
"\n",
|
403 |
+
"\n",
|
404 |
+
"# ============ Load / Save - Settings V2 ============\n",
|
405 |
+
"settings_keys = [\n",
|
406 |
+
" 'Model', 'Model_Num', 'Inpainting_Model',\n",
|
407 |
+
" 'Vae', 'Vae_Num',\n",
|
408 |
+
" 'latest_webui', 'latest_exstensions', 'detailed_download',\n",
|
409 |
+
" 'controlnet', 'controlnet_Num', 'commit_hash', 'optional_huggingface_token',\n",
|
410 |
+
" 'ngrok_token', 'commandline_arguments',\n",
|
411 |
+
" 'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url', 'Extensions_url'\n",
|
412 |
+
"]\n",
|
413 |
+
"\n",
|
414 |
+
"def save_settings():\n",
|
415 |
+
" settings = {key: globals()[f\"{key}_widget\"].value for key in settings_keys}\n",
|
416 |
+
" with open(SETTINGS_FILE, 'w') as f:\n",
|
417 |
+
" json.dump(settings, f)\n",
|
418 |
+
"\n",
|
419 |
+
"def load_settings():\n",
|
420 |
+
" if os.path.exists(SETTINGS_FILE):\n",
|
421 |
+
" with open(SETTINGS_FILE, 'r') as f:\n",
|
422 |
+
" settings = json.load(f)\n",
|
423 |
+
" for key in settings_keys:\n",
|
424 |
+
" globals()[f\"{key}_widget\"].value = settings.get(key)\n",
|
425 |
+
"\n",
|
426 |
+
"def save_data(button):\n",
|
427 |
+
" save_settings()\n",
|
428 |
+
" widgets.Widget.close_all()\n",
|
429 |
+
"\n",
|
430 |
+
"settings = load_settings()\n",
|
431 |
+
"save_button.on_click(save_data)"
|
432 |
+
],
|
433 |
+
"metadata": {
|
434 |
+
"id": "2lJmbqrs3Mu8"
|
435 |
+
},
|
436 |
+
"execution_count": null,
|
437 |
+
"outputs": []
|
438 |
+
}
|
439 |
+
]
|
440 |
+
}
|
files_cells/python/en/downloading_en.py
ADDED
@@ -0,0 +1,432 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python
|
2 |
+
# coding: utf-8
|
3 |
+
|
4 |
+
# In[ ]:
|
5 |
+
|
6 |
+
|
7 |
+
import os
|
8 |
+
import re
|
9 |
+
import sys
|
10 |
+
import time
|
11 |
+
import json
|
12 |
+
import shutil
|
13 |
+
import subprocess
|
14 |
+
from datetime import timedelta
|
15 |
+
from subprocess import getoutput
|
16 |
+
from urllib.parse import unquote
|
17 |
+
from IPython.utils import capture
|
18 |
+
from IPython.display import clear_output
|
19 |
+
|
20 |
+
|
21 |
+
# ================= DETECT ENV =================
|
22 |
+
def detect_environment():
|
23 |
+
environments = {
|
24 |
+
'COLAB_GPU': ('Google Colab', "/content"),
|
25 |
+
'KAGGLE_URL_BASE': ('Kaggle', "/kaggle/working/content"),
|
26 |
+
'SAGEMAKER_INTERNAL_IMAGE_URI': ('SageMaker Studio Lab', "/home/studio-lab-user/content")
|
27 |
+
}
|
28 |
+
|
29 |
+
for env_var, (environment, path) in environments.items():
|
30 |
+
if env_var in os.environ:
|
31 |
+
return environment, path
|
32 |
+
|
33 |
+
sys.exit("\033[31mError: an unsupported runtime environment was detected.\n\033[34mSupported environments:\033[0m Google Colab, Kaggle, Sagemaker Studio Lab")
|
34 |
+
|
35 |
+
env, root_path = detect_environment()
|
36 |
+
webui_path = f"{root_path}/sdw"
|
37 |
+
# ----------------------------------------------
|
38 |
+
|
39 |
+
|
40 |
+
# ================ LIBRARIES ================
|
41 |
+
flag_file = f"{root_path}/libraries_installed.txt"
|
42 |
+
|
43 |
+
if not os.path.exists(flag_file):
|
44 |
+
xformers = "xformers==0.0.20 triton==2.0.0"
|
45 |
+
torch = "torch==2.0.1+cu118 torchvision==0.15.2+cu118 torchaudio==2.0.2+cu118 torchtext==0.15.2 torchdata==0.6.1 --extra-index-url https://download.pytorch.org/whl/cu118"
|
46 |
+
|
47 |
+
print("Installing the libraries, it's going to take a while....", end='')
|
48 |
+
with capture.capture_output() as cap:
|
49 |
+
get_ipython().system('apt -y install -qq aria2 &> /dev/null')
|
50 |
+
get_ipython().system('npm install -g localtunnel &> /dev/null')
|
51 |
+
get_ipython().system('curl -s -OL https://github.com/DEX-1101/sd-webui-notebook/raw/main/res/new_tunnel --output-dir {root_path}')
|
52 |
+
get_ipython().system('curl -s -Lo /usr/bin/cl https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 && chmod +x /usr/bin/cl')
|
53 |
+
get_ipython().system('pip install insightface')
|
54 |
+
|
55 |
+
if env == "Google Colab":
|
56 |
+
get_ipython().system('pip install -q xformers==0.0.22.post7')
|
57 |
+
else:
|
58 |
+
get_ipython().system('pip install -q {torch} -U')
|
59 |
+
get_ipython().system('pip install -q {xformers} -U')
|
60 |
+
|
61 |
+
with open(flag_file, "w") as f:
|
62 |
+
f.write("hey ;3")
|
63 |
+
del cap
|
64 |
+
print("\rLibraries are installed!" + " "*35)
|
65 |
+
time.sleep(2)
|
66 |
+
clear_output()
|
67 |
+
|
68 |
+
|
69 |
+
# ================= loading settings V4 =================
|
70 |
+
def load_settings(path):
|
71 |
+
if os.path.exists(path):
|
72 |
+
with open(path, 'r') as file:
|
73 |
+
return json.load(file)
|
74 |
+
return {}
|
75 |
+
|
76 |
+
settings = load_settings(f'{root_path}/settings.json')
|
77 |
+
|
78 |
+
variables = [
|
79 |
+
'Model', 'Model_Num', 'Inpainting_Model',
|
80 |
+
'Vae', 'Vae_Num',
|
81 |
+
'latest_webui', 'latest_exstensions', 'detailed_download',
|
82 |
+
'controlnet', 'controlnet_Num', 'commit_hash', 'optional_huggingface_token',
|
83 |
+
'ngrok_token' 'commandline_arguments',
|
84 |
+
'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url', 'Extensions_url'
|
85 |
+
]
|
86 |
+
|
87 |
+
locals().update({key: settings.get(key) for key in variables})
|
88 |
+
|
89 |
+
|
90 |
+
# ================= OTHER =================
|
91 |
+
try:
|
92 |
+
start_colab
|
93 |
+
except:
|
94 |
+
start_colab = int(time.time())-5
|
95 |
+
|
96 |
+
# CONFIG DIR
|
97 |
+
models_dir = f"{webui_path}/models/Stable-diffusion"
|
98 |
+
vaes_dir = f"{webui_path}/models/VAE"
|
99 |
+
embeddings_dir = f"{webui_path}/embeddings"
|
100 |
+
loras_dir = f"{webui_path}/models/Lora"
|
101 |
+
extensions_dir = f"{webui_path}/extensions"
|
102 |
+
control_dir = f"{webui_path}/models/ControlNet"
|
103 |
+
|
104 |
+
|
105 |
+
# ================= MAIN CODE =================
|
106 |
+
if not os.path.exists(webui_path):
|
107 |
+
start_install = int(time.time())
|
108 |
+
print("⌚ Unpacking Stable Diffusion...", end='')
|
109 |
+
with capture.capture_output() as cap:
|
110 |
+
get_ipython().system('aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO.zip -o repo.zip')
|
111 |
+
get_ipython().system('unzip -q -o repo.zip -d {webui_path}')
|
112 |
+
get_ipython().system('rm -rf repo.zip')
|
113 |
+
|
114 |
+
get_ipython().run_line_magic('cd', '{root_path}')
|
115 |
+
os.environ["SAFETENSORS_FAST_GPU"]='1'
|
116 |
+
os.environ["CUDA_MODULE_LOADING"]="LAZY"
|
117 |
+
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3"
|
118 |
+
os.environ["PYTHONWARNINGS"] = "ignore"
|
119 |
+
|
120 |
+
get_ipython().system('echo -n {start_colab} > {webui_path}/static/colabTimer.txt')
|
121 |
+
del cap
|
122 |
+
install_time = timedelta(seconds=time.time()-start_install)
|
123 |
+
print("\r🚀 Unpacking is complete! For","%02d:%02d:%02d ⚡\n" % (install_time.seconds / 3600, (install_time.seconds / 60) % 60, install_time.seconds % 60), end='', flush=True)
|
124 |
+
else:
|
125 |
+
get_ipython().system('echo -n {start_colab} > {webui_path}/static/colabTimer.txt')
|
126 |
+
print("🚀 All unpacked... Skip. ⚡")
|
127 |
+
start_colab = float(open(f'{webui_path}/static/colabTimer.txt', 'r').read())
|
128 |
+
time_since_start = str(timedelta(seconds=time.time()-start_colab)).split('.')[0]
|
129 |
+
print(f"⌚️ You have been conducting this session for - \033[33m{time_since_start}\033[0m")
|
130 |
+
|
131 |
+
|
132 |
+
## Changes extensions and WebUi
|
133 |
+
if latest_webui or latest_exstensions:
|
134 |
+
action = "Updating WebUI and Extensions" if latest_webui and latest_exstensions else ("WebUI Update" if latest_webui else "Update Extensions")
|
135 |
+
print(f"⌚️ {action}...", end='', flush=True)
|
136 |
+
with capture.capture_output() as cap:
|
137 |
+
get_ipython().system('git config --global user.email "you@example.com"')
|
138 |
+
get_ipython().system('git config --global user.name "Your Name"')
|
139 |
+
|
140 |
+
## Update Webui
|
141 |
+
if latest_webui:
|
142 |
+
get_ipython().run_line_magic('cd', '{webui_path}')
|
143 |
+
get_ipython().system('git restore .')
|
144 |
+
get_ipython().system('git pull -X theirs --rebase --autostash')
|
145 |
+
|
146 |
+
## Update extensions
|
147 |
+
if latest_exstensions:
|
148 |
+
get_ipython().system('find {webui_path}/extensions/ -mindepth 1 -maxdepth 1 -type d -exec sh -c \'cd "$0" && git reset --hard && git pull\' {} \\;')
|
149 |
+
|
150 |
+
get_ipython().system('cd {webui_path}/repositories/stable-diffusion-stability-ai && git restore .')
|
151 |
+
del cap
|
152 |
+
print(f"\r✨ {action} Completed!")
|
153 |
+
|
154 |
+
|
155 |
+
## Version switching
|
156 |
+
if commit_hash:
|
157 |
+
print('⏳ Time machine activation...', end="", flush=True)
|
158 |
+
with capture.capture_output() as cap:
|
159 |
+
get_ipython().run_line_magic('cd', '{webui_path}')
|
160 |
+
get_ipython().system('git config --global user.email "you@example.com"')
|
161 |
+
get_ipython().system('git config --global user.name "Your Name"')
|
162 |
+
get_ipython().system('git reset --hard {commit_hash}')
|
163 |
+
del cap
|
164 |
+
print(f"\r⌛️ The time machine has been activated! Current commit: \033[34m{commit_hash}\033[0m")
|
165 |
+
|
166 |
+
|
167 |
+
## Downloading model and stuff | oh yeah~ I'm starting to misunderstand my own code ( almost my own ;3 )
|
168 |
+
print("📦 Downloading models and stuff...", end='')
|
169 |
+
model_list = {
|
170 |
+
"1.Anime (by Xpuct) + INP": [
|
171 |
+
{"url": "https://huggingface.co/XpucT/Anime/resolve/main/Anime_v1.safetensors", "name": "Anime.safetensors"},
|
172 |
+
{"url": "https://huggingface.co/XpucT/Anime/resolve/main/Anime_v1-inpainting.safetensors", "name": "Anime-inpainting.safetensors"}
|
173 |
+
],
|
174 |
+
"2.Cetus-Mix [Anime] [V4] + INP": [
|
175 |
+
{"url": "https://civitai.com/api/download/models/130298", "name": "CetusMix_V4.safetensors"},
|
176 |
+
{"url": "https://civitai.com/api/download/models/139882", "name": "CetusMix_V4-inpainting.safetensors"}
|
177 |
+
],
|
178 |
+
"3.Counterfeit [Anime] [V3] + INP": [
|
179 |
+
{"url": "https://civitai.com/api/download/models/125050", "name": "Counterfeit_V3.safetensors"},
|
180 |
+
{"url": "https://civitai.com/api/download/models/137911", "name": "Counterfeit_V3-inpainting.safetensors"}
|
181 |
+
],
|
182 |
+
"4.CuteColor [Anime] [V3]": [
|
183 |
+
{"url": "https://civitai.com/api/download/models/138754", "name": "CuteColor_V3.safetensors"}
|
184 |
+
],
|
185 |
+
"5.Dark-Sushi-Mix [Anime]": [
|
186 |
+
{"url": "https://civitai.com/api/download/models/101640", "name": "DarkSushiMix_2_5D.safetensors"},
|
187 |
+
{"url": "https://civitai.com/api/download/models/56071", "name": "DarkSushiMix_colorful.safetensors"}
|
188 |
+
],
|
189 |
+
"6.Meina-Mix [Anime] [V11] + INP": [
|
190 |
+
{"url": "https://civitai.com/api/download/models/119057", "name": "MeinaMix_V11.safetensors"},
|
191 |
+
{"url": "https://civitai.com/api/download/models/120702", "name": "MeinaMix_V11-inpainting.safetensors"}
|
192 |
+
],
|
193 |
+
"7.Mix-Pro [Anime] [V4] + INP": [
|
194 |
+
{"url": "https://civitai.com/api/download/models/125668", "name": "MixPro_V4.safetensors"},
|
195 |
+
{"url": "https://civitai.com/api/download/models/139878", "name": "MixPro_V4-inpainting.safetensors"}
|
196 |
+
],
|
197 |
+
"8.Vela-Mix [Anime] [V2] [6GB]": [ # 6GB - why so much...?
|
198 |
+
{"url": "https://civitai.com/api/download/models/83548", "name": "VelaMix_2.safetensors"}
|
199 |
+
]
|
200 |
+
}
|
201 |
+
|
202 |
+
vae_list = {
|
203 |
+
"1.Anime.vae": [{"url": "https://civitai.com/api/download/models/131654", "name": "Anime.vae.safetensors"}],
|
204 |
+
"2.Anything.vae": [{"url": "https://huggingface.co/NoCrypt/resources/resolve/main/VAE/any.vae.safetensors", "name": "Anything.vae.safetensors"}],
|
205 |
+
"3.blessed2.vae": [{"url": "https://huggingface.co/NoCrypt/resources/resolve/main/VAE/blessed2.vae.safetensors", "name": "Blessed2.vae.safetensors"}],
|
206 |
+
"4.WD.vae": [{"url": "https://huggingface.co/NoCrypt/resources/resolve/main/VAE/wd.vae.safetensors", "name": "WD.vae.safetensors"}]
|
207 |
+
}
|
208 |
+
|
209 |
+
controlnet_list = {
|
210 |
+
"1.canny": [
|
211 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_canny_fp16.safetensors", "name": "control_v11p_sd15_canny_fp16.safetensors"},
|
212 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_canny_fp16.yaml", "name": "control_v11p_sd15_canny_fp16.yaml"}
|
213 |
+
],
|
214 |
+
"2.openpose": [
|
215 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_openpose_fp16.safetensors", "name": "control_v11p_sd15_openpose_fp16.safetensors"},
|
216 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_openpose_fp16.yaml", "name": "control_v11p_sd15_openpose_fp16.yaml"}
|
217 |
+
],
|
218 |
+
"3.depth": [
|
219 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11f1p_sd15_depth_fp16.safetensors", "name": "control_v11f1p_sd15_depth_fp16.safetensors"},
|
220 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11f1p_sd15_depth_fp16.yaml", "name": "control_v11f1p_sd15_depth_fp16.yaml"},
|
221 |
+
{"url": "https://huggingface.co/NagisaNao/models/resolve/main/ControlNet_v11/control_v11p_sd15_depth_anything_fp16.safetensors", "name": "control_v11p_sd15_depth_anything_fp16.safetensors"}
|
222 |
+
],
|
223 |
+
"4.normal_map": [
|
224 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_normalbae_fp16.safetensors", "name": "control_v11p_sd15_normalbae_fp16.safetensors"},
|
225 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_normalbae_fp16.yaml", "name": "control_v11p_sd15_normalbae_fp16.yaml"}
|
226 |
+
],
|
227 |
+
"5.mlsd": [
|
228 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_mlsd_fp16.safetensors", "name": "control_v11p_sd15_mlsd_fp16.safetensors"},
|
229 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_mlsd_fp16.yaml", "name": "control_v11p_sd15_mlsd_fp16.yaml"}
|
230 |
+
],
|
231 |
+
"6.lineart": [
|
232 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_lineart_fp16.safetensors", "name": "control_v11p_sd15_lineart_fp16.safetensors"},
|
233 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15s2_lineart_anime_fp16.safetensors", "name": "control_v11p_sd15s2_lineart_anime_fp16.safetensors"},
|
234 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_lineart_fp16.yaml", "name": "control_v11p_sd15_lineart_fp16.yaml"},
|
235 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15s2_lineart_anime_fp16.yaml", "name": "control_v11p_sd15s2_lineart_anime_fp16.yaml"}
|
236 |
+
],
|
237 |
+
"7.soft_edge": [
|
238 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_softedge_fp16.safetensors", "name": "control_v11p_sd15_softedge_fp16.safetensors"},
|
239 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_softedge_fp16.yaml", "name": "control_v11p_sd15_softedge_fp16.yaml"}
|
240 |
+
],
|
241 |
+
"8.scribble": [
|
242 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_scribble_fp16.safetensors", "name": "control_v11p_sd15_scribble_fp16.safetensors"},
|
243 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_scribble_fp16.yaml", "name": "control_v11p_sd15_scribble_fp16.yaml"}
|
244 |
+
],
|
245 |
+
"9.segmentation": [
|
246 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_seg_fp16.safetensors", "name": "control_v11p_sd15_seg_fp16.safetensors"},
|
247 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_seg_fp16.yaml", "name": "control_v11p_sd15_seg_fp16.yaml"}
|
248 |
+
],
|
249 |
+
"10.shuffle": [
|
250 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11e_sd15_shuffle_fp16.safetensors", "name": "control_v11e_sd15_shuffle_fp16.safetensors"},
|
251 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11e_sd15_shuffle_fp16.yaml", "name": "control_v11e_sd15_shuffle_fp16.yaml"}
|
252 |
+
],
|
253 |
+
"11.tile": [
|
254 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11f1e_sd15_tile_fp16.safetensors", "name": "control_v11f1e_sd15_tile_fp16.safetensors"},
|
255 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11f1e_sd15_tile_fp16.yaml", "name": "control_v11f1e_sd15_tile_fp16.yaml"}
|
256 |
+
],
|
257 |
+
"12.inpaint": [
|
258 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_inpaint_fp16.safetensors", "name": "control_v11p_sd15_inpaint_fp16.safetensors"},
|
259 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_inpaint_fp16.yaml", "name": "control_v11p_sd15_inpaint_fp16.yaml"}
|
260 |
+
],
|
261 |
+
"13.instruct_p2p": [
|
262 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11e_sd15_ip2p_fp16.safetensors", "name": "control_v11e_sd15_ip2p_fp16.safetensors"},
|
263 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11e_sd15_ip2p_fp16.yaml", "name": "control_v11e_sd15_ip2p_fp16.yaml"}
|
264 |
+
]
|
265 |
+
}
|
266 |
+
|
267 |
+
extension_repo = []
|
268 |
+
prefixes = [
|
269 |
+
"model:",
|
270 |
+
"vae:",
|
271 |
+
"lora:",
|
272 |
+
"embeddings:",
|
273 |
+
"extensions:"
|
274 |
+
]
|
275 |
+
|
276 |
+
url = ""
|
277 |
+
hf_token = optional_huggingface_token if optional_huggingface_token else "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"
|
278 |
+
user_header = f"\"Authorization: Bearer {hf_token}\""
|
279 |
+
|
280 |
+
def handle_manual(url):
|
281 |
+
original_url = url
|
282 |
+
url = url.split(':', 1)[1]
|
283 |
+
file_name = re.search(r'\[(.*?)\]', url)
|
284 |
+
file_name = file_name.group(1) if file_name else None
|
285 |
+
if file_name:
|
286 |
+
url = re.sub(r'\[.*?\]', '', url)
|
287 |
+
|
288 |
+
dir_mapping = {"model": models_dir, "vae": vaes_dir, "lora": loras_dir, "embeddings": embeddings_dir, "extensions": None}
|
289 |
+
|
290 |
+
for prefix, dir in dir_mapping.items():
|
291 |
+
if original_url.startswith(f"{prefix}:"):
|
292 |
+
if prefix != "extensions":
|
293 |
+
manual_download(url, dir, file_name=file_name)
|
294 |
+
else:
|
295 |
+
extension_repo.append((url, file_name))
|
296 |
+
|
297 |
+
def manual_download(url, dst_dir, file_name):
|
298 |
+
basename = url.split("/")[-1] if file_name is None else file_name
|
299 |
+
|
300 |
+
# -- GDrive --
|
301 |
+
if 'drive.google' in url:
|
302 |
+
if 'folders' in url:
|
303 |
+
get_ipython().system('gdown --folder "{url}" -O {dst_dir} --fuzzy -c')
|
304 |
+
else:
|
305 |
+
get_ipython().system('gdown "{url}" -O {dst_dir} --fuzzy -c')
|
306 |
+
# -- Huggin Face --
|
307 |
+
elif 'huggingface' in url:
|
308 |
+
if '/blob/' in url:
|
309 |
+
url = url.replace('/blob/', '/resolve/')
|
310 |
+
if file_name:
|
311 |
+
get_ipython().system('aria2c --optimize-concurrent-downloads --console-log-level=error --summary-interval=10 --header={user_header} -c -j5 -x16 -s16 -k1M -d {dst_dir} -o {basename} {url}')
|
312 |
+
else:
|
313 |
+
parsed_link = '\n{}\n\tout={}'.format(url, unquote(url.split('/')[-1]))
|
314 |
+
get_ipython().system('echo -e "{parsed_link}" | aria2c --header={user_header} --console-log-level=error --summary-interval=10 -i- -j5 -x16 -s16 -k1M -c -d "{dst_dir}" -o {basename}')
|
315 |
+
# -- Other --
|
316 |
+
elif 'http' in url or 'magnet' in url:
|
317 |
+
if file_name:
|
318 |
+
get_ipython().system('aria2c --optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -j5 -x16 -s16 -k1M -c -d {dst_dir} -o {file_name} {url}')
|
319 |
+
else:
|
320 |
+
parsed_link = '"{}"'.format(url)
|
321 |
+
get_ipython().system('aria2c --optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -j5 -x16 -s16 -k1M -c -d {dst_dir} -Z {parsed_link}')
|
322 |
+
|
323 |
+
def download(url):
|
324 |
+
links_and_paths = url.split(',')
|
325 |
+
get_ipython().system('mkdir -p {models_dir} {vaes_dir} {embeddings_dir} {loras_dir} {control_dir}')
|
326 |
+
|
327 |
+
for link_or_path in links_and_paths:
|
328 |
+
link_or_path = link_or_path.strip()
|
329 |
+
if not link_or_path:
|
330 |
+
continue
|
331 |
+
|
332 |
+
if any(link_or_path.startswith(prefix.lower()) for prefix in prefixes):
|
333 |
+
handle_manual(link_or_path)
|
334 |
+
continue
|
335 |
+
|
336 |
+
url, dst_dir, file_name = link_or_path.split()
|
337 |
+
manual_download(url, dst_dir, file_name)
|
338 |
+
|
339 |
+
submodels = []
|
340 |
+
|
341 |
+
def add_submodels(selection, num_selection, model_dict, dst_dir):
|
342 |
+
if selection == "none":
|
343 |
+
return []
|
344 |
+
if selection == "ALL":
|
345 |
+
all_models = []
|
346 |
+
for models in model_dict.values():
|
347 |
+
all_models.extend(models)
|
348 |
+
selected_models = all_models
|
349 |
+
else:
|
350 |
+
selected_models = model_dict[selection]
|
351 |
+
selected_nums = map(int, num_selection.replace(',', '').split())
|
352 |
+
|
353 |
+
for num in selected_nums:
|
354 |
+
if 1 <= num <= len(model_dict):
|
355 |
+
name = list(model_dict)[num - 1]
|
356 |
+
selected_models.extend(model_dict[name])
|
357 |
+
|
358 |
+
unique_models = list({model['name']: model for model in selected_models}.values())
|
359 |
+
|
360 |
+
for model in unique_models:
|
361 |
+
model['dst_dir'] = dst_dir
|
362 |
+
|
363 |
+
return unique_models
|
364 |
+
|
365 |
+
submodels += add_submodels(Model, Model_Num, model_list, models_dir) # model
|
366 |
+
submodels += add_submodels(Vae, Vae_Num, vae_list, vaes_dir) # vae
|
367 |
+
submodels += add_submodels(controlnet, "" if controlnet == "ALL" else controlnet_Num, controlnet_list, control_dir) # controlnet
|
368 |
+
|
369 |
+
for submodel in submodels:
|
370 |
+
if not Inpainting_Model and "inpainting" in submodel['name']:
|
371 |
+
continue
|
372 |
+
|
373 |
+
url += f"{submodel['url']} {submodel['dst_dir']} {submodel['name']}, "
|
374 |
+
|
375 |
+
urls = [Model_url, Vae_url, LoRA_url, Embedding_url, Extensions_url]
|
376 |
+
|
377 |
+
for i, prefix in enumerate(prefixes):
|
378 |
+
if urls[i]:
|
379 |
+
prefixed_urls = [f"{prefix}{u}" for u in urls[i].replace(',', '').split()]
|
380 |
+
if prefixed_urls:
|
381 |
+
url += ", ".join(prefixed_urls) + ", "
|
382 |
+
|
383 |
+
if detailed_download == "on":
|
384 |
+
print("\n\n\033[33m# ====== Detailed Download ====== #\n\033[0m")
|
385 |
+
download(url)
|
386 |
+
print("\n\033[33m# =============================== #\n\033[0m")
|
387 |
+
else:
|
388 |
+
with capture.capture_output() as cap:
|
389 |
+
download(url)
|
390 |
+
del cap
|
391 |
+
|
392 |
+
print("\r🏁 Download Complete!" + " "*15)
|
393 |
+
|
394 |
+
|
395 |
+
# Cleaning shit after downloading...
|
396 |
+
get_ipython().system('find \\( -name ".ipynb_checkpoints" -o -name ".aria2" \\) -type d -exec rm -r {} \\; >/dev/null 2>&1')
|
397 |
+
|
398 |
+
|
399 |
+
## Install of Custom extensions
|
400 |
+
if len(extension_repo) > 0:
|
401 |
+
print("✨ Installing custom extensions...", end='', flush=True)
|
402 |
+
with capture.capture_output() as cap:
|
403 |
+
for repo, repo_name in extension_repo:
|
404 |
+
if not repo_name:
|
405 |
+
repo_name = repo.split('/')[-1]
|
406 |
+
get_ipython().system('cd {extensions_dir} && git clone {repo} {repo_name} && cd {repo_name} && git fetch')
|
407 |
+
del cap
|
408 |
+
print(f"\r📦 Installed '{len(extension_repo)}', Custom extensions!")
|
409 |
+
|
410 |
+
|
411 |
+
## List Models and stuff
|
412 |
+
if detailed_download == "off":
|
413 |
+
print("\n\n\033[33mIf you don't see any downloaded files, enable the 'Detailed Downloads' feature in the widget.")
|
414 |
+
|
415 |
+
if any(not file.endswith('.txt') for file in os.listdir(models_dir)):
|
416 |
+
print("\n\033[33m➤ Models\033[0m")
|
417 |
+
get_ipython().system("find {models_dir}/ -mindepth 1 ! -name '*.txt' -printf '%f\\n'")
|
418 |
+
if any(not file.endswith('.txt') for file in os.listdir(vaes_dir)):
|
419 |
+
print("\n\033[33m➤ VAEs\033[0m")
|
420 |
+
get_ipython().system("find {vaes_dir}/ -mindepth 1 ! -name '*.txt' -printf '%f\\n'")
|
421 |
+
if any(not file.endswith('.txt') and not os.path.isdir(os.path.join(embeddings_dir, file)) for file in os.listdir(embeddings_dir)):
|
422 |
+
print("\n\033[33m➤ Embeddings\033[0m")
|
423 |
+
get_ipython().system("find {embeddings_dir}/ -mindepth 1 -maxdepth 1 \\( -name '*.pt' -or -name '*.safetensors' \\) -printf '%f\\n'")
|
424 |
+
if any(not file.endswith('.txt') for file in os.listdir(loras_dir)):
|
425 |
+
print("\n\033[33m➤ LoRAs\033[0m")
|
426 |
+
get_ipython().system("find {loras_dir}/ -mindepth 1 ! -name '*.keep' -printf '%f\\n'")
|
427 |
+
print(f"\n\033[33m➤ Extensions\033[0m")
|
428 |
+
get_ipython().system("find {extensions_dir}/ -mindepth 1 -maxdepth 1 ! -name '*.txt' -printf '%f\\n'")
|
429 |
+
if any(not file.endswith(('.txt', '.yaml')) for file in os.listdir(control_dir)):
|
430 |
+
print("\n\033[33m➤ ControlNet\033[0m")
|
431 |
+
get_ipython().system("find {control_dir}/ -mindepth 1 ! -name '*.yaml' -printf '%f\\n' | sed 's/^[^_]*_[^_]*_[^_]*_\\(.*\\)_fp16\\.safetensors$/\\1/'")
|
432 |
+
|
files_cells/python/en/launch_en.py
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python
|
2 |
+
# coding: utf-8
|
3 |
+
|
4 |
+
# In[ ]:
|
5 |
+
|
6 |
+
|
7 |
+
import os
|
8 |
+
import re
|
9 |
+
import sys
|
10 |
+
import time
|
11 |
+
import json
|
12 |
+
import requests
|
13 |
+
import cloudpickle as pickle
|
14 |
+
from datetime import timedelta
|
15 |
+
|
16 |
+
# ================= DETECT ENV =================
|
17 |
+
def detect_environment():
|
18 |
+
environments = {
|
19 |
+
'COLAB_GPU': ('Google Colab', "/content"),
|
20 |
+
'KAGGLE_URL_BASE': ('Kaggle', "/kaggle/working/content"),
|
21 |
+
'SAGEMAKER_INTERNAL_IMAGE_URI': ('SageMaker Studio Lab', "/home/studio-lab-user/content")
|
22 |
+
}
|
23 |
+
|
24 |
+
for env_var, (environment, path) in environments.items():
|
25 |
+
if env_var in os.environ:
|
26 |
+
return environment, path
|
27 |
+
|
28 |
+
sys.exit("\033[31mError: an unsupported runtime environment was detected.\n\033[34mSupported environments:\033[0m Google Colab, Kaggle, Sagemaker Studio Lab")
|
29 |
+
|
30 |
+
env, root_path = detect_environment()
|
31 |
+
webui_path = f"{root_path}/sdw"
|
32 |
+
# ----------------------------------------------
|
33 |
+
|
34 |
+
def load_settings():
|
35 |
+
SETTINGS_FILE = f'{root_path}/settings.json'
|
36 |
+
if os.path.exists(SETTINGS_FILE):
|
37 |
+
with open(SETTINGS_FILE, 'r') as f:
|
38 |
+
settings = json.load(f)
|
39 |
+
return settings
|
40 |
+
|
41 |
+
settings = load_settings()
|
42 |
+
ngrok_token = settings['ngrok_token']
|
43 |
+
commandline_arguments = settings['commandline_arguments']
|
44 |
+
|
45 |
+
# ======================== TUNNEL ========================
|
46 |
+
password = "x1101"
|
47 |
+
def get_public_ip(version='ipv4'):
|
48 |
+
try:
|
49 |
+
url = f'https://api64.ipify.org?format=json&{version}=true'
|
50 |
+
response = requests.get(url)
|
51 |
+
data = response.json()
|
52 |
+
public_ip = data['ip']
|
53 |
+
return public_ip
|
54 |
+
except Exception as e:
|
55 |
+
print(f"Error getting public {version} address:", e)
|
56 |
+
|
57 |
+
public_ipv4 = get_public_ip(version='ipv4')
|
58 |
+
|
59 |
+
tunnel_class = pickle.load(open(f"{root_path}/new_tunnel", "rb"), encoding="utf-8")
|
60 |
+
tunnel_port= 1101
|
61 |
+
tunnel = tunnel_class(tunnel_port)
|
62 |
+
tunnel.add_tunnel(command="cl tunnel --url localhost:{port}", name="cl", pattern=re.compile(r"[\w-]+\.trycloudflare\.com"))
|
63 |
+
tunnel.add_tunnel(command="lt --port {port}", name="lt", pattern=re.compile(r"[\w-]+\.loca\.lt"), note="Password : " + "\033[32m" + public_ipv4 + "\033[0m" + " rerun cell if 404 error.")
|
64 |
+
|
65 |
+
# ======================== TUNNEL ========================
|
66 |
+
|
67 |
+
# fixing path...
|
68 |
+
get_ipython().system("sed -i 's#\\/home\\/studio-lab-user\\/content#{root_path}#g' {webui_path}/config.json")
|
69 |
+
|
70 |
+
with tunnel:
|
71 |
+
get_ipython().system('#python -m http.server 1101')
|
72 |
+
get_ipython().run_line_magic('cd', '{webui_path}')
|
73 |
+
|
74 |
+
if ngrok_token:
|
75 |
+
commandline_arguments += ' --ngrok ' + ngrok_token
|
76 |
+
commandline_arguments += f" --port=1101 " # --encrypt-pass={password}
|
77 |
+
|
78 |
+
get_ipython().system('COMMANDLINE_ARGS="{commandline_arguments}" python launch.py')
|
79 |
+
|
80 |
+
start_colab = float(open(f'{webui_path}/static/colabTimer.txt', 'r').read())
|
81 |
+
time_since_start = str(timedelta(seconds=time.time()-start_colab)).split('.')[0]
|
82 |
+
print(f"\n⌚️ \033[0mYou have been conducting this session for - \033[33m{time_since_start}\033[0m\n\n")
|
83 |
+
|
files_cells/python/en/widgets_en.py
ADDED
@@ -0,0 +1,419 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python
|
2 |
+
# coding: utf-8
|
3 |
+
|
4 |
+
# In[ ]:
|
5 |
+
|
6 |
+
|
7 |
+
import os
|
8 |
+
import sys
|
9 |
+
import json
|
10 |
+
import ipywidgets as widgets
|
11 |
+
from ipywidgets import widgets, Layout, Label, Button, VBox, HBox
|
12 |
+
from IPython.display import display, HTML, Javascript, clear_output
|
13 |
+
|
14 |
+
|
15 |
+
# ================= DETECT ENV =================
|
16 |
+
def detect_environment():
|
17 |
+
environments = {
|
18 |
+
'COLAB_GPU': ('Google Colab', "/content"),
|
19 |
+
'KAGGLE_URL_BASE': ('Kaggle', "/kaggle/working/content"),
|
20 |
+
'SAGEMAKER_INTERNAL_IMAGE_URI': ('SageMaker Studio Lab', "/home/studio-lab-user/content")
|
21 |
+
}
|
22 |
+
|
23 |
+
for env_var, (environment, path) in environments.items():
|
24 |
+
if env_var in os.environ:
|
25 |
+
return environment, path
|
26 |
+
|
27 |
+
sys.exit("\033[31mError: an unsupported runtime environment was detected.\n\033[34mSupported environments:\033[0m Google Colab, Kaggle, Sagemaker Studio Lab")
|
28 |
+
|
29 |
+
env, root_path = detect_environment()
|
30 |
+
webui_path = f"{root_path}/sdw"
|
31 |
+
# ----------------------------------------------
|
32 |
+
|
33 |
+
get_ipython().system('mkdir -p {root_path}')
|
34 |
+
|
35 |
+
|
36 |
+
style = {'description_width': 'initial'}
|
37 |
+
layout = widgets.Layout(min_width='1047px')
|
38 |
+
SETTINGS_FILE = f'{root_path}/settings.json'
|
39 |
+
|
40 |
+
|
41 |
+
# ==================== CSS JS ====================
|
42 |
+
# --- CSS ---
|
43 |
+
CSS = '''
|
44 |
+
<style>
|
45 |
+
/* General Styles */
|
46 |
+
.header {
|
47 |
+
font-family: cursive;
|
48 |
+
font-size: 20px;
|
49 |
+
font-weight: bold;
|
50 |
+
color: #ff8cee;
|
51 |
+
margin-bottom: 15px;
|
52 |
+
user-select: none;
|
53 |
+
cursor: default;
|
54 |
+
display: inline-block;
|
55 |
+
}
|
56 |
+
|
57 |
+
hr {
|
58 |
+
border-color: grey;
|
59 |
+
background-color: grey;
|
60 |
+
opacity: 0.25;
|
61 |
+
}
|
62 |
+
|
63 |
+
|
64 |
+
/* Container style */
|
65 |
+
|
66 |
+
.container {
|
67 |
+
position: relative;
|
68 |
+
background-color: #232323;
|
69 |
+
width: 1080px;
|
70 |
+
padding: 10px 15px;
|
71 |
+
border-radius: 15px;
|
72 |
+
box-shadow: 0 0 50px rgba(0, 0, 0, 0.3);
|
73 |
+
margin-bottom: 5px;
|
74 |
+
overflow: visible;
|
75 |
+
}
|
76 |
+
|
77 |
+
.container::after {
|
78 |
+
position: absolute;
|
79 |
+
top: 5px;
|
80 |
+
right: 10px;
|
81 |
+
content: "ANXETY";
|
82 |
+
font-weight: bold;
|
83 |
+
font-size: 24px;
|
84 |
+
color: rgba(0, 0, 0, 0.15);
|
85 |
+
}
|
86 |
+
|
87 |
+
.container_custom_downlad {
|
88 |
+
height: 55px;
|
89 |
+
overflow: hidden;
|
90 |
+
transition: all 0.5s;
|
91 |
+
}
|
92 |
+
|
93 |
+
.container_custom_downlad.expanded {
|
94 |
+
height: 240px;
|
95 |
+
}
|
96 |
+
|
97 |
+
|
98 |
+
/* Element text style */
|
99 |
+
|
100 |
+
.widget-html,
|
101 |
+
.widget-button,
|
102 |
+
.widget-text label,
|
103 |
+
.widget-checkbox label,
|
104 |
+
.widget-dropdown label,
|
105 |
+
.widget-dropdown select,
|
106 |
+
.widget-text input[type="text"] {
|
107 |
+
font-family: cursive;
|
108 |
+
font-size: 14px;
|
109 |
+
color: white !important;
|
110 |
+
user-select: none;
|
111 |
+
}
|
112 |
+
|
113 |
+
.widget-text input[type="text"]::placeholder {
|
114 |
+
color: grey;
|
115 |
+
}
|
116 |
+
|
117 |
+
|
118 |
+
/* Input field styles */
|
119 |
+
|
120 |
+
.widget-dropdown select,
|
121 |
+
.widget-text input[type="text"] {
|
122 |
+
height: 30px;
|
123 |
+
background-color: #1c1c1c;
|
124 |
+
border: 1px solid #262626;
|
125 |
+
border-radius: 10px;
|
126 |
+
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
|
127 |
+
transition: all 0.3s ease-in-out;
|
128 |
+
}
|
129 |
+
|
130 |
+
.widget-dropdown select:focus,
|
131 |
+
.widget-text input[type="text"]:focus {
|
132 |
+
border-color: #006ee5;
|
133 |
+
}
|
134 |
+
|
135 |
+
.widget-dropdown select:hover,
|
136 |
+
.widget-text input[type="text"]:hover {
|
137 |
+
transform: scale(1.003);
|
138 |
+
background-color: #262626;
|
139 |
+
box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
|
140 |
+
}
|
141 |
+
|
142 |
+
|
143 |
+
/* Button styles */
|
144 |
+
|
145 |
+
.button_save {
|
146 |
+
font-size: 15px;
|
147 |
+
font-weight: bold;
|
148 |
+
width: 120px;
|
149 |
+
height: 35px;
|
150 |
+
border-radius: 15px;
|
151 |
+
background-image: radial-gradient(circle at top left, purple 10%, violet 90%);
|
152 |
+
background-size: 200% 200%;
|
153 |
+
background-position: left bottom;
|
154 |
+
transition: background 0.5s ease-in-out, transform 0.3s ease;
|
155 |
+
}
|
156 |
+
|
157 |
+
.button_save:hover {
|
158 |
+
cursor: pointer;
|
159 |
+
background-image: radial-gradient(circle at top left, purple 10%, #93ac47 90%);
|
160 |
+
background-size: 200% 200%;
|
161 |
+
background-position: right bottom;
|
162 |
+
transform: translateY(1px);
|
163 |
+
}
|
164 |
+
|
165 |
+
.button_ngrok {
|
166 |
+
font-size: 12px;
|
167 |
+
height: 30px;
|
168 |
+
border-radius: 10px;
|
169 |
+
padding: 1px 12px;
|
170 |
+
background-image: radial-gradient(circle at top left, purple 10%, violet 90%);
|
171 |
+
background-size: 200% 200%;
|
172 |
+
background-position: left bottom;
|
173 |
+
transition: background 0.5s ease-in-out, transform 0.3s ease;
|
174 |
+
white-space: nowrap;
|
175 |
+
}
|
176 |
+
|
177 |
+
.button_ngrok:hover {
|
178 |
+
cursor: pointer;
|
179 |
+
background-image: radial-gradient(circle at top left, purple 10%, #e2a9a8 90%);
|
180 |
+
background-size: 200% 200%;
|
181 |
+
background-position: right bottom;
|
182 |
+
transform: translateY(1px);
|
183 |
+
}
|
184 |
+
|
185 |
+
.button_save:active,
|
186 |
+
.button_ngrok:active {
|
187 |
+
filter: brightness(0.75);
|
188 |
+
}
|
189 |
+
|
190 |
+
|
191 |
+
/* Popup style of `FAQ` window */
|
192 |
+
|
193 |
+
.info {
|
194 |
+
position: absolute;
|
195 |
+
top: -5px;
|
196 |
+
right: 95px;
|
197 |
+
color: grey;
|
198 |
+
font-family: cursive;
|
199 |
+
font-size: 14px;
|
200 |
+
font-weight: normal;
|
201 |
+
user-select: none;
|
202 |
+
pointer-events: none;
|
203 |
+
opacity: 0;
|
204 |
+
transition: opacity 0.3s ease-in-out;
|
205 |
+
display: inline-block;
|
206 |
+
}
|
207 |
+
|
208 |
+
.popup {
|
209 |
+
position: absolute;
|
210 |
+
top: 120px;
|
211 |
+
z-index: 999;
|
212 |
+
width: auto;
|
213 |
+
padding: 10px;
|
214 |
+
text-align: center;
|
215 |
+
background-color: rgba(255, 255, 255, 0.05);
|
216 |
+
backdrop-filter: blur(20px);
|
217 |
+
border: 1px solid rgba(255, 255, 255, 0.45);
|
218 |
+
border-radius: 8px;
|
219 |
+
box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
|
220 |
+
opacity: 0;
|
221 |
+
color: #fff;
|
222 |
+
font-size: 16px;
|
223 |
+
font-family: cursive;
|
224 |
+
user-select: none;
|
225 |
+
cursor: default;
|
226 |
+
pointer-events: none;
|
227 |
+
transform: rotate(-5deg);
|
228 |
+
transition: top 0.3s ease-in-out, opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
|
229 |
+
}
|
230 |
+
|
231 |
+
.sample {
|
232 |
+
display: inline-block;
|
233 |
+
margin-top: 25px;
|
234 |
+
padding: 10px 100px;
|
235 |
+
background-color: rgba(255, 255, 255, 0.2);
|
236 |
+
color: #c6e2ff;
|
237 |
+
border: 2px solid rgba(255, 255, 255, 0.2);
|
238 |
+
border-radius: 8px;
|
239 |
+
box-shadow: 0 0 10px rgba(255, 255, 255, 0.2), inset 0 0 25px rgba(255, 255, 255, 0.2);
|
240 |
+
}
|
241 |
+
|
242 |
+
.info.showed {
|
243 |
+
opacity: 1;
|
244 |
+
pointer-events: auto;
|
245 |
+
}
|
246 |
+
|
247 |
+
.info:hover + .popup {
|
248 |
+
top: 35px;
|
249 |
+
opacity: 1;
|
250 |
+
pointer-events: initial;
|
251 |
+
transform: rotate(0deg);
|
252 |
+
}
|
253 |
+
|
254 |
+
|
255 |
+
/* Animation of elements */
|
256 |
+
|
257 |
+
.container,
|
258 |
+
.button_save {
|
259 |
+
animation-name: showedWidgets;
|
260 |
+
animation-duration: 1s;
|
261 |
+
}
|
262 |
+
|
263 |
+
@keyframes showedWidgets {
|
264 |
+
0% {
|
265 |
+
transform: translate3d(-65%, 15%, 0) scale(0) rotate(15deg);
|
266 |
+
filter: blur(25px) grayscale(1) brightness(0.3);
|
267 |
+
opacity: 0;
|
268 |
+
}
|
269 |
+
100% {
|
270 |
+
transform: translate3d(0, 0, 0) scale(1) rotate(0deg);
|
271 |
+
filter: blur(0) grayscale(0) brightness(1);
|
272 |
+
opacity: 1;
|
273 |
+
}
|
274 |
+
}
|
275 |
+
</style>
|
276 |
+
|
277 |
+
<!-- TOGGLE 'CustomDL' SCRIPT -->
|
278 |
+
<script>
|
279 |
+
function toggleContainer() {
|
280 |
+
let downloadContainer = document.querySelector('.container_custom_downlad');
|
281 |
+
let info = document.querySelector('.info');
|
282 |
+
|
283 |
+
downloadContainer.classList.toggle('expanded');
|
284 |
+
info.classList.toggle('showed');
|
285 |
+
}
|
286 |
+
</script>
|
287 |
+
'''
|
288 |
+
|
289 |
+
display(HTML(CSS))
|
290 |
+
# ==================== CSS JS ====================
|
291 |
+
|
292 |
+
|
293 |
+
# ==================== WIDGETS ====================
|
294 |
+
# --- MODEL ---
|
295 |
+
model_header = widgets.HTML('<div class="header">Model Selection<div>')
|
296 |
+
model_options = ['none',
|
297 |
+
'1.Anime (by Xpuct) + INP',
|
298 |
+
'2.Cetus-Mix [Anime] [V4] + INP',
|
299 |
+
'3.Counterfeit [Anime] [V3] + INP',
|
300 |
+
'4.CuteColor [Anime] [V3]',
|
301 |
+
'5.Dark-Sushi-Mix [Anime]',
|
302 |
+
'6.Meina-Mix [Anime] [V11] + INP',
|
303 |
+
'7.Mix-Pro [Anime] [V4] + INP',
|
304 |
+
'8.Vela-Mix [Anime] [V2] [6GB]']
|
305 |
+
# ---
|
306 |
+
Model_widget = widgets.Dropdown(options=model_options, value='3.Counterfeit [Anime] [V3] + INP', description='Model:', style=style, layout=layout)
|
307 |
+
Model_Num_widget = widgets.Text(description='Model Number:', placeholder='Enter the model numbers to be downloaded using comma/space.', style=style, layout=layout)
|
308 |
+
Inpainting_Model_widget = widgets.Checkbox(value=False, description='Inpainting Models', style=style)
|
309 |
+
|
310 |
+
display(widgets.VBox([model_header, Model_widget, Model_Num_widget, Inpainting_Model_widget]).add_class("container"))
|
311 |
+
|
312 |
+
# --- VAE ---
|
313 |
+
vae_header = widgets.HTML('<div class="header" >VAE Selection</div>')
|
314 |
+
vae_options = ['none',
|
315 |
+
'1.Anime.vae',
|
316 |
+
'2.Anything.vae',
|
317 |
+
'3.blessed2.vae',
|
318 |
+
'4.WD.vae']
|
319 |
+
Vae_widget = widgets.Dropdown(options=vae_options, value='1.Anime.vae', description='Vae:', style=style, layout=layout)
|
320 |
+
Vae_Num_widget = widgets.Text(description='Vae number:', placeholder='Enter the vae numbers to be downloaded using comma/space.', style=style, layout=layout)
|
321 |
+
|
322 |
+
display(widgets.VBox([vae_header, Vae_widget, Vae_Num_widget]).add_class("container"))
|
323 |
+
|
324 |
+
# --- ADDITIONAL ---
|
325 |
+
additional_header = widgets.HTML('<div class="header">Additional</div>')
|
326 |
+
latest_webui_widget = widgets.Checkbox(value=True, description='Update WebUI', style=style)
|
327 |
+
latest_exstensions_widget = widgets.Checkbox(value=True, description='Update Extensions', style=style)
|
328 |
+
detailed_download_widget = widgets.Dropdown(options=['off', 'on'], value='off', description='Detailed Download:', style=style)
|
329 |
+
latest_changes_widget = HBox([latest_webui_widget, latest_exstensions_widget, detailed_download_widget], layout=widgets.Layout(justify_content='space-between'))
|
330 |
+
controlnet_options = ['none', 'ALL', '1.canny',
|
331 |
+
'2.openpose', '3.depth',
|
332 |
+
'4.normal_map', '5.mlsd',
|
333 |
+
'6.lineart', '7.soft_edge',
|
334 |
+
'8.scribble', '9.segmentation',
|
335 |
+
'10.shuffle', '11.tile',
|
336 |
+
'12.inpaint', '13.instruct_p2p']
|
337 |
+
# ---
|
338 |
+
controlnet_widget = widgets.Dropdown(options=controlnet_options, value='none', description='ControlNet:', style=style, layout=layout)
|
339 |
+
controlnet_Num_widget = widgets.Text(description='ControlNet Number:', placeholder='Enter the ControlNet model numbers to be downloaded using comma/space.', style=style, layout=layout)
|
340 |
+
commit_hash_widget = widgets.Text(description='Commit Hash:', style=style, layout=layout)
|
341 |
+
optional_huggingface_token_widget = widgets.Text(description='Huggingface token:', style=style, layout=layout)
|
342 |
+
ngrok_token_widget = widgets.Text(description='Ngrok token:', style=style, layout=widgets.Layout(width='1047px'))
|
343 |
+
ngrock_button = widgets.HTML('<a href="https://dashboard.ngrok.com/get-started/your-authtoken" target="_blank">Get Ngrok Token</a>').add_class("button_ngrok")
|
344 |
+
ngrok_widget = widgets.HBox([ngrok_token_widget, ngrock_button], style=style, layout=layout)
|
345 |
+
# ---
|
346 |
+
commandline_arguments_options = "--listen --enable-insecure-extension-access --theme dark --no-half-vae --disable-console-progressbars --xformers"
|
347 |
+
commandline_arguments_widget = widgets.Text(description='Arguments:', value=commandline_arguments_options, style=style, layout=layout)
|
348 |
+
|
349 |
+
display(widgets.VBox([additional_header, latest_changes_widget, widgets.HTML('<hr>'), controlnet_widget, controlnet_Num_widget, commit_hash_widget, optional_huggingface_token_widget, ngrok_widget, widgets.HTML('<hr>'), commandline_arguments_widget]).add_class("container"))
|
350 |
+
|
351 |
+
# --- CUSTOM DOWNLOAD ---
|
352 |
+
custom_download_header_popup = widgets.HTML('''
|
353 |
+
<style>
|
354 |
+
/* Term Colors */
|
355 |
+
.sample_label {color: #dbafff;}
|
356 |
+
.braces {color: #ffff00;}
|
357 |
+
.extension {color: #eb934b;}
|
358 |
+
.file_name {color: #ffffd8;}
|
359 |
+
</style>
|
360 |
+
|
361 |
+
<div class="header" style="cursor: pointer;" onclick="toggleContainer()">Custom Download</div>
|
362 |
+
<!-- PopUp Window -->
|
363 |
+
<div class="info">FAQ?</div>
|
364 |
+
<div class="popup">
|
365 |
+
Separate multiple URLs with a comma/space. For a <span class="file_name">custom name</span> file/extension, specify it with <span class="braces">[]</span>
|
366 |
+
after the URL without spaces.
|
367 |
+
<span style="color: #ff9999">For files, be sure to specify</span> - <span class="extension">Filename Extension.</span>
|
368 |
+
<div class="sample">
|
369 |
+
<span class="sample_label">Example for File:</span>
|
370 |
+
https://civitai.com/api/download/models/229782<span class="braces">[</span><span class="file_name">Detailer</span><span class="extension">.safetensors</span><span class="braces">]</span>
|
371 |
+
<br>
|
372 |
+
<span class="sample_label">Example for Extension:</span>
|
373 |
+
https://github.com/hako-mikan/sd-webui-regional-prompter<span class="braces">[</span><span class="file_name">Regional-Prompter</span><span class="braces">]</span>
|
374 |
+
</div>
|
375 |
+
</div>
|
376 |
+
''')
|
377 |
+
# ---
|
378 |
+
Model_url_widget = widgets.Text(description='Model:', style=style, layout=layout)
|
379 |
+
Vae_url_widget = widgets.Text(description='Vae:', style=style, layout=layout)
|
380 |
+
LoRA_url_widget = widgets.Text(description='LoRa:', style=style, layout=layout)
|
381 |
+
Embedding_url_widget = widgets.Text(description='Embedding:', style=style, layout=layout)
|
382 |
+
Extensions_url_widget = widgets.Text(description='Extensions:', style=style, layout=layout)
|
383 |
+
|
384 |
+
display(widgets.VBox([custom_download_header_popup, Model_url_widget, Vae_url_widget, LoRA_url_widget, Embedding_url_widget, Extensions_url_widget]).add_class("container").add_class("container_custom_downlad"))
|
385 |
+
|
386 |
+
# --- Save Button ---
|
387 |
+
save_button = widgets.Button(description='Save').add_class("button_save")
|
388 |
+
display(save_button)
|
389 |
+
|
390 |
+
|
391 |
+
# ============ Load / Save - Settings V2 ============
|
392 |
+
settings_keys = [
|
393 |
+
'Model', 'Model_Num', 'Inpainting_Model',
|
394 |
+
'Vae', 'Vae_Num',
|
395 |
+
'latest_webui', 'latest_exstensions', 'detailed_download',
|
396 |
+
'controlnet', 'controlnet_Num', 'commit_hash', 'optional_huggingface_token',
|
397 |
+
'ngrok_token', 'commandline_arguments',
|
398 |
+
'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url', 'Extensions_url'
|
399 |
+
]
|
400 |
+
|
401 |
+
def save_settings():
|
402 |
+
settings = {key: globals()[f"{key}_widget"].value for key in settings_keys}
|
403 |
+
with open(SETTINGS_FILE, 'w') as f:
|
404 |
+
json.dump(settings, f)
|
405 |
+
|
406 |
+
def load_settings():
|
407 |
+
if os.path.exists(SETTINGS_FILE):
|
408 |
+
with open(SETTINGS_FILE, 'r') as f:
|
409 |
+
settings = json.load(f)
|
410 |
+
for key in settings_keys:
|
411 |
+
globals()[f"{key}_widget"].value = settings.get(key)
|
412 |
+
|
413 |
+
def save_data(button):
|
414 |
+
save_settings()
|
415 |
+
widgets.Widget.close_all()
|
416 |
+
|
417 |
+
settings = load_settings()
|
418 |
+
save_button.on_click(save_data)
|
419 |
+
|