NagisaNao commited on
Commit
f6827c1
1 Parent(s): e5b7c33

🐛🚑️✨| Lots of changes +Many bugs :3

Browse files

- Fixed download errors;
- Fixed model url;
- Ability to select models, without comma/space;
- Swap between interfaces with saving model files;
- And something else, I don't remember.

files_cells/notebooks/en/downloading_en.ipynb CHANGED
@@ -34,6 +34,31 @@
34
  "webui_path = os.getenv('WEBUI_PATH')\n",
35
  "free_plan = os.getenv('FREE_PLAN')\n",
36
  "\n",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  "\n",
38
  "# ================ LIBRARIES V2 ================\n",
39
  "flag_file = f\"{root_path}/libraries_installed.txt\"\n",
@@ -45,8 +70,9 @@
45
  " # \"aria2\": \"apt -y install aria2\",\n",
46
  " \"aria2\": \"pip install aria2\",\n",
47
  " \"localtunnel\": \"npm install -g localtunnel\",\n",
48
- " \"insightface\": \"pip install insightface\"\n",
49
  " }\n",
 
 
50
  "\n",
51
  " additional_libs = {\n",
52
  " \"Google Colab\": {\n",
@@ -58,7 +84,6 @@
58
  " # \"aiohttp\": \"pip install trash-cli && trash-put /opt/conda/lib/python3.10/site-packages/aiohttp*\" # fix install req\n",
59
  " }\n",
60
  " }\n",
61
- "\n",
62
  " if env in additional_libs:\n",
63
  " install_lib.update(additional_libs[env])\n",
64
  "\n",
@@ -85,68 +110,106 @@
85
  " clear_output()\n",
86
  "\n",
87
  "\n",
88
- "# ================= loading settings V4 =================\n",
89
- "def load_settings(path):\n",
90
- " if os.path.exists(path):\n",
91
- " with open(path, 'r') as file:\n",
92
- " return json.load(file)\n",
93
- " return {}\n",
94
- "\n",
95
- "settings = load_settings(f'{root_path}/settings.json')\n",
96
  "\n",
97
- "VARIABLES = [\n",
98
- " 'model', 'model_num', 'inpainting_model',\n",
99
- " 'vae', 'vae_num', 'latest_webui', 'latest_exstensions',\n",
100
- " 'change_webui', 'detailed_download', 'controlnet',\n",
101
- " 'controlnet_num', 'commit_hash', 'huggingface_token',\n",
102
- " 'ngrok_token', 'zrok_token', 'commandline_arguments',\n",
103
- " 'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url',\n",
104
- " 'Extensions_url', 'custom_file_urls'\n",
105
- "]\n",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  "\n",
107
- "locals().update({key: settings.get(key) for key in VARIABLES})\n",
 
 
108
  "\n",
 
 
 
 
109
  "\n",
110
- "# ================= OTHER =================\n",
111
- "try:\n",
112
- " start_colab\n",
113
- "except:\n",
114
- " start_colab = int(time.time())-5\n",
115
  "\n",
 
 
116
  "\n",
117
- "# ================= MAIN CODE =================\n",
118
- "if not os.path.exists(webui_path):\n",
119
- " start_install = int(time.time())\n",
120
- " print(\"⌚ Unpacking Stable Diffusion...\" if change_webui != 'Forge' else \"⌚ Unpacking Stable Diffusion (Forge)...\", end='')\n",
121
- " with capture.capture_output() as cap:\n",
122
- " aria2_command = \"aria2c --console-log-level=error -c -x 16 -s 16 -k 1M\"\n",
123
- " url = \"https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO.zip\" if change_webui != 'Forge' else \"https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO_forge.zip\"\n",
124
- " !{aria2_command} {url} -o repo.zip\n",
125
  "\n",
126
- " !unzip -q -o repo.zip -d {webui_path}\n",
127
- " !rm -rf repo.zip\n",
 
128
  "\n",
129
- " %cd {root_path}\n",
130
- " os.environ[\"SAFETENSORS_FAST_GPU\"]='1'\n",
131
- " os.environ[\"CUDA_MODULE_LOADING\"]=\"LAZY\"\n",
132
- " os.environ[\"TF_CPP_MIN_LOG_LEVEL\"] = \"3\"\n",
133
- " os.environ[\"PYTHONWARNINGS\"] = \"ignore\"\n",
 
 
 
 
134
  "\n",
135
- " !echo -n {start_colab} > {webui_path}/static/colabTimer.txt\n",
136
- " del cap\n",
137
- " install_time = timedelta(seconds=time.time()-start_install)\n",
138
- " 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",
139
  "else:\n",
140
  " print(\"🚀 All unpacked... Skip. ⚡\")\n",
141
- " start_colab = float(open(f'{webui_path}/static/colabTimer.txt', 'r').read())\n",
142
- " time_since_start = str(timedelta(seconds=time.time()-start_colab)).split('.')[0]\n",
143
- " print(f\"⌚️ You have been conducting this session for - \\033[33m{time_since_start}\\033[0m\")\n",
144
  "\n",
145
  "\n",
146
  "## Changes extensions and WebUi\n",
147
  "if latest_webui or latest_exstensions:\n",
148
- " action = \"Updating WebUI and Extensions\" if latest_webui and latest_exstensions else (\"WebUI Update\" if latest_webui else \"Update Extensions\")\n",
149
- " print(f\"⌚️ {action}...\", end='', flush=True)\n",
150
  " with capture.capture_output() as cap:\n",
151
  " !git config --global user.email \"[email protected]\"\n",
152
  " !git config --global user.name \"Your Name\"\n",
@@ -161,7 +224,7 @@
161
  " if latest_exstensions:\n",
162
  " !{'for dir in ' + webui_path + '/extensions/*/; do cd \\\"$dir\\\" && git reset --hard && git pull; done'}\n",
163
  " del cap\n",
164
- " print(f\"\\r✨ {action} Completed!\")\n",
165
  "\n",
166
  "\n",
167
  "# === FIXING EXTENSIONS ===\n",
@@ -170,10 +233,8 @@
170
  "with capture.capture_output() as cap:\n",
171
  " # --- Umi-Wildcard ---\n",
172
  " !sed -i '521s/open=\\(False\\|True\\)/open=False/' {webui_path}/extensions/Umi-AI-Wildcards/scripts/wildcard_recursive.py # Closed accordion by default\n",
173
- "\n",
174
  " # --- Encrypt-Image ---\n",
175
  " !sed -i '9,37d' {webui_path}/extensions/Encrypt-Image/javascript/encrypt_images_info.js # Removes the weird text in webui\n",
176
- "\n",
177
  " # --- Additional-Networks ---\n",
178
  " !wget -O {webui_path}/extensions/additional-networks/scripts/metadata_editor.py {anxety_repos}/extensions/Additional-Networks/fix/metadata_editor.py # Fixing an error due to old style\n",
179
  "del cap\n",
@@ -181,7 +242,7 @@
181
  "\n",
182
  "## Version switching\n",
183
  "if commit_hash:\n",
184
- " print('⏳ Time machine activation...', end=\"\", flush=True)\n",
185
  " with capture.capture_output() as cap:\n",
186
  " %cd {webui_path}\n",
187
  " !git config --global user.email \"[email protected]\"\n",
@@ -221,7 +282,7 @@
221
  " padding = (terminal_width - len(text)) // 2\n",
222
  " return f\"\\033[1m\\033[36m{' ' * padding}{text}{' ' * padding}\\033[0m\\033[32m\"\n",
223
  "\n",
224
- "def format_output(url, dst_dir, file_name):\n",
225
  " info = center_text(f\"[{file_name.split('.')[0]}]\")\n",
226
  " separation_line = '\\033[32m' + '---' * 20\n",
227
  "\n",
@@ -230,89 +291,81 @@
230
  " print(f\"\\033[33mSAVE DIR: \\033[34m{dst_dir}\")\n",
231
  " print(f\"\\033[33mFILE NAME: \\033[34m{file_name}\\033[0m\")\n",
232
  "\n",
 
 
 
233
  "''' GET CivitAi API - DATA '''\n",
234
  "\n",
235
  "def CivitAi_API(url, file_name=None):\n",
236
- " SUPPORT_TYPES = ('Checkpoint', 'Model', 'TextualInversion', 'LORA')\n",
237
  " CIVITAI_TOKEN = \"62c0c5956b2f9defbd844d754000180b\"\n",
238
  "\n",
239
  " url = url.split('?token=')[0] if '?token=' in url else url\n",
240
  " url = url.replace('?type=', f'?token={CIVITAI_TOKEN}&type=') if '?type=' in url else f\"{url}?token={CIVITAI_TOKEN}\"\n",
241
  "\n",
242
  " def get_model_data(url):\n",
243
- " if \"civitai.com/models/\" in url:\n",
244
- " if '?modelVersionId=' in url:\n",
245
- " version_id = url.split('?modelVersionId=')[1]\n",
246
- " return requests.get(f\"https://civitai.com/api/v1/model-versions/{version_id}\").json()\n",
 
 
 
 
 
247
  " else:\n",
248
- " model_id = url.split('/models/')[1].split('/')[0]\n",
249
- " return requests.get(f\"https://civitai.com/api/v1/models/{model_id}\").json()\n",
250
- " else:\n",
251
- " version_id = url.split('/models/')[1].split('/')[0]\n",
252
- " return requests.get(f\"https://civitai.com/api/v1/model-versions/{version_id}\").json()\n",
253
  "\n",
254
  " data = get_model_data(url)\n",
255
  "\n",
256
  " if not data:\n",
257
- " return None, None, None, None, None, None, None\n",
 
258
  "\n",
259
  " def extract_model_info(url, data):\n",
260
- " if \"civitai.com/models/\" in url:\n",
261
- " if '?modelVersionId=' in url:\n",
262
- " model_type = data['model']['type']\n",
263
- " model_name = data['files'][0]['name']\n",
264
- " else:\n",
265
- " model_type = data['type']\n",
266
- " model_name = data['modelVersions'][0]['files'][0]['name']\n",
267
- " elif 'type=' in url:\n",
268
- " model_type = parse_qs(urlparse(url).query).get('type', [''])[0]\n",
269
- " if 'model' in model_type.lower():\n",
270
- " model_name = data['files'][0]['name']\n",
271
- " else:\n",
272
  " model_name = data['files'][1]['name']\n",
273
- " else:\n",
274
- " model_type = data['model']['type']\n",
275
- " model_name = data['files'][0]['name']\n",
276
  " return model_type, model_name\n",
277
  "\n",
278
  " model_type, model_name = extract_model_info(url, data)\n",
279
  " model_name = file_name or model_name\n",
280
  "\n",
281
- " def get_download_url(url, data, model_type):\n",
282
- " if \"civitai.com/models/\" in url:\n",
283
- " if '?modelVersionId=' in url:\n",
284
- " return data.get('downloadUrl')\n",
285
- " else:\n",
286
- " return data[\"modelVersions\"][0].get(\"downloadUrl\", \"\")\n",
287
- " elif 'type=' in url:\n",
288
- " if any(t.lower() in model_type.lower() for t in SUPPORT_TYPES):\n",
289
- " return data['files'][0]['downloadUrl']\n",
290
- " else:\n",
291
- " return data['files'][1]['downloadUrl']\n",
292
- " else:\n",
293
- " return data.get('downloadUrl')\n",
294
  "\n",
295
- " download_url = get_download_url(url, data, model_type)\n",
296
- " clean_url = re.sub(r'[?&]token=[^&]*', '', download_url)\n",
 
297
  "\n",
298
  " def get_image_info(data, model_type, model_name):\n",
299
- " image_url, image_name = None, None\n",
300
- " if any(t in model_type for t in SUPPORT_TYPES):\n",
301
- " try:\n",
302
- " images = data.get('images') or data['modelVersions'][0].get('images', [])\n",
303
- " if env == 'Kaggle':\n",
304
- " image_url = next((image['url'] for image in images if image['nsfwLevel'] < 4), None)\n",
305
- " else:\n",
306
- " image_url = images[0]['url'] if images else None\n",
307
- " except KeyError:\n",
308
- " pass\n",
309
  "\n",
310
- " image_name = f\"{model_name.split('.')[0]}.preview.{image_url.split('.')[-1]}\" if image_url else None\n",
311
- " return image_url, image_name\n",
312
  "\n",
313
  " image_url, image_name = get_image_info(data, model_type, model_name)\n",
314
  "\n",
315
- " return f\"{download_url}{'&' if '?' in download_url else '?'}token={CIVITAI_TOKEN}\", clean_url, model_type, model_name, image_url, image_name, data\n",
316
  "\n",
317
  "''' Main Download Code '''\n",
318
  "\n",
@@ -358,13 +411,13 @@
358
  " dir = PREFIXES[prefix]\n",
359
  " if prefix != \"extension\":\n",
360
  " try:\n",
361
- " manual_download(path, dir, file_name=file_name)\n",
362
  " except Exception as e:\n",
363
  " print(f\"Error downloading file: {e}\")\n",
364
  " else:\n",
365
  " extension_repo.append((path, file_name))\n",
366
  "\n",
367
- "def manual_download(url, dst_dir, file_name):\n",
368
  " header_option = f\"--header={user_header}\"\n",
369
  " aria2c_header = \"--header='User-Agent: Mozilla/5.0' --allow-overwrite=true\"\n",
370
  " aria2_args = \"--optimize-concurrent-downloads --console-log-level=error --summary-interval=10 --stderr=true -c -x16 -s16 -k1M -j5\"\n",
@@ -382,17 +435,17 @@
382
  "\n",
383
  " \"\"\" Formatted info output \"\"\"\n",
384
  " model_name_or_basename = file_name if file_name else basename\n",
385
- " format_output(clean_url or url, dst_dir, model_name_or_basename)\n",
386
- "\n",
387
- " # print(url, dst_dir, model_name_or_basename)\n",
388
- " if 'civitai' in url:\n",
389
- " if not data:\n",
390
- " print(\"\\033[31m[Data Info]:\\033[0m Failed to retrieve data from the API.\\n\")\n",
391
- " if data and image_name:\n",
392
- " print(f\"\\033[32m[Preview DL]:\\033[0m {image_name} - {image_url}\\n\")\n",
393
  "\n",
394
  " # =====================\n",
395
  " def run_aria2c(url, dst_dir, file_name=None, args=\"\", header=\"\"):\n",
 
 
 
 
396
  " out = f\"-o '{file_name}'\" if file_name else \"\"\n",
397
  " !aria2c {header} {args} -d {dst_dir} {out} '{url}'\n",
398
  "\n",
@@ -418,19 +471,44 @@
418
  "\n",
419
  "''' SubModels - Added URLs '''\n",
420
  "\n",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
421
  "def add_submodels(selection, num_selection, model_dict, dst_dir):\n",
 
422
  " if selection == \"none\":\n",
423
- " return []\n",
424
  " if selection == \"ALL\":\n",
425
- " all_models = []\n",
426
  " for models in model_dict.values():\n",
427
- " all_models.extend(models)\n",
428
- " selected_models = all_models\n",
429
  " else:\n",
430
- " selected_models = model_dict[selection]\n",
431
- " selected_nums = map(int, num_selection.replace(',', '').split())\n",
432
- " for num in selected_nums:\n",
433
- " if 1 <= num <= len(model_dict):\n",
 
 
 
 
 
 
 
 
 
 
 
434
  " name = list(model_dict)[num - 1]\n",
435
  " selected_models.extend(model_dict[name])\n",
436
  "\n",
@@ -521,7 +599,7 @@
521
  "\n",
522
  "## Install of Custom extensions\n",
523
  "if len(extension_repo) > 0:\n",
524
- " print(\"✨ Installing custom extensions...\", end='', flush=True)\n",
525
  " with capture.capture_output() as cap:\n",
526
  " for repo, repo_name in extension_repo:\n",
527
  " if not repo_name:\n",
 
34
  "webui_path = os.getenv('WEBUI_PATH')\n",
35
  "free_plan = os.getenv('FREE_PLAN')\n",
36
  "\n",
37
+ "UI = os.getenv('SDW_UI')\n",
38
+ "OLD_UI = os.getenv('SDW_OLD_UI')\n",
39
+ "\n",
40
+ "\n",
41
+ "# ============ loading settings V4 =============\n",
42
+ "def load_settings(path):\n",
43
+ " if os.path.exists(path):\n",
44
+ " with open(path, 'r') as file:\n",
45
+ " return json.load(file)\n",
46
+ " return {}\n",
47
+ "\n",
48
+ "settings = load_settings(f'{root_path}/settings.json')\n",
49
+ "\n",
50
+ "VARIABLES = [\n",
51
+ " 'model', 'model_num', 'inpainting_model',\n",
52
+ " 'vae', 'vae_num', 'latest_webui', 'latest_exstensions',\n",
53
+ " 'change_webui', 'detailed_download', 'controlnet',\n",
54
+ " 'controlnet_num', 'commit_hash', 'huggingface_token',\n",
55
+ " 'ngrok_token', 'zrok_token', 'commandline_arguments',\n",
56
+ " 'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url',\n",
57
+ " 'Extensions_url', 'custom_file_urls'\n",
58
+ "]\n",
59
+ "\n",
60
+ "locals().update({key: settings.get(key) for key in VARIABLES})\n",
61
+ "\n",
62
  "\n",
63
  "# ================ LIBRARIES V2 ================\n",
64
  "flag_file = f\"{root_path}/libraries_installed.txt\"\n",
 
70
  " # \"aria2\": \"apt -y install aria2\",\n",
71
  " \"aria2\": \"pip install aria2\",\n",
72
  " \"localtunnel\": \"npm install -g localtunnel\",\n",
 
73
  " }\n",
74
+ " if controlnet != 'none':\n",
75
+ " install_lib[\"insightface\"] = \"pip install insightface\"\n",
76
  "\n",
77
  " additional_libs = {\n",
78
  " \"Google Colab\": {\n",
 
84
  " # \"aiohttp\": \"pip install trash-cli && trash-put /opt/conda/lib/python3.10/site-packages/aiohttp*\" # fix install req\n",
85
  " }\n",
86
  " }\n",
 
87
  " if env in additional_libs:\n",
88
  " install_lib.update(additional_libs[env])\n",
89
  "\n",
 
110
  " clear_output()\n",
111
  "\n",
112
  "\n",
113
+ "# =================== OTHER ====================\n",
114
+ "# Setup Timer\n",
115
+ "if \"START_COLAB\" in os.environ:\n",
116
+ " start_colab = int(os.environ[\"START_COLAB\"])\n",
117
+ "else:\n",
118
+ " start_colab = int(time.time()) - 5\n",
119
+ " os.environ[\"START_COLAB\"] = str(start_colab)\n",
 
120
  "\n",
121
+ "# remove directory func\n",
122
+ "def _remove_dir(directory_path):\n",
123
+ " if directory_path and os.path.exists(directory_path):\n",
124
+ " try:\n",
125
+ " shutil.rmtree(directory_path)\n",
126
+ " except Exception:\n",
127
+ " !rm -rf {directory_path}\n",
128
+ "\n",
129
+ "# Save files temporarily\n",
130
+ "temporarily_dir = f'{root_path}/temp_dir'\n",
131
+ "\n",
132
+ "def copy_items_with_replace(src_base, dst_base):\n",
133
+ " items_to_copy = [\n",
134
+ " 'embeddings',\n",
135
+ " 'models/Stable-diffusion',\n",
136
+ " 'models/VAE',\n",
137
+ " 'models/Lora',\n",
138
+ " 'models/ControlNet'\n",
139
+ " ]\n",
140
+ "\n",
141
+ " print(\"⌚ Moving files...\", end='')\n",
142
+ " time.sleep(1)\n",
143
+ " for item in items_to_copy:\n",
144
+ " src = os.path.join(src_base, item)\n",
145
+ " dst = os.path.join(dst_base, item)\n",
146
+ "\n",
147
+ " if os.path.exists(src):\n",
148
+ " if os.path.exists(dst):\n",
149
+ " _remove_dir(dst)\n",
150
+ " os.makedirs(os.path.dirname(dst), exist_ok=True)\n",
151
+ " shutil.move(src, dst)\n",
152
+ " print(\"\\r🔥 Files moved!\" + \" \"*15)\n",
153
+ "\n",
154
+ "def handle_colab_timer(webui_path, timer_colab):\n",
155
+ " timer_file_path = os.path.join(webui_path, 'static', 'colabTimer.txt')\n",
156
+ " if not os.path.exists(timer_file_path):\n",
157
+ " with open(timer_file_path, 'w') as timer_file:\n",
158
+ " timer_file.write(str(timer_colab))\n",
159
+ " else:\n",
160
+ " with open(timer_file_path, 'r') as timer_file:\n",
161
+ " timer_colab = float(timer_file.read())\n",
162
+ " return timer_colab\n",
163
  "\n",
164
+ "def unpack_webui():\n",
165
+ " start_install = time.time()\n",
166
+ " print(f\"⌚ Unpacking Stable Diffusion{' (Forge)' if UI == 'Forge' else ''}...\", end='')\n",
167
  "\n",
168
+ " with capture.capture_output() as cap:\n",
169
+ " download_url = \"https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO.zip\"\n",
170
+ " if UI == 'Forge':\n",
171
+ " download_url = \"https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO_forge.zip\"\n",
172
  "\n",
