update downlaoding logic code
Browse files- files_cells/notebooks/en/auto-cleaner_en.ipynb +3 -6
- files_cells/notebooks/en/downloading_en.ipynb +30 -42
- files_cells/notebooks/en/launch_en.ipynb +3 -6
- files_cells/notebooks/en/widgets_en.ipynb +4 -7
- files_cells/notebooks/ru/auto-cleaner_ru.ipynb +3 -6
- files_cells/notebooks/ru/downloading_ru.ipynb +29 -40
- files_cells/notebooks/ru/launch_ru.ipynb +3 -6
- files_cells/notebooks/ru/widgets_ru.ipynb +4 -7
- files_cells/python/en/auto-cleaner_en.py +3 -6
- files_cells/python/en/downloading_en.py +30 -42
- files_cells/python/en/launch_en.py +3 -6
- files_cells/python/en/widgets_en.py +4 -7
- files_cells/python/ru/auto-cleaner_ru.py +3 -6
- files_cells/python/ru/downloading_ru.py +29 -40
- files_cells/python/ru/launch_ru.py +3 -6
- files_cells/python/ru/widgets_ru.py +4 -7
files_cells/notebooks/en/auto-cleaner_en.ipynb
CHANGED
|
@@ -35,11 +35,8 @@
|
|
| 35 |
"\n",
|
| 36 |
"\n",
|
| 37 |
"# ================= DETECT ENV =================\n",
|
| 38 |
-
"def check_colab_subscription():\n",
|
| 39 |
-
" return (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)\n",
|
| 40 |
-
"free_plan = check_colab_subscription()\n",
|
| 41 |
-
"\n",
|
| 42 |
"def detect_environment():\n",
|
|
|
|
| 43 |
" environments = {\n",
|
| 44 |
" 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
|
| 45 |
" 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\"),\n",
|
|
@@ -48,9 +45,9 @@
|
|
| 48 |
"\n",
|
| 49 |
" for env_var, (environment, path) in environments.items():\n",
|
| 50 |
" if env_var in os.environ:\n",
|
| 51 |
-
" return environment, path\n",
|
| 52 |
"\n",
|
| 53 |
-
"env, root_path = detect_environment()\n",
|
| 54 |
"webui_path = f\"{root_path}/sdw\"\n",
|
| 55 |
"# ----------------------------------------------\n",
|
| 56 |
"\n",
|
|
|
|
| 35 |
"\n",
|
| 36 |
"\n",
|
| 37 |
"# ================= DETECT ENV =================\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
"def detect_environment():\n",
|
| 39 |
+
" free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)\n",
|
| 40 |
" environments = {\n",
|
| 41 |
" 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
|
| 42 |
" 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\"),\n",
|
|
|
|
| 45 |
"\n",
|
| 46 |
" for env_var, (environment, path) in environments.items():\n",
|
| 47 |
" if env_var in os.environ:\n",
|
| 48 |
+
" return environment, path, free_plan\n",
|
| 49 |
"\n",
|
| 50 |
+
"env, root_path, free_plan = detect_environment()\n",
|
| 51 |
"webui_path = f\"{root_path}/sdw\"\n",
|
| 52 |
"# ----------------------------------------------\n",
|
| 53 |
"\n",
|
files_cells/notebooks/en/downloading_en.ipynb
CHANGED
|
@@ -33,11 +33,8 @@
|
|
| 33 |
"\n",
|
| 34 |
"\n",
|
| 35 |
"# ================= DETECT ENV =================\n",
|
| 36 |
-
"def check_colab_subscription():\n",
|
| 37 |
-
" return (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)\n",
|
| 38 |
-
"free_plan = check_colab_subscription()\n",
|
| 39 |
-
"\n",
|
| 40 |
"def detect_environment():\n",
|
|
|
|
| 41 |
" environments = {\n",
|
| 42 |
" 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
|
| 43 |
" 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\"),\n",
|
|
@@ -46,9 +43,9 @@
|
|
| 46 |
"\n",
|
| 47 |
" for env_var, (environment, path) in environments.items():\n",
|
| 48 |
" if env_var in os.environ:\n",
|
| 49 |
-
" return environment, path\n",
|
| 50 |
"\n",
|
| 51 |
-
"env, root_path = detect_environment()\n",
|
| 52 |
"webui_path = f\"{root_path}/sdw\"\n",
|
| 53 |
"# ----------------------------------------------\n",
|
| 54 |
"\n",
|
|
@@ -73,6 +70,7 @@
|
|
| 73 |
"\n",
|
| 74 |
" print(\"Installing the libraries, it's going to take a while....\", end='')\n",
|
| 75 |
" with capture.capture_output() as cap:\n",
|
|
|
|
| 76 |
" !apt-get update && apt -y install aria2\n",
|
| 77 |
" !npm install -g localtunnel &> /dev/null\n",
|
| 78 |
" !curl -s -OL https://github.com/DEX-1101/sd-webui-notebook/raw/main/res/new_tunnel --output-dir {root_path}\n",
|
|
@@ -91,8 +89,7 @@
|
|
| 91 |
" if env == \"Google Colab\":\n",
|
| 92 |
" !pip install -q pip install xformers==0.0.26.dev769 -U\n",
|
| 93 |
" else:\n",
|
| 94 |
-
"
|
| 95 |
-
" !pip install -q {torch} -U\n",
|
| 96 |
" !pip install -q {xformers} -U\n",
|
| 97 |
"\n",
|
| 98 |
" with open(flag_file, \"w\") as f:\n",
|
|
@@ -334,16 +331,17 @@
|
|
| 334 |
"}\n",
|
| 335 |
"\n",
|
| 336 |
"extension_repo = []\n",
|
| 337 |
-
"prefixes =
|
| 338 |
-
"
|
| 339 |
-
" \"
|
| 340 |
-
" \"
|
| 341 |
-
" \"
|
| 342 |
-
" \"
|
| 343 |
-
" \"
|
| 344 |
-
"]\n",
|
|
|
|
| 345 |
"\n",
|
| 346 |
-
"!mkdir -p {models_dir} {vaes_dir} {embeddings_dir} {
|
| 347 |
"\n",
|
| 348 |
"url = \"\"\n",
|
| 349 |
"ControlNet_url = \"\"\n",
|
|
@@ -359,9 +357,7 @@
|
|
| 359 |
" if file_name:\n",
|
| 360 |
" url = re.sub(r'\\[.*?\\]', '', url)\n",
|
| 361 |
"\n",
|
| 362 |
-
"
|
| 363 |
-
"\n",
|
| 364 |
-
" for prefix, dir in dir_mapping.items():\n",
|
| 365 |
" if original_url.startswith(f\"{prefix}:\"):\n",
|
| 366 |
" if prefix != \"extensions\":\n",
|
| 367 |
" manual_download(url, dir, file_name=file_name)\n",
|
|
@@ -384,7 +380,10 @@
|
|
| 384 |
" if 'folders' in url:\n",
|
| 385 |
" !gdown --folder \"{url}\" -O {dst_dir} --fuzzy -c\n",
|
| 386 |
" else:\n",
|
| 387 |
-
"
|
|
|
|
|
|
|
|
|
|
| 388 |
" # -- Huggin Face --\n",
|
| 389 |
" elif 'huggingface' in url:\n",
|
| 390 |
" if '/blob/' in url:\n",
|
|
@@ -409,7 +408,6 @@
|
|
| 409 |
" link_or_path = link_or_path.strip()\n",
|
| 410 |
" if not link_or_path:\n",
|
| 411 |
" continue\n",
|
| 412 |
-
"\n",
|
| 413 |
" if any(link_or_path.startswith(prefix.lower()) for prefix in prefixes):\n",
|
| 414 |
" handle_manual(link_or_path)\n",
|
| 415 |
" continue\n",
|
|
@@ -450,20 +448,9 @@
|
|
| 450 |
"for submodel in submodels:\n",
|
| 451 |
" if not Inpainting_Model and \"inpainting\" in submodel['name']:\n",
|
| 452 |
" continue\n",
|
| 453 |
-
"\n",
|
| 454 |
" url += f\"{submodel['url']} {submodel['dst_dir']} {submodel['name']}, \"\n",
|
| 455 |
"\n",
|
| 456 |
"def process_file_download(file_url):\n",
|
| 457 |
-
" global Model_url, Vae_url, LoRA_url, Embedding_url, Extensions_url\n",
|
| 458 |
-
" urls_dict = {\n",
|
| 459 |
-
" 'model': 'Model_url',\n",
|
| 460 |
-
" 'vae': 'Vae_url',\n",
|
| 461 |
-
" 'embed': 'Embedding_url',\n",
|
| 462 |
-
" 'lora': 'LoRA_url',\n",
|
| 463 |
-
" 'extension': 'Extensions_url',\n",
|
| 464 |
-
" 'control': 'ControlNet_url'\n",
|
| 465 |
-
" }\n",
|
| 466 |
-
"\n",
|
| 467 |
" if file_url.startswith(\"http\"):\n",
|
| 468 |
" if \"blob\" in file_url:\n",
|
| 469 |
" file_url = file_url.replace(\"blob\", \"raw\")\n",
|
|
@@ -476,12 +463,13 @@
|
|
| 476 |
" current_tag = None\n",
|
| 477 |
" for line in lines:\n",
|
| 478 |
" if line.strip().startswith('#'):\n",
|
| 479 |
-
"
|
| 480 |
-
"
|
| 481 |
-
"
|
| 482 |
-
"
|
| 483 |
-
"
|
| 484 |
-
"
|
|
|
|
| 485 |
"\n",
|
| 486 |
"# fix all possible errors/options and function call\n",
|
| 487 |
"if custom_file_urls:\n",
|
|
@@ -496,11 +484,11 @@
|
|
| 496 |
" except FileNotFoundError:\n",
|
| 497 |
" pass\n",
|
| 498 |
"\n",
|
| 499 |
-
"
|
| 500 |
-
"\n",
|
| 501 |
"for i, prefix in enumerate(prefixes):\n",
|
| 502 |
" if urls[i]:\n",
|
| 503 |
-
" prefixed_urls = [f\"{prefix}{
|
| 504 |
" if prefixed_urls:\n",
|
| 505 |
" url += \", \".join(prefixed_urls) + \", \"\n",
|
| 506 |
"\n",
|
|
|
|
| 33 |
"\n",
|
| 34 |
"\n",
|
| 35 |
"# ================= DETECT ENV =================\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
"def detect_environment():\n",
|
| 37 |
+
" free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)\n",
|
| 38 |
" environments = {\n",
|
| 39 |
" 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
|
| 40 |
" 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\"),\n",
|
|
|
|
| 43 |
"\n",
|
| 44 |
" for env_var, (environment, path) in environments.items():\n",
|
| 45 |
" if env_var in os.environ:\n",
|
| 46 |
+
" return environment, path, free_plan\n",
|
| 47 |
"\n",
|
| 48 |
+
"env, root_path, free_plan = detect_environment()\n",
|
| 49 |
"webui_path = f\"{root_path}/sdw\"\n",
|
| 50 |
"# ----------------------------------------------\n",
|
| 51 |
"\n",
|
|
|
|
| 70 |
"\n",
|
| 71 |
" print(\"Installing the libraries, it's going to take a while....\", end='')\n",
|
| 72 |
" with capture.capture_output() as cap:\n",
|
| 73 |
+
" !pip install -U gdown\n",
|
| 74 |
" !apt-get update && apt -y install aria2\n",
|
| 75 |
" !npm install -g localtunnel &> /dev/null\n",
|
| 76 |
" !curl -s -OL https://github.com/DEX-1101/sd-webui-notebook/raw/main/res/new_tunnel --output-dir {root_path}\n",
|
|
|
|
| 89 |
" if env == \"Google Colab\":\n",
|
| 90 |
" !pip install -q pip install xformers==0.0.26.dev769 -U\n",
|
| 91 |
" else:\n",
|
| 92 |
+
" !pip install -q {torch} -U\n",
|
|
|
|
| 93 |
" !pip install -q {xformers} -U\n",
|
| 94 |
"\n",
|
| 95 |
" with open(flag_file, \"w\") as f:\n",
|
|
|
|
| 331 |
"}\n",
|
| 332 |
"\n",
|
| 333 |
"extension_repo = []\n",
|
| 334 |
+
"prefixes = {\n",
|
| 335 |
+
" # It's complicated, but supplementing has become easier\n",
|
| 336 |
+
" \"model\": [models_dir, \"Model_url\"],\n",
|
| 337 |
+
" \"vae\": [vaes_dir, \"Vae_url\"],\n",
|
| 338 |
+
" \"lora\": [loras_dir, \"LoRA_url\"],\n",
|
| 339 |
+
" \"embeddings\": [embeddings_dir, \"Embedding_url\"],\n",
|
| 340 |
+
" \"extensions\": [extensions_dir, \"Extensions_url\"],\n",
|
| 341 |
+
" \"control\": [control_dir, \"ControlNet_url\"]\n",
|
| 342 |
+
"}\n",
|
| 343 |
"\n",
|
| 344 |
+
"!mkdir -p {models_dir} {vaes_dir} {loras_dir} {embeddings_dir} {extensions_dir} {control_dir}\n",
|
| 345 |
"\n",
|
| 346 |
"url = \"\"\n",
|
| 347 |
"ControlNet_url = \"\"\n",
|
|
|
|
| 357 |
" if file_name:\n",
|
| 358 |
" url = re.sub(r'\\[.*?\\]', '', url)\n",
|
| 359 |
"\n",
|
| 360 |
+
" for prefix, (dir, _) in prefixes.items():\n",
|
|
|
|
|
|
|
| 361 |
" if original_url.startswith(f\"{prefix}:\"):\n",
|
| 362 |
" if prefix != \"extensions\":\n",
|
| 363 |
" manual_download(url, dir, file_name=file_name)\n",
|
|
|
|
| 380 |
" if 'folders' in url:\n",
|
| 381 |
" !gdown --folder \"{url}\" -O {dst_dir} --fuzzy -c\n",
|
| 382 |
" else:\n",
|
| 383 |
+
" if file_name:\n",
|
| 384 |
+
" !gdown \"{url}\" -O {dst_dir}/{file_name} --fuzzy -c\n",
|
| 385 |
+
" else:\n",
|
| 386 |
+
" !gdown \"{url}\" -O {dst_dir} --fuzzy -c\n",
|
| 387 |
" # -- Huggin Face --\n",
|
| 388 |
" elif 'huggingface' in url:\n",
|
| 389 |
" if '/blob/' in url:\n",
|
|
|
|
| 408 |
" link_or_path = link_or_path.strip()\n",
|
| 409 |
" if not link_or_path:\n",
|
| 410 |
" continue\n",
|
|
|
|
| 411 |
" if any(link_or_path.startswith(prefix.lower()) for prefix in prefixes):\n",
|
| 412 |
" handle_manual(link_or_path)\n",
|
| 413 |
" continue\n",
|
|
|
|
| 448 |
"for submodel in submodels:\n",
|
| 449 |
" if not Inpainting_Model and \"inpainting\" in submodel['name']:\n",
|
| 450 |
" continue\n",
|
|
|
|
| 451 |
" url += f\"{submodel['url']} {submodel['dst_dir']} {submodel['name']}, \"\n",
|
| 452 |
"\n",
|
| 453 |
"def process_file_download(file_url):\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 454 |
" if file_url.startswith(\"http\"):\n",
|
| 455 |
" if \"blob\" in file_url:\n",
|
| 456 |
" file_url = file_url.replace(\"blob\", \"raw\")\n",
|
|
|
|
| 463 |
" current_tag = None\n",
|
| 464 |
" for line in lines:\n",
|
| 465 |
" if line.strip().startswith('#'):\n",
|
| 466 |
+
" if any(tag in line.lower() for tag in prefixes):\n",
|
| 467 |
+
" current_tag = next((tag for tag in prefixes if tag in line.lower()))\n",
|
| 468 |
+
"\n",
|
| 469 |
+
" urls = [url.strip() for url in line.split()]\n",
|
| 470 |
+
" for url in urls:\n",
|
| 471 |
+
" if url.startswith(\"http\"):\n",
|
| 472 |
+
" globals()[prefixes[current_tag][1]] += \", \" + url\n",
|
| 473 |
"\n",
|
| 474 |
"# fix all possible errors/options and function call\n",
|
| 475 |
"if custom_file_urls:\n",
|
|
|
|
| 484 |
" except FileNotFoundError:\n",
|
| 485 |
" pass\n",
|
| 486 |
"\n",
|
| 487 |
+
"# url prefixing\n",
|
| 488 |
+
"urls = [globals()[urls[1]] for urls in prefixes.values()]\n",
|
| 489 |
"for i, prefix in enumerate(prefixes):\n",
|
| 490 |
" if urls[i]:\n",
|
| 491 |
+
" prefixed_urls = [f\"{prefix}:{url}\" for url in urls[i].replace(',', '').split()]\n",
|
| 492 |
" if prefixed_urls:\n",
|
| 493 |
" url += \", \".join(prefixed_urls) + \", \"\n",
|
| 494 |
"\n",
|
files_cells/notebooks/en/launch_en.ipynb
CHANGED
|
@@ -33,11 +33,8 @@
|
|
| 33 |
"\n",
|
| 34 |
"\n",
|
| 35 |
"# ================= DETECT ENV =================\n",
|
| 36 |
-
"def check_colab_subscription():\n",
|
| 37 |
-
" return (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)\n",
|
| 38 |
-
"free_plan = check_colab_subscription()\n",
|
| 39 |
-
"\n",
|
| 40 |
"def detect_environment():\n",
|
|
|
|
| 41 |
" environments = {\n",
|
| 42 |
" 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
|
| 43 |
" 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\"),\n",
|
|
@@ -46,9 +43,9 @@
|
|
| 46 |
"\n",
|
| 47 |
" for env_var, (environment, path) in environments.items():\n",
|
| 48 |
" if env_var in os.environ:\n",
|
| 49 |
-
" return environment, path\n",
|
| 50 |
"\n",
|
| 51 |
-
"env, root_path = detect_environment()\n",
|
| 52 |
"webui_path = f\"{root_path}/sdw\"\n",
|
| 53 |
"# ----------------------------------------------\n",
|
| 54 |
"\n",
|
|
|
|
| 33 |
"\n",
|
| 34 |
"\n",
|
| 35 |
"# ================= DETECT ENV =================\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
"def detect_environment():\n",
|
| 37 |
+
" free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)\n",
|
| 38 |
" environments = {\n",
|
| 39 |
" 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
|
| 40 |
" 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\"),\n",
|
|
|
|
| 43 |
"\n",
|
| 44 |
" for env_var, (environment, path) in environments.items():\n",
|
| 45 |
" if env_var in os.environ:\n",
|
| 46 |
+
" return environment, path, free_plan\n",
|
| 47 |
"\n",
|
| 48 |
+
"env, root_path, free_plan = detect_environment()\n",
|
| 49 |
"webui_path = f\"{root_path}/sdw\"\n",
|
| 50 |
"# ----------------------------------------------\n",
|
| 51 |
"\n",
|
files_cells/notebooks/en/widgets_en.ipynb
CHANGED
|
@@ -27,11 +27,8 @@
|
|
| 27 |
"\n",
|
| 28 |
"\n",
|
| 29 |
"# ================= DETECT ENV =================\n",
|
| 30 |
-
"def check_colab_subscription():\n",
|
| 31 |
-
" return (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)\n",
|
| 32 |
-
"free_plan = check_colab_subscription()\n",
|
| 33 |
-
"\n",
|
| 34 |
"def detect_environment():\n",
|
|
|
|
| 35 |
" environments = {\n",
|
| 36 |
" 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
|
| 37 |
" 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\"),\n",
|
|
@@ -40,9 +37,9 @@
|
|
| 40 |
"\n",
|
| 41 |
" for env_var, (environment, path) in environments.items():\n",
|
| 42 |
" if env_var in os.environ:\n",
|
| 43 |
-
" return environment, path\n",
|
| 44 |
"\n",
|
| 45 |
-
"env, root_path = detect_environment()\n",
|
| 46 |
"webui_path = f\"{root_path}/sdw\"\n",
|
| 47 |
"\n",
|
| 48 |
"!mkdir -p {root_path}\n",
|
|
@@ -364,7 +361,7 @@
|
|
| 364 |
"commandline_arguments_widget = widgets.Text(description='Arguments:', value=commandline_arguments_options, style=style, layout=layout)\n",
|
| 365 |
"\n",
|
| 366 |
"additional_widget_list = [additional_header, latest_changes_widget, HR, controlnet_widget, controlnet_Num_widget, commit_hash_widget, optional_huggingface_token_widget, ngrok_widget, HR, commandline_arguments_widget]\n",
|
| 367 |
-
"if free_plan:\n",
|
| 368 |
" additional_widget_list.remove(ngrok_widget)\n",
|
| 369 |
"display(widgets.VBox(additional_widget_list).add_class(\"container\"))\n",
|
| 370 |
"\n",
|
|
|
|
| 27 |
"\n",
|
| 28 |
"\n",
|
| 29 |
"# ================= DETECT ENV =================\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
"def detect_environment():\n",
|
| 31 |
+
" free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)\n",
|
| 32 |
" environments = {\n",
|
| 33 |
" 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
|
| 34 |
" 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\"),\n",
|
|
|
|
| 37 |
"\n",
|
| 38 |
" for env_var, (environment, path) in environments.items():\n",
|
| 39 |
" if env_var in os.environ:\n",
|
| 40 |
+
" return environment, path, free_plan\n",
|
| 41 |
"\n",
|
| 42 |
+
"env, root_path, free_plan = detect_environment()\n",
|
| 43 |
"webui_path = f\"{root_path}/sdw\"\n",
|
| 44 |
"\n",
|
| 45 |
"!mkdir -p {root_path}\n",
|
|
|
|
| 361 |
"commandline_arguments_widget = widgets.Text(description='Arguments:', value=commandline_arguments_options, style=style, layout=layout)\n",
|
| 362 |
"\n",
|
| 363 |
"additional_widget_list = [additional_header, latest_changes_widget, HR, controlnet_widget, controlnet_Num_widget, commit_hash_widget, optional_huggingface_token_widget, ngrok_widget, HR, commandline_arguments_widget]\n",
|
| 364 |
+
"if free_plan and env == \"Google Colab\":\n",
|
| 365 |
" additional_widget_list.remove(ngrok_widget)\n",
|
| 366 |
"display(widgets.VBox(additional_widget_list).add_class(\"container\"))\n",
|
| 367 |
"\n",
|
files_cells/notebooks/ru/auto-cleaner_ru.ipynb
CHANGED
|
@@ -35,11 +35,8 @@
|
|
| 35 |
"\n",
|
| 36 |
"\n",
|
| 37 |
"# ================= DETECT ENV =================\n",
|
| 38 |
-
"def check_colab_subscription():\n",
|
| 39 |
-
" return (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)\n",
|
| 40 |
-
"free_plan = check_colab_subscription()\n",
|
| 41 |
-
"\n",
|
| 42 |
"def detect_environment():\n",
|
|
|
|
| 43 |
" environments = {\n",
|
| 44 |
" 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
|
| 45 |
" 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\"),\n",
|
|
@@ -48,9 +45,9 @@
|
|
| 48 |
"\n",
|
| 49 |
" for env_var, (environment, path) in environments.items():\n",
|
| 50 |
" if env_var in os.environ:\n",
|
| 51 |
-
" return environment, path\n",
|
| 52 |
"\n",
|
| 53 |
-
"env, root_path = detect_environment()\n",
|
| 54 |
"webui_path = f\"{root_path}/sdw\"\n",
|
| 55 |
"# ----------------------------------------------\n",
|
| 56 |
"\n",
|
|
|
|
| 35 |
"\n",
|
| 36 |
"\n",
|
| 37 |
"# ================= DETECT ENV =================\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
"def detect_environment():\n",
|
| 39 |
+
" free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)\n",
|
| 40 |
" environments = {\n",
|
| 41 |
" 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
|
| 42 |
" 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\"),\n",
|
|
|
|
| 45 |
"\n",
|
| 46 |
" for env_var, (environment, path) in environments.items():\n",
|
| 47 |
" if env_var in os.environ:\n",
|
| 48 |
+
" return environment, path, free_plan\n",
|
| 49 |
"\n",
|
| 50 |
+
"env, root_path, free_plan = detect_environment()\n",
|
| 51 |
"webui_path = f\"{root_path}/sdw\"\n",
|
| 52 |
"# ----------------------------------------------\n",
|
| 53 |
"\n",
|
files_cells/notebooks/ru/downloading_ru.ipynb
CHANGED
|
@@ -33,11 +33,8 @@
|
|
| 33 |
"\n",
|
| 34 |
"\n",
|
| 35 |
"# ================= DETECT ENV =================\n",
|
| 36 |
-
"def check_colab_subscription():\n",
|
| 37 |
-
" return (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)\n",
|
| 38 |
-
"free_plan = check_colab_subscription()\n",
|
| 39 |
-
"\n",
|
| 40 |
"def detect_environment():\n",
|
|
|
|
| 41 |
" environments = {\n",
|
| 42 |
" 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
|
| 43 |
" 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\"),\n",
|
|
@@ -46,9 +43,9 @@
|
|
| 46 |
"\n",
|
| 47 |
" for env_var, (environment, path) in environments.items():\n",
|
| 48 |
" if env_var in os.environ:\n",
|
| 49 |
-
" return environment, path\n",
|
| 50 |
"\n",
|
| 51 |
-
"env, root_path = detect_environment()\n",
|
| 52 |
"webui_path = f\"{root_path}/sdw\"\n",
|
| 53 |
"# ----------------------------------------------\n",
|
| 54 |
"\n",
|
|
@@ -73,6 +70,7 @@
|
|
| 73 |
"\n",
|
| 74 |
" print(\"Установка библиотек, это займет какое-то время...\", end='')\n",
|
| 75 |
" with capture.capture_output() as cap:\n",
|
|
|
|
| 76 |
" !apt-get update && apt -y install aria2\n",
|
| 77 |
" !npm install -g localtunnel &> /dev/null\n",
|
| 78 |
" !curl -s -OL https://github.com/DEX-1101/sd-webui-notebook/raw/main/res/new_tunnel --output-dir {root_path}\n",
|
|
@@ -333,16 +331,17 @@
|
|
| 333 |
"}\n",
|
| 334 |
"\n",
|
| 335 |
"extension_repo = []\n",
|
| 336 |
-
"prefixes =
|
| 337 |
-
"
|
| 338 |
-
" \"
|
| 339 |
-
" \"
|
| 340 |
-
" \"
|
| 341 |
-
" \"
|
| 342 |
-
" \"
|
| 343 |
-
"]\n",
|
|
|
|
| 344 |
"\n",
|
| 345 |
-
"!mkdir -p {models_dir} {vaes_dir} {embeddings_dir} {
|
| 346 |
"\n",
|
| 347 |
"url = \"\"\n",
|
| 348 |
"ControlNet_url = \"\"\n",
|
|
@@ -358,9 +357,7 @@
|
|
| 358 |
" if file_name:\n",
|
| 359 |
" url = re.sub(r'\\[.*?\\]', '', url)\n",
|
| 360 |
"\n",
|
| 361 |
-
"
|
| 362 |
-
"\n",
|
| 363 |
-
" for prefix, dir in dir_mapping.items():\n",
|
| 364 |
" if original_url.startswith(f\"{prefix}:\"):\n",
|
| 365 |
" if prefix != \"extensions\":\n",
|
| 366 |
" manual_download(url, dir, file_name=file_name)\n",
|
|
@@ -383,7 +380,10 @@
|
|
| 383 |
" if 'folders' in url:\n",
|
| 384 |
" !gdown --folder \"{url}\" -O {dst_dir} --fuzzy -c\n",
|
| 385 |
" else:\n",
|
| 386 |
-
"
|
|
|
|
|
|
|
|
|
|
| 387 |
" # -- Huggin Face --\n",
|
| 388 |
" elif 'huggingface' in url:\n",
|
| 389 |
" if '/blob/' in url:\n",
|
|
@@ -408,7 +408,6 @@
|
|
| 408 |
" link_or_path = link_or_path.strip()\n",
|
| 409 |
" if not link_or_path:\n",
|
| 410 |
" continue\n",
|
| 411 |
-
"\n",
|
| 412 |
" if any(link_or_path.startswith(prefix.lower()) for prefix in prefixes):\n",
|
| 413 |
" handle_manual(link_or_path)\n",
|
| 414 |
" continue\n",
|
|
@@ -449,20 +448,9 @@
|
|
| 449 |
"for submodel in submodels:\n",
|
| 450 |
" if not Inpainting_Model and \"inpainting\" in submodel['name']:\n",
|
| 451 |
" continue\n",
|
| 452 |
-
"\n",
|
| 453 |
" url += f\"{submodel['url']} {submodel['dst_dir']} {submodel['name']}, \"\n",
|
| 454 |
"\n",
|
| 455 |
"def process_file_download(file_url):\n",
|
| 456 |
-
" global Model_url, Vae_url, LoRA_url, Embedding_url, Extensions_url, ControlNet_url\n",
|
| 457 |
-
" urls_dict = {\n",
|
| 458 |
-
" 'model': 'Model_url',\n",
|
| 459 |
-
" 'vae': 'Vae_url',\n",
|
| 460 |
-
" 'embed': 'Embedding_url',\n",
|
| 461 |
-
" 'lora': 'LoRA_url',\n",
|
| 462 |
-
" 'extension': 'Extensions_url',\n",
|
| 463 |
-
" 'control': 'ControlNet_url'\n",
|
| 464 |
-
" }\n",
|
| 465 |
-
"\n",
|
| 466 |
" if file_url.startswith(\"http\"):\n",
|
| 467 |
" if \"blob\" in file_url:\n",
|
| 468 |
" file_url = file_url.replace(\"blob\", \"raw\")\n",
|
|
@@ -475,12 +463,13 @@
|
|
| 475 |
" current_tag = None\n",
|
| 476 |
" for line in lines:\n",
|
| 477 |
" if line.strip().startswith('#'):\n",
|
| 478 |
-
"
|
| 479 |
-
"
|
| 480 |
-
"
|
| 481 |
-
"
|
| 482 |
-
"
|
| 483 |
-
"
|
|
|
|
| 484 |
"\n",
|
| 485 |
"# fix all possible errors/options and function call\n",
|
| 486 |
"if custom_file_urls:\n",
|
|
@@ -495,11 +484,11 @@
|
|
| 495 |
" except FileNotFoundError:\n",
|
| 496 |
" pass\n",
|
| 497 |
"\n",
|
| 498 |
-
"
|
| 499 |
-
"\n",
|
| 500 |
"for i, prefix in enumerate(prefixes):\n",
|
| 501 |
" if urls[i]:\n",
|
| 502 |
-
" prefixed_urls = [f\"{prefix}{
|
| 503 |
" if prefixed_urls:\n",
|
| 504 |
" url += \", \".join(prefixed_urls) + \", \"\n",
|
| 505 |
"\n",
|
|
|
|
| 33 |
"\n",
|
| 34 |
"\n",
|
| 35 |
"# ================= DETECT ENV =================\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
"def detect_environment():\n",
|
| 37 |
+
" free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)\n",
|
| 38 |
" environments = {\n",
|
| 39 |
" 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
|
| 40 |
" 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\"),\n",
|
|
|
|
| 43 |
"\n",
|
| 44 |
" for env_var, (environment, path) in environments.items():\n",
|
| 45 |
" if env_var in os.environ:\n",
|
| 46 |
+
" return environment, path, free_plan\n",
|
| 47 |
"\n",
|
| 48 |
+
"env, root_path, free_plan = detect_environment()\n",
|
| 49 |
"webui_path = f\"{root_path}/sdw\"\n",
|
| 50 |
"# ----------------------------------------------\n",
|
| 51 |
"\n",
|
|
|
|
| 70 |
"\n",
|
| 71 |
" print(\"Установка библиотек, это займет какое-то время...\", end='')\n",
|
| 72 |
" with capture.capture_output() as cap:\n",
|
| 73 |
+
" !pip install -U gdown\n",
|
| 74 |
" !apt-get update && apt -y install aria2\n",
|
| 75 |
" !npm install -g localtunnel &> /dev/null\n",
|
| 76 |
" !curl -s -OL https://github.com/DEX-1101/sd-webui-notebook/raw/main/res/new_tunnel --output-dir {root_path}\n",
|
|
|
|
| 331 |
"}\n",
|
| 332 |
"\n",
|
| 333 |
"extension_repo = []\n",
|
| 334 |
+
"prefixes = {\n",
|
| 335 |
+
" # It's complicated, but supplementing has become easier\n",
|
| 336 |
+
" \"model\": [models_dir, \"Model_url\"],\n",
|
| 337 |
+
" \"vae\": [vaes_dir, \"Vae_url\"],\n",
|
| 338 |
+
" \"lora\": [loras_dir, \"LoRA_url\"],\n",
|
| 339 |
+
" \"embeddings\": [embeddings_dir, \"Embedding_url\"],\n",
|
| 340 |
+
" \"extensions\": [extensions_dir, \"Extensions_url\"],\n",
|
| 341 |
+
" \"control\": [control_dir, \"ControlNet_url\"]\n",
|
| 342 |
+
"}\n",
|
| 343 |
"\n",
|
| 344 |
+
"!mkdir -p {models_dir} {vaes_dir} {loras_dir} {embeddings_dir} {extensions_dir} {control_dir}\n",
|
| 345 |
"\n",
|
| 346 |
"url = \"\"\n",
|
| 347 |
"ControlNet_url = \"\"\n",
|
|
|
|
| 357 |
" if file_name:\n",
|
| 358 |
" url = re.sub(r'\\[.*?\\]', '', url)\n",
|
| 359 |
"\n",
|
| 360 |
+
" for prefix, (dir, _) in prefixes.items():\n",
|
|
|
|
|
|
|
| 361 |
" if original_url.startswith(f\"{prefix}:\"):\n",
|
| 362 |
" if prefix != \"extensions\":\n",
|
| 363 |
" manual_download(url, dir, file_name=file_name)\n",
|
|
|
|
| 380 |
" if 'folders' in url:\n",
|
| 381 |
" !gdown --folder \"{url}\" -O {dst_dir} --fuzzy -c\n",
|
| 382 |
" else:\n",
|
| 383 |
+
" if file_name:\n",
|
| 384 |
+
" !gdown \"{url}\" -O {dst_dir}/{file_name} --fuzzy -c\n",
|
| 385 |
+
" else:\n",
|
| 386 |
+
" !gdown \"{url}\" -O {dst_dir} --fuzzy -c\n",
|
| 387 |
" # -- Huggin Face --\n",
|
| 388 |
" elif 'huggingface' in url:\n",
|
| 389 |
" if '/blob/' in url:\n",
|
|
|
|
| 408 |
" link_or_path = link_or_path.strip()\n",
|
| 409 |
" if not link_or_path:\n",
|
| 410 |
" continue\n",
|
|
|
|
| 411 |
" if any(link_or_path.startswith(prefix.lower()) for prefix in prefixes):\n",
|
| 412 |
" handle_manual(link_or_path)\n",
|
| 413 |
" continue\n",
|
|
|
|
| 448 |
"for submodel in submodels:\n",
|
| 449 |
" if not Inpainting_Model and \"inpainting\" in submodel['name']:\n",
|
| 450 |
" continue\n",
|
|
|
|
| 451 |
" url += f\"{submodel['url']} {submodel['dst_dir']} {submodel['name']}, \"\n",
|
| 452 |
"\n",
|
| 453 |
"def process_file_download(file_url):\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 454 |
" if file_url.startswith(\"http\"):\n",
|
| 455 |
" if \"blob\" in file_url:\n",
|
| 456 |
" file_url = file_url.replace(\"blob\", \"raw\")\n",
|
|
|
|
| 463 |
" current_tag = None\n",
|
| 464 |
" for line in lines:\n",
|
| 465 |
" if line.strip().startswith('#'):\n",
|
| 466 |
+
" if any(tag in line.lower() for tag in prefixes):\n",
|
| 467 |
+
" current_tag = next((tag for tag in prefixes if tag in line.lower()))\n",
|
| 468 |
+
"\n",
|
| 469 |
+
" urls = [url.strip() for url in line.split()]\n",
|
| 470 |
+
" for url in urls:\n",
|
| 471 |
+
" if url.startswith(\"http\"):\n",
|
| 472 |
+
" globals()[prefixes[current_tag][1]] += \", \" + url\n",
|
| 473 |
"\n",
|
| 474 |
"# fix all possible errors/options and function call\n",
|
| 475 |
"if custom_file_urls:\n",
|
|
|
|
| 484 |
" except FileNotFoundError:\n",
|
| 485 |
" pass\n",
|
| 486 |
"\n",
|
| 487 |
+
"# url prefixing\n",
|
| 488 |
+
"urls = [globals()[urls[1]] for urls in prefixes.values()]\n",
|
| 489 |
"for i, prefix in enumerate(prefixes):\n",
|
| 490 |
" if urls[i]:\n",
|
| 491 |
+
" prefixed_urls = [f\"{prefix}:{url}\" for url in urls[i].replace(',', '').split()]\n",
|
| 492 |
" if prefixed_urls:\n",
|
| 493 |
" url += \", \".join(prefixed_urls) + \", \"\n",
|
| 494 |
"\n",
|
files_cells/notebooks/ru/launch_ru.ipynb
CHANGED
|
@@ -33,11 +33,8 @@
|
|
| 33 |
"\n",
|
| 34 |
"\n",
|
| 35 |
"# ================= DETECT ENV =================\n",
|
| 36 |
-
"def check_colab_subscription():\n",
|
| 37 |
-
" return (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)\n",
|
| 38 |
-
"free_plan = check_colab_subscription()\n",
|
| 39 |
-
"\n",
|
| 40 |
"def detect_environment():\n",
|
|
|
|
| 41 |
" environments = {\n",
|
| 42 |
" 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
|
| 43 |
" 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\"),\n",
|
|
@@ -46,9 +43,9 @@
|
|
| 46 |
"\n",
|
| 47 |
" for env_var, (environment, path) in environments.items():\n",
|
| 48 |
" if env_var in os.environ:\n",
|
| 49 |
-
" return environment, path\n",
|
| 50 |
"\n",
|
| 51 |
-
"env, root_path = detect_environment()\n",
|
| 52 |
"webui_path = f\"{root_path}/sdw\"\n",
|
| 53 |
"# ----------------------------------------------\n",
|
| 54 |
"\n",
|
|
|
|
| 33 |
"\n",
|
| 34 |
"\n",
|
| 35 |
"# ================= DETECT ENV =================\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
"def detect_environment():\n",
|
| 37 |
+
" free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)\n",
|
| 38 |
" environments = {\n",
|
| 39 |
" 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
|
| 40 |
" 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\"),\n",
|
|
|
|
| 43 |
"\n",
|
| 44 |
" for env_var, (environment, path) in environments.items():\n",
|
| 45 |
" if env_var in os.environ:\n",
|
| 46 |
+
" return environment, path, free_plan\n",
|
| 47 |
"\n",
|
| 48 |
+
"env, root_path, free_plan = detect_environment()\n",
|
| 49 |
"webui_path = f\"{root_path}/sdw\"\n",
|
| 50 |
"# ----------------------------------------------\n",
|
| 51 |
"\n",
|
files_cells/notebooks/ru/widgets_ru.ipynb
CHANGED
|
@@ -27,11 +27,8 @@
|
|
| 27 |
"\n",
|
| 28 |
"\n",
|
| 29 |
"# ================= DETECT ENV =================\n",
|
| 30 |
-
"def check_colab_subscription():\n",
|
| 31 |
-
" return (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)\n",
|
| 32 |
-
"free_plan = check_colab_subscription()\n",
|
| 33 |
-
"\n",
|
| 34 |
"def detect_environment():\n",
|
|
|
|
| 35 |
" environments = {\n",
|
| 36 |
" 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
|
| 37 |
" 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\"),\n",
|
|
@@ -40,9 +37,9 @@
|
|
| 40 |
"\n",
|
| 41 |
" for env_var, (environment, path) in environments.items():\n",
|
| 42 |
" if env_var in os.environ:\n",
|
| 43 |
-
" return environment, path\n",
|
| 44 |
"\n",
|
| 45 |
-
"env, root_path = detect_environment()\n",
|
| 46 |
"webui_path = f\"{root_path}/sdw\"\n",
|
| 47 |
"\n",
|
| 48 |
"!mkdir -p {root_path}\n",
|
|
@@ -364,7 +361,7 @@
|
|
| 364 |
"commandline_arguments_widget = widgets.Text(description='Аргументы:', value=commandline_arguments_options, style=style, layout=layout)\n",
|
| 365 |
"\n",
|
| 366 |
"additional_widget_list = [additional_header, latest_changes_widget, HR, controlnet_widget, controlnet_Num_widget, commit_hash_widget, optional_huggingface_token_widget, ngrok_widget, HR, commandline_arguments_widget]\n",
|
| 367 |
-
"if free_plan:\n",
|
| 368 |
" additional_widget_list.remove(ngrok_widget)\n",
|
| 369 |
"display(widgets.VBox(additional_widget_list).add_class(\"container\"))\n",
|
| 370 |
"\n",
|
|
|
|
| 27 |
"\n",
|
| 28 |
"\n",
|
| 29 |
"# ================= DETECT ENV =================\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
"def detect_environment():\n",
|
| 31 |
+
" free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)\n",
|
| 32 |
" environments = {\n",
|
| 33 |
" 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
|
| 34 |
" 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\"),\n",
|
|
|
|
| 37 |
"\n",
|
| 38 |
" for env_var, (environment, path) in environments.items():\n",
|
| 39 |
" if env_var in os.environ:\n",
|
| 40 |
+
" return environment, path, free_plan\n",
|
| 41 |
"\n",
|
| 42 |
+
"env, root_path, free_plan = detect_environment()\n",
|
| 43 |
"webui_path = f\"{root_path}/sdw\"\n",
|
| 44 |
"\n",
|
| 45 |
"!mkdir -p {root_path}\n",
|
|
|
|
| 361 |
"commandline_arguments_widget = widgets.Text(description='Аргументы:', value=commandline_arguments_options, style=style, layout=layout)\n",
|
| 362 |
"\n",
|
| 363 |
"additional_widget_list = [additional_header, latest_changes_widget, HR, controlnet_widget, controlnet_Num_widget, commit_hash_widget, optional_huggingface_token_widget, ngrok_widget, HR, commandline_arguments_widget]\n",
|
| 364 |
+
"if free_plan and env == \"Google Colab\":\n",
|
| 365 |
" additional_widget_list.remove(ngrok_widget)\n",
|
| 366 |
"display(widgets.VBox(additional_widget_list).add_class(\"container\"))\n",
|
| 367 |
"\n",
|
files_cells/python/en/auto-cleaner_en.py
CHANGED
|
@@ -16,11 +16,8 @@ from IPython.display import display, HTML, Javascript
|
|
| 16 |
|
| 17 |
|
| 18 |
# ================= DETECT ENV =================
|
| 19 |
-
def check_colab_subscription():
|
| 20 |
-
return (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)
|
| 21 |
-
free_plan = check_colab_subscription()
|
| 22 |
-
|
| 23 |
def detect_environment():
|
|
|
|
| 24 |
environments = {
|
| 25 |
'COLAB_GPU': ('Google Colab', "/root" if free_plan else "/content"),
|
| 26 |
'KAGGLE_URL_BASE': ('Kaggle', "/kaggle/working/content"),
|
|
@@ -29,9 +26,9 @@ def detect_environment():
|
|
| 29 |
|
| 30 |
for env_var, (environment, path) in environments.items():
|
| 31 |
if env_var in os.environ:
|
| 32 |
-
return environment, path
|
| 33 |
|
| 34 |
-
env, root_path = detect_environment()
|
| 35 |
webui_path = f"{root_path}/sdw"
|
| 36 |
# ----------------------------------------------
|
| 37 |
|
|
|
|
| 16 |
|
| 17 |
|
| 18 |
# ================= DETECT ENV =================
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
def detect_environment():
|
| 20 |
+
free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)
|
| 21 |
environments = {
|
| 22 |
'COLAB_GPU': ('Google Colab', "/root" if free_plan else "/content"),
|
| 23 |
'KAGGLE_URL_BASE': ('Kaggle', "/kaggle/working/content"),
|
|
|
|
| 26 |
|
| 27 |
for env_var, (environment, path) in environments.items():
|
| 28 |
if env_var in os.environ:
|
| 29 |
+
return environment, path, free_plan
|
| 30 |
|
| 31 |
+
env, root_path, free_plan = detect_environment()
|
| 32 |
webui_path = f"{root_path}/sdw"
|
| 33 |
# ----------------------------------------------
|
| 34 |
|
files_cells/python/en/downloading_en.py
CHANGED
|
@@ -14,11 +14,8 @@ from IPython.display import clear_output
|
|
| 14 |
|
| 15 |
|
| 16 |
# ================= DETECT ENV =================
|
| 17 |
-
def check_colab_subscription():
|
| 18 |
-
return (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)
|
| 19 |
-
free_plan = check_colab_subscription()
|
| 20 |
-
|
| 21 |
def detect_environment():
|
|
|
|
| 22 |
environments = {
|
| 23 |
'COLAB_GPU': ('Google Colab', "/root" if free_plan else "/content"),
|
| 24 |
'KAGGLE_URL_BASE': ('Kaggle', "/kaggle/working/content"),
|
|
@@ -27,9 +24,9 @@ def detect_environment():
|
|
| 27 |
|
| 28 |
for env_var, (environment, path) in environments.items():
|
| 29 |
if env_var in os.environ:
|
| 30 |
-
return environment, path
|
| 31 |
|
| 32 |
-
env, root_path = detect_environment()
|
| 33 |
webui_path = f"{root_path}/sdw"
|
| 34 |
# ----------------------------------------------
|
| 35 |
|
|
@@ -54,6 +51,7 @@ if not os.path.exists(flag_file):
|
|
| 54 |
|
| 55 |
print("Installing the libraries, it's going to take a while....", end='')
|
| 56 |
with capture.capture_output() as cap:
|
|
|
|
| 57 |
get_ipython().system('apt-get update && apt -y install aria2')
|
| 58 |
get_ipython().system('npm install -g localtunnel &> /dev/null')
|
| 59 |
get_ipython().system('curl -s -OL https://github.com/DEX-1101/sd-webui-notebook/raw/main/res/new_tunnel --output-dir {root_path}')
|
|
@@ -72,8 +70,7 @@ if not os.path.exists(flag_file):
|
|
| 72 |
if env == "Google Colab":
|
| 73 |
get_ipython().system('pip install -q pip install xformers==0.0.26.dev769 -U')
|
| 74 |
else:
|
| 75 |
-
|
| 76 |
-
get_ipython().system('pip install -q {torch} -U')
|
| 77 |
get_ipython().system('pip install -q {xformers} -U')
|
| 78 |
|
| 79 |
with open(flag_file, "w") as f:
|
|
@@ -315,16 +312,17 @@ controlnet_list = {
|
|
| 315 |
}
|
| 316 |
|
| 317 |
extension_repo = []
|
| 318 |
-
prefixes =
|
| 319 |
-
|
| 320 |
-
"
|
| 321 |
-
"
|
| 322 |
-
"
|
| 323 |
-
"
|
| 324 |
-
"
|
| 325 |
-
]
|
|
|
|
| 326 |
|
| 327 |
-
get_ipython().system('mkdir -p {models_dir} {vaes_dir} {embeddings_dir} {
|
| 328 |
|
| 329 |
url = ""
|
| 330 |
ControlNet_url = ""
|
|
@@ -340,9 +338,7 @@ def handle_manual(url):
|
|
| 340 |
if file_name:
|
| 341 |
url = re.sub(r'\[.*?\]', '', url)
|
| 342 |
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
for prefix, dir in dir_mapping.items():
|
| 346 |
if original_url.startswith(f"{prefix}:"):
|
| 347 |
if prefix != "extensions":
|
| 348 |
manual_download(url, dir, file_name=file_name)
|
|
@@ -365,7 +361,10 @@ def manual_download(url, dst_dir, file_name):
|
|
| 365 |
if 'folders' in url:
|
| 366 |
get_ipython().system('gdown --folder "{url}" -O {dst_dir} --fuzzy -c')
|
| 367 |
else:
|
| 368 |
-
|
|
|
|
|
|
|
|
|
|
| 369 |
# -- Huggin Face --
|
| 370 |
elif 'huggingface' in url:
|
| 371 |
if '/blob/' in url:
|
|
@@ -390,7 +389,6 @@ def download(url):
|
|
| 390 |
link_or_path = link_or_path.strip()
|
| 391 |
if not link_or_path:
|
| 392 |
continue
|
| 393 |
-
|
| 394 |
if any(link_or_path.startswith(prefix.lower()) for prefix in prefixes):
|
| 395 |
handle_manual(link_or_path)
|
| 396 |
continue
|
|
@@ -431,20 +429,9 @@ submodels += add_submodels(controlnet, "" if controlnet == "ALL" else controlnet
|
|
| 431 |
for submodel in submodels:
|
| 432 |
if not Inpainting_Model and "inpainting" in submodel['name']:
|
| 433 |
continue
|
| 434 |
-
|
| 435 |
url += f"{submodel['url']} {submodel['dst_dir']} {submodel['name']}, "
|
| 436 |
|
| 437 |
def process_file_download(file_url):
|
| 438 |
-
global Model_url, Vae_url, LoRA_url, Embedding_url, Extensions_url
|
| 439 |
-
urls_dict = {
|
| 440 |
-
'model': 'Model_url',
|
| 441 |
-
'vae': 'Vae_url',
|
| 442 |
-
'embed': 'Embedding_url',
|
| 443 |
-
'lora': 'LoRA_url',
|
| 444 |
-
'extension': 'Extensions_url',
|
| 445 |
-
'control': 'ControlNet_url'
|
| 446 |
-
}
|
| 447 |
-
|
| 448 |
if file_url.startswith("http"):
|
| 449 |
if "blob" in file_url:
|
| 450 |
file_url = file_url.replace("blob", "raw")
|
|
@@ -457,12 +444,13 @@ def process_file_download(file_url):
|
|
| 457 |
current_tag = None
|
| 458 |
for line in lines:
|
| 459 |
if line.strip().startswith('#'):
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
|
| 465 |
-
|
|
|
|
| 466 |
|
| 467 |
# fix all possible errors/options and function call
|
| 468 |
if custom_file_urls:
|
|
@@ -477,11 +465,11 @@ if custom_file_urls:
|
|
| 477 |
except FileNotFoundError:
|
| 478 |
pass
|
| 479 |
|
| 480 |
-
|
| 481 |
-
|
| 482 |
for i, prefix in enumerate(prefixes):
|
| 483 |
if urls[i]:
|
| 484 |
-
prefixed_urls = [f"{prefix}{
|
| 485 |
if prefixed_urls:
|
| 486 |
url += ", ".join(prefixed_urls) + ", "
|
| 487 |
|
|
|
|
| 14 |
|
| 15 |
|
| 16 |
# ================= DETECT ENV =================
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
def detect_environment():
|
| 18 |
+
free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)
|
| 19 |
environments = {
|
| 20 |
'COLAB_GPU': ('Google Colab', "/root" if free_plan else "/content"),
|
| 21 |
'KAGGLE_URL_BASE': ('Kaggle', "/kaggle/working/content"),
|
|
|
|
| 24 |
|
| 25 |
for env_var, (environment, path) in environments.items():
|
| 26 |
if env_var in os.environ:
|
| 27 |
+
return environment, path, free_plan
|
| 28 |
|
| 29 |
+
env, root_path, free_plan = detect_environment()
|
| 30 |
webui_path = f"{root_path}/sdw"
|
| 31 |
# ----------------------------------------------
|
| 32 |
|
|
|
|
| 51 |
|
| 52 |
print("Installing the libraries, it's going to take a while....", end='')
|
| 53 |
with capture.capture_output() as cap:
|
| 54 |
+
get_ipython().system('pip install -U gdown')
|
| 55 |
get_ipython().system('apt-get update && apt -y install aria2')
|
| 56 |
get_ipython().system('npm install -g localtunnel &> /dev/null')
|
| 57 |
get_ipython().system('curl -s -OL https://github.com/DEX-1101/sd-webui-notebook/raw/main/res/new_tunnel --output-dir {root_path}')
|
|
|
|
| 70 |
if env == "Google Colab":
|
| 71 |
get_ipython().system('pip install -q pip install xformers==0.0.26.dev769 -U')
|
| 72 |
else:
|
| 73 |
+
get_ipython().system('pip install -q {torch} -U')
|
|
|
|
| 74 |
get_ipython().system('pip install -q {xformers} -U')
|
| 75 |
|
| 76 |
with open(flag_file, "w") as f:
|
|
|
|
| 312 |
}
|
| 313 |
|
| 314 |
extension_repo = []
|
| 315 |
+
prefixes = {
|
| 316 |
+
# It's complicated, but supplementing has become easier
|
| 317 |
+
"model": [models_dir, "Model_url"],
|
| 318 |
+
"vae": [vaes_dir, "Vae_url"],
|
| 319 |
+
"lora": [loras_dir, "LoRA_url"],
|
| 320 |
+
"embeddings": [embeddings_dir, "Embedding_url"],
|
| 321 |
+
"extensions": [extensions_dir, "Extensions_url"],
|
| 322 |
+
"control": [control_dir, "ControlNet_url"]
|
| 323 |
+
}
|
| 324 |
|
| 325 |
+
get_ipython().system('mkdir -p {models_dir} {vaes_dir} {loras_dir} {embeddings_dir} {extensions_dir} {control_dir}')
|
| 326 |
|
| 327 |
url = ""
|
| 328 |
ControlNet_url = ""
|
|
|
|
| 338 |
if file_name:
|
| 339 |
url = re.sub(r'\[.*?\]', '', url)
|
| 340 |
|
| 341 |
+
for prefix, (dir, _) in prefixes.items():
|
|
|
|
|
|
|
| 342 |
if original_url.startswith(f"{prefix}:"):
|
| 343 |
if prefix != "extensions":
|
| 344 |
manual_download(url, dir, file_name=file_name)
|
|
|
|
| 361 |
if 'folders' in url:
|
| 362 |
get_ipython().system('gdown --folder "{url}" -O {dst_dir} --fuzzy -c')
|
| 363 |
else:
|
| 364 |
+
if file_name:
|
| 365 |
+
get_ipython().system('gdown "{url}" -O {dst_dir}/{file_name} --fuzzy -c')
|
| 366 |
+
else:
|
| 367 |
+
get_ipython().system('gdown "{url}" -O {dst_dir} --fuzzy -c')
|
| 368 |
# -- Huggin Face --
|
| 369 |
elif 'huggingface' in url:
|
| 370 |
if '/blob/' in url:
|
|
|
|
| 389 |
link_or_path = link_or_path.strip()
|
| 390 |
if not link_or_path:
|
| 391 |
continue
|
|
|
|
| 392 |
if any(link_or_path.startswith(prefix.lower()) for prefix in prefixes):
|
| 393 |
handle_manual(link_or_path)
|
| 394 |
continue
|
|
|
|
| 429 |
for submodel in submodels:
|
| 430 |
if not Inpainting_Model and "inpainting" in submodel['name']:
|
| 431 |
continue
|
|
|
|
| 432 |
url += f"{submodel['url']} {submodel['dst_dir']} {submodel['name']}, "
|
| 433 |
|
| 434 |
def process_file_download(file_url):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 435 |
if file_url.startswith("http"):
|
| 436 |
if "blob" in file_url:
|
| 437 |
file_url = file_url.replace("blob", "raw")
|
|
|
|
| 444 |
current_tag = None
|
| 445 |
for line in lines:
|
| 446 |
if line.strip().startswith('#'):
|
| 447 |
+
if any(tag in line.lower() for tag in prefixes):
|
| 448 |
+
current_tag = next((tag for tag in prefixes if tag in line.lower()))
|
| 449 |
+
|
| 450 |
+
urls = [url.strip() for url in line.split()]
|
| 451 |
+
for url in urls:
|
| 452 |
+
if url.startswith("http"):
|
| 453 |
+
globals()[prefixes[current_tag][1]] += ", " + url
|
| 454 |
|
| 455 |
# fix all possible errors/options and function call
|
| 456 |
if custom_file_urls:
|
|
|
|
| 465 |
except FileNotFoundError:
|
| 466 |
pass
|
| 467 |
|
| 468 |
+
# url prefixing
|
| 469 |
+
urls = [globals()[urls[1]] for urls in prefixes.values()]
|
| 470 |
for i, prefix in enumerate(prefixes):
|
| 471 |
if urls[i]:
|
| 472 |
+
prefixed_urls = [f"{prefix}:{url}" for url in urls[i].replace(',', '').split()]
|
| 473 |
if prefixed_urls:
|
| 474 |
url += ", ".join(prefixed_urls) + ", "
|
| 475 |
|
files_cells/python/en/launch_en.py
CHANGED
|
@@ -9,11 +9,8 @@ from datetime import timedelta
|
|
| 9 |
|
| 10 |
|
| 11 |
# ================= DETECT ENV =================
|
| 12 |
-
def check_colab_subscription():
|
| 13 |
-
return (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)
|
| 14 |
-
free_plan = check_colab_subscription()
|
| 15 |
-
|
| 16 |
def detect_environment():
|
|
|
|
| 17 |
environments = {
|
| 18 |
'COLAB_GPU': ('Google Colab', "/root" if free_plan else "/content"),
|
| 19 |
'KAGGLE_URL_BASE': ('Kaggle', "/kaggle/working/content"),
|
|
@@ -22,9 +19,9 @@ def detect_environment():
|
|
| 22 |
|
| 23 |
for env_var, (environment, path) in environments.items():
|
| 24 |
if env_var in os.environ:
|
| 25 |
-
return environment, path
|
| 26 |
|
| 27 |
-
env, root_path = detect_environment()
|
| 28 |
webui_path = f"{root_path}/sdw"
|
| 29 |
# ----------------------------------------------
|
| 30 |
|
|
|
|
| 9 |
|
| 10 |
|
| 11 |
# ================= DETECT ENV =================
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
def detect_environment():
|
| 13 |
+
free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)
|
| 14 |
environments = {
|
| 15 |
'COLAB_GPU': ('Google Colab', "/root" if free_plan else "/content"),
|
| 16 |
'KAGGLE_URL_BASE': ('Kaggle', "/kaggle/working/content"),
|
|
|
|
| 19 |
|
| 20 |
for env_var, (environment, path) in environments.items():
|
| 21 |
if env_var in os.environ:
|
| 22 |
+
return environment, path, free_plan
|
| 23 |
|
| 24 |
+
env, root_path, free_plan = detect_environment()
|
| 25 |
webui_path = f"{root_path}/sdw"
|
| 26 |
# ----------------------------------------------
|
| 27 |
|
files_cells/python/en/widgets_en.py
CHANGED
|
@@ -8,11 +8,8 @@ from IPython.display import display, HTML, Javascript, clear_output
|
|
| 8 |
|
| 9 |
|
| 10 |
# ================= DETECT ENV =================
|
| 11 |
-
def check_colab_subscription():
|
| 12 |
-
return (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)
|
| 13 |
-
free_plan = check_colab_subscription()
|
| 14 |
-
|
| 15 |
def detect_environment():
|
|
|
|
| 16 |
environments = {
|
| 17 |
'COLAB_GPU': ('Google Colab', "/root" if free_plan else "/content"),
|
| 18 |
'KAGGLE_URL_BASE': ('Kaggle', "/kaggle/working/content"),
|
|
@@ -21,9 +18,9 @@ def detect_environment():
|
|
| 21 |
|
| 22 |
for env_var, (environment, path) in environments.items():
|
| 23 |
if env_var in os.environ:
|
| 24 |
-
return environment, path
|
| 25 |
|
| 26 |
-
env, root_path = detect_environment()
|
| 27 |
webui_path = f"{root_path}/sdw"
|
| 28 |
|
| 29 |
get_ipython().system('mkdir -p {root_path}')
|
|
@@ -345,7 +342,7 @@ commandline_arguments_options = "--listen --enable-insecure-extension-access --t
|
|
| 345 |
commandline_arguments_widget = widgets.Text(description='Arguments:', value=commandline_arguments_options, style=style, layout=layout)
|
| 346 |
|
| 347 |
additional_widget_list = [additional_header, latest_changes_widget, HR, controlnet_widget, controlnet_Num_widget, commit_hash_widget, optional_huggingface_token_widget, ngrok_widget, HR, commandline_arguments_widget]
|
| 348 |
-
if free_plan:
|
| 349 |
additional_widget_list.remove(ngrok_widget)
|
| 350 |
display(widgets.VBox(additional_widget_list).add_class("container"))
|
| 351 |
|
|
|
|
| 8 |
|
| 9 |
|
| 10 |
# ================= DETECT ENV =================
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
def detect_environment():
|
| 12 |
+
free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)
|
| 13 |
environments = {
|
| 14 |
'COLAB_GPU': ('Google Colab', "/root" if free_plan else "/content"),
|
| 15 |
'KAGGLE_URL_BASE': ('Kaggle', "/kaggle/working/content"),
|
|
|
|
| 18 |
|
| 19 |
for env_var, (environment, path) in environments.items():
|
| 20 |
if env_var in os.environ:
|
| 21 |
+
return environment, path, free_plan
|
| 22 |
|
| 23 |
+
env, root_path, free_plan = detect_environment()
|
| 24 |
webui_path = f"{root_path}/sdw"
|
| 25 |
|
| 26 |
get_ipython().system('mkdir -p {root_path}')
|
|
|
|
| 342 |
commandline_arguments_widget = widgets.Text(description='Arguments:', value=commandline_arguments_options, style=style, layout=layout)
|
| 343 |
|
| 344 |
additional_widget_list = [additional_header, latest_changes_widget, HR, controlnet_widget, controlnet_Num_widget, commit_hash_widget, optional_huggingface_token_widget, ngrok_widget, HR, commandline_arguments_widget]
|
| 345 |
+
if free_plan and env == "Google Colab":
|
| 346 |
additional_widget_list.remove(ngrok_widget)
|
| 347 |
display(widgets.VBox(additional_widget_list).add_class("container"))
|
| 348 |
|
files_cells/python/ru/auto-cleaner_ru.py
CHANGED
|
@@ -16,11 +16,8 @@ from IPython.display import display, HTML
|
|
| 16 |
|
| 17 |
|
| 18 |
# ================= DETECT ENV =================
|
| 19 |
-
def check_colab_subscription():
|
| 20 |
-
return (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)
|
| 21 |
-
free_plan = check_colab_subscription()
|
| 22 |
-
|
| 23 |
def detect_environment():
|
|
|
|
| 24 |
environments = {
|
| 25 |
'COLAB_GPU': ('Google Colab', "/root" if free_plan else "/content"),
|
| 26 |
'KAGGLE_URL_BASE': ('Kaggle', "/kaggle/working/content"),
|
|
@@ -29,9 +26,9 @@ def detect_environment():
|
|
| 29 |
|
| 30 |
for env_var, (environment, path) in environments.items():
|
| 31 |
if env_var in os.environ:
|
| 32 |
-
return environment, path
|
| 33 |
|
| 34 |
-
env, root_path = detect_environment()
|
| 35 |
webui_path = f"{root_path}/sdw"
|
| 36 |
# ----------------------------------------------
|
| 37 |
|
|
|
|
| 16 |
|
| 17 |
|
| 18 |
# ================= DETECT ENV =================
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
def detect_environment():
|
| 20 |
+
free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)
|
| 21 |
environments = {
|
| 22 |
'COLAB_GPU': ('Google Colab', "/root" if free_plan else "/content"),
|
| 23 |
'KAGGLE_URL_BASE': ('Kaggle', "/kaggle/working/content"),
|
|
|
|
| 26 |
|
| 27 |
for env_var, (environment, path) in environments.items():
|
| 28 |
if env_var in os.environ:
|
| 29 |
+
return environment, path, free_plan
|
| 30 |
|
| 31 |
+
env, root_path, free_plan = detect_environment()
|
| 32 |
webui_path = f"{root_path}/sdw"
|
| 33 |
# ----------------------------------------------
|
| 34 |
|
files_cells/python/ru/downloading_ru.py
CHANGED
|
@@ -14,11 +14,8 @@ from IPython.display import clear_output
|
|
| 14 |
|
| 15 |
|
| 16 |
# ================= DETECT ENV =================
|
| 17 |
-
def check_colab_subscription():
|
| 18 |
-
return (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)
|
| 19 |
-
free_plan = check_colab_subscription()
|
| 20 |
-
|
| 21 |
def detect_environment():
|
|
|
|
| 22 |
environments = {
|
| 23 |
'COLAB_GPU': ('Google Colab', "/root" if free_plan else "/content"),
|
| 24 |
'KAGGLE_URL_BASE': ('Kaggle', "/kaggle/working/content"),
|
|
@@ -27,9 +24,9 @@ def detect_environment():
|
|
| 27 |
|
| 28 |
for env_var, (environment, path) in environments.items():
|
| 29 |
if env_var in os.environ:
|
| 30 |
-
return environment, path
|
| 31 |
|
| 32 |
-
env, root_path = detect_environment()
|
| 33 |
webui_path = f"{root_path}/sdw"
|
| 34 |
# ----------------------------------------------
|
| 35 |
|
|
@@ -54,6 +51,7 @@ if not os.path.exists(flag_file):
|
|
| 54 |
|
| 55 |
print("Установка библиотек, это займет какое-то время...", end='')
|
| 56 |
with capture.capture_output() as cap:
|
|
|
|
| 57 |
get_ipython().system('apt-get update && apt -y install aria2')
|
| 58 |
get_ipython().system('npm install -g localtunnel &> /dev/null')
|
| 59 |
get_ipython().system('curl -s -OL https://github.com/DEX-1101/sd-webui-notebook/raw/main/res/new_tunnel --output-dir {root_path}')
|
|
@@ -314,16 +312,17 @@ controlnet_list = {
|
|
| 314 |
}
|
| 315 |
|
| 316 |
extension_repo = []
|
| 317 |
-
prefixes =
|
| 318 |
-
|
| 319 |
-
"
|
| 320 |
-
"
|
| 321 |
-
"
|
| 322 |
-
"
|
| 323 |
-
"
|
| 324 |
-
]
|
|
|
|
| 325 |
|
| 326 |
-
get_ipython().system('mkdir -p {models_dir} {vaes_dir} {embeddings_dir} {
|
| 327 |
|
| 328 |
url = ""
|
| 329 |
ControlNet_url = ""
|
|
@@ -339,9 +338,7 @@ def handle_manual(url):
|
|
| 339 |
if file_name:
|
| 340 |
url = re.sub(r'\[.*?\]', '', url)
|
| 341 |
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
for prefix, dir in dir_mapping.items():
|
| 345 |
if original_url.startswith(f"{prefix}:"):
|
| 346 |
if prefix != "extensions":
|
| 347 |
manual_download(url, dir, file_name=file_name)
|
|
@@ -364,7 +361,10 @@ def manual_download(url, dst_dir, file_name):
|
|
| 364 |
if 'folders' in url:
|
| 365 |
get_ipython().system('gdown --folder "{url}" -O {dst_dir} --fuzzy -c')
|
| 366 |
else:
|
| 367 |
-
|
|
|
|
|
|
|
|
|
|
| 368 |
# -- Huggin Face --
|
| 369 |
elif 'huggingface' in url:
|
| 370 |
if '/blob/' in url:
|
|
@@ -389,7 +389,6 @@ def download(url):
|
|
| 389 |
link_or_path = link_or_path.strip()
|
| 390 |
if not link_or_path:
|
| 391 |
continue
|
| 392 |
-
|
| 393 |
if any(link_or_path.startswith(prefix.lower()) for prefix in prefixes):
|
| 394 |
handle_manual(link_or_path)
|
| 395 |
continue
|
|
@@ -430,20 +429,9 @@ submodels += add_submodels(controlnet, "" if controlnet == "ALL" else controlnet
|
|
| 430 |
for submodel in submodels:
|
| 431 |
if not Inpainting_Model and "inpainting" in submodel['name']:
|
| 432 |
continue
|
| 433 |
-
|
| 434 |
url += f"{submodel['url']} {submodel['dst_dir']} {submodel['name']}, "
|
| 435 |
|
| 436 |
def process_file_download(file_url):
|
| 437 |
-
global Model_url, Vae_url, LoRA_url, Embedding_url, Extensions_url, ControlNet_url
|
| 438 |
-
urls_dict = {
|
| 439 |
-
'model': 'Model_url',
|
| 440 |
-
'vae': 'Vae_url',
|
| 441 |
-
'embed': 'Embedding_url',
|
| 442 |
-
'lora': 'LoRA_url',
|
| 443 |
-
'extension': 'Extensions_url',
|
| 444 |
-
'control': 'ControlNet_url'
|
| 445 |
-
}
|
| 446 |
-
|
| 447 |
if file_url.startswith("http"):
|
| 448 |
if "blob" in file_url:
|
| 449 |
file_url = file_url.replace("blob", "raw")
|
|
@@ -456,12 +444,13 @@ def process_file_download(file_url):
|
|
| 456 |
current_tag = None
|
| 457 |
for line in lines:
|
| 458 |
if line.strip().startswith('#'):
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
|
|
|
|
| 465 |
|
| 466 |
# fix all possible errors/options and function call
|
| 467 |
if custom_file_urls:
|
|
@@ -476,11 +465,11 @@ if custom_file_urls:
|
|
| 476 |
except FileNotFoundError:
|
| 477 |
pass
|
| 478 |
|
| 479 |
-
|
| 480 |
-
|
| 481 |
for i, prefix in enumerate(prefixes):
|
| 482 |
if urls[i]:
|
| 483 |
-
prefixed_urls = [f"{prefix}{
|
| 484 |
if prefixed_urls:
|
| 485 |
url += ", ".join(prefixed_urls) + ", "
|
| 486 |
|
|
|
|
| 14 |
|
| 15 |
|
| 16 |
# ================= DETECT ENV =================
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
def detect_environment():
|
| 18 |
+
free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)
|
| 19 |
environments = {
|
| 20 |
'COLAB_GPU': ('Google Colab', "/root" if free_plan else "/content"),
|
| 21 |
'KAGGLE_URL_BASE': ('Kaggle', "/kaggle/working/content"),
|
|
|
|
| 24 |
|
| 25 |
for env_var, (environment, path) in environments.items():
|
| 26 |
if env_var in os.environ:
|
| 27 |
+
return environment, path, free_plan
|
| 28 |
|
| 29 |
+
env, root_path, free_plan = detect_environment()
|
| 30 |
webui_path = f"{root_path}/sdw"
|
| 31 |
# ----------------------------------------------
|
| 32 |
|
|
|
|
| 51 |
|
| 52 |
print("Установка библиотек, это займет какое-то время...", end='')
|
| 53 |
with capture.capture_output() as cap:
|
| 54 |
+
get_ipython().system('pip install -U gdown')
|
| 55 |
get_ipython().system('apt-get update && apt -y install aria2')
|
| 56 |
get_ipython().system('npm install -g localtunnel &> /dev/null')
|
| 57 |
get_ipython().system('curl -s -OL https://github.com/DEX-1101/sd-webui-notebook/raw/main/res/new_tunnel --output-dir {root_path}')
|
|
|
|
| 312 |
}
|
| 313 |
|
| 314 |
extension_repo = []
|
| 315 |
+
prefixes = {
|
| 316 |
+
# It's complicated, but supplementing has become easier
|
| 317 |
+
"model": [models_dir, "Model_url"],
|
| 318 |
+
"vae": [vaes_dir, "Vae_url"],
|
| 319 |
+
"lora": [loras_dir, "LoRA_url"],
|
| 320 |
+
"embeddings": [embeddings_dir, "Embedding_url"],
|
| 321 |
+
"extensions": [extensions_dir, "Extensions_url"],
|
| 322 |
+
"control": [control_dir, "ControlNet_url"]
|
| 323 |
+
}
|
| 324 |
|
| 325 |
+
get_ipython().system('mkdir -p {models_dir} {vaes_dir} {loras_dir} {embeddings_dir} {extensions_dir} {control_dir}')
|
| 326 |
|
| 327 |
url = ""
|
| 328 |
ControlNet_url = ""
|
|
|
|
| 338 |
if file_name:
|
| 339 |
url = re.sub(r'\[.*?\]', '', url)
|
| 340 |
|
| 341 |
+
for prefix, (dir, _) in prefixes.items():
|
|
|
|
|
|
|
| 342 |
if original_url.startswith(f"{prefix}:"):
|
| 343 |
if prefix != "extensions":
|
| 344 |
manual_download(url, dir, file_name=file_name)
|
|
|
|
| 361 |
if 'folders' in url:
|
| 362 |
get_ipython().system('gdown --folder "{url}" -O {dst_dir} --fuzzy -c')
|
| 363 |
else:
|
| 364 |
+
if file_name:
|
| 365 |
+
get_ipython().system('gdown "{url}" -O {dst_dir}/{file_name} --fuzzy -c')
|
| 366 |
+
else:
|
| 367 |
+
get_ipython().system('gdown "{url}" -O {dst_dir} --fuzzy -c')
|
| 368 |
# -- Huggin Face --
|
| 369 |
elif 'huggingface' in url:
|
| 370 |
if '/blob/' in url:
|
|
|
|
| 389 |
link_or_path = link_or_path.strip()
|
| 390 |
if not link_or_path:
|
| 391 |
continue
|
|
|
|
| 392 |
if any(link_or_path.startswith(prefix.lower()) for prefix in prefixes):
|
| 393 |
handle_manual(link_or_path)
|
| 394 |
continue
|
|
|
|
| 429 |
for submodel in submodels:
|
| 430 |
if not Inpainting_Model and "inpainting" in submodel['name']:
|
| 431 |
continue
|
|
|
|
| 432 |
url += f"{submodel['url']} {submodel['dst_dir']} {submodel['name']}, "
|
| 433 |
|
| 434 |
def process_file_download(file_url):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 435 |
if file_url.startswith("http"):
|
| 436 |
if "blob" in file_url:
|
| 437 |
file_url = file_url.replace("blob", "raw")
|
|
|
|
| 444 |
current_tag = None
|
| 445 |
for line in lines:
|
| 446 |
if line.strip().startswith('#'):
|
| 447 |
+
if any(tag in line.lower() for tag in prefixes):
|
| 448 |
+
current_tag = next((tag for tag in prefixes if tag in line.lower()))
|
| 449 |
+
|
| 450 |
+
urls = [url.strip() for url in line.split()]
|
| 451 |
+
for url in urls:
|
| 452 |
+
if url.startswith("http"):
|
| 453 |
+
globals()[prefixes[current_tag][1]] += ", " + url
|
| 454 |
|
| 455 |
# fix all possible errors/options and function call
|
| 456 |
if custom_file_urls:
|
|
|
|
| 465 |
except FileNotFoundError:
|
| 466 |
pass
|
| 467 |
|
| 468 |
+
# url prefixing
|
| 469 |
+
urls = [globals()[urls[1]] for urls in prefixes.values()]
|
| 470 |
for i, prefix in enumerate(prefixes):
|
| 471 |
if urls[i]:
|
| 472 |
+
prefixed_urls = [f"{prefix}:{url}" for url in urls[i].replace(',', '').split()]
|
| 473 |
if prefixed_urls:
|
| 474 |
url += ", ".join(prefixed_urls) + ", "
|
| 475 |
|
files_cells/python/ru/launch_ru.py
CHANGED
|
@@ -9,11 +9,8 @@ from datetime import timedelta
|
|
| 9 |
|
| 10 |
|
| 11 |
# ================= DETECT ENV =================
|
| 12 |
-
def check_colab_subscription():
|
| 13 |
-
return (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)
|
| 14 |
-
free_plan = check_colab_subscription()
|
| 15 |
-
|
| 16 |
def detect_environment():
|
|
|
|
| 17 |
environments = {
|
| 18 |
'COLAB_GPU': ('Google Colab', "/root" if free_plan else "/content"),
|
| 19 |
'KAGGLE_URL_BASE': ('Kaggle', "/kaggle/working/content"),
|
|
@@ -22,9 +19,9 @@ def detect_environment():
|
|
| 22 |
|
| 23 |
for env_var, (environment, path) in environments.items():
|
| 24 |
if env_var in os.environ:
|
| 25 |
-
return environment, path
|
| 26 |
|
| 27 |
-
env, root_path = detect_environment()
|
| 28 |
webui_path = f"{root_path}/sdw"
|
| 29 |
# ----------------------------------------------
|
| 30 |
|
|
|
|
| 9 |
|
| 10 |
|
| 11 |
# ================= DETECT ENV =================
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
def detect_environment():
|
| 13 |
+
free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)
|
| 14 |
environments = {
|
| 15 |
'COLAB_GPU': ('Google Colab', "/root" if free_plan else "/content"),
|
| 16 |
'KAGGLE_URL_BASE': ('Kaggle', "/kaggle/working/content"),
|
|
|
|
| 19 |
|
| 20 |
for env_var, (environment, path) in environments.items():
|
| 21 |
if env_var in os.environ:
|
| 22 |
+
return environment, path, free_plan
|
| 23 |
|
| 24 |
+
env, root_path, free_plan = detect_environment()
|
| 25 |
webui_path = f"{root_path}/sdw"
|
| 26 |
# ----------------------------------------------
|
| 27 |
|
files_cells/python/ru/widgets_ru.py
CHANGED
|
@@ -8,11 +8,8 @@ from IPython.display import display, HTML, Javascript, clear_output
|
|
| 8 |
|
| 9 |
|
| 10 |
# ================= DETECT ENV =================
|
| 11 |
-
def check_colab_subscription():
|
| 12 |
-
return (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)
|
| 13 |
-
free_plan = check_colab_subscription()
|
| 14 |
-
|
| 15 |
def detect_environment():
|
|
|
|
| 16 |
environments = {
|
| 17 |
'COLAB_GPU': ('Google Colab', "/root" if free_plan else "/content"),
|
| 18 |
'KAGGLE_URL_BASE': ('Kaggle', "/kaggle/working/content"),
|
|
@@ -21,9 +18,9 @@ def detect_environment():
|
|
| 21 |
|
| 22 |
for env_var, (environment, path) in environments.items():
|
| 23 |
if env_var in os.environ:
|
| 24 |
-
return environment, path
|
| 25 |
|
| 26 |
-
env, root_path = detect_environment()
|
| 27 |
webui_path = f"{root_path}/sdw"
|
| 28 |
|
| 29 |
get_ipython().system('mkdir -p {root_path}')
|
|
@@ -345,7 +342,7 @@ commandline_arguments_options = "--listen --enable-insecure-extension-access --t
|
|
| 345 |
commandline_arguments_widget = widgets.Text(description='Аргументы:', value=commandline_arguments_options, style=style, layout=layout)
|
| 346 |
|
| 347 |
additional_widget_list = [additional_header, latest_changes_widget, HR, controlnet_widget, controlnet_Num_widget, commit_hash_widget, optional_huggingface_token_widget, ngrok_widget, HR, commandline_arguments_widget]
|
| 348 |
-
if free_plan:
|
| 349 |
additional_widget_list.remove(ngrok_widget)
|
| 350 |
display(widgets.VBox(additional_widget_list).add_class("container"))
|
| 351 |
|
|
|
|
| 8 |
|
| 9 |
|
| 10 |
# ================= DETECT ENV =================
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
def detect_environment():
|
| 12 |
+
free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)
|
| 13 |
environments = {
|
| 14 |
'COLAB_GPU': ('Google Colab', "/root" if free_plan else "/content"),
|
| 15 |
'KAGGLE_URL_BASE': ('Kaggle', "/kaggle/working/content"),
|
|
|
|
| 18 |
|
| 19 |
for env_var, (environment, path) in environments.items():
|
| 20 |
if env_var in os.environ:
|
| 21 |
+
return environment, path, free_plan
|
| 22 |
|
| 23 |
+
env, root_path, free_plan = detect_environment()
|
| 24 |
webui_path = f"{root_path}/sdw"
|
| 25 |
|
| 26 |
get_ipython().system('mkdir -p {root_path}')
|
|
|
|
| 342 |
commandline_arguments_widget = widgets.Text(description='Аргументы:', value=commandline_arguments_options, style=style, layout=layout)
|
| 343 |
|
| 344 |
additional_widget_list = [additional_header, latest_changes_widget, HR, controlnet_widget, controlnet_Num_widget, commit_hash_widget, optional_huggingface_token_widget, ngrok_widget, HR, commandline_arguments_widget]
|
| 345 |
+
if free_plan and env == "Google Colab":
|
| 346 |
additional_widget_list.remove(ngrok_widget)
|
| 347 |
display(widgets.VBox(additional_widget_list).add_class("container"))
|
| 348 |
|