173
+ " aria2_args = \"--console-log-level=error -c -x 16 -s 16 -k 1M\"\n",
174
+ " zip_path = f\"{root_path}/repo.zip\"\n",
175
+ " !aria2c {aria2_args} {download_url} -d {root_path} -o repo.zip\n",
176
+ " !unzip -q -o {zip_path} -d {webui_path}\n",
177
+ " !rm -rf {zip_path}\n",
178
  "\n",
179
+ " get_ipython().system(f'echo -n {start_colab} > {webui_path}/static/colabTimer.txt')\n",
180
+ " del cap\n",
181
  "\n",
182
+ " install_time = time.time() - start_install\n",
183
+ " minutes, seconds = divmod(int(install_time), 60)\n",
184
+ " print(f\"\\r🚀 Unpacking complete! For {minutes:02}:{seconds:02} ⚡\" + \" \"*15)\n",
 
 
 
 
 
185
  "\n",
186
+ " if os.path.exists(temporarily_dir):\n",
187
+ " copy_items_with_replace(temporarily_dir, webui_path)\n",
188
+ " _remove_dir(temporarily_dir)\n",
189
  "\n",
190
+ "# ================= MAIN CODE ==================\n",
191
+ "if os.path.exists(webui_path):\n",
192
+ " if UI != OLD_UI:\n",
193
+ " print(f'Switching the WebUI from \\033[33m{OLD_UI}\\033[0m to \\033[33m{UI}\\033[0m:')\n",
194
+ " copy_items_with_replace(webui_path, temporarily_dir)\n",
195
+ " _remove_dir(webui_path)\n",
196
+ " os.environ['SDW_OLD_UI'] = UI\n",
197
+ " time.sleep(2)\n",
198
+ " clear_output()\n",
199
  "\n",
200
+ "if not os.path.exists(webui_path):\n",
201
+ " unpack_webui()\n",
 
 
202
  "else:\n",
203
  " print(\"🚀 All unpacked... Skip. ⚡\")\n",
204
+ " timer_colab = handle_colab_timer(webui_path, start_colab)\n",
205
+ " elapsed_time = str(timedelta(seconds=time.time() - timer_colab)).split('.')[0]\n",
206
+ " print(f\"⌚️ You have been conducting this session for - \\033[33m{elapsed_time}\\033[0m\")\n",
207
  "\n",
208
  "\n",
209
  "## Changes extensions and WebUi\n",
210
  "if latest_webui or latest_exstensions:\n",
211
+ " action = \"WebUI and Extensions\" if latest_webui and latest_exstensions else (\"WebUI\" if latest_webui else \"Extensions\")\n",
212
+ " print(f\"⌚️ Updating {action}...\", end='')\n",
213
  " with capture.capture_output() as cap:\n",
214
  " !git config --global user.email \"[email protected]\"\n",
215
  " !git config --global user.name \"Your Name\"\n",
 
224
  " if latest_exstensions:\n",
225
  " !{'for dir in ' + webui_path + '/extensions/*/; do cd \\\"$dir\\\" && git reset --hard && git pull; done'}\n",
226
  " del cap\n",
227
+ " print(f\"\\r✨ Updating {action} Completed!\")\n",
228
  "\n",
229
  "\n",
230
  "# === FIXING EXTENSIONS ===\n",
 
233
  "with capture.capture_output() as cap:\n",
234
  " # --- Umi-Wildcard ---\n",
235
  " !sed -i '521s/open=\\(False\\|True\\)/open=False/' {webui_path}/extensions/Umi-AI-Wildcards/scripts/wildcard_recursive.py # Closed accordion by default\n",
 
236
  " # --- Encrypt-Image ---\n",
237
  " !sed -i '9,37d' {webui_path}/extensions/Encrypt-Image/javascript/encrypt_images_info.js # Removes the weird text in webui\n",
 
238
  " # --- Additional-Networks ---\n",
239
  " !wget -O {webui_path}/extensions/additional-networks/scripts/metadata_editor.py {anxety_repos}/extensions/Additional-Networks/fix/metadata_editor.py # Fixing an error due to old style\n",
240
  "del cap\n",
 
242
  "\n",
243
  "## Version switching\n",
244
  "if commit_hash:\n",
245
+ " print('⏳ Time machine activation...', end=\"\")\n",
246
  " with capture.capture_output() as cap:\n",
247
  " %cd {webui_path}\n",
248
  " !git config --global user.email \"[email protected]\"\n",
 
282
  " padding = (terminal_width - len(text)) // 2\n",
283
  " return f\"\\033[1m\\033[36m{' ' * padding}{text}{' ' * padding}\\033[0m\\033[32m\"\n",
284
  "\n",
285
+ "def format_output(url, dst_dir, file_name, image_name=None, image_url=None):\n",
286
  " info = center_text(f\"[{file_name.split('.')[0]}]\")\n",
287
  " separation_line = '\\033[32m' + '---' * 20\n",
288
  "\n",
 
291
  " print(f\"\\033[33mSAVE DIR: \\033[34m{dst_dir}\")\n",
292
  " print(f\"\\033[33mFILE NAME: \\033[34m{file_name}\\033[0m\")\n",
293
  "\n",
294
+ " if 'civitai' in url and image_url:\n",
295
+ " print(f\"\\033[32m[Preview DL]:\\033[0m {image_name} - {image_url}\\n\")\n",
296
+ "\n",
297
  "''' GET CivitAi API - DATA '''\n",
298
  "\n",
299
  "def CivitAi_API(url, file_name=None):\n",
300
+ " SUPPORT_TYPES = ('Checkpoint', 'TextualInversion', 'LORA')\n",
301
  " CIVITAI_TOKEN = \"62c0c5956b2f9defbd844d754000180b\"\n",
302
  "\n",
303
  " url = url.split('?token=')[0] if '?token=' in url else url\n",
304
  " url = url.replace('?type=', f'?token={CIVITAI_TOKEN}&type=') if '?type=' in url else f\"{url}?token={CIVITAI_TOKEN}\"\n",
305
  "\n",
306
  " def get_model_data(url):\n",
307
+ " base_url = \"https://civitai.com/api/v1\"\n",
308
+ " try:\n",
309
+ " if \"civitai.com/models/\" in url:\n",
310
+ " if '?modelVersionId=' in url:\n",
311
+ " version_id = url.split('?modelVersionId=')[1]\n",
312
+ " else:\n",
313
+ " model_id = url.split('/models/')[1].split('/')[0]\n",
314
+ " model_data = requests.get(f\"{base_url}/models/{model_id}\").json()\n",
315
+ " version_id = model_data['modelVersions'][0].get('id')\n",
316
  " else:\n",
317
+ " version_id = url.split('/models/')[1].split('/')[0]\n",
318
+ "\n",
319
+ " return requests.get(f\"{base_url}/model-versions/{version_id}\").json()\n",
320
+ " except (KeyError, IndexError, requests.RequestException) as e:\n",
321
+ " return None\n",
322
  "\n",
323
  " data = get_model_data(url)\n",
324
  "\n",
325
  " if not data:\n",
326
+ " print(\"\\033[31m[Data Info]:\\033[0m Failed to retrieve data from the API.\\n\")\n",
327
+ " return 'None', None, None, None, None, None, None\n",
328
  "\n",
329
  " def extract_model_info(url, data):\n",
330
+ " model_type = data['model']['type']\n",
331
+ " model_name = data['files'][0]['name']\n",
332
+ "\n",
333
+ " if 'type=' in url:\n",
334
+ " url_model_type = parse_qs(urlparse(url).query).get('type', [''])[0].lower()\n",
335
+ " if 'vae' in url_model_type:\n",
336
+ " model_type = data['files'][1]['type']\n",
 
 
 
 
 
337
  " model_name = data['files'][1]['name']\n",
338
+ "\n",
 
 
339
  " return model_type, model_name\n",
340
  "\n",
341
  " model_type, model_name = extract_model_info(url, data)\n",
342
  " model_name = file_name or model_name\n",
343
  "\n",
344
+ " def get_download_url(data, model_type):\n",
345
+ " if any(t.lower() in model_type.lower() for t in SUPPORT_TYPES):\n",
346
+ " return data['files'][0]['downloadUrl']\n",
 
 
 
 
 
 
 
 
 
 
347
  "\n",
348
+ " return data['files'][1]['downloadUrl'] if 'type' in url else data['files'][0]['downloadUrl']\n",
349
+ "\n",
350
+ " download_url = get_download_url(data, model_type)\n",
351
  "\n",
352
  " def get_image_info(data, model_type, model_name):\n",
353
+ " if not any(t in model_type for t in SUPPORT_TYPES):\n",
354
+ " return None, None\n",
355
+ "\n",
356
+ " for image in data.get('images', []):\n",
357
+ " if image['nsfwLevel'] >= 4 and env == 'Kaggle': # Filter NSFW images for Kaggle\n",
358
+ " continue\n",
359
+ " image_url = image['url']\n",
360
+ " image_extension = image_url.split('.')[-1]\n",
361
+ " image_name = f\"{model_name.split('.')[0]}.preview.{image_extension}\" if image_url else None\n",
362
+ " return image_url, image_name\n",
363
  "\n",
364
+ " return None, None\n",
 
365
  "\n",
366
  " image_url, image_name = get_image_info(data, model_type, model_name)\n",
367
  "\n",
368
+ " return f\"{download_url}{'&' if '?' in download_url else '?'}token={CIVITAI_TOKEN}\", download_url, model_type, model_name, image_url, image_name, data\n",
369
  "\n",
370
  "''' Main Download Code '''\n",
371
  "\n",
 
411
  " dir = PREFIXES[prefix]\n",
412
  " if prefix != \"extension\":\n",
413
  " try:\n",
414
+ " manual_download(path, dir, file_name=file_name, prefix=prefix)\n",
415
  " except Exception as e:\n",
416
  " print(f\"Error downloading file: {e}\")\n",
417
  " else:\n",
418
  " extension_repo.append((path, file_name))\n",
419
  "\n",
420
+ "def manual_download(url, dst_dir, file_name, prefix=None):\n",
421
  " header_option = f\"--header={user_header}\"\n",
422
  " aria2c_header = \"--header='User-Agent: Mozilla/5.0' --allow-overwrite=true\"\n",
423
  " aria2_args = \"--optimize-concurrent-downloads --console-log-level=error --summary-interval=10 --stderr=true -c -x16 -s16 -k1M -j5\"\n",
 
435
  "\n",
436
  " \"\"\" Formatted info output \"\"\"\n",
437
  " model_name_or_basename = file_name if file_name else basename\n",
438
+ " try:\n",
439
+ " format_output(clean_url or url, dst_dir, model_name_or_basename, image_name, image_url)\n",
440
+ " except UnboundLocalError:\n",
441
+ " format_output(clean_url or url, dst_dir, model_name_or_basename, None, None)\n",
 
 
 
 
442
  "\n",
443
  " # =====================\n",
444
  " def run_aria2c(url, dst_dir, file_name=None, args=\"\", header=\"\"):\n",
445
+ " file_path = os.path.join(dst_dir, file_name) # replaces config files\n",
446
+ " if os.path.exists(file_path) and prefix == 'config':\n",
447
+ " os.remove(file_path)\n",
448
+ "\n",
449
  " out = f\"-o '{file_name}'\" if file_name else \"\"\n",
450
  " !aria2c {header} {args} -d {dst_dir} {out} '{url}'\n",
451
  "\n",
 
471
  "\n",
472
  "''' SubModels - Added URLs '''\n",
473
  "\n",
474
+ "# Separation of merged numbers\n",
475
+ "def split_numbers(num_str, max_num):\n",
476
+ " def helper(s):\n",
477
+ " if not s:\n",
478
+ " return []\n",
479
+ " for length in range(2, 0, -1):\n",
480
+ " if len(s) >= length:\n",
481
+ " part = int(s[:length])\n",
482
+ " if part <= max_num:\n",
483
+ " result = helper(s[length:])\n",
484
+ " if result is not None:\n",
485
+ " return [part] + result\n",
486
+ " return None\n",
487
+ " return helper(num_str)\n",
488
+ "\n",
489
  "def add_submodels(selection, num_selection, model_dict, dst_dir):\n",
490
+ " selected_models = []\n",
491
  " if selection == \"none\":\n",
492
+ " return selected_models\n",
493
  " if selection == \"ALL\":\n",
 
494
  " for models in model_dict.values():\n",
495
+ " selected_models.extend(models)\n",
 
496
  " else:\n",
497
+ " if selection in model_dict:\n",
498
+ " selected_models.extend(model_dict[selection])\n",
499
+ " nums = num_selection.replace(',', ' ').split()\n",
500
+ " max_num = len(model_dict)\n",
501
+ " selected_nums = []\n",
502
+ "\n",
503
+ " for num_part in nums:\n",
504
+ " split_nums = split_numbers(num_part, max_num)\n",
505
+ " if split_nums:\n",
506
+ " selected_nums.extend(split_nums)\n",
507
+ "\n",
508
+ " unique_nums = list(set(selected_nums))\n",
509
+ "\n",
510
+ " for num in unique_nums:\n",
511
+ " if 1 <= num <= max_num:\n",
512
  " name = list(model_dict)[num - 1]\n",
513
  " selected_models.extend(model_dict[name])\n",
514
  "\n",
 
599
  "\n",
600
  "## Install of Custom extensions\n",
601
  "if len(extension_repo) > 0:\n",
602
+ " print(\"✨ Installing custom extensions...\", end='')\n",
603
  " with capture.capture_output() as cap:\n",
604
  " for repo, repo_name in extension_repo:\n",
605
  " if not repo_name:\n",
files_cells/notebooks/en/launch_en.ipynb CHANGED
@@ -29,6 +29,7 @@
29
  "import time\n",
30
  "import json\n",
31
  "import requests\n",
 
32
  "import cloudpickle as pickle\n",
33
  "from datetime import timedelta\n",
34
  "from IPython.display import clear_output\n",
@@ -55,6 +56,17 @@
55
  "change_webui = settings.get('change_webui', \"\")\n",
56
  "\n",
57
  "\n",
 
 
 
 
 
 
 
 
 
 
 
58
  "# ======================== TUNNEL V2 ========================\n",
59
  "print('Please Wait...')\n",
60
  "\n",
@@ -80,7 +92,9 @@
80
  "tunnel_port = 1834\n",
81
  "tunnel = tunnel_class(tunnel_port)\n",
82
  "tunnel.add_tunnel(command=\"cl tunnel --url localhost:{port}\", name=\"cl\", pattern=re.compile(r\"[\\w-]+\\.trycloudflare\\.com\"))\n",
83
- "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",
 
 
84
  "\n",
85
  "if zrok_token:\n",
86
  " !zrok enable {zrok_token} &> /dev/null\n",
@@ -89,7 +103,7 @@
89
  "clear_output()\n",
90
  "\n",
91
  "\n",
92
- "# =============== Automatic Fixing Path V3 ===============\n",
93
  "paths_to_check = {\n",
94
  " \"tagger_hf_cache_dir\": f\"{webui_path}/models/interrogators/\",\n",
95
  " \"additional_networks_extra_lora_path\": f\"{webui_path}/models/Lora/\",\n",
@@ -120,8 +134,10 @@
120
  " if env != \"Google Colab\":\n",
121
  " commandline_arguments += f' --encrypt-pass={tunnel_port} --api'\n",
122
  "\n",
123
- " if change_webui == 'Forge':\n",
124
- " commandline_arguments += ' --cuda-stream --pin-shared-memory'\n",
 
 
125
  "\n",
126
  " !COMMANDLINE_ARGS=\"{commandline_arguments}\" python launch.py\n",
127
  "\n",
 
29
  "import time\n",
30
  "import json\n",
31
  "import requests\n",
32
+ "import subprocess\n",
33
  "import cloudpickle as pickle\n",
34
  "from datetime import timedelta\n",
35
  "from IPython.display import clear_output\n",
 
56
  "change_webui = settings.get('change_webui', \"\")\n",
57
  "\n",
58
  "\n",
59
+ "# ========================== OTHER ==========================\n",
60
+ "def is_package_installed(package_name):\n",
61
+ " try:\n",
62
+ " subprocess.run([\"npm\", \"ls\", \"-g\", package_name], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n",
63
+ " return True\n",
64
+ " except subprocess.CalledProcessError:\n",
65
+ " return False\n",
66
+ "\n",
67
+ "lt_tunnel = is_package_installed('localtunnel')\n",
68
+ "\n",
69
+ "\n",
70
  "# ======================== TUNNEL V2 ========================\n",
71
  "print('Please Wait...')\n",
72
  "\n",
 
92
  "tunnel_port = 1834\n",
93
  "tunnel = tunnel_class(tunnel_port)\n",
94
  "tunnel.add_tunnel(command=\"cl tunnel --url localhost:{port}\", name=\"cl\", pattern=re.compile(r\"[\\w-]+\\.trycloudflare\\.com\"))\n",
95
+ "\n",
96
+ "if lt_tunnel:\n",
97
+ " 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",
98
  "\n",
99
  "if zrok_token:\n",
100
  " !zrok enable {zrok_token} &> /dev/null\n",
 
103
  "clear_output()\n",
104
  "\n",
105
  "\n",
106
+ "# ================= Automatic Fixing Path V3 ================\n",
107
  "paths_to_check = {\n",
108
  " \"tagger_hf_cache_dir\": f\"{webui_path}/models/interrogators/\",\n",
109
  " \"additional_networks_extra_lora_path\": f\"{webui_path}/models/Lora/\",\n",
 
134
  " if env != \"Google Colab\":\n",
135
  " commandline_arguments += f' --encrypt-pass={tunnel_port} --api'\n",
136
  "\n",
137
+ " if change_webui == 'A1111':\n",
138
+ " commandline_arguments += ' --xformers'\n",
139
+ " else:\n",
140
+ " commandline_arguments += ' --disable-xformers --opt-sdp-attention --cuda-stream --pin-shared-memory'\n",
141
  "\n",
142
  " !COMMANDLINE_ARGS=\"{commandline_arguments}\" python launch.py\n",
143
  "\n",
files_cells/notebooks/en/widgets_en.ipynb CHANGED
@@ -116,6 +116,7 @@
116
  "'''\n",
117
  "display(HTML(JS))\n",
118
  "\n",
 
119
  "# ==================== WIDGETS V2 ====================\n",
120
  "HR = widgets.HTML('<hr>')\n",
121
  "\n",
@@ -227,7 +228,7 @@
227
  "zrok_button = factory.create_html('<a href=\"https://colab.research.google.com/drive/1d2sjWDJi_GYBUavrHSuQyHTDuLy36WpU\" target=\"_blank\">Зарегать Zrok Токен</a>', class_name=\"button_ngrok\")\n",
228
  "zrok_widget = factory.create_hbox([zrok_token_widget, zrok_button])\n",
229
  "\n",
230
- "commandline_arguments_options = \"--listen --enable-insecure-extension-access --theme dark --no-half-vae --disable-console-progressbars --xformers\"\n",
231
  "commandline_arguments_widget = factory.create_text('Arguments:', value=commandline_arguments_options)\n",
232
  "\n",
233
  "# Display Additional\n",
@@ -245,8 +246,6 @@
245
  "\n",
246
  "if free_plan and env == \"Google Colab\": # remove ngrok from colab\n",
247
  " additional_widget_list.remove(ngrok_widget)\n",
248
- "if os.path.exists(webui_path): # remove selection after selection ;3\n",
249
- " choose_changes_widget.children = [widget for widget in choose_changes_widget.children if widget != change_webui_widget]\n",
250
  "\n",
251
  "all_additional_box = factory.create_vbox(additional_widget_list, class_names=[\"container\", \"image_3\"])\n",
252
  "factory.display(all_additional_box)\n",
@@ -296,6 +295,21 @@
296
  "factory.display(save_button)\n",
297
  "\n",
298
  "\n",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
299
  "# ============ Load / Save - Settings V2 ============\n",
300
  "SETTINGS_FILE = f'{root_path}/settings.json'\n",
301
  "\n",
@@ -330,6 +344,7 @@
330
  "\n",
331
  "def save_data(button):\n",
332
  " save_settings()\n",
 
333
  " hide_widgets()\n",
334
  "\n",
335
  "load_settings()\n",
 
116
  "'''\n",
117
  "display(HTML(JS))\n",
118
  "\n",
119
+ "\n",
120
  "# ==================== WIDGETS V2 ====================\n",
121
  "HR = widgets.HTML('<hr>')\n",
122
  "\n",
 
228
  "zrok_button = factory.create_html('<a href=\"https://colab.research.google.com/drive/1d2sjWDJi_GYBUavrHSuQyHTDuLy36WpU\" target=\"_blank\">Зарегать Zrok Токен</a>', class_name=\"button_ngrok\")\n",
229
  "zrok_widget = factory.create_hbox([zrok_token_widget, zrok_button])\n",
230
  "\n",
231
+ "commandline_arguments_options = \"--listen --enable-insecure-extension-access --theme dark --no-half-vae --disable-console-progressbars\"\n",
232
  "commandline_arguments_widget = factory.create_text('Arguments:', value=commandline_arguments_options)\n",
233
  "\n",
234
  "# Display Additional\n",
 
246
  "\n",
247
  "if free_plan and env == \"Google Colab\": # remove ngrok from colab\n",
248
  " additional_widget_list.remove(ngrok_widget)\n",
 
 
249
  "\n",
250
  "all_additional_box = factory.create_vbox(additional_widget_list, class_names=[\"container\", \"image_3\"])\n",
251
  "factory.display(all_additional_box)\n",
 
295
  "factory.display(save_button)\n",
296
  "\n",
297
  "\n",
298
+ "# ==================== OTHER FUNC ====================\n",
299
+ "# Setup UI\n",
300
+ "def setup_webui(change_webui_widget):\n",
301
+ " if 'SDW_UI' in os.environ:\n",
302
+ " UI = os.environ['SDW_UI']\n",
303
+ " else:\n",
304
+ " os.environ['SDW_UI'] = change_webui_widget\n",
305
+ " os.environ['SDW_OLD_UI'] = change_webui_widget\n",
306
+ "\n",
307
+ " UI = os.getenv('SDW_UI')\n",
308
+ "\n",
309
+ " if UI != change_webui_widget:\n",
310
+ " os.environ['SDW_UI'] = change_webui_widget\n",
311
+ "\n",
312
+ "\n",
313
  "# ============ Load / Save - Settings V2 ============\n",
314
  "SETTINGS_FILE = f'{root_path}/settings.json'\n",
315
  "\n",
 
344
  "\n",
345
  "def save_data(button):\n",
346
  " save_settings()\n",
347
+ " setup_webui(change_webui_widget.value)\n",
348
  " hide_widgets()\n",
349
  "\n",
350
  "load_settings()\n",
files_cells/notebooks/ru/downloading_ru.ipynb CHANGED
@@ -34,6 +34,31 @@
34
  "webui_path = os.getenv('WEBUI_PATH')\n",
35
  "free_plan = os.getenv('FREE_PLAN')\n",
36
  "\n",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  "\n",
38
  "# ================ LIBRARIES V2 ================\n",
39
  "flag_file = f\"{root_path}/libraries_installed.txt\"\n",
@@ -45,8 +70,9 @@
45
  " # \"aria2\": \"apt -y install aria2\",\n",
46
  " \"aria2\": \"pip install aria2\",\n",
47
  " \"localtunnel\": \"npm install -g localtunnel\",\n",
48
- " \"insightface\": \"pip install insightface\"\n",
49
  " }\n",
 
 
50
  "\n",
51
  " additional_libs = {\n",
52
  " \"Google Colab\": {\n",
@@ -58,7 +84,6 @@
58
  " # \"aiohttp\": \"pip install trash-cli && trash-put /opt/conda/lib/python3.10/site-packages/aiohttp*\" # fix install req\n",
59
  " }\n",
60
  " }\n",
61
- "\n",
62
  " if env in additional_libs:\n",
63
  " install_lib.update(additional_libs[env])\n",
64
  "\n",
@@ -85,68 +110,106 @@
85
  " clear_output()\n",
86
  "\n",
87
  "\n",
88
- "# ================= loading settings V4 =================\n",
89
- "def load_settings(path):\n",
90
- " if os.path.exists(path):\n",
91
- " with open(path, 'r') as file:\n",
92
- " return json.load(file)\n",
93
- " return {}\n",
94
- "\n",
95
- "settings = load_settings(f'{root_path}/settings.json')\n",
96
  "\n",
97
- "VARIABLES = [\n",
98
- " 'model', 'model_num', 'inpainting_model',\n",
99
- " 'vae', 'vae_num', 'latest_webui', 'latest_exstensions',\n",
100
- " 'change_webui', 'detailed_download', 'controlnet',\n",
101
- " 'controlnet_num', 'commit_hash', 'huggingface_token',\n",
102
- " 'ngrok_token', 'zrok_token', 'commandline_arguments',\n",
103
- " 'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url',\n",
104
- " 'Extensions_url', 'custom_file_urls'\n",
105
- "]\n",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  "\n",
107
- "locals().update({key: settings.get(key) for key in VARIABLES})\n",
 
 
108
  "\n",
 
 
 
 
109
  "\n",
110
- "# ================= OTHER =================\n",
111
- "try:\n",
112
- " start_colab\n",
113
- "except:\n",
114
- " start_colab = int(time.time())-5\n",
115
  "\n",
 
 
116
  "\n",
117
- "# ================= MAIN CODE =================\n",
118
- "if not os.path.exists(webui_path):\n",
119
- " start_install = int(time.time())\n",
120
- " print(\"⌚ Распаковка Stable Diffusion...\" if change_webui != 'Forge' else \"⌚ Распаковка Stable Diffusion (Forge)...\", end='')\n",
121
- " with capture.capture_output() as cap:\n",
122
- " aria2_command = \"aria2c --console-log-level=error -c -x 16 -s 16 -k 1M\"\n",
123
- " url = \"https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO.zip\" if change_webui != 'Forge' else \"https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO_forge.zip\"\n",
124
- " !{aria2_command} {url} -o repo.zip\n",
125
  "\n",
126
- " !unzip -q -o repo.zip -d {webui_path}\n",
127
- " !rm -rf repo.zip\n",
 
128
  "\n",
129
- " %cd {root_path}\n",
130
- " os.environ[\"SAFETENSORS_FAST_GPU\"]='1'\n",
131
- " os.environ[\"CUDA_MODULE_LOADING\"]=\"LAZY\"\n",
132
- " os.environ[\"TF_CPP_MIN_LOG_LEVEL\"] = \"3\"\n",
133
- " os.environ[\"PYTHONWARNINGS\"] = \"ignore\"\n",
 
 
 
 
134
  "\n",
135
- " !echo -n {start_colab} > {webui_path}/static/colabTimer.txt\n",
136
- " del cap\n",
137
- " install_time = timedelta(seconds=time.time()-start_install)\n",
138
- " print(\"\\r🚀 Распаковка Завершена! За\",\"%02d:%02d:%02d ⚡\\n\" % (install_time.seconds / 3600, (install_time.seconds / 60) % 60, install_time.seconds % 60), end='', flush=True)\n",
139
  "else:\n",
140
  " print(\"🚀 Все распакованно... Пропуск. ⚡\")\n",
141
- " start_colab = float(open(f'{webui_path}/static/colabTimer.txt', 'r').read())\n",
142
- " time_since_start = str(timedelta(seconds=time.time()-start_colab)).split('.')[0]\n",
143
- " print(f\"⌚️ Вы проводите эту сессию в течение - \\033[33m{time_since_start}\\033[0m\")\n",
144
  "\n",
145
  "\n",
146
  "## Changes extensions and WebUi\n",
147
  "if latest_webui or latest_exstensions:\n",
148
- " action = \"Обновление WebUI и Расширений\" if latest_webui and latest_exstensions else (\"Обновление WebUI\" if latest_webui else \"Обновление Расширений\")\n",
149
- " print(f\"⌚️ {action}...\", end='', flush=True)\n",
150
  " with capture.capture_output() as cap:\n",
151
  " !git config --global user.email \"[email protected]\"\n",
152
  " !git config --global user.name \"Your Name\"\n",
@@ -161,7 +224,7 @@
161
  " if latest_exstensions:\n",
162
  " !{'for dir in ' + webui_path + '/extensions/*/; do cd \\\"$dir\\\" && git reset --hard && git pull; done'}\n",
163
  " del cap\n",
164
- " print(f\"\\r✨ {action} Завершено!\")\n",
165
  "\n",
166
  "\n",
167
  "# === FIXING EXTENSIONS ===\n",
@@ -170,10 +233,8 @@
170
  "with capture.capture_output() as cap:\n",
171
  " # --- Umi-Wildcard ---\n",
172
  " !sed -i '521s/open=\\(False\\|True\\)/open=False/' {webui_path}/extensions/Umi-AI-Wildcards/scripts/wildcard_recursive.py # Closed accordion by default\n",
173
- "\n",
174
  " # --- Encrypt-Image ---\n",
175
  " !sed -i '9,37d' {webui_path}/extensions/Encrypt-Image/javascript/encrypt_images_info.js # Removes the weird text in webui\n",
176
- "\n",
177
  " # --- Additional-Networks ---\n",
178
  " !wget -O {webui_path}/extensions/additional-networks/scripts/metadata_editor.py {anxety_repos}/extensions/Additional-Networks/fix/metadata_editor.py # Fixing an error due to old style\n",
179
  "del cap\n",
@@ -181,7 +242,7 @@
181
  "\n",
182
  "## Version switching\n",
183
  "if commit_hash:\n",
184
- " print('⏳ Активация машины времени...', end=\"\", flush=True)\n",
185
  " with capture.capture_output() as cap:\n",
186
  " %cd {webui_path}\n",
187
  " !git config --global user.email \"[email protected]\"\n",
@@ -221,7 +282,7 @@
221
  " padding = (terminal_width - len(text)) // 2\n",
222
  " return f\"\\033[1m\\033[36m{' ' * padding}{text}{' ' * padding}\\033[0m\\033[32m\"\n",
223
  "\n",
224
- "def format_output(url, dst_dir, file_name):\n",
225
  " info = center_text(f\"[{file_name.split('.')[0]}]\")\n",
226
  " separation_line = '\\033[32m' + '---' * 20\n",
227
  "\n",
@@ -230,89 +291,81 @@
230
  " print(f\"\\033[33mSAVE DIR: \\033[34m{dst_dir}\")\n",
231
  " print(f\"\\033[33mFILE NAME: \\033[34m{file_name}\\033[0m\")\n",
232
  "\n",
 
 
 
233
  "''' GET CivitAi API - DATA '''\n",
234
  "\n",
235
  "def CivitAi_API(url, file_name=None):\n",
236
- " SUPPORT_TYPES = ('Checkpoint', 'Model', 'TextualInversion', 'LORA')\n",
237
  " CIVITAI_TOKEN = \"62c0c5956b2f9defbd844d754000180b\"\n",
238
  "\n",
239
  " url = url.split('?token=')[0] if '?token=' in url else url\n",
240
  " url = url.replace('?type=', f'?token={CIVITAI_TOKEN}&type=') if '?type=' in url else f\"{url}?token={CIVITAI_TOKEN}\"\n",
241
  "\n",
242
  " def get_model_data(url):\n",
243
- " if \"civitai.com/models/\" in url:\n",
244
- " if '?modelVersionId=' in url:\n",
245
- " version_id = url.split('?modelVersionId=')[1]\n",
246
- " return requests.get(f\"https://civitai.com/api/v1/model-versions/{version_id}\").json()\n",
 
 
 
 
 
247
  " else:\n",
248
- " model_id = url.split('/models/')[1].split('/')[0]\n",
249
- " return requests.get(f\"https://civitai.com/api/v1/models/{model_id}\").json()\n",
250
- " else:\n",
251
- " version_id = url.split('/models/')[1].split('/')[0]\n",
252
- " return requests.get(f\"https://civitai.com/api/v1/model-versions/{version_id}\").json()\n",
253
  "\n",
254
  " data = get_model_data(url)\n",
255
  "\n",
256
  " if not data:\n",
257
- " return None, None, None, None, None, None, None\n",
 
258
  "\n",
259
  " def extract_model_info(url, data):\n",
260
- " if \"civitai.com/models/\" in url:\n",
261
- " if '?modelVersionId=' in url:\n",
262
- " model_type = data['model']['type']\n",
263
- " model_name = data['files'][0]['name']\n",
264
- " else:\n",
265
- " model_type = data['type']\n",
266
- " model_name = data['modelVersions'][0]['files'][0]['name']\n",
267
- " elif 'type=' in url:\n",
268
- " model_type = parse_qs(urlparse(url).query).get('type', [''])[0]\n",
269
- " if 'model' in model_type.lower():\n",
270
- " model_name = data['files'][0]['name']\n",
271
- " else:\n",
272
  " model_name = data['files'][1]['name']\n",
273
- " else:\n",
274
- " model_type = data['model']['type']\n",
275
- " model_name = data['files'][0]['name']\n",
276
  " return model_type, model_name\n",
277
  "\n",
278
  " model_type, model_name = extract_model_info(url, data)\n",
279
  " model_name = file_name or model_name\n",
280
  "\n",
281
- " def get_download_url(url, data, model_type):\n",
282
- " if \"civitai.com/models/\" in url:\n",
283
- " if '?modelVersionId=' in url:\n",
284
- " return data.get('downloadUrl')\n",
285
- " else:\n",
286
- " return data[\"modelVersions\"][0].get(\"downloadUrl\", \"\")\n",
287
- " elif 'type=' in url:\n",
288
- " if any(t.lower() in model_type.lower() for t in SUPPORT_TYPES):\n",
289
- " return data['files'][0]['downloadUrl']\n",
290
- " else:\n",
291
- " return data['files'][1]['downloadUrl']\n",
292
- " else:\n",
293
- " return data.get('downloadUrl')\n",
294
  "\n",
295
- " download_url = get_download_url(url, data, model_type)\n",
296
- " clean_url = re.sub(r'[?&]token=[^&]*', '', download_url)\n",
 
297
  "\n",
298
  " def get_image_info(data, model_type, model_name):\n",
299
- " image_url, image_name = None, None\n",
300
- " if any(t in model_type for t in SUPPORT_TYPES):\n",
301
- " try:\n",
302
- " images = data.get('images') or data['modelVersions'][0].get('images', [])\n",
303
- " if env == 'Kaggle':\n",
304
- " image_url = next((image['url'] for image in images if image['nsfwLevel'] < 4), None)\n",
305
- " else:\n",
306
- " image_url = images[0]['url'] if images else None\n",
307
- " except KeyError:\n",
308
- " pass\n",
309
  "\n",
310
- " image_name = f\"{model_name.split('.')[0]}.preview.{image_url.split('.')[-1]}\" if image_url else None\n",
311
- " return image_url, image_name\n",
312
  "\n",
313
  " image_url, image_name = get_image_info(data, model_type, model_name)\n",
314
  "\n",
315
- " return f\"{download_url}{'&' if '?' in download_url else '?'}token={CIVITAI_TOKEN}\", clean_url, model_type, model_name, image_url, image_name, data\n",
316
  "\n",
317
  "''' Main Download Code '''\n",
318
  "\n",
@@ -358,13 +411,13 @@
358
  " dir = PREFIXES[prefix]\n",
359
  " if prefix != \"extension\":\n",
360
  " try:\n",
361
- " manual_download(path, dir, file_name=file_name)\n",
362
  " except Exception as e:\n",
363
  " print(f\"Error downloading file: {e}\")\n",
364
  " else:\n",
365
  " extension_repo.append((path, file_name))\n",
366
  "\n",
367
- "def manual_download(url, dst_dir, file_name):\n",
368
  " header_option = f\"--header={user_header}\"\n",
369
  " aria2c_header = \"--header='User-Agent: Mozilla/5.0' --allow-overwrite=true\"\n",
370
  " aria2_args = \"--optimize-concurrent-downloads --console-log-level=error --summary-interval=10 --stderr=true -c -x16 -s16 -k1M -j5\"\n",
@@ -382,17 +435,17 @@
382
  "\n",
383
  " \"\"\" Formatted info output \"\"\"\n",
384
  " model_name_or_basename = file_name if file_name else basename\n",
385
- " format_output(clean_url or url, dst_dir, model_name_or_basename)\n",
386
- "\n",
387
- " # print(url, dst_dir, model_name_or_basename)\n",
388
- " if 'civitai' in url:\n",
389
- " if not data:\n",
390
- " print(\"\\033[31m[Data Info]:\\033[0m Failed to retrieve data from the API.\\n\")\n",
391
- " if data and image_name:\n",
392
- " print(f\"\\033[32m[Preview DL]:\\033[0m {image_name} - {image_url}\\n\")\n",
393
  "\n",
394
  " # =====================\n",
395
  " def run_aria2c(url, dst_dir, file_name=None, args=\"\", header=\"\"):\n",
 
 
 
 
396
  " out = f\"-o '{file_name}'\" if file_name else \"\"\n",
397
  " !aria2c {header} {args} -d {dst_dir} {out} '{url}'\n",
398
  "\n",
@@ -418,19 +471,44 @@
418
  "\n",
419
  "''' SubModels - Added URLs '''\n",
420
  "\n",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
421
  "def add_submodels(selection, num_selection, model_dict, dst_dir):\n",
 
422
  " if selection == \"none\":\n",
423
- " return []\n",
424
  " if selection == \"ALL\":\n",
425
- " all_models = []\n",
426
  " for models in model_dict.values():\n",
427
- " all_models.extend(models)\n",
428
- " selected_models = all_models\n",
429
  " else:\n",
430
- " selected_models = model_dict[selection]\n",
431
- " selected_nums = map(int, num_selection.replace(',', '').split())\n",
432
- " for num in selected_nums:\n",
433
- " if 1 <= num <= len(model_dict):\n",
 
 
 
 
 
 
 
 
 
 
 
434
  " name = list(model_dict)[num - 1]\n",
435
  " selected_models.extend(model_dict[name])\n",
436
  "\n",
@@ -521,7 +599,7 @@
521
  "\n",
522
  "## Install of Custom extensions\n",
523
  "if len(extension_repo) > 0:\n",
524
- " print(\"✨ Установка кастомных расширений...\", end='', flush=True)\n",
525
  " with capture.capture_output() as cap:\n",
526
  " for repo, repo_name in extension_repo:\n",
527
  " if not repo_name:\n",
 
34
  "webui_path = os.getenv('WEBUI_PATH')\n",
35
  "free_plan = os.getenv('FREE_PLAN')\n",
36
  "\n",
37
+ "UI = os.getenv('SDW_UI')\n",
38
+ "OLD_UI = os.getenv('SDW_OLD_UI')\n",
39
+ "\n",
40
+ "\n",
41
+ "# ============ loading settings V4 =============\n",
42
+ "def load_settings(path):\n",
43
+ " if os.path.exists(path):\n",
44
+ " with open(path, 'r') as file:\n",
45
+ " return json.load(file)\n",
46
+ " return {}\n",
47
+ "\n",
48
+ "settings = load_settings(f'{root_path}/settings.json')\n",
49
+ "\n",
50
+ "VARIABLES = [\n",
51
+ " 'model', 'model_num', 'inpainting_model',\n",
52
+ " 'vae', 'vae_num', 'latest_webui', 'latest_exstensions',\n",
53
+ " 'change_webui', 'detailed_download', 'controlnet',\n",
54
+ " 'controlnet_num', 'commit_hash', 'huggingface_token',\n",
55
+ " 'ngrok_token', 'zrok_token', 'commandline_arguments',\n",
56
+ " 'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url',\n",
57
+ " 'Extensions_url', 'custom_file_urls'\n",
58
+ "]\n",
59
+ "\n",
60
+ "locals().update({key: settings.get(key) for key in VARIABLES})\n",
61
+ "\n",
62
  "\n",
63
  "# ================ LIBRARIES V2 ================\n",
64
  "flag_file = f\"{root_path}/libraries_installed.txt\"\n",
 
70
  " # \"aria2\": \"apt -y install aria2\",\n",
71
  " \"aria2\": \"pip install aria2\",\n",
72
  " \"localtunnel\": \"npm install -g localtunnel\",\n",
 
73
  " }\n",
74
+ " if controlnet != 'none':\n",
75
+ " install_lib[\"insightface\"] = \"pip install insightface\"\n",
76
  "\n",
77
  " additional_libs = {\n",
78
  " \"Google Colab\": {\n",
 
84
  " # \"aiohttp\": \"pip install trash-cli && trash-put /opt/conda/lib/python3.10/site-packages/aiohttp*\" # fix install req\n",
85
  " }\n",
86
  " }\n",
 
87
  " if env in additional_libs:\n",
88
  " install_lib.update(additional_libs[env])\n",
89
  "\n",
 
110
  " clear_output()\n",
111
  "\n",
112
  "\n",
113
+ "# =================== OTHER ====================\n",
114
+ "# Setup Timer\n",
115
+ "if \"START_COLAB\" in os.environ:\n",
116
+ " start_colab = int(os.environ[\"START_COLAB\"])\n",
117
+ "else:\n",
118
+ " start_colab = int(time.time()) - 5\n",
119
+ " os.environ[\"START_COLAB\"] = str(start_colab)\n",
 
120
  "\n",
121
+ "# remove directory func\n",
122
+ "def _remove_dir(directory_path):\n",
123
+ " if directory_path and os.path.exists(directory_path):\n",
124
+ " try:\n",
125
+ " shutil.rmtree(directory_path)\n",
126
+ " except Exception:\n",
127
+ " !rm -rf {directory_path}\n",
128
+ "\n",
129
+ "# Save files temporarily\n",
130
+ "temporarily_dir = f'{root_path}/temp_dir'\n",
131
+ "\n",
132
+ "def copy_items_with_replace(src_base, dst_base):\n",
133
+ " items_to_copy = [\n",
134
+ " 'embeddings',\n",
135
+ " 'models/Stable-diffusion',\n",
136
+ " 'models/VAE',\n",
137
+ " 'models/Lora',\n",
138
+ " 'models/ControlNet'\n",
139
+ " ]\n",
140
+ "\n",
141
+ " print(\"⌚ Перемещение файлов...\", end='')\n",
142
+ " time.sleep(1)\n",
143
+ " for item in items_to_copy:\n",
144
+ " src = os.path.join(src_base, item)\n",
145
+ " dst = os.path.join(dst_base, item)\n",
146
+ "\n",
147
+ " if os.path.exists(src):\n",
148
+ " if os.path.exists(dst):\n",
149
+ " _remove_dir(dst)\n",
150
+ " os.makedirs(os.path.dirname(dst), exist_ok=True)\n",
151
+ " shutil.move(src, dst)\n",
152
+ " print(\"\\r🔥 Файлы перемещены!\" + \" \"*15)\n",
153
+ "\n",
154
+ "def handle_colab_timer(webui_path, timer_colab):\n",
155
+ " timer_file_path = os.path.join(webui_path, 'static', 'colabTimer.txt')\n",
156
+ " if not os.path.exists(timer_file_path):\n",
157
+ " with open(timer_file_path, 'w') as timer_file:\n",
158
+ " timer_file.write(str(timer_colab))\n",
159
+ " else:\n",
160
+ " with open(timer_file_path, 'r') as timer_file:\n",
161
+ " timer_colab = float(timer_file.read())\n",
162
+ " return timer_colab\n",
163
  "\n",
164
+ "def unpack_webui():\n",
165
+ " start_install = time.time()\n",
166
+ " print(f\"⌚ Распаковка Stable Diffusion{' (Forge)' if UI == 'Forge' else ''}...\", end='')\n",
167
  "\n",
168
+ " with capture.capture_output() as cap:\n",
169
+ " download_url = \"https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO.zip\"\n",
170
+ " if UI == 'Forge':\n",
171
+ " download_url = \"https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO_forge.zip\"\n",
172
  "\n",
173
+ " aria2_args = \"--console-log-level=error -c -x 16 -s 16 -k 1M\"\n",
174
+ " zip_path = f\"{root_path}/repo.zip\"\n",
175
+ " !aria2c {aria2_args} {download_url} -d {root_path} -o repo.zip\n",
176
+ " !unzip -q -o {zip_path} -d {webui_path}\n",
177
+ " !rm -rf {zip_path}\n",
178
  "\n",
179
+ " get_ipython().system(f'echo -n {start_colab} > {webui_path}/static/colabTimer.txt')\n",
180
+ " del cap\n",
181
  "\n",
182
+ " install_time = time.time() - start_install\n",
183
+ " minutes, seconds = divmod(int(install_time), 60)\n",
184
+ " print(f\"\\r🚀 Распаковка Завершена! За {minutes:02}:{seconds:02} ⚡\" + \" \"*15)\n",
 
 
 
 
 
185
  "\n",
186
+ " if os.path.exists(temporarily_dir):\n",
187
+ " copy_items_with_replace(temporarily_dir, webui_path)\n",
188
+ " _remove_dir(temporarily_dir)\n",
189
  "\n",
190
+ "# ================= MAIN CODE ==================\n",
191
+ "if os.path.exists(webui_path):\n",
192
+ " if UI != OLD_UI:\n",
193
+ " print(f'Переключение веб-интерфейса с \\033[33m{OLD_UI}\\033[0m на \\033[33m{UI}\\033[0m:')\n",
194
+ " copy_items_with_replace(webui_path, temporarily_dir)\n",
195
+ " _remove_dir(webui_path)\n",
196
+ " os.environ['SDW_OLD_UI'] = UI\n",
197
+ " time.sleep(2)\n",
198
+ " clear_output()\n",
199
  "\n",
200
+ "if not os.path.exists(webui_path):\n",
201
+ " unpack_webui()\n",
 
 
202
  "else:\n",
203
  " print(\"🚀 Все распакованно... Пропуск. ⚡\")\n",
204
+ " timer_colab = handle_colab_timer(webui_path, start_colab)\n",
205
+ " elapsed_time = str(timedelta(seconds=time.time() - timer_colab)).split('.')[0]\n",
206
+ " print(f\"⌚️ Вы проводите эту сессию в течение - \\033[33m{elapsed_time}\\033[0m\")\n",
207
  "\n",
208
  "\n",
209
  "## Changes extensions and WebUi\n",
210
  "if latest_webui or latest_exstensions:\n",
211
+ " action = \"WebUI и Расширений\" if latest_webui and latest_exstensions else (\"WebUI\" if latest_webui else \"Расширений\")\n",
212
+ " print(f\"⌚️ Обновление {action}...\", end='')\n",
213
  " with capture.capture_output() as cap:\n",
214
  " !git config --global user.email \"[email protected]\"\n",
215
  " !git config --global user.name \"Your Name\"\n",
 
224
  " if latest_exstensions:\n",
225
  " !{'for dir in ' + webui_path + '/extensions/*/; do cd \\\"$dir\\\" && git reset --hard && git pull; done'}\n",
226
  " del cap\n",
227
+ " print(f\"\\r✨ Обновление {action} Завершено!\")\n",
228
  "\n",
229
  "\n",
230
  "# === FIXING EXTENSIONS ===\n",
 
233
  "with capture.capture_output() as cap:\n",
234
  " # --- Umi-Wildcard ---\n",
235
  " !sed -i '521s/open=\\(False\\|True\\)/open=False/' {webui_path}/extensions/Umi-AI-Wildcards/scripts/wildcard_recursive.py # Closed accordion by default\n",
 
236
  " # --- Encrypt-Image ---\n",
237
  " !sed -i '9,37d' {webui_path}/extensions/Encrypt-Image/javascript/encrypt_images_info.js # Removes the weird text in webui\n",
 
238
  " # --- Additional-Networks ---\n",
239
  " !wget -O {webui_path}/extensions/additional-networks/scripts/metadata_editor.py {anxety_repos}/extensions/Additional-Networks/fix/metadata_editor.py # Fixing an error due to old style\n",
240
  "del cap\n",
 
242
  "\n",
243
  "## Version switching\n",
244
  "if commit_hash:\n",
245
+ " print('⏳ Активация машины времени...', end=\"\")\n",
246
  " with capture.capture_output() as cap:\n",
247
  " %cd {webui_path}\n",
248
  " !git config --global user.email \"[email protected]\"\n",
 
282
  " padding = (terminal_width - len(text)) // 2\n",
283
  " return f\"\\033[1m\\033[36m{' ' * padding}{text}{' ' * padding}\\033[0m\\033[32m\"\n",
284
  "\n",
285
+ "def format_output(url, dst_dir, file_name, image_name=None, image_url=None):\n",
286
  " info = center_text(f\"[{file_name.split('.')[0]}]\")\n",
287
  " separation_line = '\\033[32m' + '---' * 20\n",
288
  "\n",
 
291
  " print(f\"\\033[33mSAVE DIR: \\033[34m{dst_dir}\")\n",
292
  " print(f\"\\033[33mFILE NAME: \\033[34m{file_name}\\033[0m\")\n",
293
  "\n",
294
+ " if 'civitai' in url and image_url:\n",
295
+ " print(f\"\\033[32m[Preview DL]:\\033[0m {image_name} - {image_url}\\n\")\n",
296
+ "\n",
297
  "''' GET CivitAi API - DATA '''\n",
298
  "\n",
299
  "def CivitAi_API(url, file_name=None):\n",
300
+ " SUPPORT_TYPES = ('Checkpoint', 'TextualInversion', 'LORA')\n",
301
  " CIVITAI_TOKEN = \"62c0c5956b2f9defbd844d754000180b\"\n",
302
  "\n",
303
  " url = url.split('?token=')[0] if '?token=' in url else url\n",
304
  " url = url.replace('?type=', f'?token={CIVITAI_TOKEN}&type=') if '?type=' in url else f\"{url}?token={CIVITAI_TOKEN}\"\n",
305
  "\n",
306
  " def get_model_data(url):\n",
307
+ " base_url = \"https://civitai.com/api/v1\"\n",
308
+ " try:\n",
309
+ " if \"civitai.com/models/\" in url:\n",
310
+ " if '?modelVersionId=' in url:\n",
311
+ " version_id = url.split('?modelVersionId=')[1]\n",
312
+ " else:\n",
313
+ " model_id = url.split('/models/')[1].split('/')[0]\n",
314
+ " model_data = requests.get(f\"{base_url}/models/{model_id}\").json()\n",
315
+ " version_id = model_data['modelVersions'][0].get('id')\n",
316
  " else:\n",
317
+ " version_id = url.split('/models/')[1].split('/')[0]\n",
318
+ "\n",
319
+ " return requests.get(f\"{base_url}/model-versions/{version_id}\").json()\n",
320
+ " except (KeyError, IndexError, requests.RequestException) as e:\n",
321
+ " return None\n",
322
  "\n",
323
  " data = get_model_data(url)\n",
324
  "\n",
325
  " if not data:\n",
326
+ " print(\"\\033[31m[Data Info]:\\033[0m Failed to retrieve data from the API.\\n\")\n",
327
+ " return 'None', None, None, None, None, None, None\n",
328
  "\n",
329
  " def extract_model_info(url, data):\n",
330
+ " model_type = data['model']['type']\n",
331
+ " model_name = data['files'][0]['name']\n",
332
+ "\n",
333
+ " if 'type=' in url:\n",
334
+ " url_model_type = parse_qs(urlparse(url).query).get('type', [''])[0].lower()\n",
335
+ " if 'vae' in url_model_type:\n",
336
+ " model_type = data['files'][1]['type']\n",
 
 
 
 
 
337
  " model_name = data['files'][1]['name']\n",
338
+ "\n",
 
 
339
  " return model_type, model_name\n",
340
  "\n",
341
  " model_type, model_name = extract_model_info(url, data)\n",
342
  " model_name = file_name or model_name\n",
343
  "\n",
344
+ " def get_download_url(data, model_type):\n",
345
+ " if any(t.lower() in model_type.lower() for t in SUPPORT_TYPES):\n",
346
+ " return data['files'][0]['downloadUrl']\n",
 
 
 
 
 
 
 
 
 
 
347
  "\n",
348
+ " return data['files'][1]['downloadUrl'] if 'type' in url else data['files'][0]['downloadUrl']\n",
349
+ "\n",
350
+ " download_url = get_download_url(data, model_type)\n",
351
  "\n",
352
  " def get_image_info(data, model_type, model_name):\n",
353
+ " if not any(t in model_type for t in SUPPORT_TYPES):\n",
354
+ " return None, None\n",
355
+ "\n",
356
+ " for image in data.get('images', []):\n",
357
+ " if image['nsfwLevel'] >= 4 and env == 'Kaggle': # Filter NSFW images for Kaggle\n",
358
+ " continue\n",
359
+ " image_url = image['url']\n",
360
+ " image_extension = image_url.split('.')[-1]\n",
361
+ " image_name = f\"{model_name.split('.')[0]}.preview.{image_extension}\" if image_url else None\n",
362
+ " return image_url, image_name\n",
363
  "\n",
364
+ " return None, None\n",
 
365
  "\n",
366
  " image_url, image_name = get_image_info(data, model_type, model_name)\n",
367
  "\n",
368
+ " return f\"{download_url}{'&' if '?' in download_url else '?'}token={CIVITAI_TOKEN}\", download_url, model_type, model_name, image_url, image_name, data\n",
369
  "\n",
370
  "''' Main Download Code '''\n",
371
  "\n",
 
411
  " dir = PREFIXES[prefix]\n",
412
  " if prefix != \"extension\":\n",
413
  " try:\n",
414
+ " manual_download(path, dir, file_name=file_name, prefix=prefix)\n",
415
  " except Exception as e:\n",
416
  " print(f\"Error downloading file: {e}\")\n",
417
  " else:\n",
418
  " extension_repo.append((path, file_name))\n",
419
  "\n",
420
+ "def manual_download(url, dst_dir, file_name, prefix=None):\n",
421
  " header_option = f\"--header={user_header}\"\n",
422
  " aria2c_header = \"--header='User-Agent: Mozilla/5.0' --allow-overwrite=true\"\n",
423
  " aria2_args = \"--optimize-concurrent-downloads --console-log-level=error --summary-interval=10 --stderr=true -c -x16 -s16 -k1M -j5\"\n",
 
435
  "\n",
436
  " \"\"\" Formatted info output \"\"\"\n",
437
  " model_name_or_basename = file_name if file_name else basename\n",
438
+ " try:\n",
439
+ " format_output(clean_url or url, dst_dir, model_name_or_basename, image_name, image_url)\n",
440
+ " except UnboundLocalError:\n",
441
+ " format_output(clean_url or url, dst_dir, model_name_or_basename, None, None)\n",
 
 
 
 
442
  "\n",
443
  " # =====================\n",
444
  " def run_aria2c(url, dst_dir, file_name=None, args=\"\", header=\"\"):\n",
445
+ " file_path = os.path.join(dst_dir, file_name) # replaces config files\n",
446
+ " if os.path.exists(file_path) and prefix == 'config':\n",
447
+ " os.remove(file_path)\n",
448
+ "\n",
449
  " out = f\"-o '{file_name}'\" if file_name else \"\"\n",
450
  " !aria2c {header} {args} -d {dst_dir} {out} '{url}'\n",
451
  "\n",
 
471
  "\n",
472
  "''' SubModels - Added URLs '''\n",
473
  "\n",
474
+ "# Separation of merged numbers\n",
475
+ "def split_numbers(num_str, max_num):\n",
476
+ " def helper(s):\n",
477
+ " if not s:\n",
478
+ " return []\n",
479
+ " for length in range(2, 0, -1):\n",
480
+ " if len(s) >= length:\n",
481
+ " part = int(s[:length])\n",
482
+ " if part <= max_num:\n",
483
+ " result = helper(s[length:])\n",
484
+ " if result is not None:\n",
485
+ " return [part] + result\n",
486
+ " return None\n",
487
+ " return helper(num_str)\n",
488
+ "\n",
489
  "def add_submodels(selection, num_selection, model_dict, dst_dir):\n",
490
+ " selected_models = []\n",
491
  " if selection == \"none\":\n",
492
+ " return selected_models\n",
493
  " if selection == \"ALL\":\n",
 
494
  " for models in model_dict.values():\n",
495
+ " selected_models.extend(models)\n",
 
496
  " else:\n",
497
+ " if selection in model_dict:\n",
498
+ " selected_models.extend(model_dict[selection])\n",
499
+ " nums = num_selection.replace(',', ' ').split()\n",
500
+ " max_num = len(model_dict)\n",
501
+ " selected_nums = []\n",
502
+ "\n",
503
+ " for num_part in nums:\n",
504
+ " split_nums = split_numbers(num_part, max_num)\n",
505
+ " if split_nums:\n",
506
+ " selected_nums.extend(split_nums)\n",
507
+ "\n",
508
+ " unique_nums = list(set(selected_nums))\n",
509
+ "\n",
510
+ " for num in unique_nums:\n",
511
+ " if 1 <= num <= max_num:\n",
512
  " name = list(model_dict)[num - 1]\n",
513
  " selected_models.extend(model_dict[name])\n",
514
  "\n",
 
599
  "\n",
600
  "## Install of Custom extensions\n",
601
  "if len(extension_repo) > 0:\n",
602
+ " print(\"✨ Установка кастомных расширений...\", end='')\n",
603
  " with capture.capture_output() as cap:\n",
604
  " for repo, repo_name in extension_repo:\n",
605
  " if not repo_name:\n",
files_cells/notebooks/ru/launch_ru.ipynb CHANGED
@@ -29,6 +29,7 @@
29
  "import time\n",
30
  "import json\n",
31
  "import requests\n",
 
32
  "import cloudpickle as pickle\n",
33
  "from datetime import timedelta\n",
34
  "from IPython.display import clear_output\n",
@@ -55,6 +56,17 @@
55
  "change_webui = settings.get('change_webui', \"\")\n",
56
  "\n",
57
  "\n",
 
 
 
 
 
 
 
 
 
 
 
58
  "# ======================== TUNNEL V2 ========================\n",
59
  "print('Please Wait...')\n",
60
  "\n",
@@ -80,7 +92,9 @@
80
  "tunnel_port = 1834\n",
81
  "tunnel = tunnel_class(tunnel_port)\n",
82
  "tunnel.add_tunnel(command=\"cl tunnel --url localhost:{port}\", name=\"cl\", pattern=re.compile(r\"[\\w-]+\\.trycloudflare\\.com\"))\n",
83
- "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",
 
 
84
  "\n",
85
  "if zrok_token:\n",
86
  " !zrok enable {zrok_token} &> /dev/null\n",
@@ -89,7 +103,7 @@
89
  "clear_output()\n",
90
  "\n",
91
  "\n",
92
- "# =============== Automatic Fixing Path V3 ===============\n",
93
  "paths_to_check = {\n",
94
  " \"tagger_hf_cache_dir\": f\"{webui_path}/models/interrogators/\",\n",
95
  " \"additional_networks_extra_lora_path\": f\"{webui_path}/models/Lora/\",\n",
@@ -120,8 +134,10 @@
120
  " if env != \"Google Colab\":\n",
121
  " commandline_arguments += f' --encrypt-pass={tunnel_port} --api'\n",
122
  "\n",
123
- " if change_webui == 'Forge':\n",
124
- " commandline_arguments += ' --cuda-stream --pin-shared-memory'\n",
 
 
125
  "\n",
126
  " !COMMANDLINE_ARGS=\"{commandline_arguments}\" python launch.py\n",
127
  "\n",
 
29
  "import time\n",
30
  "import json\n",
31
  "import requests\n",
32
+ "import subprocess\n",
33
  "import cloudpickle as pickle\n",
34
  "from datetime import timedelta\n",
35
  "from IPython.display import clear_output\n",
 
56
  "change_webui = settings.get('change_webui', \"\")\n",
57
  "\n",
58
  "\n",
59
+ "# ========================== OTHER ==========================\n",
60
+ "def is_package_installed(package_name):\n",
61
+ " try:\n",
62
+ " subprocess.run([\"npm\", \"ls\", \"-g\", package_name], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n",
63
+ " return True\n",
64
+ " except subprocess.CalledProcessError:\n",
65
+ " return False\n",
66
+ "\n",
67
+ "lt_tunnel = is_package_installed('localtunnel')\n",
68
+ "\n",
69
+ "\n",
70
  "# ======================== TUNNEL V2 ========================\n",
71
  "print('Please Wait...')\n",
72
  "\n",
 
92
  "tunnel_port = 1834\n",
93
  "tunnel = tunnel_class(tunnel_port)\n",
94
  "tunnel.add_tunnel(command=\"cl tunnel --url localhost:{port}\", name=\"cl\", pattern=re.compile(r\"[\\w-]+\\.trycloudflare\\.com\"))\n",
95
+ "\n",
96
+ "if lt_tunnel:\n",
97
+ " 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",
98
  "\n",
99
  "if zrok_token:\n",
100
  " !zrok enable {zrok_token} &> /dev/null\n",
 
103
  "clear_output()\n",
104
  "\n",
105
  "\n",
106
+ "# ================= Automatic Fixing Path V3 ================\n",
107
  "paths_to_check = {\n",
108
  " \"tagger_hf_cache_dir\": f\"{webui_path}/models/interrogators/\",\n",
109
  " \"additional_networks_extra_lora_path\": f\"{webui_path}/models/Lora/\",\n",
 
134
  " if env != \"Google Colab\":\n",
135
  " commandline_arguments += f' --encrypt-pass={tunnel_port} --api'\n",
136
  "\n",
137
+ " if change_webui == 'A1111':\n",
138
+ " commandline_arguments += ' --xformers'\n",
139
+ " else:\n",
140
+ " commandline_arguments += ' --disable-xformers --opt-sdp-attention --cuda-stream --pin-shared-memory'\n",
141
  "\n",
142
  " !COMMANDLINE_ARGS=\"{commandline_arguments}\" python launch.py\n",
143
  "\n",
files_cells/notebooks/ru/widgets_ru.ipynb CHANGED
@@ -116,6 +116,7 @@
116
  "'''\n",
117
  "display(HTML(JS))\n",
118
  "\n",
 
119
  "# ==================== WIDGETS V2 ====================\n",
120
  "HR = widgets.HTML('<hr>')\n",
121
  "\n",
@@ -227,7 +228,7 @@
227
  "zrok_button = factory.create_html('<a href=\"https://colab.research.google.com/drive/1d2sjWDJi_GYBUavrHSuQyHTDuLy36WpU\" target=\"_blank\">Зарегать Zrok Токен</a>', class_name=\"button_ngrok\")\n",
228
  "zrok_widget = factory.create_hbox([zrok_token_widget, zrok_button])\n",
229
  "\n",
230
- "commandline_arguments_options = \"--listen --enable-insecure-extension-access --theme dark --no-half-vae --disable-console-progressbars --xformers\"\n",
231
  "commandline_arguments_widget = factory.create_text('Аргументы:', value=commandline_arguments_options)\n",
232
  "\n",
233
  "# Display Additional\n",
@@ -245,8 +246,6 @@
245
  "\n",
246
  "if free_plan and env == \"Google Colab\": # remove ngrok from colab\n",
247
  " additional_widget_list.remove(ngrok_widget)\n",
248
- "if os.path.exists(webui_path): # remove selection after selection ;3\n",
249
- " choose_changes_widget.children = [widget for widget in choose_changes_widget.children if widget != change_webui_widget]\n",
250
  "\n",
251
  "all_additional_box = factory.create_vbox(additional_widget_list, class_names=[\"container\", \"image_3\"])\n",
252
  "factory.display(all_additional_box)\n",
@@ -296,6 +295,21 @@
296
  "factory.display(save_button)\n",
297
  "\n",
298
  "\n",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
299
  "# ============ Load / Save - Settings V2 ============\n",
300
  "SETTINGS_FILE = f'{root_path}/settings.json'\n",
301
  "\n",
@@ -330,6 +344,7 @@
330
  "\n",
331
  "def save_data(button):\n",
332
  " save_settings()\n",
 
333
  " hide_widgets()\n",
334
  "\n",
335
  "load_settings()\n",
 
116
  "'''\n",
117
  "display(HTML(JS))\n",
118
  "\n",
119
+ "\n",
120
  "# ==================== WIDGETS V2 ====================\n",
121
  "HR = widgets.HTML('<hr>')\n",
122
  "\n",
 
228
  "zrok_button = factory.create_html('<a href=\"https://colab.research.google.com/drive/1d2sjWDJi_GYBUavrHSuQyHTDuLy36WpU\" target=\"_blank\">Зарегать Zrok Токен</a>', class_name=\"button_ngrok\")\n",
229
  "zrok_widget = factory.create_hbox([zrok_token_widget, zrok_button])\n",
230
  "\n",
231
+ "commandline_arguments_options = \"--listen --enable-insecure-extension-access --theme dark --no-half-vae --disable-console-progressbars\"\n",
232
  "commandline_arguments_widget = factory.create_text('Аргументы:', value=commandline_arguments_options)\n",
233
  "\n",
234
  "# Display Additional\n",
 
246
  "\n",
247
  "if free_plan and env == \"Google Colab\": # remove ngrok from colab\n",
248
  " additional_widget_list.remove(ngrok_widget)\n",
 
 
249
  "\n",
250
  "all_additional_box = factory.create_vbox(additional_widget_list, class_names=[\"container\", \"image_3\"])\n",
251
  "factory.display(all_additional_box)\n",
 
295
  "factory.display(save_button)\n",
296
  "\n",
297
  "\n",
298
+ "# ==================== OTHER FUNC ====================\n",
299
+ "# Setup UI\n",
300
+ "def setup_webui(change_webui_widget):\n",
301
+ " if 'SDW_UI' in os.environ:\n",
302
+ " UI = os.environ['SDW_UI']\n",
303
+ " else:\n",
304
+ " os.environ['SDW_UI'] = change_webui_widget\n",
305
+ " os.environ['SDW_OLD_UI'] = change_webui_widget\n",
306
+ "\n",
307
+ " UI = os.getenv('SDW_UI')\n",
308
+ "\n",
309
+ " if UI != change_webui_widget:\n",
310
+ " os.environ['SDW_UI'] = change_webui_widget\n",
311
+ "\n",
312
+ "\n",
313
  "# ============ Load / Save - Settings V2 ============\n",
314
  "SETTINGS_FILE = f'{root_path}/settings.json'\n",
315
  "\n",
 
344
  "\n",
345
  "def save_data(button):\n",
346
  " save_settings()\n",
347
+ " setup_webui(change_webui_widget.value)\n",
348
  " hide_widgets()\n",
349
  "\n",
350
  "load_settings()\n",
files_cells/python/en/downloading_en.py CHANGED
@@ -24,6 +24,31 @@ root_path = os.getenv('ROOT_PATH')
24
  webui_path = os.getenv('WEBUI_PATH')
25
  free_plan = os.getenv('FREE_PLAN')
26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
  # ================ LIBRARIES V2 ================
29
  flag_file = f"{root_path}/libraries_installed.txt"
@@ -35,8 +60,9 @@ if not os.path.exists(flag_file):
35
  # "aria2": "apt -y install aria2",
36
  "aria2": "pip install aria2",
37
  "localtunnel": "npm install -g localtunnel",
38
- "insightface": "pip install insightface"
39
  }
 
 
40
 
41
  additional_libs = {
42
  "Google Colab": {
@@ -48,7 +74,6 @@ if not os.path.exists(flag_file):
48
  # "aiohttp": "pip install trash-cli && trash-put /opt/conda/lib/python3.10/site-packages/aiohttp*" # fix install req
49
  }
50
  }
51
-
52
  if env in additional_libs:
53
  install_lib.update(additional_libs[env])
54
 
@@ -75,68 +100,106 @@ if not os.path.exists(flag_file):
75
  clear_output()
76
 
77
 
78
- # ================= loading settings V4 =================
79
- def load_settings(path):
80
- if os.path.exists(path):
81
- with open(path, 'r') as file:
82
- return json.load(file)
83
- return {}
84
-
85
- settings = load_settings(f'{root_path}/settings.json')
86
 
87
- VARIABLES = [
88
- 'model', 'model_num', 'inpainting_model',
89
- 'vae', 'vae_num', 'latest_webui', 'latest_exstensions',
90
- 'change_webui', 'detailed_download', 'controlnet',
91
- 'controlnet_num', 'commit_hash', 'huggingface_token',
92
- 'ngrok_token', 'zrok_token', 'commandline_arguments',
93
- 'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url',
94
- 'Extensions_url', 'custom_file_urls'
95
- ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
 
97
- locals().update({key: settings.get(key) for key in VARIABLES})
 
 
98
 
 
 
 
 
99
 
100
- # ================= OTHER =================
101
- try:
102
- start_colab
103
- except:
104
- start_colab = int(time.time())-5
105
 
 
 
106
 
107
- # ================= MAIN CODE =================
108
- if not os.path.exists(webui_path):
109
- start_install = int(time.time())
110
- print("⌚ Unpacking Stable Diffusion..." if change_webui != 'Forge' else "⌚ Unpacking Stable Diffusion (Forge)...", end='')
111
- with capture.capture_output() as cap:
112
- aria2_command = "aria2c --console-log-level=error -c -x 16 -s 16 -k 1M"
113
- url = "https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO.zip" if change_webui != 'Forge' else "https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO_forge.zip"
114
- get_ipython().system('{aria2_command} {url} -o repo.zip')
115
 
116
- get_ipython().system('unzip -q -o repo.zip -d {webui_path}')
117
- get_ipython().system('rm -rf repo.zip')
 
118
 
119
- get_ipython().run_line_magic('cd', '{root_path}')
120
- os.environ["SAFETENSORS_FAST_GPU"]='1'
121
- os.environ["CUDA_MODULE_LOADING"]="LAZY"
122
- os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3"
123
- os.environ["PYTHONWARNINGS"] = "ignore"
 
 
 
 
124
 
125
- get_ipython().system('echo -n {start_colab} > {webui_path}/static/colabTimer.txt')
126
- del cap
127
- install_time = timedelta(seconds=time.time()-start_install)
128
- 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)
129
  else:
130
  print("🚀 All unpacked... Skip. ⚡")
131
- start_colab = float(open(f'{webui_path}/static/colabTimer.txt', 'r').read())
132
- time_since_start = str(timedelta(seconds=time.time()-start_colab)).split('.')[0]
133
- print(f"⌚️ You have been conducting this session for - \033[33m{time_since_start}\033[0m")
134
 
135
 
136
  ## Changes extensions and WebUi
137
  if latest_webui or latest_exstensions:
138
- action = "Updating WebUI and Extensions" if latest_webui and latest_exstensions else ("WebUI Update" if latest_webui else "Update Extensions")
139
- print(f"⌚️ {action}...", end='', flush=True)
140
  with capture.capture_output() as cap:
141
  get_ipython().system('git config --global user.email "[email protected]"')
142
  get_ipython().system('git config --global user.name "Your Name"')
@@ -151,7 +214,7 @@ if latest_webui or latest_exstensions:
151
  if latest_exstensions:
152
  get_ipython().system('{\'for dir in \' + webui_path + \'/extensions/*/; do cd \\"$dir\\" && git reset --hard && git pull; done\'}')
153
  del cap
154
- print(f"\r✨ {action} Completed!")
155
 
156
 
157
  # === FIXING EXTENSIONS ===
@@ -160,10 +223,8 @@ anxety_repos = "https://huggingface.co/NagisaNao/fast_repo/resolve/main"
160
  with capture.capture_output() as cap:
161
  # --- Umi-Wildcard ---
162
  get_ipython().system("sed -i '521s/open=\\(False\\|True\\)/open=False/' {webui_path}/extensions/Umi-AI-Wildcards/scripts/wildcard_recursive.py # Closed accordion by default")
163
-
164
  # --- Encrypt-Image ---
165
  get_ipython().system("sed -i '9,37d' {webui_path}/extensions/Encrypt-Image/javascript/encrypt_images_info.js # Removes the weird text in webui")
166
-
167
  # --- Additional-Networks ---
168
  get_ipython().system('wget -O {webui_path}/extensions/additional-networks/scripts/metadata_editor.py {anxety_repos}/extensions/Additional-Networks/fix/metadata_editor.py # Fixing an error due to old style')
169
  del cap
@@ -171,7 +232,7 @@ del cap
171
 
172
  ## Version switching
173
  if commit_hash:
174
- print('⏳ Time machine activation...', end="", flush=True)
175
  with capture.capture_output() as cap:
176
  get_ipython().run_line_magic('cd', '{webui_path}')
177
  get_ipython().system('git config --global user.email "[email protected]"')
@@ -211,7 +272,7 @@ def center_text(text, terminal_width=45):
211
  padding = (terminal_width - len(text)) // 2
212
  return f"\033[1m\033[36m{' ' * padding}{text}{' ' * padding}\033[0m\033[32m"
213
 
214
- def format_output(url, dst_dir, file_name):
215
  info = center_text(f"[{file_name.split('.')[0]}]")
216
  separation_line = '\033[32m' + '---' * 20
217
 
@@ -220,89 +281,81 @@ def format_output(url, dst_dir, file_name):
220
  print(f"\033[33mSAVE DIR: \033[34m{dst_dir}")
221
  print(f"\033[33mFILE NAME: \033[34m{file_name}\033[0m")
222
 
 
 
 
223
  ''' GET CivitAi API - DATA '''
224
 
225
  def CivitAi_API(url, file_name=None):
226
- SUPPORT_TYPES = ('Checkpoint', 'Model', 'TextualInversion', 'LORA')
227
  CIVITAI_TOKEN = "62c0c5956b2f9defbd844d754000180b"
228
 
229
  url = url.split('?token=')[0] if '?token=' in url else url
230
  url = url.replace('?type=', f'?token={CIVITAI_TOKEN}&type=') if '?type=' in url else f"{url}?token={CIVITAI_TOKEN}"
231
 
232
  def get_model_data(url):
233
- if "civitai.com/models/" in url:
234
- if '?modelVersionId=' in url:
235
- version_id = url.split('?modelVersionId=')[1]
236
- return requests.get(f"https://civitai.com/api/v1/model-versions/{version_id}").json()
 
 
 
 
 
237
  else:
238
- model_id = url.split('/models/')[1].split('/')[0]
239
- return requests.get(f"https://civitai.com/api/v1/models/{model_id}").json()
240
- else:
241
- version_id = url.split('/models/')[1].split('/')[0]
242
- return requests.get(f"https://civitai.com/api/v1/model-versions/{version_id}").json()
243
 
244
  data = get_model_data(url)
245
 
246
  if not data:
247
- return None, None, None, None, None, None, None
 
248
 
249
  def extract_model_info(url, data):
250
- if "civitai.com/models/" in url:
251
- if '?modelVersionId=' in url:
252
- model_type = data['model']['type']
253
- model_name = data['files'][0]['name']
254
- else:
255
- model_type = data['type']
256
- model_name = data['modelVersions'][0]['files'][0]['name']
257
- elif 'type=' in url:
258
- model_type = parse_qs(urlparse(url).query).get('type', [''])[0]
259
- if 'model' in model_type.lower():
260
- model_name = data['files'][0]['name']
261
- else:
262
  model_name = data['files'][1]['name']
263
- else:
264
- model_type = data['model']['type']
265
- model_name = data['files'][0]['name']
266
  return model_type, model_name
267
 
268
  model_type, model_name = extract_model_info(url, data)
269
  model_name = file_name or model_name
270
 
271
- def get_download_url(url, data, model_type):
272
- if "civitai.com/models/" in url:
273
- if '?modelVersionId=' in url:
274
- return data.get('downloadUrl')
275
- else:
276
- return data["modelVersions"][0].get("downloadUrl", "")
277
- elif 'type=' in url:
278
- if any(t.lower() in model_type.lower() for t in SUPPORT_TYPES):
279
- return data['files'][0]['downloadUrl']
280
- else:
281
- return data['files'][1]['downloadUrl']
282
- else:
283
- return data.get('downloadUrl')
284
 
285
- download_url = get_download_url(url, data, model_type)
286
- clean_url = re.sub(r'[?&]token=[^&]*', '', download_url)
 
287
 
288
  def get_image_info(data, model_type, model_name):
289
- image_url, image_name = None, None
290
- if any(t in model_type for t in SUPPORT_TYPES):
291
- try:
292
- images = data.get('images') or data['modelVersions'][0].get('images', [])
293
- if env == 'Kaggle':
294
- image_url = next((image['url'] for image in images if image['nsfwLevel'] < 4), None)
295
- else:
296
- image_url = images[0]['url'] if images else None
297
- except KeyError:
298
- pass
299
 
300
- image_name = f"{model_name.split('.')[0]}.preview.{image_url.split('.')[-1]}" if image_url else None
301
- return image_url, image_name
302
 
303
  image_url, image_name = get_image_info(data, model_type, model_name)
304
 
305
- return f"{download_url}{'&' if '?' in download_url else '?'}token={CIVITAI_TOKEN}", clean_url, model_type, model_name, image_url, image_name, data
306
 
307
  ''' Main Download Code '''
308
 
@@ -348,13 +401,13 @@ def handle_manual(url):
348
  dir = PREFIXES[prefix]
349
  if prefix != "extension":
350
  try:
351
- manual_download(path, dir, file_name=file_name)
352
  except Exception as e:
353
  print(f"Error downloading file: {e}")
354
  else:
355
  extension_repo.append((path, file_name))
356
 
357
- def manual_download(url, dst_dir, file_name):
358
  header_option = f"--header={user_header}"
359
  aria2c_header = "--header='User-Agent: Mozilla/5.0' --allow-overwrite=true"
360
  aria2_args = "--optimize-concurrent-downloads --console-log-level=error --summary-interval=10 --stderr=true -c -x16 -s16 -k1M -j5"
@@ -372,17 +425,17 @@ def manual_download(url, dst_dir, file_name):
372
 
373
  """ Formatted info output """
374
  model_name_or_basename = file_name if file_name else basename
375
- format_output(clean_url or url, dst_dir, model_name_or_basename)
376
-
377
- # print(url, dst_dir, model_name_or_basename)
378
- if 'civitai' in url:
379
- if not data:
380
- print("\033[31m[Data Info]:\033[0m Failed to retrieve data from the API.\n")
381
- if data and image_name:
382
- print(f"\033[32m[Preview DL]:\033[0m {image_name} - {image_url}\n")
383
 
384
  # =====================
385
  def run_aria2c(url, dst_dir, file_name=None, args="", header=""):
 
 
 
 
386
  out = f"-o '{file_name}'" if file_name else ""
387
  get_ipython().system("aria2c {header} {args} -d {dst_dir} {out} '{url}'")
388
 
@@ -408,19 +461,44 @@ def manual_download(url, dst_dir, file_name):
408
 
409
  ''' SubModels - Added URLs '''
410
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
411
  def add_submodels(selection, num_selection, model_dict, dst_dir):
 
412
  if selection == "none":
413
- return []
414
  if selection == "ALL":
415
- all_models = []
416
  for models in model_dict.values():
417
- all_models.extend(models)
418
- selected_models = all_models
419
  else:
420
- selected_models = model_dict[selection]
421
- selected_nums = map(int, num_selection.replace(',', '').split())
422
- for num in selected_nums:
423
- if 1 <= num <= len(model_dict):
 
 
 
 
 
 
 
 
 
 
 
424
  name = list(model_dict)[num - 1]
425
  selected_models.extend(model_dict[name])
426
 
@@ -511,7 +589,7 @@ get_ipython().system('find {webui_path} \\( -type d \\( -name ".ipynb_checkpoint
511
 
512
  ## Install of Custom extensions
513
  if len(extension_repo) > 0:
514
- print("✨ Installing custom extensions...", end='', flush=True)
515
  with capture.capture_output() as cap:
516
  for repo, repo_name in extension_repo:
517
  if not repo_name:
 
24
  webui_path = os.getenv('WEBUI_PATH')
25
  free_plan = os.getenv('FREE_PLAN')
26
 
27
+ UI = os.getenv('SDW_UI')
28
+ OLD_UI = os.getenv('SDW_OLD_UI')
29
+
30
+
31
+ # ============ loading settings V4 =============
32
+ def load_settings(path):
33
+ if os.path.exists(path):
34
+ with open(path, 'r') as file:
35
+ return json.load(file)
36
+ return {}
37
+
38
+ settings = load_settings(f'{root_path}/settings.json')
39
+
40
+ VARIABLES = [
41
+ 'model', 'model_num', 'inpainting_model',
42
+ 'vae', 'vae_num', 'latest_webui', 'latest_exstensions',
43
+ 'change_webui', 'detailed_download', 'controlnet',
44
+ 'controlnet_num', 'commit_hash', 'huggingface_token',
45
+ 'ngrok_token', 'zrok_token', 'commandline_arguments',
46
+ 'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url',
47
+ 'Extensions_url', 'custom_file_urls'
48
+ ]
49
+
50
+ locals().update({key: settings.get(key) for key in VARIABLES})
51
+
52
 
53
  # ================ LIBRARIES V2 ================
54
  flag_file = f"{root_path}/libraries_installed.txt"
 
60
  # "aria2": "apt -y install aria2",
61
  "aria2": "pip install aria2",
62
  "localtunnel": "npm install -g localtunnel",
 
63
  }
64
+ if controlnet != 'none':
65
+ install_lib["insightface"] = "pip install insightface"
66
 
67
  additional_libs = {
68
  "Google Colab": {
 
74
  # "aiohttp": "pip install trash-cli && trash-put /opt/conda/lib/python3.10/site-packages/aiohttp*" # fix install req
75
  }
76
  }
 
77
  if env in additional_libs:
78
  install_lib.update(additional_libs[env])
79
 
 
100
  clear_output()
101
 
102
 
103
+ # =================== OTHER ====================
104
+ # Setup Timer
105
+ if "START_COLAB" in os.environ:
106
+ start_colab = int(os.environ["START_COLAB"])
107
+ else:
108
+ start_colab = int(time.time()) - 5
109
+ os.environ["START_COLAB"] = str(start_colab)
 
110
 
111
+ # remove directory func
112
+ def _remove_dir(directory_path):
113
+ if directory_path and os.path.exists(directory_path):
114
+ try:
115
+ shutil.rmtree(directory_path)
116
+ except Exception:
117
+ get_ipython().system('rm -rf {directory_path}')
118
+
119
+ # Save files temporarily
120
+ temporarily_dir = f'{root_path}/temp_dir'
121
+
122
+ def copy_items_with_replace(src_base, dst_base):
123
+ items_to_copy = [
124
+ 'embeddings',
125
+ 'models/Stable-diffusion',
126
+ 'models/VAE',
127
+ 'models/Lora',
128
+ 'models/ControlNet'
129
+ ]
130
+
131
+ print("⌚ Moving files...", end='')
132
+ time.sleep(1)
133
+ for item in items_to_copy:
134
+ src = os.path.join(src_base, item)
135
+ dst = os.path.join(dst_base, item)
136
+
137
+ if os.path.exists(src):
138
+ if os.path.exists(dst):
139
+ _remove_dir(dst)
140
+ os.makedirs(os.path.dirname(dst), exist_ok=True)
141
+ shutil.move(src, dst)
142
+ print("\r🔥 Files moved!" + " "*15)
143
+
144
+ def handle_colab_timer(webui_path, timer_colab):
145
+ timer_file_path = os.path.join(webui_path, 'static', 'colabTimer.txt')
146
+ if not os.path.exists(timer_file_path):
147
+ with open(timer_file_path, 'w') as timer_file:
148
+ timer_file.write(str(timer_colab))
149
+ else:
150
+ with open(timer_file_path, 'r') as timer_file:
151
+ timer_colab = float(timer_file.read())
152
+ return timer_colab
153
 
154
+ def unpack_webui():
155
+ start_install = time.time()
156
+ print(f"⌚ Unpacking Stable Diffusion{' (Forge)' if UI == 'Forge' else ''}...", end='')
157
 
158
+ with capture.capture_output() as cap:
159
+ download_url = "https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO.zip"
160
+ if UI == 'Forge':
161
+ download_url = "https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO_forge.zip"
162
 
163
+ aria2_args = "--console-log-level=error -c -x 16 -s 16 -k 1M"
164
+ zip_path = f"{root_path}/repo.zip"
165
+ get_ipython().system('aria2c {aria2_args} {download_url} -d {root_path} -o repo.zip')
166
+ get_ipython().system('unzip -q -o {zip_path} -d {webui_path}')
167
+ get_ipython().system('rm -rf {zip_path}')
168
 
169
+ get_ipython().system(f'echo -n {start_colab} > {webui_path}/static/colabTimer.txt')
170
+ del cap
171
 
172
+ install_time = time.time() - start_install
173
+ minutes, seconds = divmod(int(install_time), 60)
174
+ print(f"\r🚀 Unpacking complete! For {minutes:02}:{seconds:02} ⚡" + " "*15)
 
 
 
 
 
175
 
176
+ if os.path.exists(temporarily_dir):
177
+ copy_items_with_replace(temporarily_dir, webui_path)
178
+ _remove_dir(temporarily_dir)
179
 
180
+ # ================= MAIN CODE ==================
181
+ if os.path.exists(webui_path):
182
+ if UI != OLD_UI:
183
+ print(f'Switching the WebUI from \033[33m{OLD_UI}\033[0m to \033[33m{UI}\033[0m:')
184
+ copy_items_with_replace(webui_path, temporarily_dir)
185
+ _remove_dir(webui_path)
186
+ os.environ['SDW_OLD_UI'] = UI
187
+ time.sleep(2)
188
+ clear_output()
189
 
190
+ if not os.path.exists(webui_path):
191
+ unpack_webui()
 
 
192
  else:
193
  print("🚀 All unpacked... Skip. ⚡")
194
+ timer_colab = handle_colab_timer(webui_path, start_colab)
195
+ elapsed_time = str(timedelta(seconds=time.time() - timer_colab)).split('.')[0]
196
+ print(f"⌚️ You have been conducting this session for - \033[33m{elapsed_time}\033[0m")
197
 
198
 
199
  ## Changes extensions and WebUi
200
  if latest_webui or latest_exstensions:
201
+ action = "WebUI and Extensions" if latest_webui and latest_exstensions else ("WebUI" if latest_webui else "Extensions")
202
+ print(f"⌚️ Updating {action}...", end='')
203
  with capture.capture_output() as cap:
204
  get_ipython().system('git config --global user.email "[email protected]"')
205
  get_ipython().system('git config --global user.name "Your Name"')
 
214
  if latest_exstensions:
215
  get_ipython().system('{\'for dir in \' + webui_path + \'/extensions/*/; do cd \\"$dir\\" && git reset --hard && git pull; done\'}')
216
  del cap
217
+ print(f"\r✨ Updating {action} Completed!")
218
 
219
 
220
  # === FIXING EXTENSIONS ===
 
223
  with capture.capture_output() as cap:
224
  # --- Umi-Wildcard ---
225
  get_ipython().system("sed -i '521s/open=\\(False\\|True\\)/open=False/' {webui_path}/extensions/Umi-AI-Wildcards/scripts/wildcard_recursive.py # Closed accordion by default")
 
226
  # --- Encrypt-Image ---
227
  get_ipython().system("sed -i '9,37d' {webui_path}/extensions/Encrypt-Image/javascript/encrypt_images_info.js # Removes the weird text in webui")
 
228
  # --- Additional-Networks ---
229
  get_ipython().system('wget -O {webui_path}/extensions/additional-networks/scripts/metadata_editor.py {anxety_repos}/extensions/Additional-Networks/fix/metadata_editor.py # Fixing an error due to old style')
230
  del cap
 
232
 
233
  ## Version switching
234
  if commit_hash:
235
+ print('⏳ Time machine activation...', end="")
236
  with capture.capture_output() as cap:
237
  get_ipython().run_line_magic('cd', '{webui_path}')
238
  get_ipython().system('git config --global user.email "[email protected]"')
 
272
  padding = (terminal_width - len(text)) // 2
273
  return f"\033[1m\033[36m{' ' * padding}{text}{' ' * padding}\033[0m\033[32m"
274
 
275
+ def format_output(url, dst_dir, file_name, image_name=None, image_url=None):
276
  info = center_text(f"[{file_name.split('.')[0]}]")
277
  separation_line = '\033[32m' + '---' * 20
278
 
 
281
  print(f"\033[33mSAVE DIR: \033[34m{dst_dir}")
282
  print(f"\033[33mFILE NAME: \033[34m{file_name}\033[0m")
283
 
284
+ if 'civitai' in url and image_url:
285
+ print(f"\033[32m[Preview DL]:\033[0m {image_name} - {image_url}\n")
286
+
287
  ''' GET CivitAi API - DATA '''
288
 
289
  def CivitAi_API(url, file_name=None):
290
+ SUPPORT_TYPES = ('Checkpoint', 'TextualInversion', 'LORA')
291
  CIVITAI_TOKEN = "62c0c5956b2f9defbd844d754000180b"
292
 
293
  url = url.split('?token=')[0] if '?token=' in url else url
294
  url = url.replace('?type=', f'?token={CIVITAI_TOKEN}&type=') if '?type=' in url else f"{url}?token={CIVITAI_TOKEN}"
295
 
296
  def get_model_data(url):
297
+ base_url = "https://civitai.com/api/v1"
298
+ try:
299
+ if "civitai.com/models/" in url:
300
+ if '?modelVersionId=' in url:
301
+ version_id = url.split('?modelVersionId=')[1]
302
+ else:
303
+ model_id = url.split('/models/')[1].split('/')[0]
304
+ model_data = requests.get(f"{base_url}/models/{model_id}").json()
305
+ version_id = model_data['modelVersions'][0].get('id')
306
  else:
307
+ version_id = url.split('/models/')[1].split('/')[0]
308
+
309
+ return requests.get(f"{base_url}/model-versions/{version_id}").json()
310
+ except (KeyError, IndexError, requests.RequestException) as e:
311
+ return None
312
 
313
  data = get_model_data(url)
314
 
315
  if not data:
316
+ print("\033[31m[Data Info]:\033[0m Failed to retrieve data from the API.\n")
317
+ return 'None', None, None, None, None, None, None
318
 
319
  def extract_model_info(url, data):
320
+ model_type = data['model']['type']
321
+ model_name = data['files'][0]['name']
322
+
323
+ if 'type=' in url:
324
+ url_model_type = parse_qs(urlparse(url).query).get('type', [''])[0].lower()
325
+ if 'vae' in url_model_type:
326
+ model_type = data['files'][1]['type']
 
 
 
 
 
327
  model_name = data['files'][1]['name']
328
+
 
 
329
  return model_type, model_name
330
 
331
  model_type, model_name = extract_model_info(url, data)
332
  model_name = file_name or model_name
333
 
334
+ def get_download_url(data, model_type):
335
+ if any(t.lower() in model_type.lower() for t in SUPPORT_TYPES):
336
+ return data['files'][0]['downloadUrl']
 
 
 
 
 
 
 
 
 
 
337
 
338
+ return data['files'][1]['downloadUrl'] if 'type' in url else data['files'][0]['downloadUrl']
339
+
340
+ download_url = get_download_url(data, model_type)
341
 
342
  def get_image_info(data, model_type, model_name):
343
+ if not any(t in model_type for t in SUPPORT_TYPES):
344
+ return None, None
345
+
346
+ for image in data.get('images', []):
347
+ if image['nsfwLevel'] >= 4 and env == 'Kaggle': # Filter NSFW images for Kaggle
348
+ continue
349
+ image_url = image['url']
350
+ image_extension = image_url.split('.')[-1]
351
+ image_name = f"{model_name.split('.')[0]}.preview.{image_extension}" if image_url else None
352
+ return image_url, image_name
353
 
354
+ return None, None
 
355
 
356
  image_url, image_name = get_image_info(data, model_type, model_name)
357
 
358
+ return f"{download_url}{'&' if '?' in download_url else '?'}token={CIVITAI_TOKEN}", download_url, model_type, model_name, image_url, image_name, data
359
 
360
  ''' Main Download Code '''
361
 
 
401
  dir = PREFIXES[prefix]
402
  if prefix != "extension":
403
  try:
404
+ manual_download(path, dir, file_name=file_name, prefix=prefix)
405
  except Exception as e:
406
  print(f"Error downloading file: {e}")
407
  else:
408
  extension_repo.append((path, file_name))
409
 
410
+ def manual_download(url, dst_dir, file_name, prefix=None):
411
  header_option = f"--header={user_header}"
412
  aria2c_header = "--header='User-Agent: Mozilla/5.0' --allow-overwrite=true"
413
  aria2_args = "--optimize-concurrent-downloads --console-log-level=error --summary-interval=10 --stderr=true -c -x16 -s16 -k1M -j5"
 
425
 
426
  """ Formatted info output """
427
  model_name_or_basename = file_name if file_name else basename
428
+ try:
429
+ format_output(clean_url or url, dst_dir, model_name_or_basename, image_name, image_url)
430
+ except UnboundLocalError:
431
+ format_output(clean_url or url, dst_dir, model_name_or_basename, None, None)
 
 
 
 
432
 
433
  # =====================
434
  def run_aria2c(url, dst_dir, file_name=None, args="", header=""):
435
+ file_path = os.path.join(dst_dir, file_name) # replaces config files
436
+ if os.path.exists(file_path) and prefix == 'config':
437
+ os.remove(file_path)
438
+
439
  out = f"-o '{file_name}'" if file_name else ""
440
  get_ipython().system("aria2c {header} {args} -d {dst_dir} {out} '{url}'")
441
 
 
461
 
462
  ''' SubModels - Added URLs '''
463
 
464
+ # Separation of merged numbers
465
+ def split_numbers(num_str, max_num):
466
+ def helper(s):
467
+ if not s:
468
+ return []
469
+ for length in range(2, 0, -1):
470
+ if len(s) >= length:
471
+ part = int(s[:length])
472
+ if part <= max_num:
473
+ result = helper(s[length:])
474
+ if result is not None:
475
+ return [part] + result
476
+ return None
477
+ return helper(num_str)
478
+
479
  def add_submodels(selection, num_selection, model_dict, dst_dir):
480
+ selected_models = []
481
  if selection == "none":
482
+ return selected_models
483
  if selection == "ALL":
 
484
  for models in model_dict.values():
485
+ selected_models.extend(models)
 
486
  else:
487
+ if selection in model_dict:
488
+ selected_models.extend(model_dict[selection])
489
+ nums = num_selection.replace(',', ' ').split()
490
+ max_num = len(model_dict)
491
+ selected_nums = []
492
+
493
+ for num_part in nums:
494
+ split_nums = split_numbers(num_part, max_num)
495
+ if split_nums:
496
+ selected_nums.extend(split_nums)
497
+
498
+ unique_nums = list(set(selected_nums))
499
+
500
+ for num in unique_nums:
501
+ if 1 <= num <= max_num:
502
  name = list(model_dict)[num - 1]
503
  selected_models.extend(model_dict[name])
504
 
 
589
 
590
  ## Install of Custom extensions
591
  if len(extension_repo) > 0:
592
+ print("✨ Installing custom extensions...", end='')
593
  with capture.capture_output() as cap:
594
  for repo, repo_name in extension_repo:
595
  if not repo_name:
files_cells/python/en/launch_en.py CHANGED
@@ -5,6 +5,7 @@ import re
5
  import time
6
  import json
7
  import requests
 
8
  import cloudpickle as pickle
9
  from datetime import timedelta
10
  from IPython.display import clear_output
@@ -31,6 +32,17 @@ commandline_arguments = settings.get('commandline_arguments', "")
31
  change_webui = settings.get('change_webui', "")
32
 
33
 
 
 
 
 
 
 
 
 
 
 
 
34
  # ======================== TUNNEL V2 ========================
35
  print('Please Wait...')
36
 
@@ -56,7 +68,9 @@ tunnel_class = pickle.load(open(f"{root_path}/new_tunnel", "rb"), encoding="utf-
56
  tunnel_port = 1834
57
  tunnel = tunnel_class(tunnel_port)
58
  tunnel.add_tunnel(command="cl tunnel --url localhost:{port}", name="cl", pattern=re.compile(r"[\w-]+\.trycloudflare\.com"))
59
- 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.")
 
 
60
 
61
  if zrok_token:
62
  get_ipython().system('zrok enable {zrok_token} &> /dev/null')
@@ -65,7 +79,7 @@ if zrok_token:
65
  clear_output()
66
 
67
 
68
- # =============== Automatic Fixing Path V3 ===============
69
  paths_to_check = {
70
  "tagger_hf_cache_dir": f"{webui_path}/models/interrogators/",
71
  "additional_networks_extra_lora_path": f"{webui_path}/models/Lora/",
@@ -96,8 +110,10 @@ with tunnel:
96
  if env != "Google Colab":
97
  commandline_arguments += f' --encrypt-pass={tunnel_port} --api'
98
 
99
- if change_webui == 'Forge':
100
- commandline_arguments += ' --cuda-stream --pin-shared-memory'
 
 
101
 
102
  get_ipython().system('COMMANDLINE_ARGS="{commandline_arguments}" python launch.py')
103
 
 
5
  import time
6
  import json
7
  import requests
8
+ import subprocess
9
  import cloudpickle as pickle
10
  from datetime import timedelta
11
  from IPython.display import clear_output
 
32
  change_webui = settings.get('change_webui', "")
33
 
34
 
35
+ # ========================== OTHER ==========================
36
+ def is_package_installed(package_name):
37
+ try:
38
+ subprocess.run(["npm", "ls", "-g", package_name], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
39
+ return True
40
+ except subprocess.CalledProcessError:
41
+ return False
42
+
43
+ lt_tunnel = is_package_installed('localtunnel')
44
+
45
+
46
  # ======================== TUNNEL V2 ========================
47
  print('Please Wait...')
48
 
 
68
  tunnel_port = 1834
69
  tunnel = tunnel_class(tunnel_port)
70
  tunnel.add_tunnel(command="cl tunnel --url localhost:{port}", name="cl", pattern=re.compile(r"[\w-]+\.trycloudflare\.com"))
71
+
72
+ if lt_tunnel:
73
+ 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.")
74
 
75
  if zrok_token:
76
  get_ipython().system('zrok enable {zrok_token} &> /dev/null')
 
79
  clear_output()
80
 
81
 
82
+ # ================= Automatic Fixing Path V3 ================
83
  paths_to_check = {
84
  "tagger_hf_cache_dir": f"{webui_path}/models/interrogators/",
85
  "additional_networks_extra_lora_path": f"{webui_path}/models/Lora/",
 
110
  if env != "Google Colab":
111
  commandline_arguments += f' --encrypt-pass={tunnel_port} --api'
112
 
113
+ if change_webui == 'A1111':
114
+ commandline_arguments += ' --xformers'
115
+ else:
116
+ commandline_arguments += ' --disable-xformers --opt-sdp-attention --cuda-stream --pin-shared-memory'
117
 
118
  get_ipython().system('COMMANDLINE_ARGS="{commandline_arguments}" python launch.py')
119
 
files_cells/python/en/widgets_en.py CHANGED
@@ -92,6 +92,7 @@ function toggleContainer() {
92
  '''
93
  display(HTML(JS))
94
 
 
95
  # ==================== WIDGETS V2 ====================
96
  HR = widgets.HTML('<hr>')
97
 
@@ -203,7 +204,7 @@ zrok_token_widget = factory.create_text('Zrok Token:')
203
  zrok_button = factory.create_html('<a href="https://colab.research.google.com/drive/1d2sjWDJi_GYBUavrHSuQyHTDuLy36WpU" target="_blank">Зарегать Zrok Токен</a>', class_name="button_ngrok")
204
  zrok_widget = factory.create_hbox([zrok_token_widget, zrok_button])
205
 
206
- commandline_arguments_options = "--listen --enable-insecure-extension-access --theme dark --no-half-vae --disable-console-progressbars --xformers"
207
  commandline_arguments_widget = factory.create_text('Arguments:', value=commandline_arguments_options)
208
 
209
  # Display Additional
@@ -221,8 +222,6 @@ additional_widget_list = [additional_header,
221
 
222
  if free_plan and env == "Google Colab": # remove ngrok from colab
223
  additional_widget_list.remove(ngrok_widget)
224
- if os.path.exists(webui_path): # remove selection after selection ;3
225
- choose_changes_widget.children = [widget for widget in choose_changes_widget.children if widget != change_webui_widget]
226
 
227
  all_additional_box = factory.create_vbox(additional_widget_list, class_names=["container", "image_3"])
228
  factory.display(all_additional_box)
@@ -272,6 +271,21 @@ save_button = factory.create_button('Save', class_name="button_save")
272
  factory.display(save_button)
273
 
274
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
275
  # ============ Load / Save - Settings V2 ============
276
  SETTINGS_FILE = f'{root_path}/settings.json'
277
 
@@ -306,6 +320,7 @@ def hide_widgets():
306
 
307
  def save_data(button):
308
  save_settings()
 
309
  hide_widgets()
310
 
311
  load_settings()
 
92
  '''
93
  display(HTML(JS))
94
 
95
+
96
  # ==================== WIDGETS V2 ====================
97
  HR = widgets.HTML('<hr>')
98
 
 
204
  zrok_button = factory.create_html('<a href="https://colab.research.google.com/drive/1d2sjWDJi_GYBUavrHSuQyHTDuLy36WpU" target="_blank">Зарегать Zrok Токен</a>', class_name="button_ngrok")
205
  zrok_widget = factory.create_hbox([zrok_token_widget, zrok_button])
206
 
207
+ commandline_arguments_options = "--listen --enable-insecure-extension-access --theme dark --no-half-vae --disable-console-progressbars"
208
  commandline_arguments_widget = factory.create_text('Arguments:', value=commandline_arguments_options)
209
 
210
  # Display Additional
 
222
 
223
  if free_plan and env == "Google Colab": # remove ngrok from colab
224
  additional_widget_list.remove(ngrok_widget)
 
 
225
 
226
  all_additional_box = factory.create_vbox(additional_widget_list, class_names=["container", "image_3"])
227
  factory.display(all_additional_box)
 
271
  factory.display(save_button)
272
 
273
 
274
+ # ==================== OTHER FUNC ====================
275
+ # Setup UI
276
+ def setup_webui(change_webui_widget):
277
+ if 'SDW_UI' in os.environ:
278
+ UI = os.environ['SDW_UI']
279
+ else:
280
+ os.environ['SDW_UI'] = change_webui_widget
281
+ os.environ['SDW_OLD_UI'] = change_webui_widget
282
+
283
+ UI = os.getenv('SDW_UI')
284
+
285
+ if UI != change_webui_widget:
286
+ os.environ['SDW_UI'] = change_webui_widget
287
+
288
+
289
  # ============ Load / Save - Settings V2 ============
290
  SETTINGS_FILE = f'{root_path}/settings.json'
291
 
 
320
 
321
  def save_data(button):
322
  save_settings()
323
+ setup_webui(change_webui_widget.value)
324
  hide_widgets()
325
 
326
  load_settings()
files_cells/python/ru/downloading_ru.py CHANGED
@@ -24,6 +24,31 @@ root_path = os.getenv('ROOT_PATH')
24
  webui_path = os.getenv('WEBUI_PATH')
25
  free_plan = os.getenv('FREE_PLAN')
26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
  # ================ LIBRARIES V2 ================
29
  flag_file = f"{root_path}/libraries_installed.txt"
@@ -35,8 +60,9 @@ if not os.path.exists(flag_file):
35
  # "aria2": "apt -y install aria2",
36
  "aria2": "pip install aria2",
37
  "localtunnel": "npm install -g localtunnel",
38
- "insightface": "pip install insightface"
39
  }
 
 
40
 
41
  additional_libs = {
42
  "Google Colab": {
@@ -48,7 +74,6 @@ if not os.path.exists(flag_file):
48
  # "aiohttp": "pip install trash-cli && trash-put /opt/conda/lib/python3.10/site-packages/aiohttp*" # fix install req
49
  }
50
  }
51
-
52
  if env in additional_libs:
53
  install_lib.update(additional_libs[env])
54
 
@@ -75,68 +100,106 @@ if not os.path.exists(flag_file):
75
  clear_output()
76
 
77
 
78
- # ================= loading settings V4 =================
79
- def load_settings(path):
80
- if os.path.exists(path):
81
- with open(path, 'r') as file:
82
- return json.load(file)
83
- return {}
84
-
85
- settings = load_settings(f'{root_path}/settings.json')
86
 
87
- VARIABLES = [
88
- 'model', 'model_num', 'inpainting_model',
89
- 'vae', 'vae_num', 'latest_webui', 'latest_exstensions',
90
- 'change_webui', 'detailed_download', 'controlnet',
91
- 'controlnet_num', 'commit_hash', 'huggingface_token',
92
- 'ngrok_token', 'zrok_token', 'commandline_arguments',
93
- 'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url',
94
- 'Extensions_url', 'custom_file_urls'
95
- ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
 
97
- locals().update({key: settings.get(key) for key in VARIABLES})
 
 
98
 
 
 
 
 
99
 
100
- # ================= OTHER =================
101
- try:
102
- start_colab
103
- except:
104
- start_colab = int(time.time())-5
105
 
 
 
106
 
107
- # ================= MAIN CODE =================
108
- if not os.path.exists(webui_path):
109
- start_install = int(time.time())
110
- print("⌚ Распаковка Stable Diffusion..." if change_webui != 'Forge' else "⌚ Распаковка Stable Diffusion (Forge)...", end='')
111
- with capture.capture_output() as cap:
112
- aria2_command = "aria2c --console-log-level=error -c -x 16 -s 16 -k 1M"
113
- url = "https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO.zip" if change_webui != 'Forge' else "https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO_forge.zip"
114
- get_ipython().system('{aria2_command} {url} -o repo.zip')
115
 
116
- get_ipython().system('unzip -q -o repo.zip -d {webui_path}')
117
- get_ipython().system('rm -rf repo.zip')
 
118
 
119
- get_ipython().run_line_magic('cd', '{root_path}')
120
- os.environ["SAFETENSORS_FAST_GPU"]='1'
121
- os.environ["CUDA_MODULE_LOADING"]="LAZY"
122
- os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3"
123
- os.environ["PYTHONWARNINGS"] = "ignore"
 
 
 
 
124
 
125
- get_ipython().system('echo -n {start_colab} > {webui_path}/static/colabTimer.txt')
126
- del cap
127
- install_time = timedelta(seconds=time.time()-start_install)
128
- print("\r🚀 Распаковка Завершена! За","%02d:%02d:%02d ⚡\n" % (install_time.seconds / 3600, (install_time.seconds / 60) % 60, install_time.seconds % 60), end='', flush=True)
129
  else:
130
  print("🚀 Все распакованно... Пропуск. ⚡")
131
- start_colab = float(open(f'{webui_path}/static/colabTimer.txt', 'r').read())
132
- time_since_start = str(timedelta(seconds=time.time()-start_colab)).split('.')[0]
133
- print(f"⌚️ Вы проводите эту сессию в течение - \033[33m{time_since_start}\033[0m")
134
 
135
 
136
  ## Changes extensions and WebUi
137
  if latest_webui or latest_exstensions:
138
- action = "Обновление WebUI и Расширений" if latest_webui and latest_exstensions else ("Обновление WebUI" if latest_webui else "Обновление Расширений")
139
- print(f"⌚️ {action}...", end='', flush=True)
140
  with capture.capture_output() as cap:
141
  get_ipython().system('git config --global user.email "[email protected]"')
142
  get_ipython().system('git config --global user.name "Your Name"')
@@ -151,7 +214,7 @@ if latest_webui or latest_exstensions:
151
  if latest_exstensions:
152
  get_ipython().system('{\'for dir in \' + webui_path + \'/extensions/*/; do cd \\"$dir\\" && git reset --hard && git pull; done\'}')
153
  del cap
154
- print(f"\r✨ {action} Завершено!")
155
 
156
 
157
  # === FIXING EXTENSIONS ===
@@ -160,10 +223,8 @@ anxety_repos = "https://huggingface.co/NagisaNao/fast_repo/resolve/main"
160
  with capture.capture_output() as cap:
161
  # --- Umi-Wildcard ---
162
  get_ipython().system("sed -i '521s/open=\\(False\\|True\\)/open=False/' {webui_path}/extensions/Umi-AI-Wildcards/scripts/wildcard_recursive.py # Closed accordion by default")
163
-
164
  # --- Encrypt-Image ---
165
  get_ipython().system("sed -i '9,37d' {webui_path}/extensions/Encrypt-Image/javascript/encrypt_images_info.js # Removes the weird text in webui")
166
-
167
  # --- Additional-Networks ---
168
  get_ipython().system('wget -O {webui_path}/extensions/additional-networks/scripts/metadata_editor.py {anxety_repos}/extensions/Additional-Networks/fix/metadata_editor.py # Fixing an error due to old style')
169
  del cap
@@ -171,7 +232,7 @@ del cap
171
 
172
  ## Version switching
173
  if commit_hash:
174
- print('⏳ Активация машины времени...', end="", flush=True)
175
  with capture.capture_output() as cap:
176
  get_ipython().run_line_magic('cd', '{webui_path}')
177
  get_ipython().system('git config --global user.email "[email protected]"')
@@ -211,7 +272,7 @@ def center_text(text, terminal_width=45):
211
  padding = (terminal_width - len(text)) // 2
212
  return f"\033[1m\033[36m{' ' * padding}{text}{' ' * padding}\033[0m\033[32m"
213
 
214
- def format_output(url, dst_dir, file_name):
215
  info = center_text(f"[{file_name.split('.')[0]}]")
216
  separation_line = '\033[32m' + '---' * 20
217
 
@@ -220,89 +281,81 @@ def format_output(url, dst_dir, file_name):
220
  print(f"\033[33mSAVE DIR: \033[34m{dst_dir}")
221
  print(f"\033[33mFILE NAME: \033[34m{file_name}\033[0m")
222
 
 
 
 
223
  ''' GET CivitAi API - DATA '''
224
 
225
  def CivitAi_API(url, file_name=None):
226
- SUPPORT_TYPES = ('Checkpoint', 'Model', 'TextualInversion', 'LORA')
227
  CIVITAI_TOKEN = "62c0c5956b2f9defbd844d754000180b"
228
 
229
  url = url.split('?token=')[0] if '?token=' in url else url
230
  url = url.replace('?type=', f'?token={CIVITAI_TOKEN}&type=') if '?type=' in url else f"{url}?token={CIVITAI_TOKEN}"
231
 
232
  def get_model_data(url):
233
- if "civitai.com/models/" in url:
234
- if '?modelVersionId=' in url:
235
- version_id = url.split('?modelVersionId=')[1]
236
- return requests.get(f"https://civitai.com/api/v1/model-versions/{version_id}").json()
 
 
 
 
 
237
  else:
238
- model_id = url.split('/models/')[1].split('/')[0]
239
- return requests.get(f"https://civitai.com/api/v1/models/{model_id}").json()
240
- else:
241
- version_id = url.split('/models/')[1].split('/')[0]
242
- return requests.get(f"https://civitai.com/api/v1/model-versions/{version_id}").json()
243
 
244
  data = get_model_data(url)
245
 
246
  if not data:
247
- return None, None, None, None, None, None, None
 
248
 
249
  def extract_model_info(url, data):
250
- if "civitai.com/models/" in url:
251
- if '?modelVersionId=' in url:
252
- model_type = data['model']['type']
253
- model_name = data['files'][0]['name']
254
- else:
255
- model_type = data['type']
256
- model_name = data['modelVersions'][0]['files'][0]['name']
257
- elif 'type=' in url:
258
- model_type = parse_qs(urlparse(url).query).get('type', [''])[0]
259
- if 'model' in model_type.lower():
260
- model_name = data['files'][0]['name']
261
- else:
262
  model_name = data['files'][1]['name']
263
- else:
264
- model_type = data['model']['type']
265
- model_name = data['files'][0]['name']
266
  return model_type, model_name
267
 
268
  model_type, model_name = extract_model_info(url, data)
269
  model_name = file_name or model_name
270
 
271
- def get_download_url(url, data, model_type):
272
- if "civitai.com/models/" in url:
273
- if '?modelVersionId=' in url:
274
- return data.get('downloadUrl')
275
- else:
276
- return data["modelVersions"][0].get("downloadUrl", "")
277
- elif 'type=' in url:
278
- if any(t.lower() in model_type.lower() for t in SUPPORT_TYPES):
279
- return data['files'][0]['downloadUrl']
280
- else:
281
- return data['files'][1]['downloadUrl']
282
- else:
283
- return data.get('downloadUrl')
284
 
285
- download_url = get_download_url(url, data, model_type)
286
- clean_url = re.sub(r'[?&]token=[^&]*', '', download_url)
 
287
 
288
  def get_image_info(data, model_type, model_name):
289
- image_url, image_name = None, None
290
- if any(t in model_type for t in SUPPORT_TYPES):
291
- try:
292
- images = data.get('images') or data['modelVersions'][0].get('images', [])
293
- if env == 'Kaggle':
294
- image_url = next((image['url'] for image in images if image['nsfwLevel'] < 4), None)
295
- else:
296
- image_url = images[0]['url'] if images else None
297
- except KeyError:
298
- pass
299
 
300
- image_name = f"{model_name.split('.')[0]}.preview.{image_url.split('.')[-1]}" if image_url else None
301
- return image_url, image_name
302
 
303
  image_url, image_name = get_image_info(data, model_type, model_name)
304
 
305
- return f"{download_url}{'&' if '?' in download_url else '?'}token={CIVITAI_TOKEN}", clean_url, model_type, model_name, image_url, image_name, data
306
 
307
  ''' Main Download Code '''
308
 
@@ -348,13 +401,13 @@ def handle_manual(url):
348
  dir = PREFIXES[prefix]
349
  if prefix != "extension":
350
  try:
351
- manual_download(path, dir, file_name=file_name)
352
  except Exception as e:
353
  print(f"Error downloading file: {e}")
354
  else:
355
  extension_repo.append((path, file_name))
356
 
357
- def manual_download(url, dst_dir, file_name):
358
  header_option = f"--header={user_header}"
359
  aria2c_header = "--header='User-Agent: Mozilla/5.0' --allow-overwrite=true"
360
  aria2_args = "--optimize-concurrent-downloads --console-log-level=error --summary-interval=10 --stderr=true -c -x16 -s16 -k1M -j5"
@@ -372,17 +425,17 @@ def manual_download(url, dst_dir, file_name):
372
 
373
  """ Formatted info output """
374
  model_name_or_basename = file_name if file_name else basename
375
- format_output(clean_url or url, dst_dir, model_name_or_basename)
376
-
377
- # print(url, dst_dir, model_name_or_basename)
378
- if 'civitai' in url:
379
- if not data:
380
- print("\033[31m[Data Info]:\033[0m Failed to retrieve data from the API.\n")
381
- if data and image_name:
382
- print(f"\033[32m[Preview DL]:\033[0m {image_name} - {image_url}\n")
383
 
384
  # =====================
385
  def run_aria2c(url, dst_dir, file_name=None, args="", header=""):
 
 
 
 
386
  out = f"-o '{file_name}'" if file_name else ""
387
  get_ipython().system("aria2c {header} {args} -d {dst_dir} {out} '{url}'")
388
 
@@ -408,19 +461,44 @@ def manual_download(url, dst_dir, file_name):
408
 
409
  ''' SubModels - Added URLs '''
410
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
411
  def add_submodels(selection, num_selection, model_dict, dst_dir):
 
412
  if selection == "none":
413
- return []
414
  if selection == "ALL":
415
- all_models = []
416
  for models in model_dict.values():
417
- all_models.extend(models)
418
- selected_models = all_models
419
  else:
420
- selected_models = model_dict[selection]
421
- selected_nums = map(int, num_selection.replace(',', '').split())
422
- for num in selected_nums:
423
- if 1 <= num <= len(model_dict):
 
 
 
 
 
 
 
 
 
 
 
424
  name = list(model_dict)[num - 1]
425
  selected_models.extend(model_dict[name])
426
 
@@ -511,7 +589,7 @@ get_ipython().system('find {webui_path} \\( -type d \\( -name ".ipynb_checkpoint
511
 
512
  ## Install of Custom extensions
513
  if len(extension_repo) > 0:
514
- print("✨ Установка кастомных расширений...", end='', flush=True)
515
  with capture.capture_output() as cap:
516
  for repo, repo_name in extension_repo:
517
  if not repo_name:
 
24
  webui_path = os.getenv('WEBUI_PATH')
25
  free_plan = os.getenv('FREE_PLAN')
26
 
27
+ UI = os.getenv('SDW_UI')
28
+ OLD_UI = os.getenv('SDW_OLD_UI')
29
+
30
+
31
+ # ============ loading settings V4 =============
32
+ def load_settings(path):
33
+ if os.path.exists(path):
34
+ with open(path, 'r') as file:
35
+ return json.load(file)
36
+ return {}
37
+
38
+ settings = load_settings(f'{root_path}/settings.json')
39
+
40
+ VARIABLES = [
41
+ 'model', 'model_num', 'inpainting_model',
42
+ 'vae', 'vae_num', 'latest_webui', 'latest_exstensions',
43
+ 'change_webui', 'detailed_download', 'controlnet',
44
+ 'controlnet_num', 'commit_hash', 'huggingface_token',
45
+ 'ngrok_token', 'zrok_token', 'commandline_arguments',
46
+ 'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url',
47
+ 'Extensions_url', 'custom_file_urls'
48
+ ]
49
+
50
+ locals().update({key: settings.get(key) for key in VARIABLES})
51
+
52
 
53
  # ================ LIBRARIES V2 ================
54
  flag_file = f"{root_path}/libraries_installed.txt"
 
60
  # "aria2": "apt -y install aria2",
61
  "aria2": "pip install aria2",
62
  "localtunnel": "npm install -g localtunnel",
 
63
  }
64
+ if controlnet != 'none':
65
+ install_lib["insightface"] = "pip install insightface"
66
 
67
  additional_libs = {
68
  "Google Colab": {
 
74
  # "aiohttp": "pip install trash-cli && trash-put /opt/conda/lib/python3.10/site-packages/aiohttp*" # fix install req
75
  }
76
  }
 
77
  if env in additional_libs:
78
  install_lib.update(additional_libs[env])
79
 
 
100
  clear_output()
101
 
102
 
103
+ # =================== OTHER ====================
104
+ # Setup Timer
105
+ if "START_COLAB" in os.environ:
106
+ start_colab = int(os.environ["START_COLAB"])
107
+ else:
108
+ start_colab = int(time.time()) - 5
109
+ os.environ["START_COLAB"] = str(start_colab)
 
110
 
111
+ # remove directory func
112
+ def _remove_dir(directory_path):
113
+ if directory_path and os.path.exists(directory_path):
114
+ try:
115
+ shutil.rmtree(directory_path)
116
+ except Exception:
117
+ get_ipython().system('rm -rf {directory_path}')
118
+
119
+ # Save files temporarily
120
+ temporarily_dir = f'{root_path}/temp_dir'
121
+
122
+ def copy_items_with_replace(src_base, dst_base):
123
+ items_to_copy = [
124
+ 'embeddings',
125
+ 'models/Stable-diffusion',
126
+ 'models/VAE',
127
+ 'models/Lora',
128
+ 'models/ControlNet'
129
+ ]
130
+
131
+ print("⌚ Перемещение файлов...", end='')
132
+ time.sleep(1)
133
+ for item in items_to_copy:
134
+ src = os.path.join(src_base, item)
135
+ dst = os.path.join(dst_base, item)
136
+
137
+ if os.path.exists(src):
138
+ if os.path.exists(dst):
139
+ _remove_dir(dst)
140
+ os.makedirs(os.path.dirname(dst), exist_ok=True)
141
+ shutil.move(src, dst)
142
+ print("\r🔥 Файлы перемещены!" + " "*15)
143
+
144
+ def handle_colab_timer(webui_path, timer_colab):
145
+ timer_file_path = os.path.join(webui_path, 'static', 'colabTimer.txt')
146
+ if not os.path.exists(timer_file_path):
147
+ with open(timer_file_path, 'w') as timer_file:
148
+ timer_file.write(str(timer_colab))
149
+ else:
150
+ with open(timer_file_path, 'r') as timer_file:
151
+ timer_colab = float(timer_file.read())
152
+ return timer_colab
153
 
154
+ def unpack_webui():
155
+ start_install = time.time()
156
+ print(f"⌚ Распаковка Stable Diffusion{' (Forge)' if UI == 'Forge' else ''}...", end='')
157
 
158
+ with capture.capture_output() as cap:
159
+ download_url = "https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO.zip"
160
+ if UI == 'Forge':
161
+ download_url = "https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO_forge.zip"
162
 
163
+ aria2_args = "--console-log-level=error -c -x 16 -s 16 -k 1M"
164
+ zip_path = f"{root_path}/repo.zip"
165
+ get_ipython().system('aria2c {aria2_args} {download_url} -d {root_path} -o repo.zip')
166
+ get_ipython().system('unzip -q -o {zip_path} -d {webui_path}')
167
+ get_ipython().system('rm -rf {zip_path}')
168
 
169
+ get_ipython().system(f'echo -n {start_colab} > {webui_path}/static/colabTimer.txt')
170
+ del cap
171
 
172
+ install_time = time.time() - start_install
173
+ minutes, seconds = divmod(int(install_time), 60)
174
+ print(f"\r🚀 Распаковка Завершена! За {minutes:02}:{seconds:02} ⚡" + " "*15)
 
 
 
 
 
175
 
176
+ if os.path.exists(temporarily_dir):
177
+ copy_items_with_replace(temporarily_dir, webui_path)
178
+ _remove_dir(temporarily_dir)
179
 
180
+ # ================= MAIN CODE ==================
181
+ if os.path.exists(webui_path):
182
+ if UI != OLD_UI:
183
+ print(f'Переключение веб-интерфейса с \033[33m{OLD_UI}\033[0m на \033[33m{UI}\033[0m:')
184
+ copy_items_with_replace(webui_path, temporarily_dir)
185
+ _remove_dir(webui_path)
186
+ os.environ['SDW_OLD_UI'] = UI
187
+ time.sleep(2)
188
+ clear_output()
189
 
190
+ if not os.path.exists(webui_path):
191
+ unpack_webui()
 
 
192
  else:
193
  print("🚀 Все распакованно... Пропуск. ⚡")
194
+ timer_colab = handle_colab_timer(webui_path, start_colab)
195
+ elapsed_time = str(timedelta(seconds=time.time() - timer_colab)).split('.')[0]
196
+ print(f"⌚️ Вы проводите эту сессию в течение - \033[33m{elapsed_time}\033[0m")
197
 
198
 
199
  ## Changes extensions and WebUi
200
  if latest_webui or latest_exstensions:
201
+ action = "WebUI и Расширений" if latest_webui and latest_exstensions else ("WebUI" if latest_webui else "Расширений")
202
+ print(f"⌚️ Обновление {action}...", end='')
203
  with capture.capture_output() as cap:
204
  get_ipython().system('git config --global user.email "[email protected]"')
205
  get_ipython().system('git config --global user.name "Your Name"')
 
214
  if latest_exstensions:
215
  get_ipython().system('{\'for dir in \' + webui_path + \'/extensions/*/; do cd \\"$dir\\" && git reset --hard && git pull; done\'}')
216
  del cap
217
+ print(f"\r✨ Обновление {action} Завершено!")
218
 
219
 
220
  # === FIXING EXTENSIONS ===
 
223
  with capture.capture_output() as cap:
224
  # --- Umi-Wildcard ---
225
  get_ipython().system("sed -i '521s/open=\\(False\\|True\\)/open=False/' {webui_path}/extensions/Umi-AI-Wildcards/scripts/wildcard_recursive.py # Closed accordion by default")
 
226
  # --- Encrypt-Image ---
227
  get_ipython().system("sed -i '9,37d' {webui_path}/extensions/Encrypt-Image/javascript/encrypt_images_info.js # Removes the weird text in webui")
 
228
  # --- Additional-Networks ---
229
  get_ipython().system('wget -O {webui_path}/extensions/additional-networks/scripts/metadata_editor.py {anxety_repos}/extensions/Additional-Networks/fix/metadata_editor.py # Fixing an error due to old style')
230
  del cap
 
232
 
233
  ## Version switching
234
  if commit_hash:
235
+ print('⏳ Активация машины времени...', end="")
236
  with capture.capture_output() as cap:
237
  get_ipython().run_line_magic('cd', '{webui_path}')
238
  get_ipython().system('git config --global user.email "[email protected]"')
 
272
  padding = (terminal_width - len(text)) // 2
273
  return f"\033[1m\033[36m{' ' * padding}{text}{' ' * padding}\033[0m\033[32m"
274
 
275
+ def format_output(url, dst_dir, file_name, image_name=None, image_url=None):
276
  info = center_text(f"[{file_name.split('.')[0]}]")
277
  separation_line = '\033[32m' + '---' * 20
278
 
 
281
  print(f"\033[33mSAVE DIR: \033[34m{dst_dir}")
282
  print(f"\033[33mFILE NAME: \033[34m{file_name}\033[0m")
283
 
284
+ if 'civitai' in url and image_url:
285
+ print(f"\033[32m[Preview DL]:\033[0m {image_name} - {image_url}\n")
286
+
287
  ''' GET CivitAi API - DATA '''
288
 
289
  def CivitAi_API(url, file_name=None):
290
+ SUPPORT_TYPES = ('Checkpoint', 'TextualInversion', 'LORA')
291
  CIVITAI_TOKEN = "62c0c5956b2f9defbd844d754000180b"
292
 
293
  url = url.split('?token=')[0] if '?token=' in url else url
294
  url = url.replace('?type=', f'?token={CIVITAI_TOKEN}&type=') if '?type=' in url else f"{url}?token={CIVITAI_TOKEN}"
295
 
296
  def get_model_data(url):
297
+ base_url = "https://civitai.com/api/v1"
298
+ try:
299
+ if "civitai.com/models/" in url:
300
+ if '?modelVersionId=' in url:
301
+ version_id = url.split('?modelVersionId=')[1]
302
+ else:
303
+ model_id = url.split('/models/')[1].split('/')[0]
304
+ model_data = requests.get(f"{base_url}/models/{model_id}").json()
305
+ version_id = model_data['modelVersions'][0].get('id')
306
  else:
307
+ version_id = url.split('/models/')[1].split('/')[0]
308
+
309
+ return requests.get(f"{base_url}/model-versions/{version_id}").json()
310
+ except (KeyError, IndexError, requests.RequestException) as e:
311
+ return None
312
 
313
  data = get_model_data(url)
314
 
315
  if not data:
316
+ print("\033[31m[Data Info]:\033[0m Failed to retrieve data from the API.\n")
317
+ return 'None', None, None, None, None, None, None
318
 
319
  def extract_model_info(url, data):
320
+ model_type = data['model']['type']
321
+ model_name = data['files'][0]['name']
322
+
323
+ if 'type=' in url:
324
+ url_model_type = parse_qs(urlparse(url).query).get('type', [''])[0].lower()
325
+ if 'vae' in url_model_type:
326
+ model_type = data['files'][1]['type']
 
 
 
 
 
327
  model_name = data['files'][1]['name']
328
+
 
 
329
  return model_type, model_name
330
 
331
  model_type, model_name = extract_model_info(url, data)
332
  model_name = file_name or model_name
333
 
334
+ def get_download_url(data, model_type):
335
+ if any(t.lower() in model_type.lower() for t in SUPPORT_TYPES):
336
+ return data['files'][0]['downloadUrl']
 
 
 
 
 
 
 
 
 
 
337
 
338
+ return data['files'][1]['downloadUrl'] if 'type' in url else data['files'][0]['downloadUrl']
339
+
340
+ download_url = get_download_url(data, model_type)
341
 
342
  def get_image_info(data, model_type, model_name):
343
+ if not any(t in model_type for t in SUPPORT_TYPES):
344
+ return None, None
345
+
346
+ for image in data.get('images', []):
347
+ if image['nsfwLevel'] >= 4 and env == 'Kaggle': # Filter NSFW images for Kaggle
348
+ continue
349
+ image_url = image['url']
350
+ image_extension = image_url.split('.')[-1]
351
+ image_name = f"{model_name.split('.')[0]}.preview.{image_extension}" if image_url else None
352
+ return image_url, image_name
353
 
354
+ return None, None
 
355
 
356
  image_url, image_name = get_image_info(data, model_type, model_name)
357
 
358
+ return f"{download_url}{'&' if '?' in download_url else '?'}token={CIVITAI_TOKEN}", download_url, model_type, model_name, image_url, image_name, data
359
 
360
  ''' Main Download Code '''
361
 
 
401
  dir = PREFIXES[prefix]
402
  if prefix != "extension":
403
  try:
404
+ manual_download(path, dir, file_name=file_name, prefix=prefix)
405
  except Exception as e:
406
  print(f"Error downloading file: {e}")
407
  else:
408
  extension_repo.append((path, file_name))
409
 
410
+ def manual_download(url, dst_dir, file_name, prefix=None):
411
  header_option = f"--header={user_header}"
412
  aria2c_header = "--header='User-Agent: Mozilla/5.0' --allow-overwrite=true"
413
  aria2_args = "--optimize-concurrent-downloads --console-log-level=error --summary-interval=10 --stderr=true -c -x16 -s16 -k1M -j5"
 
425
 
426
  """ Formatted info output """
427
  model_name_or_basename = file_name if file_name else basename
428
+ try:
429
+ format_output(clean_url or url, dst_dir, model_name_or_basename, image_name, image_url)
430
+ except UnboundLocalError:
431
+ format_output(clean_url or url, dst_dir, model_name_or_basename, None, None)
 
 
 
 
432
 
433
  # =====================
434
  def run_aria2c(url, dst_dir, file_name=None, args="", header=""):
435
+ file_path = os.path.join(dst_dir, file_name) # replaces config files
436
+ if os.path.exists(file_path) and prefix == 'config':
437
+ os.remove(file_path)
438
+
439
  out = f"-o '{file_name}'" if file_name else ""
440
  get_ipython().system("aria2c {header} {args} -d {dst_dir} {out} '{url}'")
441
 
 
461
 
462
  ''' SubModels - Added URLs '''
463
 
464
+ # Separation of merged numbers
465
+ def split_numbers(num_str, max_num):
466
+ def helper(s):
467
+ if not s:
468
+ return []
469
+ for length in range(2, 0, -1):
470
+ if len(s) >= length:
471
+ part = int(s[:length])
472
+ if part <= max_num:
473
+ result = helper(s[length:])
474
+ if result is not None:
475
+ return [part] + result
476
+ return None
477
+ return helper(num_str)
478
+
479
  def add_submodels(selection, num_selection, model_dict, dst_dir):
480
+ selected_models = []
481
  if selection == "none":
482
+ return selected_models
483
  if selection == "ALL":
 
484
  for models in model_dict.values():
485
+ selected_models.extend(models)
 
486
  else:
487
+ if selection in model_dict:
488
+ selected_models.extend(model_dict[selection])
489
+ nums = num_selection.replace(',', ' ').split()
490
+ max_num = len(model_dict)
491
+ selected_nums = []
492
+
493
+ for num_part in nums:
494
+ split_nums = split_numbers(num_part, max_num)
495
+ if split_nums:
496
+ selected_nums.extend(split_nums)
497
+
498
+ unique_nums = list(set(selected_nums))
499
+
500
+ for num in unique_nums:
501
+ if 1 <= num <= max_num:
502
  name = list(model_dict)[num - 1]
503
  selected_models.extend(model_dict[name])
504
 
 
589
 
590
  ## Install of Custom extensions
591
  if len(extension_repo) > 0:
592
+ print("✨ Установка кастомных расширений...", end='')
593
  with capture.capture_output() as cap:
594
  for repo, repo_name in extension_repo:
595
  if not repo_name:
files_cells/python/ru/launch_ru.py CHANGED
@@ -5,6 +5,7 @@ import re
5
  import time
6
  import json
7
  import requests
 
8
  import cloudpickle as pickle
9
  from datetime import timedelta
10
  from IPython.display import clear_output
@@ -31,6 +32,17 @@ commandline_arguments = settings.get('commandline_arguments', "")
31
  change_webui = settings.get('change_webui', "")
32
 
33
 
 
 
 
 
 
 
 
 
 
 
 
34
  # ======================== TUNNEL V2 ========================
35
  print('Please Wait...')
36
 
@@ -56,7 +68,9 @@ tunnel_class = pickle.load(open(f"{root_path}/new_tunnel", "rb"), encoding="utf-
56
  tunnel_port = 1834
57
  tunnel = tunnel_class(tunnel_port)
58
  tunnel.add_tunnel(command="cl tunnel --url localhost:{port}", name="cl", pattern=re.compile(r"[\w-]+\.trycloudflare\.com"))
59
- 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.")
 
 
60
 
61
  if zrok_token:
62
  get_ipython().system('zrok enable {zrok_token} &> /dev/null')
@@ -65,7 +79,7 @@ if zrok_token:
65
  clear_output()
66
 
67
 
68
- # =============== Automatic Fixing Path V3 ===============
69
  paths_to_check = {
70
  "tagger_hf_cache_dir": f"{webui_path}/models/interrogators/",
71
  "additional_networks_extra_lora_path": f"{webui_path}/models/Lora/",
@@ -96,8 +110,10 @@ with tunnel:
96
  if env != "Google Colab":
97
  commandline_arguments += f' --encrypt-pass={tunnel_port} --api'
98
 
99
- if change_webui == 'Forge':
100
- commandline_arguments += ' --cuda-stream --pin-shared-memory'
 
 
101
 
102
  get_ipython().system('COMMANDLINE_ARGS="{commandline_arguments}" python launch.py')
103
 
 
5
  import time
6
  import json
7
  import requests
8
+ import subprocess
9
  import cloudpickle as pickle
10
  from datetime import timedelta
11
  from IPython.display import clear_output
 
32
  change_webui = settings.get('change_webui', "")
33
 
34
 
35
+ # ========================== OTHER ==========================
36
+ def is_package_installed(package_name):
37
+ try:
38
+ subprocess.run(["npm", "ls", "-g", package_name], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
39
+ return True
40
+ except subprocess.CalledProcessError:
41
+ return False
42
+
43
+ lt_tunnel = is_package_installed('localtunnel')
44
+
45
+
46
  # ======================== TUNNEL V2 ========================
47
  print('Please Wait...')
48
 
 
68
  tunnel_port = 1834
69
  tunnel = tunnel_class(tunnel_port)
70
  tunnel.add_tunnel(command="cl tunnel --url localhost:{port}", name="cl", pattern=re.compile(r"[\w-]+\.trycloudflare\.com"))
71
+
72
+ if lt_tunnel:
73
+ 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.")
74
 
75
  if zrok_token:
76
  get_ipython().system('zrok enable {zrok_token} &> /dev/null')
 
79
  clear_output()
80
 
81
 
82
+ # ================= Automatic Fixing Path V3 ================
83
  paths_to_check = {
84
  "tagger_hf_cache_dir": f"{webui_path}/models/interrogators/",
85
  "additional_networks_extra_lora_path": f"{webui_path}/models/Lora/",
 
110
  if env != "Google Colab":
111
  commandline_arguments += f' --encrypt-pass={tunnel_port} --api'
112
 
113
+ if change_webui == 'A1111':
114
+ commandline_arguments += ' --xformers'
115
+ else:
116
+ commandline_arguments += ' --disable-xformers --opt-sdp-attention --cuda-stream --pin-shared-memory'
117
 
118
  get_ipython().system('COMMANDLINE_ARGS="{commandline_arguments}" python launch.py')
119
 
files_cells/python/ru/widgets_ru.py CHANGED
@@ -92,6 +92,7 @@ function toggleContainer() {
92
  '''
93
  display(HTML(JS))
94
 
 
95
  # ==================== WIDGETS V2 ====================
96
  HR = widgets.HTML('<hr>')
97
 
@@ -203,7 +204,7 @@ zrok_token_widget = factory.create_text('Токен Zrok:')
203
  zrok_button = factory.create_html('<a href="https://colab.research.google.com/drive/1d2sjWDJi_GYBUavrHSuQyHTDuLy36WpU" target="_blank">Зарегать Zrok Токен</a>', class_name="button_ngrok")
204
  zrok_widget = factory.create_hbox([zrok_token_widget, zrok_button])
205
 
206
- commandline_arguments_options = "--listen --enable-insecure-extension-access --theme dark --no-half-vae --disable-console-progressbars --xformers"
207
  commandline_arguments_widget = factory.create_text('Аргументы:', value=commandline_arguments_options)
208
 
209
  # Display Additional
@@ -221,8 +222,6 @@ additional_widget_list = [additional_header,
221
 
222
  if free_plan and env == "Google Colab": # remove ngrok from colab
223
  additional_widget_list.remove(ngrok_widget)
224
- if os.path.exists(webui_path): # remove selection after selection ;3
225
- choose_changes_widget.children = [widget for widget in choose_changes_widget.children if widget != change_webui_widget]
226
 
227
  all_additional_box = factory.create_vbox(additional_widget_list, class_names=["container", "image_3"])
228
  factory.display(all_additional_box)
@@ -272,6 +271,21 @@ save_button = factory.create_button('Сохранить', class_name="button_sav
272
  factory.display(save_button)
273
 
274
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
275
  # ============ Load / Save - Settings V2 ============
276
  SETTINGS_FILE = f'{root_path}/settings.json'
277
 
@@ -306,6 +320,7 @@ def hide_widgets():
306
 
307
  def save_data(button):
308
  save_settings()
 
309
  hide_widgets()
310
 
311
  load_settings()
 
92
  '''
93
  display(HTML(JS))
94
 
95
+
96
  # ==================== WIDGETS V2 ====================
97
  HR = widgets.HTML('<hr>')
98
 
 
204
  zrok_button = factory.create_html('<a href="https://colab.research.google.com/drive/1d2sjWDJi_GYBUavrHSuQyHTDuLy36WpU" target="_blank">Зарегать Zrok Токен</a>', class_name="button_ngrok")
205
  zrok_widget = factory.create_hbox([zrok_token_widget, zrok_button])
206
 
207
+ commandline_arguments_options = "--listen --enable-insecure-extension-access --theme dark --no-half-vae --disable-console-progressbars"
208
  commandline_arguments_widget = factory.create_text('Аргументы:', value=commandline_arguments_options)
209
 
210
  # Display Additional
 
222
 
223
  if free_plan and env == "Google Colab": # remove ngrok from colab
224
  additional_widget_list.remove(ngrok_widget)
 
 
225
 
226
  all_additional_box = factory.create_vbox(additional_widget_list, class_names=["container", "image_3"])
227
  factory.display(all_additional_box)
 
271
  factory.display(save_button)
272
 
273
 
274
+ # ==================== OTHER FUNC ====================
275
+ # Setup UI
276
+ def setup_webui(change_webui_widget):
277
+ if 'SDW_UI' in os.environ:
278
+ UI = os.environ['SDW_UI']
279
+ else:
280
+ os.environ['SDW_UI'] = change_webui_widget
281
+ os.environ['SDW_OLD_UI'] = change_webui_widget
282
+
283
+ UI = os.getenv('SDW_UI')
284
+
285
+ if UI != change_webui_widget:
286
+ os.environ['SDW_UI'] = change_webui_widget
287
+
288
+
289
  # ============ Load / Save - Settings V2 ============
290
  SETTINGS_FILE = f'{root_path}/settings.json'
291
 
 
320
 
321
  def save_data(button):
322
  save_settings()
323
+ setup_webui(change_webui_widget.value)
324
  hide_widgets()
325
 
326
  load_settings()
modules/directory_setup.py CHANGED
@@ -2,7 +2,7 @@ import os
2
 
3
  webui_path = os.getenv('WEBUI_PATH')
4
 
5
- output_dir = f"{webui_path}/output"
6
  models_dir = f"{webui_path}/models/Stable-diffusion"
7
  vaes_dir = f"{webui_path}/models/VAE"
8
  embeddings_dir = f"{webui_path}/embeddings"
 
2
 
3
  webui_path = os.getenv('WEBUI_PATH')
4
 
5
+ output_dir = f"{webui_path}/outputs"
6
  models_dir = f"{webui_path}/models/Stable-diffusion"
7
  vaes_dir = f"{webui_path}/models/VAE"
8
  embeddings_dir = f"{webui_path}/embeddings"
modules/models_data.py CHANGED
@@ -8,12 +8,12 @@ model_list = {
8
  {"url": "https://civitai.com/api/download/models/363850", "name": "BluMix_V7-inpainting.safetensors"}
9
  ],
10
  "3.Cetus-Mix [Anime] [V4] + INP": [
11
- {"url": "https://civitai.com/api/download/models/130298", "name": "CetusMix_V4.safetensors"},
12
- {"url": "https://civitai.com/api/download/models/139882", "name": "CetusMix_V4-inpainting.safetensors"}
13
  ],
14
  "4.Counterfeit [Anime] [V3] + INP": [
15
- {"url": "https://huggingface.co/gsdf/Counterfeit-V3.0/resolve/main/Counterfeit-V3.0_fix_fp16.safetensors", "name": "Counterfeit_V3.safetensors"},
16
- {"url": "https://civitai.com/api/download/models/137911", "name": "Counterfeit_V3-inpainting.safetensors"}
17
  ],
18
  "5.CuteColor [Anime] [V3]": [
19
  {"url": "https://civitai.com/api/download/models/138754", "name": "CuteColor_V3.safetensors"}
@@ -31,16 +31,21 @@ model_list = {
31
  {"url": "https://civitai.com/api/download/models/120702", "name": "MeinaMix_V11-inpainting.safetensors"}
32
  ],
33
  "9.Mix-Pro [Anime] [V4] + INP": [
34
- {"url": "https://civitai.com/api/download/models/125668", "name": "MixPro_V4.safetensors"},
35
- {"url": "https://civitai.com/api/download/models/139878", "name": "MixPro_V4-inpainting.safetensors"}
 
 
36
  ]
37
  }
38
 
39
  vae_list = {
40
- "1.Anime.vae": [{"url": "https://civitai.com/api/download/models/311162", "name": "Anime.vae.safetensors"}],
41
- "2.Anything.vae": [{"url": "https://huggingface.co/NoCrypt/resources/resolve/main/VAE/any.vae.safetensors", "name": "Anything.vae.safetensors"}],
42
- "3.Blessed2.vae": [{"url": "https://huggingface.co/NoCrypt/resources/resolve/main/VAE/blessed2.vae.safetensors", "name": "Blessed2.vae.safetensors"}],
43
- "4.ClearVae.vae": [{"url": "https://civitai.com/api/download/models/88156", "name": "ClearVae_23.vae.safetensors"}],
 
 
 
44
  "5.WD.vae": [{"url": "https://huggingface.co/NoCrypt/resources/resolve/main/VAE/wd.vae.safetensors", "name": "WD.vae.safetensors"}]
45
  }
46
 
 
8
  {"url": "https://civitai.com/api/download/models/363850", "name": "BluMix_V7-inpainting.safetensors"}
9
  ],
10
  "3.Cetus-Mix [Anime] [V4] + INP": [
11
+ {"url": "https://huggingface.co/fp16-guy/Cetus-Mix_v4_fp16_cleaned/resolve/main/cetusMix_v4_fp16.safetensors", "name": "CetusMix_V4.safetensors"},
12
+ {"url": "https://huggingface.co/fp16-guy/Cetus-Mix_v4_fp16_cleaned/resolve/main/cetusMix_v4_inp_fp16.safetensors", "name": "CetusMix_V4-inpainting.safetensors"}
13
  ],
14
  "4.Counterfeit [Anime] [V3] + INP": [
15
+ {"url": "https://huggingface.co/fp16-guy/Counterfeit-V3.0_fp16_cleaned/resolve/main/CounterfeitV30_v30_fp16.safetensors", "name": "Counterfeit_V3.safetensors"},
16
+ {"url": "https://huggingface.co/fp16-guy/Counterfeit-V3.0_fp16_cleaned/resolve/main/CounterfeitV30_v30_inp_fp16.safetensors", "name": "Counterfeit_V3-inpainting.safetensors"}
17
  ],
18
  "5.CuteColor [Anime] [V3]": [
19
  {"url": "https://civitai.com/api/download/models/138754", "name": "CuteColor_V3.safetensors"}
 
31
  {"url": "https://civitai.com/api/download/models/120702", "name": "MeinaMix_V11-inpainting.safetensors"}
32
  ],
33
  "9.Mix-Pro [Anime] [V4] + INP": [
34
+ {"url": "https://huggingface.co/fp16-guy/MIX-Pro-V4_fp16_cleaned/resolve/main/mixProV4_v4_fp16.safetensors", "name": "MixPro_V4.safetensors"},
35
+ {"url": "https://huggingface.co/fp16-guy/MIX-Pro-V4_fp16_cleaned/resolve/main/mixProV4_v4_inp_fp16.safetensors", "name": "MixPro_V4-inpainting.safetensors"},
36
+ {"url": "https://huggingface.co/fp16-guy/MIX-Pro-V4.5_fp16_cleaned/resolve/main/mixProV45Colorbox_v45_fp16.safetensors", "name": "MixPro_V4_5.safetensors"},
37
+ {"url": "https://huggingface.co/fp16-guy/MIX-Pro-V4.5_fp16_cleaned/resolve/main/mixProV45Colorbox_v45_inp_fp16.safetensors", "name": "MixPro_V4_5-inpainting.safetensors"}
38
  ]
39
  }
40
 
41
  vae_list = {
42
+ "1.Anime.vae": [
43
+ {"url": "https://huggingface.co/fp16-guy/anything_kl-f8-anime2_vae-ft-mse-840000-ema-pruned_blessed_clearvae_fp16_cleaned/resolve/main/kl-f8-anime2_fp16.safetensors", "name": "Anime-kl-f8.vae.safetensors"},
44
+ {"url": "https://huggingface.co/fp16-guy/anything_kl-f8-anime2_vae-ft-mse-840000-ema-pruned_blessed_clearvae_fp16_cleaned/resolve/main/vae-ft-mse-840000-ema-pruned_fp16.safetensors", "name": "Anime-mse.vae.safetensors"}
45
+ ],
46
+ "2.Anything.vae": [{"url": "https://huggingface.co/fp16-guy/anything_kl-f8-anime2_vae-ft-mse-840000-ema-pruned_blessed_clearvae_fp16_cleaned/resolve/main/anything_fp16.safetensors", "name": "Anything.vae.safetensors"}],
47
+ "3.Blessed2.vae": [{"url": "https://huggingface.co/fp16-guy/anything_kl-f8-anime2_vae-ft-mse-840000-ema-pruned_blessed_clearvae_fp16_cleaned/resolve/main/blessed2_fp16.safetensors", "name": "Blessed2.vae.safetensors"}],
48
+ "4.ClearVae.vae": [{"url": "https://huggingface.co/fp16-guy/anything_kl-f8-anime2_vae-ft-mse-840000-ema-pruned_blessed_clearvae_fp16_cleaned/resolve/main/ClearVAE_V2.3_fp16.safetensors", "name": "ClearVae_23.vae.safetensors"}],
49
  "5.WD.vae": [{"url": "https://huggingface.co/NoCrypt/resources/resolve/main/VAE/wd.vae.safetensors", "name": "WD.vae.safetensors"}]
50
  }
51