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 |
+
import os
|
| 4 |
+
import time
|
| 5 |
+
import ipywidgets as widgets
|
| 6 |
+
from ipywidgets import Label, Button, VBox, HBox
|
| 7 |
+
from IPython.display import display, HTML
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
root_path = "/home/studio-lab-user/content"
|
| 11 |
+
webui_path = f"{root_path}/sdw"
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
# ==================== CSS ====================
|
| 15 |
+
CSS_AC = """
|
| 16 |
+
<style>
|
| 17 |
+
/* General Styles */
|
| 18 |
+
|
| 19 |
+
hr {
|
| 20 |
+
border-color: grey;
|
| 21 |
+
background-color: grey;
|
| 22 |
+
opacity: 0.25;
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
.instruction_AC {
|
| 26 |
+
font-family: cursive;
|
| 27 |
+
font-size: 18px;
|
| 28 |
+
color: grey;
|
| 29 |
+
user-select: none;
|
| 30 |
+
cursor: default;
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
/* Container style */
|
| 35 |
+
|
| 36 |
+
.container_AC {
|
| 37 |
+
position: relative;
|
| 38 |
+
background-color: #232323;
|
| 39 |
+
width: 800px;
|
| 40 |
+
height: auto;
|
| 41 |
+
padding: 15px;
|
| 42 |
+
border-radius: 15px;
|
| 43 |
+
box-shadow: 0 0 50px rgba(0, 0, 0, 0.3);
|
| 44 |
+
margin-bottom: 5px;
|
| 45 |
+
overflow: visible;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
.container_AC::before {
|
| 49 |
+
position: absolute;
|
| 50 |
+
top: 5px;
|
| 51 |
+
right: 10px;
|
| 52 |
+
content: "AutoCleanerV3.6";
|
| 53 |
+
font-weight: bold;
|
| 54 |
+
font-size: 24px;
|
| 55 |
+
color: rgba(0, 0, 0, 0.2);
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
.container_AC::after {
|
| 59 |
+
position: absolute;
|
| 60 |
+
top: 30px;
|
| 61 |
+
right: 10px;
|
| 62 |
+
content: "ANXETY";
|
| 63 |
+
font-weight: bold;
|
| 64 |
+
font-size: 18px;
|
| 65 |
+
color: rgba(0, 0, 0, 0.2);
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
.custom-select-multiple_AC select {
|
| 69 |
+
padding: 10px;
|
| 70 |
+
font-family: cursive;
|
| 71 |
+
border: 1px solid #262626 !important;
|
| 72 |
+
border-radius: 10px;
|
| 73 |
+
color: white;
|
| 74 |
+
background-color: #1c1c1c;
|
| 75 |
+
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
.output_AC {
|
| 79 |
+
padding: 10px;
|
| 80 |
+
height: auto;
|
| 81 |
+
border: 1px solid #262626;
|
| 82 |
+
border-radius: 10px;
|
| 83 |
+
background-color: #1c1c1c;
|
| 84 |
+
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
|
| 85 |
+
width: auto;
|
| 86 |
+
box-sizing: border-box;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
.output_message_AC {
|
| 90 |
+
font-family: cursive;
|
| 91 |
+
color: white !important;
|
| 92 |
+
font-size: 14px;
|
| 93 |
+
user-select: none;
|
| 94 |
+
cursor: default
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
.storage_info_AC {
|
| 99 |
+
padding: 5px 20px;
|
| 100 |
+
height: auto;
|
| 101 |
+
border: 1px solid #262626;
|
| 102 |
+
border-radius: 10px;
|
| 103 |
+
background-color: #1c1c1c;
|
| 104 |
+
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
|
| 105 |
+
width: auto;
|
| 106 |
+
font-family: cursive;
|
| 107 |
+
color: #B2B2B2 !important;
|
| 108 |
+
font-size: 14px;
|
| 109 |
+
user-select: none;
|
| 110 |
+
cursor: default
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
/* Button and storage info layout */
|
| 115 |
+
.lower_information_panel_AC {
|
| 116 |
+
display: flex;
|
| 117 |
+
align-items: center;
|
| 118 |
+
justify-content: space-between;
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
/* Button style */
|
| 123 |
+
|
| 124 |
+
.button_AC {
|
| 125 |
+
width: auto;
|
| 126 |
+
font-family: cursive;
|
| 127 |
+
color: white !important;
|
| 128 |
+
font-size: 14px;
|
| 129 |
+
font-weight: bold;
|
| 130 |
+
height: 35px;
|
| 131 |
+
border-radius: 15px;
|
| 132 |
+
background-image: radial-gradient(circle at top left, purple 10%, violet 90%);
|
| 133 |
+
background-size: 200% 200%;
|
| 134 |
+
background-position: left bottom;
|
| 135 |
+
transition: background 0.5s ease-in-out, transform 0.3s ease;
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
.button_AC:hover {
|
| 139 |
+
cursor: pointer;
|
| 140 |
+
background-size: 200% 200%;
|
| 141 |
+
background-position: right bottom;
|
| 142 |
+
transform: translateY(1px);
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
.button_execute_AC:hover {
|
| 146 |
+
background-image: radial-gradient(circle at top left, purple 10%, #93ac47 90%);
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
.button_clear_AC:hover {
|
| 150 |
+
background-image: radial-gradient(circle at top left, purple 10%, #fc3468 90%);
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
.button_execute_AC:active,
|
| 154 |
+
.button_clear_AC:active {
|
| 155 |
+
filter: brightness(0.75);
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
.jupyter-widgets.lm-Widget:focus {
|
| 159 |
+
outline: none;
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
/* Animation of elements */
|
| 164 |
+
|
| 165 |
+
/* Emergence */
|
| 166 |
+
.container_AC {
|
| 167 |
+
animation-name: slideInTopBlur;
|
| 168 |
+
animation-duration: 0.7s;
|
| 169 |
+
animation-fill-mode: forwards;
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
@keyframes slideInTopBlur {
|
| 173 |
+
0% {
|
| 174 |
+
transform: translate3d(0, 50%, 0) scale(0.85) rotate3d(1, 0, 0, -85deg);
|
| 175 |
+
filter: blur(5px) grayscale(1) brightness(0.5);
|
| 176 |
+
opacity: 0;
|
| 177 |
+
}
|
| 178 |
+
100% {
|
| 179 |
+
transform: translate3d(0, 0, 0) scale(1) rotate3d(1, 0, 0, 0deg);
|
| 180 |
+
filter: blur(0) grayscale(0) brightness(1);
|
| 181 |
+
opacity: 1;
|
| 182 |
+
}
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
/* Leaving */
|
| 186 |
+
.container_AC.hide {
|
| 187 |
+
animation-name: slideOutTopBlur;
|
| 188 |
+
animation-duration: 0.3s;
|
| 189 |
+
animation-fill-mode: forwards;
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
@keyframes slideOutTopBlur {
|
| 193 |
+
0% {
|
| 194 |
+
transform: translate3d(0, 0, 0) scale(1);
|
| 195 |
+
filter: blur(0) grayscale(0) brightness(1);
|
| 196 |
+
opacity: 1;
|
| 197 |
+
}
|
| 198 |
+
100% {
|
| 199 |
+
transform: translate3d(0, -100%, 0);
|
| 200 |
+
filter: blur(5px) grayscale(1) brightness(0);
|
| 201 |
+
opacity: 0;
|
| 202 |
+
}
|
| 203 |
+
}
|
| 204 |
+
</style>
|
| 205 |
+
"""
|
| 206 |
+
|
| 207 |
+
display(HTML(CSS_AC))
|
| 208 |
+
# ==================== CSS ====================
|
| 209 |
+
|
| 210 |
+
|
| 211 |
+
# ================ AutoCleaner function ================
|
| 212 |
+
directories = {
|
| 213 |
+
"Изображения": f"{webui_path}/outputs",
|
| 214 |
+
"Модели": f"{webui_path}/models/Stable-diffusion/",
|
| 215 |
+
"Vae": f"{webui_path}/models/VAE/",
|
| 216 |
+
"LoRa": f"{webui_path}/models/Lora/",
|
| 217 |
+
"ControlNet Модели": f"{webui_path}/models/ControlNet/"
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
""" functions """
|
| 221 |
+
def clean_directory(directory):
|
| 222 |
+
deleted_files = 0
|
| 223 |
+
for root, dirs, files in os.walk(directory):
|
| 224 |
+
for file in files:
|
| 225 |
+
if file.endswith(".txt"):
|
| 226 |
+
continue
|
| 227 |
+
os.remove(os.path.join(root, file))
|
| 228 |
+
if not file.endswith(".yaml"):
|
| 229 |
+
deleted_files += 1
|
| 230 |
+
return deleted_files
|
| 231 |
+
|
| 232 |
+
def update_memory_info():
|
| 233 |
+
disk_space = psutil.disk_usage(os.getcwd())
|
| 234 |
+
total = disk_space.total / (1024 ** 3)
|
| 235 |
+
used = disk_space.used / (1024 ** 3)
|
| 236 |
+
free = disk_space.free / (1024 ** 3)
|
| 237 |
+
|
| 238 |
+
storage_info.value = f'''
|
| 239 |
+
<div class="storage_info_AC">Всего: {total:.2f} GB <span style="color: #555">|</span> Используется: {used:.2f} GB <span style="color: #555">|</span> Свободно: {free:.2f} GB</div>
|
| 240 |
+
'''
|
| 241 |
+
|
| 242 |
+
def on_execute_button_press(button):
|
| 243 |
+
selected_cleaners = auto_cleaner_widget.value
|
| 244 |
+
deleted_files_dict = {}
|
| 245 |
+
|
| 246 |
+
for option in selected_cleaners:
|
| 247 |
+
if option in directories:
|
| 248 |
+
deleted_files_dict[option] = clean_directory(directories[option])
|
| 249 |
+
|
| 250 |
+
output.clear_output()
|
| 251 |
+
|
| 252 |
+
with output:
|
| 253 |
+
for message in generate_messages(deleted_files_dict):
|
| 254 |
+
message_widget = HTML(f'<p class="output_message_AC">{message}</p>')
|
| 255 |
+
display(message_widget)
|
| 256 |
+
|
| 257 |
+
update_memory_info()
|
| 258 |
+
|
| 259 |
+
def on_clear_button_press(button):
|
| 260 |
+
container.add_class("hide")
|
| 261 |
+
time.sleep(0.5)
|
| 262 |
+
widgets.Widget.close_all()
|
| 263 |
+
|
| 264 |
+
def generate_messages(deleted_files_dict):
|
| 265 |
+
messages = []
|
| 266 |
+
word_variants = {
|
| 267 |
+
"Изображения": "Изображений",
|
| 268 |
+
"Модели": "Моделей",
|
| 269 |
+
"Vae": "Vae",
|
| 270 |
+
"LoRa": "LoRa",
|
| 271 |
+
"ControlNet Модели": "ControlNet Моделей"
|
| 272 |
+
}
|
| 273 |
+
for key, value in deleted_files_dict.items():
|
| 274 |
+
object_word = word_variants.get(key)
|
| 275 |
+
messages.append(f"Удалено {value} {object_word}")
|
| 276 |
+
return messages
|
| 277 |
+
# ================ AutoCleaner function ================
|
| 278 |
+
|
| 279 |
+
|
| 280 |
+
# --- storage memory ---
|
| 281 |
+
import psutil
|
| 282 |
+
disk_space = psutil.disk_usage(os.getcwd())
|
| 283 |
+
total = disk_space.total / (1024 ** 3)
|
| 284 |
+
used = disk_space.used / (1024 ** 3)
|
| 285 |
+
free = disk_space.free / (1024 ** 3)
|
| 286 |
+
|
| 287 |
+
|
| 288 |
+
# UI Code
|
| 289 |
+
AutoCleaner_options = AutoCleaner_options = list(directories.keys())
|
| 290 |
+
instruction_label = widgets.HTML('''
|
| 291 |
+
<span class="instruction_AC">Используйте <span style="color: #B2B2B2;">ctrl</span> или <span style="color: #B2B2B2;">shift</span> для множественного выбора.</span>
|
| 292 |
+
''')
|
| 293 |
+
auto_cleaner_widget = widgets.SelectMultiple(options=AutoCleaner_options, layout=widgets.Layout(width="auto")).add_class("custom-select-multiple_AC")
|
| 294 |
+
output = widgets.Output().add_class("output_AC")
|
| 295 |
+
# ---
|
| 296 |
+
execute_button = Button(description='Выполнить Очистку').add_class("button_execute_AC").add_class("button_AC")
|
| 297 |
+
execute_button.on_click(on_execute_button_press)
|
| 298 |
+
clear_button = Button(description='Скрыть Виджет').add_class("button_clear_AC").add_class("button_AC")
|
| 299 |
+
clear_button.on_click(on_clear_button_press)
|
| 300 |
+
# ---
|
| 301 |
+
storage_info = widgets.HTML(f'''
|
| 302 |
+
<div class="storage_info_AC">Всего: {total:.2f} GB <span style="color: #555">|</span> Используется: {used:.2f} GB <span style="color: #555">|</span> Свободно: {free:.2f} GB</div>
|
| 303 |
+
''')
|
| 304 |
+
# ---
|
| 305 |
+
buttons = widgets.HBox([execute_button, clear_button])
|
| 306 |
+
lower_information_panel = widgets.HBox([buttons, storage_info]).add_class("lower_information_panel_AC")
|
| 307 |
+
|
| 308 |
+
container = VBox([instruction_label, widgets.HTML('<hr>'), auto_cleaner_widget, output, widgets.HTML('<hr>'), lower_information_panel]).add_class("container_AC")
|
| 309 |
+
|
| 310 |
+
display(container)
|
| 311 |
+
|
downloading_cn.py
ADDED
|
@@ -0,0 +1,575 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
##~ WIDGET CODE | Special for SageMaker | BY: ANXETY ~##
|
| 2 |
+
|
| 3 |
+
import os
|
| 4 |
+
import re
|
| 5 |
+
import time
|
| 6 |
+
import json
|
| 7 |
+
import requests
|
| 8 |
+
import subprocess
|
| 9 |
+
from datetime import timedelta
|
| 10 |
+
from subprocess import getoutput
|
| 11 |
+
from urllib.parse import unquote
|
| 12 |
+
from IPython.utils import capture
|
| 13 |
+
from IPython.display import clear_output
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
home_path = "/home/studio-lab-user"
|
| 17 |
+
root_path = "/home/studio-lab-user/content"
|
| 18 |
+
webui_path = f"{root_path}/sdw"
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
# ================ LIBRARIES V2 ================
|
| 22 |
+
flag_file = f"{root_path}/libraries_installed.txt"
|
| 23 |
+
|
| 24 |
+
if not os.path.exists(flag_file):
|
| 25 |
+
print("💿 安装文件需要一些时间:\n")
|
| 26 |
+
|
| 27 |
+
install_lib = {
|
| 28 |
+
"localtunnel": "npm install -g localtunnel",
|
| 29 |
+
# "cloudpickle": "pip install cloudpickle",
|
| 30 |
+
"insightface": "pip install insightface",
|
| 31 |
+
"xformers": "pip install xformers==0.0.23.post1 triton==2.1.0",
|
| 32 |
+
"torch": "pip install torch==2.1.2+cu121 torchvision==0.16.2+cu121 torchaudio==2.1.2 --extra-index-url https://download.pytorch.org/whl/cu121"
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
# Loop through libraries and execute install commands
|
| 36 |
+
for index, (package, install_cmd) in enumerate(install_lib.items(), start=1):
|
| 37 |
+
print(f"\r[{index}/{len(install_lib)}] \033[32m>>\033[0m Installing \033[33m{package}\033[0m..." + " "*35, end='')
|
| 38 |
+
subprocess.run(install_cmd, shell=True, capture_output=True)
|
| 39 |
+
|
| 40 |
+
# Additional manual installation steps for specific packages
|
| 41 |
+
with capture.capture_output() as cap:
|
| 42 |
+
# get_ipython().system(f'curl -sLo ~/content/new_tunnel https://github.com/DEX-1101/sd-webui-notebook/raw/main/res/new_tunnel')
|
| 43 |
+
# get_ipython().system(f'curl -sLo ~/.conda/envs/default/bin/cl https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 && chmod +x ~/.conda/envs/default/bin/cl')
|
| 44 |
+
get_ipython().system(f'curl -sLO https://github.com/openziti/zrok/releases/download/v0.4.23/zrok_0.4.23_linux_amd64.tar.gz && tar -xzf zrok_0.4.23_linux_amd64.tar.gz -C ~/.conda/envs/default/bin && rm -f zrok_0.4.23_linux_amd64.tar.gz')
|
| 45 |
+
del cap
|
| 46 |
+
|
| 47 |
+
clear_output()
|
| 48 |
+
|
| 49 |
+
# Save file install lib
|
| 50 |
+
with open(flag_file, "w") as f:
|
| 51 |
+
f.write(">W<'")
|
| 52 |
+
|
| 53 |
+
print("🍪 Библиотеки установлены!" + " "*35)
|
| 54 |
+
time.sleep(2)
|
| 55 |
+
clear_output()
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
# ================= loading settings V4 =================
|
| 59 |
+
def load_settings(path):
|
| 60 |
+
if os.path.exists(path):
|
| 61 |
+
with open(path, 'r') as file:
|
| 62 |
+
return json.load(file)
|
| 63 |
+
return {}
|
| 64 |
+
|
| 65 |
+
settings = load_settings(f'{root_path}/settings.json')
|
| 66 |
+
|
| 67 |
+
variables = [
|
| 68 |
+
'Model', 'Model_Num', 'Inpainting_Model',
|
| 69 |
+
'Vae', 'Vae_Num',
|
| 70 |
+
'latest_webui', 'latest_exstensions', 'temporary_files', 'detailed_download',
|
| 71 |
+
'controlnet', 'controlnet_Num', 'commit_hash', 'optional_huggingface_token',
|
| 72 |
+
'ngrok_token', 'zrok_token', 'commandline_arguments',
|
| 73 |
+
'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url', 'Extensions_url', 'custom_file_urls'
|
| 74 |
+
]
|
| 75 |
+
|
| 76 |
+
locals().update({key: settings.get(key) for key in variables})
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
# ================= OTHER =================
|
| 80 |
+
try:
|
| 81 |
+
start_colab
|
| 82 |
+
except:
|
| 83 |
+
start_colab = int(time.time())-5
|
| 84 |
+
|
| 85 |
+
# CONFIG DIR
|
| 86 |
+
models_dir = f"{webui_path}/models/Stable-diffusion/"
|
| 87 |
+
vaes_dir = f"{webui_path}/models/VAE/"
|
| 88 |
+
embeddings_dir = f"{webui_path}/embeddings/"
|
| 89 |
+
loras_dir = f"{webui_path}/models/Lora/"
|
| 90 |
+
extensions_dir = f"{webui_path}/extensions/"
|
| 91 |
+
control_dir = f"{webui_path}/models/ControlNet/"
|
| 92 |
+
|
| 93 |
+
if temporary_files:
|
| 94 |
+
models_dir = f"{root_path}/tmp/tmp_models/"
|
| 95 |
+
vaes_dir = f"{root_path}/tmp/tmp_VAE/"
|
| 96 |
+
loras_dir = f"{root_path}/tmp/tmp_Lora/"
|
| 97 |
+
control_dir = f"{root_path}/tmp/tmp_ControlNet/"
|
| 98 |
+
|
| 99 |
+
get_ipython().system(f'mkdir -p {models_dir} {vaes_dir} {loras_dir} {control_dir}')
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
## add tmp folder and init zrok
|
| 103 |
+
fff = {"shell": True, "stdout": subprocess.DEVNULL, "stderr": subprocess.DEVNULL}
|
| 104 |
+
|
| 105 |
+
## del tmp files
|
| 106 |
+
subprocess.run(f"rm -rf {home_path}/.zrok", **fff)
|
| 107 |
+
subprocess.run(f"rm -rf {home_path}/tmp/* {home_path}/tmp", **fff)
|
| 108 |
+
subprocess.run(f"rm -rf {root_path}/tmp/* {root_path}/tmp", **fff)
|
| 109 |
+
subprocess.run(f"rm -rf {root_path}/tmp/tmp_models", **fff)
|
| 110 |
+
subprocess.run(f"rm -rf {root_path}/tmp/tmp_VAE", **fff)
|
| 111 |
+
subprocess.run(f"rm -rf {root_path}/tmp/tmp_Lora", **fff)
|
| 112 |
+
subprocess.run(f"rm -rf {root_path}/tmp/tmp_ControlNet", **fff)
|
| 113 |
+
|
| 114 |
+
if not temporary_files:
|
| 115 |
+
subprocess.run(f"rm -rf {webui_path}/models/Stable-diffusion/tmp_models", **fff)
|
| 116 |
+
subprocess.run(f"rm -rf {webui_path}/models/VAE/tmp_VAE", **fff)
|
| 117 |
+
subprocess.run(f"rm -rf {webui_path}/models/Lora/tmp_Lora", **fff)
|
| 118 |
+
subprocess.run(f"rm -rf {webui_path}/models/ControlNet/tmp_ControlNet", **fff)
|
| 119 |
+
|
| 120 |
+
if temporary_files:
|
| 121 |
+
def clean_up_temp(root_path, webui_path):
|
| 122 |
+
return [
|
| 123 |
+
f"ln -vs {root_path}/tmp/tmp_models {webui_path}/models/Stable-diffusion/",
|
| 124 |
+
f"ln -vs {root_path}/tmp/tmp_VAE {webui_path}/models/VAE/",
|
| 125 |
+
f"ln -vs {root_path}/tmp/tmp_Lora {webui_path}/models/Lora/",
|
| 126 |
+
f"ln -vs {root_path}/tmp/tmp_ControlNet {webui_path}/models/ControlNet/"
|
| 127 |
+
]
|
| 128 |
+
|
| 129 |
+
# Create symbolic links for temporary files
|
| 130 |
+
temp_links = clean_up_temp(root_path, webui_path)
|
| 131 |
+
for link_cmd in temp_links:
|
| 132 |
+
subprocess.run(link_cmd, **fff)
|
| 133 |
+
|
| 134 |
+
# Additional manual installation steps for specific packages
|
| 135 |
+
get_ipython().system(f'curl -sLo {root_path}/special/zrok.py https://huggingface.co/NagisaNao/sagemaker_special/resolve/main/special/zrok.py')
|
| 136 |
+
get_ipython().system(f'curl -sLo {root_path}/special/zrun.py https://huggingface.co/NagisaNao/sagemaker_special/resolve/main/special/zrun.py')
|
| 137 |
+
# my files
|
| 138 |
+
get_ipython().system(f'curl -sLo {root_path}/special/zrok2.py https://huggingface.co/NagisaNao/sagemaker_special/resolve/main/special/zrok2.py')
|
| 139 |
+
get_ipython().system(f'curl -sLo {root_path}/special/zrok3.py https://huggingface.co/NagisaNao/sagemaker_special/resolve/main/special/zrok3.py')
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
# ================= MAIN CODE =================
|
| 144 |
+
if not os.path.exists(webui_path):
|
| 145 |
+
start_install = int(time.time())
|
| 146 |
+
print("⌚ Распоковка Stable Diffusion...", end='')
|
| 147 |
+
with capture.capture_output() as cap:
|
| 148 |
+
get_ipython().system('aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/datasets/ai202388/g_sd/resolve/main/FULL_REPO1.zip -o repo.zip')
|
| 149 |
+
get_ipython().system('unzip -q -o repo.zip -d {webui_path}')
|
| 150 |
+
get_ipython().system('rm -rf repo.zip')
|
| 151 |
+
|
| 152 |
+
get_ipython().run_line_magic('cd', '{root_path}')
|
| 153 |
+
os.environ["SAFETENSORS_FAST_GPU"]='1'
|
| 154 |
+
os.environ["CUDA_MODULE_LOADING"]="LAZY"
|
| 155 |
+
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3"
|
| 156 |
+
os.environ["PYTHONWARNINGS"] = "ignore"
|
| 157 |
+
|
| 158 |
+
get_ipython().system('echo -n {start_colab} > {webui_path}/static/colabTimer.txt')
|
| 159 |
+
|
| 160 |
+
del cap
|
| 161 |
+
install_time = timedelta(seconds=time.time()-start_install)
|
| 162 |
+
print("\r🚀 Распаковка Завершена! За","%02d:%02d:%02d ⚡\n" % (install_time.seconds / 3600, (install_time.seconds / 60) % 60, install_time.seconds % 60), end='', flush=True)
|
| 163 |
+
else:
|
| 164 |
+
if not start_colab and os.path.exists(f"{webui_path}/static/colabTimer.txt"):
|
| 165 |
+
get_ipython().system('echo -n {start_colab} > {webui_path}/static/colabTimer.txt')
|
| 166 |
+
print("🚀 Все распакованно... Пропуск. ⚡")
|
| 167 |
+
start_colab = float(open(f'{webui_path}/static/colabTimer.txt', 'r').read())
|
| 168 |
+
time_since_start = str(timedelta(seconds=time.time()-start_colab)).split('.')[0]
|
| 169 |
+
print(f"⌚️ Вы проводите эту сессию в течение - \033[33m{time_since_start}\033[0m")
|
| 170 |
+
|
| 171 |
+
|
| 172 |
+
## Changes extensions and WebUi
|
| 173 |
+
if latest_webui or latest_exstensions:
|
| 174 |
+
action = "Обновление WebUI и Расширений" if latest_webui and latest_exstensions else ("Обновление WebUI" if latest_webui else "Обновление Расширений")
|
| 175 |
+
print(f"⌚️ {action}...", end='', flush=True)
|
| 176 |
+
with capture.capture_output() as cap:
|
| 177 |
+
get_ipython().system('git config --global user.email "you@example.com"')
|
| 178 |
+
get_ipython().system('git config --global user.name "Your Name"')
|
| 179 |
+
|
| 180 |
+
## Update Webui
|
| 181 |
+
if latest_webui:
|
| 182 |
+
get_ipython().run_line_magic('cd', '{webui_path}')
|
| 183 |
+
get_ipython().system('git restore .')
|
| 184 |
+
get_ipython().system('git pull -X theirs --rebase --autostash')
|
| 185 |
+
|
| 186 |
+
## Update extensions
|
| 187 |
+
if latest_exstensions:
|
| 188 |
+
get_ipython().system('{\'for dir in \' + webui_path + \'/extensions/*/; do cd \\"$dir\\" && git reset --hard && git pull; done\'}')
|
| 189 |
+
|
| 190 |
+
# My Chinese friend, you broke the images again in the latest update... >W<'
|
| 191 |
+
get_ipython().run_line_magic('cd', '{webui_path}/extensions/Encrypt-Image')
|
| 192 |
+
get_ipython().system('git reset --hard 376358d8854472b9ea50e9fc8800367d1ca51137 # stable commit :3')
|
| 193 |
+
del cap
|
| 194 |
+
print(f"\r✨ {action} Завершено!")
|
| 195 |
+
|
| 196 |
+
|
| 197 |
+
# === FIXING EXTENSIONS ===
|
| 198 |
+
anxety_repos = "https://huggingface.co/NagisaNao/fast_repo/resolve/main"
|
| 199 |
+
|
| 200 |
+
with capture.capture_output() as cap:
|
| 201 |
+
# --- Encrypt-Image ---
|
| 202 |
+
get_ipython().system("sed -i '9,37d' {webui_path}/extensions/Encrypt-Image/javascript/encrypt_images_info.js")
|
| 203 |
+
|
| 204 |
+
# --- Additional-Networks ---
|
| 205 |
+
get_ipython().system('wget -O {webui_path}/extensions/additional-networks/scripts/metadata_editor.py {anxety_repos}/extensions/Additional-Networks/fix/metadata_editor.py')
|
| 206 |
+
del cap
|
| 207 |
+
|
| 208 |
+
|
| 209 |
+
## Version switching
|
| 210 |
+
if commit_hash:
|
| 211 |
+
print('⏳ Активация машины времени...', end="", flush=True)
|
| 212 |
+
with capture.capture_output() as cap:
|
| 213 |
+
get_ipython().run_line_magic('cd', '{webui_path}')
|
| 214 |
+
get_ipython().system('git config --global user.email "you@example.com"')
|
| 215 |
+
get_ipython().system('git config --global user.name "Your Name"')
|
| 216 |
+
get_ipython().system('git reset --hard {commit_hash}')
|
| 217 |
+
del cap
|
| 218 |
+
print(f"\r⌛️ Машина времени активированна! Текущий коммит: \033[34m{commit_hash}\033[0m")
|
| 219 |
+
|
| 220 |
+
|
| 221 |
+
|
| 222 |
+
## Downloading model and stuff | oh yeah~ I'm starting to misunderstand my own code ( almost my own ;3 )
|
| 223 |
+
print("📦 Скачивание моделей и прочего...", end='')
|
| 224 |
+
model_list = {
|
| 225 |
+
"1.Anime (by XpucT) + INP": [
|
| 226 |
+
{"url": "https://huggingface.co/XpucT/Anime/resolve/main/Anime_v2.safetensors", "name": "Anime_v2.safetensors"},
|
| 227 |
+
{"url": "https://huggingface.co/XpucT/Anime/resolve/main/Anime_v2-inpainting.safetensors", "name": "Anime_v2-inpainting.safetensors"}
|
| 228 |
+
],
|
| 229 |
+
"2.BluMix [Anime] [V7] + INP": [
|
| 230 |
+
{"url": "https://civitai.com/api/download/models/361779", "name": "BluMix_v7.safetensors"},
|
| 231 |
+
{"url": "https://civitai.com/api/download/models/363850", "name": "BluMix_v7-inpainting.safetensors"}
|
| 232 |
+
],
|
| 233 |
+
"3.Cetus-Mix [Anime] [V4] + INP": [
|
| 234 |
+
{"url": "https://civitai.com/api/download/models/130298", "name": "CetusMix_V4.safetensors"},
|
| 235 |
+
{"url": "https://civitai.com/api/download/models/139882", "name": "CetusMix_V4-inpainting.safetensors"}
|
| 236 |
+
],
|
| 237 |
+
"4.Counterfeit [Anime] [V3] + INP": [
|
| 238 |
+
{"url": "https://civitai.com/api/download/models/125050", "name": "Counterfeit_V3.safetensors"},
|
| 239 |
+
{"url": "https://civitai.com/api/download/models/137911", "name": "Counterfeit_V3-inpainting.safetensors"}
|
| 240 |
+
],
|
| 241 |
+
"5.CuteColor [Anime] [V3]": [
|
| 242 |
+
{"url": "https://civitai.com/api/download/models/138754", "name": "CuteColor_V3.safetensors"}
|
| 243 |
+
],
|
| 244 |
+
"6.Dark-Sushi-Mix [Anime]": [
|
| 245 |
+
{"url": "https://civitai.com/api/download/models/101640", "name": "DarkSushiMix_2_5D.safetensors"},
|
| 246 |
+
{"url": "https://civitai.com/api/download/models/56071", "name": "DarkSushiMix_colorful.safetensors"}
|
| 247 |
+
],
|
| 248 |
+
"7.Deliberate [Realism] [V6] + INP": [
|
| 249 |
+
{"url": "https://huggingface.co/XpucT/Deliberate/resolve/main/Deliberate_v6.safetensors", "name": "Deliberate_v6.safetensors"},
|
| 250 |
+
{"url": "https://huggingface.co/XpucT/Deliberate/resolve/main/Deliberate_v6-inpainting.safetensors", "name": "Deliberate_v6-inpainting.safetensors"}
|
| 251 |
+
],
|
| 252 |
+
"8.Meina-Mix [Anime] [V11] + INP": [
|
| 253 |
+
{"url": "https://civitai.com/api/download/models/119057", "name": "MeinaMix_V11.safetensors"},
|
| 254 |
+
{"url": "https://civitai.com/api/download/models/120702", "name": "MeinaMix_V11-inpainting.safetensors"}
|
| 255 |
+
],
|
| 256 |
+
"9.Mix-Pro [Anime] [V4] + INP": [
|
| 257 |
+
{"url": "https://civitai.com/api/download/models/125668", "name": "MixPro_V4.safetensors"},
|
| 258 |
+
{"url": "https://civitai.com/api/download/models/139878", "name": "MixPro_V4-inpainting.safetensors"}
|
| 259 |
+
]
|
| 260 |
+
}
|
| 261 |
+
|
| 262 |
+
# 1-4 (fp16/cleaned)
|
| 263 |
+
vae_list = {
|
| 264 |
+
"1.Anime.vae": [
|
| 265 |
+
{"url": "https://civitai.com/api/download/models/131654", "name": "Anime.vae.safetensors"},
|
| 266 |
+
{"url": "https://civitai.com/api/download/models/131658", "name": "vae-ft-mse.vae.safetensors"}
|
| 267 |
+
],
|
| 268 |
+
"2.Anything.vae": [{"url": "https://civitai.com/api/download/models/131656", "name": "Anything.vae.safetensors"}],
|
| 269 |
+
"3.Blessed2.vae": [{"url": "https://civitai.com/api/download/models/142467", "name": "Blessed2.vae.safetensors"}],
|
| 270 |
+
"4.ClearVae.vae": [{"url": "https://civitai.com/api/download/models/133362", "name": "ClearVae_23.vae.safetensors"}],
|
| 271 |
+
"5.WD.vae": [{"url": "https://huggingface.co/NoCrypt/resources/resolve/main/VAE/wd.vae.safetensors", "name": "WD.vae.safetensors"}]
|
| 272 |
+
}
|
| 273 |
+
|
| 274 |
+
controlnet_list = {
|
| 275 |
+
"1.canny": [
|
| 276 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_canny_fp16.safetensors", "name": "control_v11p_sd15_canny_fp16.safetensors"},
|
| 277 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_canny_fp16.yaml", "name": "control_v11p_sd15_canny_fp16.yaml"}
|
| 278 |
+
],
|
| 279 |
+
"2.openpose": [
|
| 280 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_openpose_fp16.safetensors", "name": "control_v11p_sd15_openpose_fp16.safetensors"},
|
| 281 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_openpose_fp16.yaml", "name": "control_v11p_sd15_openpose_fp16.yaml"}
|
| 282 |
+
],
|
| 283 |
+
"3.depth": [
|
| 284 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11f1p_sd15_depth_fp16.safetensors", "name": "control_v11f1p_sd15_depth_fp16.safetensors"},
|
| 285 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11f1p_sd15_depth_fp16.yaml", "name": "control_v11f1p_sd15_depth_fp16.yaml"},
|
| 286 |
+
{"url": "https://huggingface.co/NagisaNao/models/resolve/main/ControlNet_v11/control_v11p_sd15_depth_anything_fp16.safetensors", "name": "control_v11p_sd15_depth_anything_fp16.safetensors"}
|
| 287 |
+
],
|
| 288 |
+
"4.normal_map": [
|
| 289 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_normalbae_fp16.safetensors", "name": "control_v11p_sd15_normalbae_fp16.safetensors"},
|
| 290 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_normalbae_fp16.yaml", "name": "control_v11p_sd15_normalbae_fp16.yaml"}
|
| 291 |
+
],
|
| 292 |
+
"5.mlsd": [
|
| 293 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_mlsd_fp16.safetensors", "name": "control_v11p_sd15_mlsd_fp16.safetensors"},
|
| 294 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_mlsd_fp16.yaml", "name": "control_v11p_sd15_mlsd_fp16.yaml"}
|
| 295 |
+
],
|
| 296 |
+
"6.lineart": [
|
| 297 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_lineart_fp16.safetensors", "name": "control_v11p_sd15_lineart_fp16.safetensors"},
|
| 298 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15s2_lineart_anime_fp16.safetensors", "name": "control_v11p_sd15s2_lineart_anime_fp16.safetensors"},
|
| 299 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_lineart_fp16.yaml", "name": "control_v11p_sd15_lineart_fp16.yaml"},
|
| 300 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15s2_lineart_anime_fp16.yaml", "name": "control_v11p_sd15s2_lineart_anime_fp16.yaml"}
|
| 301 |
+
],
|
| 302 |
+
"7.soft_edge": [
|
| 303 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_softedge_fp16.safetensors", "name": "control_v11p_sd15_softedge_fp16.safetensors"},
|
| 304 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_softedge_fp16.yaml", "name": "control_v11p_sd15_softedge_fp16.yaml"}
|
| 305 |
+
],
|
| 306 |
+
"8.scribble": [
|
| 307 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_scribble_fp16.safetensors", "name": "control_v11p_sd15_scribble_fp16.safetensors"},
|
| 308 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_scribble_fp16.yaml", "name": "control_v11p_sd15_scribble_fp16.yaml"}
|
| 309 |
+
],
|
| 310 |
+
"9.segmentation": [
|
| 311 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_seg_fp16.safetensors", "name": "control_v11p_sd15_seg_fp16.safetensors"},
|
| 312 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_seg_fp16.yaml", "name": "control_v11p_sd15_seg_fp16.yaml"}
|
| 313 |
+
],
|
| 314 |
+
"10.shuffle": [
|
| 315 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11e_sd15_shuffle_fp16.safetensors", "name": "control_v11e_sd15_shuffle_fp16.safetensors"},
|
| 316 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11e_sd15_shuffle_fp16.yaml", "name": "control_v11e_sd15_shuffle_fp16.yaml"}
|
| 317 |
+
],
|
| 318 |
+
"11.tile": [
|
| 319 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11f1e_sd15_tile_fp16.safetensors", "name": "control_v11f1e_sd15_tile_fp16.safetensors"},
|
| 320 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11f1e_sd15_tile_fp16.yaml", "name": "control_v11f1e_sd15_tile_fp16.yaml"}
|
| 321 |
+
],
|
| 322 |
+
"12.inpaint": [
|
| 323 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_inpaint_fp16.safetensors", "name": "control_v11p_sd15_inpaint_fp16.safetensors"},
|
| 324 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_inpaint_fp16.yaml", "name": "control_v11p_sd15_inpaint_fp16.yaml"}
|
| 325 |
+
],
|
| 326 |
+
"13.instruct_p2p": [
|
| 327 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11e_sd15_ip2p_fp16.safetensors", "name": "control_v11e_sd15_ip2p_fp16.safetensors"},
|
| 328 |
+
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11e_sd15_ip2p_fp16.yaml", "name": "control_v11e_sd15_ip2p_fp16.yaml"}
|
| 329 |
+
]
|
| 330 |
+
}
|
| 331 |
+
|
| 332 |
+
extension_repo = []
|
| 333 |
+
prefixes = {
|
| 334 |
+
# It's complicated, but supplementing has become easier
|
| 335 |
+
"model": [models_dir, "Model_url"],
|
| 336 |
+
"vae": [vaes_dir, "Vae_url"],
|
| 337 |
+
"lora": [loras_dir, "LoRA_url"],
|
| 338 |
+
"embed": [embeddings_dir, "Embedding_url"],
|
| 339 |
+
"extension": [extensions_dir, "Extensions_url"],
|
| 340 |
+
"control": [control_dir, "ControlNet_url"]
|
| 341 |
+
}
|
| 342 |
+
|
| 343 |
+
get_ipython().system('mkdir -p {models_dir} {vaes_dir} {loras_dir} {embeddings_dir} {extensions_dir} {control_dir}')
|
| 344 |
+
|
| 345 |
+
url = ""
|
| 346 |
+
ControlNet_url = ""
|
| 347 |
+
hf_token = optional_huggingface_token if optional_huggingface_token else "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"
|
| 348 |
+
user_header = f"\"Authorization: Bearer {hf_token}\""
|
| 349 |
+
|
| 350 |
+
''' main download code '''
|
| 351 |
+
|
| 352 |
+
def handle_manual(url):
|
| 353 |
+
original_url = url
|
| 354 |
+
url = url.split(':', 1)[1]
|
| 355 |
+
file_name = re.search(r'\[(.*?)\]', url)
|
| 356 |
+
file_name = file_name.group(1) if file_name else None
|
| 357 |
+
if file_name:
|
| 358 |
+
url = re.sub(r'\[.*?\]', '', url)
|
| 359 |
+
|
| 360 |
+
for prefix, (dir, _) in prefixes.items():
|
| 361 |
+
if original_url.startswith(f"{prefix}:"):
|
| 362 |
+
if prefix != "extension":
|
| 363 |
+
manual_download(url, dir, file_name=file_name)
|
| 364 |
+
else:
|
| 365 |
+
extension_repo.append((url, file_name))
|
| 366 |
+
|
| 367 |
+
def manual_download(url, dst_dir, file_name):
|
| 368 |
+
basename = url.split("/")[-1] if file_name is None else file_name
|
| 369 |
+
header_option = f"--header={user_header}"
|
| 370 |
+
|
| 371 |
+
print("\033[32m---"*45 + f"\n\033[33mURL: \033[34m{url}\n\033[33mSAVE DIR: \033[34m{dst_dir}\n\033[33mFILE NAME: \033[34m{file_name}\033[32m\n~~~\033[0m")
|
| 372 |
+
|
| 373 |
+
# I do it at my own risk..... Fucking CivitAi >:(
|
| 374 |
+
civitai_token = "62c0c5956b2f9defbd844d754000180b"
|
| 375 |
+
if 'civitai' in url and civitai_token:
|
| 376 |
+
url = f"{url}?token={civitai_token}"
|
| 377 |
+
|
| 378 |
+
# -- GDrive --
|
| 379 |
+
if 'drive.google' in url:
|
| 380 |
+
if 'folders' in url:
|
| 381 |
+
get_ipython().system('gdown --folder "{url}" -O {dst_dir} --fuzzy -c')
|
| 382 |
+
else:
|
| 383 |
+
if file_name:
|
| 384 |
+
get_ipython().system('gdown "{url}" -O {dst_dir}/{file_name} --fuzzy -c')
|
| 385 |
+
else:
|
| 386 |
+
get_ipython().system('gdown "{url}" -O {dst_dir} --fuzzy -c')
|
| 387 |
+
# -- Huggin Face --
|
| 388 |
+
elif 'huggingface' in url:
|
| 389 |
+
if '/blob/' in url:
|
| 390 |
+
url = url.replace('/blob/', '/resolve/')
|
| 391 |
+
if file_name:
|
| 392 |
+
get_ipython().system('aria2c {header_option} --optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -c -j5 -x16 -s16 -k1M -d {dst_dir} -o {basename} {url}')
|
| 393 |
+
else:
|
| 394 |
+
parsed_link = f'\n{url}\n\tout={unquote(url.split("/")[-1])}'
|
| 395 |
+
get_ipython().system('echo -e "{parsed_link}" | aria2c {header_option} --console-log-level=error --summary-interval=10 -i- -j5 -x16 -s16 -k1M -c -d "{dst_dir}" -o {basename}')
|
| 396 |
+
# -- Other --
|
| 397 |
+
elif 'http' in url or 'magnet' in url:
|
| 398 |
+
if file_name:
|
| 399 |
+
get_ipython().system('aria2c --optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -j5 -x16 -s16 -k1M -c -d {dst_dir} -o {file_name} {url}')
|
| 400 |
+
else:
|
| 401 |
+
parsed_link = '"{}"'.format(url)
|
| 402 |
+
get_ipython().system('aria2c --optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -j5 -x16 -s16 -k1M -c -d {dst_dir} -Z {parsed_link}')
|
| 403 |
+
|
| 404 |
+
def download(url):
|
| 405 |
+
links_and_paths = url.split(',')
|
| 406 |
+
|
| 407 |
+
for link_or_path in links_and_paths:
|
| 408 |
+
link_or_path = link_or_path.strip()
|
| 409 |
+
if not link_or_path:
|
| 410 |
+
continue
|
| 411 |
+
if any(link_or_path.startswith(prefix.lower()) for prefix in prefixes):
|
| 412 |
+
handle_manual(link_or_path)
|
| 413 |
+
continue
|
| 414 |
+
|
| 415 |
+
url, dst_dir, file_name = link_or_path.split()
|
| 416 |
+
manual_download(url, dst_dir, file_name)
|
| 417 |
+
|
| 418 |
+
''' submodels - added urls '''
|
| 419 |
+
|
| 420 |
+
submodels = []
|
| 421 |
+
|
| 422 |
+
def add_submodels(selection, num_selection, model_dict, dst_dir):
|
| 423 |
+
if selection == "none":
|
| 424 |
+
return []
|
| 425 |
+
if selection == "ALL":
|
| 426 |
+
all_models = []
|
| 427 |
+
for models in model_dict.values():
|
| 428 |
+
all_models.extend(models)
|
| 429 |
+
selected_models = all_models
|
| 430 |
+
else:
|
| 431 |
+
selected_models = model_dict[selection]
|
| 432 |
+
selected_nums = map(int, num_selection.replace(',', '').split())
|
| 433 |
+
|
| 434 |
+
for num in selected_nums:
|
| 435 |
+
if 1 <= num <= len(model_dict):
|
| 436 |
+
name = list(model_dict)[num - 1]
|
| 437 |
+
selected_models.extend(model_dict[name])
|
| 438 |
+
|
| 439 |
+
unique_models = list({model['name']: model for model in selected_models}.values())
|
| 440 |
+
|
| 441 |
+
for model in unique_models:
|
| 442 |
+
model['dst_dir'] = dst_dir
|
| 443 |
+
|
| 444 |
+
return unique_models
|
| 445 |
+
|
| 446 |
+
submodels += add_submodels(Model, Model_Num, model_list, models_dir) # model
|
| 447 |
+
submodels += add_submodels(Vae, Vae_Num, vae_list, vaes_dir) # vae
|
| 448 |
+
submodels += add_submodels(controlnet, "" if controlnet == "ALL" else controlnet_Num, controlnet_list, control_dir) # controlnet
|
| 449 |
+
|
| 450 |
+
for submodel in submodels:
|
| 451 |
+
if not Inpainting_Model and "inpainting" in submodel['name']:
|
| 452 |
+
continue
|
| 453 |
+
url += f"{submodel['url']} {submodel['dst_dir']} {submodel['name']}, "
|
| 454 |
+
|
| 455 |
+
''' file.txt - added urls '''
|
| 456 |
+
|
| 457 |
+
unique_urls = []
|
| 458 |
+
|
| 459 |
+
def process_file_download(file_url):
|
| 460 |
+
if file_url.startswith("http"):
|
| 461 |
+
if "blob" in file_url:
|
| 462 |
+
file_url = file_url.replace("blob", "raw")
|
| 463 |
+
response = requests.get(file_url)
|
| 464 |
+
lines = response.text.split('\n')
|
| 465 |
+
else:
|
| 466 |
+
with open(file_url, 'r') as file:
|
| 467 |
+
lines = file.readlines()
|
| 468 |
+
|
| 469 |
+
current_tag = None
|
| 470 |
+
for line in lines:
|
| 471 |
+
if any(f'# {tag}' in line.lower() for tag in prefixes):
|
| 472 |
+
current_tag = next((tag for tag in prefixes if tag in line.lower()))
|
| 473 |
+
|
| 474 |
+
urls = [url.strip() for url in line.split(',')]
|
| 475 |
+
for url in urls:
|
| 476 |
+
if url.startswith("http") and url not in unique_urls:
|
| 477 |
+
globals()[prefixes[current_tag][1]] += ", " + url
|
| 478 |
+
unique_urls.append(url)
|
| 479 |
+
|
| 480 |
+
# fix all possible errors/options and function call
|
| 481 |
+
if custom_file_urls:
|
| 482 |
+
for custom_file_url in custom_file_urls.replace(',', '').split():
|
| 483 |
+
if not custom_file_url.endswith('.txt'):
|
| 484 |
+
custom_file_url += '.txt'
|
| 485 |
+
if not custom_file_url.startswith('http'):
|
| 486 |
+
if not custom_file_url.startswith(root_path):
|
| 487 |
+
custom_file_url = f'{root_path}/{custom_file_url}'
|
| 488 |
+
|
| 489 |
+
try:
|
| 490 |
+
process_file_download(custom_file_url)
|
| 491 |
+
except FileNotFoundError:
|
| 492 |
+
pass
|
| 493 |
+
|
| 494 |
+
# url prefixing
|
| 495 |
+
urls = [globals()[urls[1]] for urls in prefixes.values()]
|
| 496 |
+
for i, prefix in enumerate(prefixes):
|
| 497 |
+
if urls[i]:
|
| 498 |
+
prefixed_urls = [f"{prefix}:{url}" for url in urls[i].replace(',', '').split()]
|
| 499 |
+
if prefixed_urls:
|
| 500 |
+
url += ", ".join(prefixed_urls) + ", "
|
| 501 |
+
|
| 502 |
+
if detailed_download == "on":
|
| 503 |
+
print("\n\n\033[33m# ====== Подробная Загрузка ====== #\n\033[0m")
|
| 504 |
+
download(url)
|
| 505 |
+
print("\n\033[33m# =============================== #\n\033[0m")
|
| 506 |
+
else:
|
| 507 |
+
with capture.capture_output() as cap:
|
| 508 |
+
download(url)
|
| 509 |
+
del cap
|
| 510 |
+
|
| 511 |
+
print("\r🏁 Скачивание Завершено!" + " "*15)
|
| 512 |
+
|
| 513 |
+
|
| 514 |
+
# Cleaning shit after downloading...
|
| 515 |
+
get_ipython().system('find {webui_path} \\( -type d \\( -name ".ipynb_checkpoints" -o -name ".aria2" \\) -o -type f -name "*.aria2" \\) -exec rm -r {{}} \\; >/dev/null 2>&1')
|
| 516 |
+
|
| 517 |
+
|
| 518 |
+
## Install of Custom extensions
|
| 519 |
+
if len(extension_repo) > 0:
|
| 520 |
+
print("✨ Устанвока кастомных расширений...", end='', flush=True)
|
| 521 |
+
with capture.capture_output() as cap:
|
| 522 |
+
for repo, repo_name in extension_repo:
|
| 523 |
+
if not repo_name:
|
| 524 |
+
repo_name = repo.split('/')[-1]
|
| 525 |
+
get_ipython().system('cd {extensions_dir} && git clone {repo} {repo_name} && cd {repo_name} && git fetch')
|
| 526 |
+
del cap
|
| 527 |
+
print(f"\r📦 Установлено '{len(extension_repo)}', Кастомных расширений!")
|
| 528 |
+
|
| 529 |
+
|
| 530 |
+
## List Models and stuff
|
| 531 |
+
if detailed_download == "off":
|
| 532 |
+
print("\n\n\033[33mЕсли вы не видете каких-то скаченных файлов, включите в виджетах функцию 'Подробная Загрузка'.")
|
| 533 |
+
|
| 534 |
+
if any(not file.endswith('.txt') for file in os.listdir(models_dir)):
|
| 535 |
+
print("\n\033[33m➤ Models\033[0m")
|
| 536 |
+
get_ipython().system("find {models_dir}/ -mindepth 1 ! -name '*.txt' -printf '%f\\n'")
|
| 537 |
+
if any(not file.endswith('.txt') for file in os.listdir(vaes_dir)):
|
| 538 |
+
print("\n\033[33m➤ VAEs\033[0m")
|
| 539 |
+
get_ipython().system("find {vaes_dir}/ -mindepth 1 ! -name '*.txt' -printf '%f\\n'")
|
| 540 |
+
if any(not file.endswith('.txt') and not os.path.isdir(os.path.join(embeddings_dir, file)) for file in os.listdir(embeddings_dir)):
|
| 541 |
+
print("\n\033[33m➤ Embeddings\033[0m")
|
| 542 |
+
get_ipython().system("find {embeddings_dir}/ -mindepth 1 -maxdepth 1 \\( -name '*.pt' -or -name '*.safetensors' \\) -printf '%f\\n'")
|
| 543 |
+
if any(not file.endswith('.txt') for file in os.listdir(loras_dir)):
|
| 544 |
+
print("\n\033[33m➤ LoRAs\033[0m")
|
| 545 |
+
get_ipython().system("find {loras_dir}/ -mindepth 1 ! -name '*.keep' -printf '%f\\n'")
|
| 546 |
+
print(f"\n\033[33m➤ Extensions\033[0m")
|
| 547 |
+
get_ipython().system("find {extensions_dir}/ -mindepth 1 -maxdepth 1 ! -name '*.txt' -printf '%f\\n'")
|
| 548 |
+
if any(not file.endswith(('.txt', '.yaml')) for file in os.listdir(control_dir)):
|
| 549 |
+
print("\n\033[33m➤ ControlNet\033[0m")
|
| 550 |
+
get_ipython().system("find {control_dir}/ -mindepth 1 ! -name '*.yaml' -printf '%f\\n' | sed 's/^[^_]*_[^_]*_[^_]*_\\(.*\\)_fp16\\.safetensors$/\\1/'")
|
| 551 |
+
|
| 552 |
+
|
| 553 |
+
# === OTHER ===
|
| 554 |
+
# Downlaod discord tags UmiWildcards
|
| 555 |
+
files_umi = [
|
| 556 |
+
"https://huggingface.co/NagisaNao/fast_repo/resolve/main/extensions/UmiWildacrd/discord/200_pan_gen.txt",
|
| 557 |
+
"https://huggingface.co/NagisaNao/fast_repo/resolve/main/extensions/UmiWildacrd/discord/150_bra_gen.txt"
|
| 558 |
+
]
|
| 559 |
+
save_dir_path = f"{webui_path}/extensions/Umi-AI-Wildcards/wildcards/discord"
|
| 560 |
+
|
| 561 |
+
with capture.capture_output() as cap:
|
| 562 |
+
for file in files_umi:
|
| 563 |
+
get_ipython().system('aria2c --optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -j5 -x16 -s16 -k1M -c -d {save_dir_path} {file}')
|
| 564 |
+
del cap
|
| 565 |
+
|
| 566 |
+
|
| 567 |
+
# === CLEAR SAGEMAKER ===
|
| 568 |
+
with capture.capture_output() as cap:
|
| 569 |
+
get_ipython().system('rm -rf ~/.conda/envs/studiolab-safemode')
|
| 570 |
+
get_ipython().system('rm -rf ~/.conda/envs/sagemaker-distribution')
|
| 571 |
+
get_ipython().system('rm -rf ~/.conda/pkgs/cache')
|
| 572 |
+
get_ipython().system('pip cache purge')
|
| 573 |
+
get_ipython().system('rm -rf ~/.cache')
|
| 574 |
+
get_ipython().system('conda clean -y --all')
|
| 575 |
+
del cap
|
launch_cn.py
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
##~ WIDGET CODE | Special for SageMaker | BY: ANXETY ~##
|
| 2 |
+
|
| 3 |
+
import os
|
| 4 |
+
import re
|
| 5 |
+
import time
|
| 6 |
+
import json
|
| 7 |
+
import requests
|
| 8 |
+
from datetime import timedelta
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
root_path = "/home/studio-lab-user/content"
|
| 12 |
+
webui_path = f"{root_path}/sdw"
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def load_settings():
|
| 16 |
+
SETTINGS_FILE = f'{root_path}/settings.json'
|
| 17 |
+
if os.path.exists(SETTINGS_FILE):
|
| 18 |
+
with open(SETTINGS_FILE, 'r') as f:
|
| 19 |
+
settings = json.load(f)
|
| 20 |
+
return settings
|
| 21 |
+
|
| 22 |
+
settings = load_settings()
|
| 23 |
+
ngrok_token = settings['ngrok_token']
|
| 24 |
+
zrok_token = settings['zrok_token']
|
| 25 |
+
commandline_arguments = settings['commandline_arguments']
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
# automatic fixing path V2
|
| 29 |
+
get_ipython().system('sed -i \'s#"tagger_hf_cache_dir": ".*models/interrogators"#"tagger_hf_cache_dir": "{root_path}/sdw/models/interrogators"#\' {webui_path}/config.json')
|
| 30 |
+
get_ipython().system('sed -i \'s#"additional_networks_extra_lora_path": ".*models/Lora/"#"additional_networks_extra_lora_path": "{root_path}/sdw/models/Lora/"#\' {webui_path}/config.json')
|
| 31 |
+
# ---
|
| 32 |
+
get_ipython().system('sed -i \'s/"sd_vae":.*/"sd_vae": "None",/; s/"sd_model_checkpoint":.*/"sd_model_checkpoint": "None",/; s/"sd_checkpoint_hash":.*/"sd_checkpoint_hash": "None",/\' {webui_path}/config.json')
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
get_ipython().run_line_magic('cd', '{webui_path}')
|
| 36 |
+
commandline_arguments += f" --port=1769"
|
| 37 |
+
|
| 38 |
+
if ngrok_token or zrok_token:
|
| 39 |
+
if ngrok_token:
|
| 40 |
+
commandline_arguments += ' --ngrok ' + ngrok_token
|
| 41 |
+
|
| 42 |
+
if zrok_token:
|
| 43 |
+
get_ipython().system(f'python ~/content/special/zrok3.py {zrok_token} {commandline_arguments}')
|
| 44 |
+
|
| 45 |
+
else:
|
| 46 |
+
get_ipython().system(f'COMMANDLINE_ARGS="{commandline_arguments}" python launch.py')
|
| 47 |
+
|
| 48 |
+
start_colab = float(open(f'{webui_path}/static/colabTimer.txt', 'r').read())
|
| 49 |
+
time_since_start = str(timedelta(seconds=time.time()-start_colab)).split('.')[0]
|
| 50 |
+
print(f"\n⌚️ \033[0mВы проводите эту сессию в течение - \033[33m{time_since_start}\033[0m\n\n")
|
| 51 |
+
|
| 52 |
+
else:
|
| 53 |
+
print("Not found tokens: Zrok/Ngrok")
|
widgets_cn.py
ADDED
|
@@ -0,0 +1,582 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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ANXETY ~##
|
| 2 |
+
|
| 3 |
+
import os
|
| 4 |
+
import json
|
| 5 |
+
import time
|
| 6 |
+
import ipywidgets as widgets
|
| 7 |
+
from ipywidgets import widgets, Layout, Label, Button, VBox, HBox
|
| 8 |
+
from IPython.display import display, HTML, Javascript, clear_output
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
root_path = "/home/studio-lab-user/content"
|
| 12 |
+
webui_path = f"{root_path}/sdw"
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
# ==================== CSS JS ====================
|
| 16 |
+
# custom background images V1.5
|
| 17 |
+
import argparse
|
| 18 |
+
parser = argparse.ArgumentParser(description='This script processes an background image.')
|
| 19 |
+
parser.add_argument('-i', '--image', type=str, help='URL of the image to process', metavar='')
|
| 20 |
+
parser.add_argument('-o', '--opacity', type=float, help='Opacity level for the image, between 0 and 1', metavar='', default=0.3)
|
| 21 |
+
parser.add_argument('-b', '--blur', type=str, help='Blur level for the image', metavar='', default=0)
|
| 22 |
+
parser.add_argument('-y', type=int, help='Y coordinate for the image in px', metavar='', default=0)
|
| 23 |
+
parser.add_argument('-x', type=int, help='X coordinate for the image in px', metavar='', default=0)
|
| 24 |
+
parser.add_argument('-s', '--scale', type=int, help='Scale image in %%', metavar='', default=100)
|
| 25 |
+
parser.add_argument('-m', '--mode',action='store_true', help='Removes repetitive image tiles')
|
| 26 |
+
parser.add_argument('-t', '--transparent', action='store_true', help='Makes input/selection fields 35%% more transparent')
|
| 27 |
+
parser.add_argument('-bf', '--blur-fields', type=str, help='Background blur level for input/selection fields', metavar='', default=2)
|
| 28 |
+
args = parser.parse_args()
|
| 29 |
+
"""---"""
|
| 30 |
+
url_img = args.image
|
| 31 |
+
opacity_img = args.opacity
|
| 32 |
+
blur_img = args.blur
|
| 33 |
+
y_img = args.y
|
| 34 |
+
x_img = args.x
|
| 35 |
+
scale_img = args.scale
|
| 36 |
+
blur_fields = args.blur_fields
|
| 37 |
+
|
| 38 |
+
## ---
|
| 39 |
+
fix_heigh_img = "-810px"
|
| 40 |
+
|
| 41 |
+
""" transperent fields """
|
| 42 |
+
t_bg_alpha = "1" if not args.transparent else "0.65"
|
| 43 |
+
|
| 44 |
+
""" mode img - repeats """
|
| 45 |
+
mode_img = "repeat" if not args.mode else "no-repeat"
|
| 46 |
+
## ---
|
| 47 |
+
|
| 48 |
+
container_background = f'''
|
| 49 |
+
<style>
|
| 50 |
+
:root {{
|
| 51 |
+
/* for background container*/
|
| 52 |
+
--img_background: url({url_img});
|
| 53 |
+
--img_opacity: {opacity_img};
|
| 54 |
+
--img_blur: {blur_img}px;
|
| 55 |
+
--image_y: {y_img}px;
|
| 56 |
+
--image_x: {x_img}px;
|
| 57 |
+
--img_scale: {scale_img}%;
|
| 58 |
+
--img_mode: {mode_img};
|
| 59 |
+
--img_height_dif: {fix_heigh_img};
|
| 60 |
+
|
| 61 |
+
/* for fields */
|
| 62 |
+
--bg-field-color: rgba(28, 28, 28, {t_bg_alpha}); /* -> #1c1c1c */
|
| 63 |
+
--bg-field-color-hover: rgba(38, 38, 38, {t_bg_alpha}); /* -> #262626; */
|
| 64 |
+
--bg-field-blur-level: {blur_fields}px;
|
| 65 |
+
}}
|
| 66 |
+
'''
|
| 67 |
+
|
| 68 |
+
display(HTML(container_background))
|
| 69 |
+
# ---
|
| 70 |
+
|
| 71 |
+
CSS = '''
|
| 72 |
+
<style>
|
| 73 |
+
/* General Styles */
|
| 74 |
+
.header {
|
| 75 |
+
font-family: cursive;
|
| 76 |
+
font-size: 20px;
|
| 77 |
+
font-weight: bold;
|
| 78 |
+
color: #ff8cee;
|
| 79 |
+
margin-bottom: 15px;
|
| 80 |
+
user-select: none;
|
| 81 |
+
cursor: default;
|
| 82 |
+
display: inline-block;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
hr {
|
| 86 |
+
border-color: grey;
|
| 87 |
+
background-color: grey;
|
| 88 |
+
opacity: 0.25;
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
a {
|
| 92 |
+
text-decoration: none;
|
| 93 |
+
color: inherit;
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
/* Container style */
|
| 98 |
+
|
| 99 |
+
.container {
|
| 100 |
+
position: relative;
|
| 101 |
+
background-color: #232323;
|
| 102 |
+
width: 1080px;
|
| 103 |
+
padding: 10px 15px;
|
| 104 |
+
border-radius: 15px;
|
| 105 |
+
box-shadow: 0 0 50px rgba(0, 0, 0, 0.3);
|
| 106 |
+
margin-bottom: 5px;
|
| 107 |
+
overflow: hidden;
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
.container::after {
|
| 111 |
+
position: absolute;
|
| 112 |
+
top: 5px;
|
| 113 |
+
right: 10px;
|
| 114 |
+
content: "ANXETY";
|
| 115 |
+
font-weight: bold;
|
| 116 |
+
font-size: 24px;
|
| 117 |
+
color: rgba(0, 0, 0, 0.2);
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
/* background img */
|
| 121 |
+
.container::before {
|
| 122 |
+
content: "";
|
| 123 |
+
position: absolute;
|
| 124 |
+
top: 0;
|
| 125 |
+
left: 0;
|
| 126 |
+
right: 0;
|
| 127 |
+
bottom: 0;
|
| 128 |
+
background-image: var(--img_background);
|
| 129 |
+
background-size: var(--img_scale);
|
| 130 |
+
background-repeat: var(--img_mode);
|
| 131 |
+
opacity: var(--img_opacity);
|
| 132 |
+
mix-blend-mode: screen;
|
| 133 |
+
pointer-events: none;
|
| 134 |
+
filter: blur(var(--img_blur));
|
| 135 |
+
z-index: -1;
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
.image_1::before {
|
| 139 |
+
background-position: var(--image_x) calc(-120px - var(--image_y));
|
| 140 |
+
}
|
| 141 |
+
.image_2::before {
|
| 142 |
+
background-position: var(--image_x) calc(-290px - var(--image_y));
|
| 143 |
+
}
|
| 144 |
+
.image_3::before {
|
| 145 |
+
background-position: var(--image_x) calc(-430px - var(--image_y));
|
| 146 |
+
}
|
| 147 |
+
.image_4::before {
|
| 148 |
+
background-position: var(--image_x) calc(var(--img_height_dif) - var(--image_y));
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
.container_custom_downlad {
|
| 152 |
+
height: 55px;
|
| 153 |
+
transition: all 0.5s;
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
.container_custom_downlad.expanded {
|
| 157 |
+
height: 270px;
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
/* Element text style */
|
| 162 |
+
|
| 163 |
+
.widget-html,
|
| 164 |
+
.widget-button,
|
| 165 |
+
.widget-text label,
|
| 166 |
+
.widget-checkbox label,
|
| 167 |
+
.widget-dropdown label,
|
| 168 |
+
.widget-dropdown select,
|
| 169 |
+
.widget-text input[type="text"] {
|
| 170 |
+
font-family: cursive;
|
| 171 |
+
font-size: 14px;
|
| 172 |
+
color: white !important;
|
| 173 |
+
user-select: none;
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
.widget-text input[type="text"]::placeholder {
|
| 177 |
+
color: grey;
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
|
| 181 |
+
/* Input field styles */
|
| 182 |
+
|
| 183 |
+
.widget-dropdown select,
|
| 184 |
+
.widget-text input[type="text"] {
|
| 185 |
+
height: 30px;
|
| 186 |
+
background-color: var(--bg-field-color);
|
| 187 |
+
border: 1px solid #262626;
|
| 188 |
+
border-radius: 10px;
|
| 189 |
+
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
|
| 190 |
+
transition: all 0.3s ease-in-out;
|
| 191 |
+
backdrop-filter: blur(var(--bg-field-blur-level));
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
.widget-dropdown select:focus,
|
| 195 |
+
.widget-text input[type="text"]:focus {
|
| 196 |
+
border-color: #006ee5;
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
.widget-dropdown select:hover,
|
| 200 |
+
.widget-text input[type="text"]:hover {
|
| 201 |
+
transform: scale(1.003);
|
| 202 |
+
background-color: var(--bg-field-color-hover);
|
| 203 |
+
box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
.widget-dropdown option {
|
| 207 |
+
background-color: #1c1c1c;
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
|
| 211 |
+
/* Slider Checkbox style */
|
| 212 |
+
|
| 213 |
+
.widget-checkbox input[type="checkbox"] {
|
| 214 |
+
appearance: none;
|
| 215 |
+
position: relative;
|
| 216 |
+
top: 4px; /* Why is he taller?! */
|
| 217 |
+
width: 40px;
|
| 218 |
+
height: 20px;
|
| 219 |
+
border: none;
|
| 220 |
+
border-radius: 10px;
|
| 221 |
+
background-color: #20b2aa;
|
| 222 |
+
cursor: pointer;
|
| 223 |
+
box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.3);
|
| 224 |
+
transition: background-color 0.3s ease;
|
| 225 |
+
}
|
| 226 |
+
.widget-checkbox input[type="checkbox"]:checked {
|
| 227 |
+
background-color: #2196F3;
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
.widget-checkbox input[type="checkbox"]:before {
|
| 231 |
+
content: '';
|
| 232 |
+
position: absolute;
|
| 233 |
+
top: 50%;
|
| 234 |
+
left: 3px;
|
| 235 |
+
width: 16px;
|
| 236 |
+
height: 16px;
|
| 237 |
+
border-radius: inherit;
|
| 238 |
+
background-color: white;
|
| 239 |
+
box-shadow: 0 0 8px rgba(0, 0, 0, 0.3);
|
| 240 |
+
transform: translateY(-50%);
|
| 241 |
+
transition: left 0.3s ease;
|
| 242 |
+
}
|
| 243 |
+
.widget-checkbox input[type="checkbox"]:checked:before {
|
| 244 |
+
left: 21px;
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
|
| 248 |
+
/* Button styles */
|
| 249 |
+
|
| 250 |
+
.button_save {
|
| 251 |
+
font-size: 15px;
|
| 252 |
+
font-weight: bold;
|
| 253 |
+
width: 120px;
|
| 254 |
+
height: 35px;
|
| 255 |
+
border-radius: 15px;
|
| 256 |
+
background-image: radial-gradient(circle at top left, purple 10%, violet 90%);
|
| 257 |
+
background-size: 200% 200%;
|
| 258 |
+
background-position: left bottom;
|
| 259 |
+
transition: background 0.5s ease-in-out, transform 0.3s ease;
|
| 260 |
+
}
|
| 261 |
+
|
| 262 |
+
.button_save:hover {
|
| 263 |
+
cursor: pointer;
|
| 264 |
+
background-image: radial-gradient(circle at top left, purple 10%, #93ac47 90%);
|
| 265 |
+
background-size: 200% 200%;
|
| 266 |
+
background-position: right bottom;
|
| 267 |
+
transform: translateY(1px);
|
| 268 |
+
}
|
| 269 |
+
|
| 270 |
+
.button_ngrok {
|
| 271 |
+
font-size: 12px;
|
| 272 |
+
height: 30px;
|
| 273 |
+
border-radius: 10px;
|
| 274 |
+
padding: 1px 12px;
|
| 275 |
+
background-image: radial-gradient(circle at top left, purple 10%, violet 90%);
|
| 276 |
+
background-size: 200% 200%;
|
| 277 |
+
background-position: left bottom;
|
| 278 |
+
transition: background 0.5s ease-in-out, transform 0.3s ease;
|
| 279 |
+
white-space: nowrap;
|
| 280 |
+
}
|
| 281 |
+
|
| 282 |
+
.button_ngrok:hover {
|
| 283 |
+
cursor: pointer;
|
| 284 |
+
background-image: radial-gradient(circle at top left, purple 10%, #1D94BB 90%);
|
| 285 |
+
background-size: 200% 200%;
|
| 286 |
+
background-position: right bottom;
|
| 287 |
+
transform: translateY(1px);
|
| 288 |
+
}
|
| 289 |
+
|
| 290 |
+
.button_save:active,
|
| 291 |
+
.button_ngrok:active {
|
| 292 |
+
filter: brightness(0.75) !important;
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
/* Removes ugly stroke from widget buttons. */
|
| 296 |
+
.jupyter-widgets.lm-Widget:focus {
|
| 297 |
+
outline: none;
|
| 298 |
+
}
|
| 299 |
+
|
| 300 |
+
|
| 301 |
+
/* Popup style of `INFO` window */
|
| 302 |
+
|
| 303 |
+
.info {
|
| 304 |
+
position: absolute;
|
| 305 |
+
top: -5px;
|
| 306 |
+
right: 95px;
|
| 307 |
+
color: grey;
|
| 308 |
+
font-family: cursive;
|
| 309 |
+
font-size: 14px;
|
| 310 |
+
font-weight: normal;
|
| 311 |
+
user-select: none;
|
| 312 |
+
pointer-events: none;
|
| 313 |
+
opacity: 0;
|
| 314 |
+
transition: opacity 0.3s ease-in-out;
|
| 315 |
+
display: inline-block;
|
| 316 |
+
}
|
| 317 |
+
|
| 318 |
+
.popup {
|
| 319 |
+
position: absolute;
|
| 320 |
+
top: 120px;
|
| 321 |
+
z-index: 999;
|
| 322 |
+
width: auto;
|
| 323 |
+
padding: 10px;
|
| 324 |
+
text-align: center;
|
| 325 |
+
background-color: rgba(255, 255, 255, 0.05);
|
| 326 |
+
backdrop-filter: blur(20px);
|
| 327 |
+
border: 1px solid rgba(255, 255, 255, 0.45);
|
| 328 |
+
border-radius: 8px;
|
| 329 |
+
box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
|
| 330 |
+
opacity: 0;
|
| 331 |
+
color: #fff;
|
| 332 |
+
font-size: 16px;
|
| 333 |
+
font-family: cursive;
|
| 334 |
+
user-select: none;
|
| 335 |
+
cursor: default;
|
| 336 |
+
pointer-events: none;
|
| 337 |
+
transform: rotate(-5deg);
|
| 338 |
+
transition: top 0.3s ease-in-out, opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
|
| 339 |
+
}
|
| 340 |
+
|
| 341 |
+
.sample {
|
| 342 |
+
display: inline-block;
|
| 343 |
+
margin-top: 25px;
|
| 344 |
+
padding: 10px 100px;
|
| 345 |
+
background-color: rgba(255, 255, 255, 0.2);
|
| 346 |
+
color: #c6e2ff;
|
| 347 |
+
border: 2px solid rgba(255, 255, 255, 0.2);
|
| 348 |
+
border-radius: 8px;
|
| 349 |
+
box-shadow: 0 0 10px rgba(255, 255, 255, 0.2), inset 0 0 25px rgba(255, 255, 255, 0.2);
|
| 350 |
+
}
|
| 351 |
+
|
| 352 |
+
.info.showed {
|
| 353 |
+
opacity: 1;
|
| 354 |
+
pointer-events: auto;
|
| 355 |
+
}
|
| 356 |
+
|
| 357 |
+
.info:hover + .popup {
|
| 358 |
+
top: 35px;
|
| 359 |
+
opacity: 1;
|
| 360 |
+
pointer-events: initial;
|
| 361 |
+
transform: rotate(0deg);
|
| 362 |
+
}
|
| 363 |
+
|
| 364 |
+
|
| 365 |
+
/* Animation of elements */
|
| 366 |
+
|
| 367 |
+
.container,
|
| 368 |
+
.button_save {
|
| 369 |
+
animation-name: showedWidgets;
|
| 370 |
+
animation-duration: 1s;
|
| 371 |
+
animation-fill-mode: forwards;
|
| 372 |
+
}
|
| 373 |
+
|
| 374 |
+
.container.hide,
|
| 375 |
+
.button_save.hide {
|
| 376 |
+
animation-name: hideWidgets;
|
| 377 |
+
animation-duration: 0.5s;
|
| 378 |
+
animation-fill-mode: forwards;
|
| 379 |
+
}
|
| 380 |
+
|
| 381 |
+
@keyframes showedWidgets {
|
| 382 |
+
0% {
|
| 383 |
+
transform: translate3d(-65%, 15%, 0) scale(0) rotate(15deg);
|
| 384 |
+
filter: blur(25px) grayscale(1) brightness(0.3);
|
| 385 |
+
opacity: 0;
|
| 386 |
+
}
|
| 387 |
+
100% {
|
| 388 |
+
transform: translate3d(0, 0, 0) scale(1) rotate(0deg);
|
| 389 |
+
filter: blur(0) grayscale(0) brightness(1);
|
| 390 |
+
opacity: 1;
|
| 391 |
+
}
|
| 392 |
+
}
|
| 393 |
+
|
| 394 |
+
@keyframes hideWidgets {
|
| 395 |
+
0% {
|
| 396 |
+
transform: translate3d(0, 0, 0) scale(1) rotate3d(1, 0, 0, 0deg);
|
| 397 |
+
filter: blur(0) grayscale(0) brightness(1);
|
| 398 |
+
opacity: 1;
|
| 399 |
+
}
|
| 400 |
+
100% {
|
| 401 |
+
transform: translate3d(0, 5%, 0) scale(0.9) rotate3d(1, 0, 0, 90deg);
|
| 402 |
+
filter: blur(15px) grayscale(1) brightness(0.5);
|
| 403 |
+
opacity: 0;
|
| 404 |
+
}
|
| 405 |
+
}
|
| 406 |
+
</style>
|
| 407 |
+
|
| 408 |
+
<!-- TOGGLE 'CustomDL' SCRIPT -->
|
| 409 |
+
<script>
|
| 410 |
+
function toggleContainer() {
|
| 411 |
+
let downloadContainer = document.querySelector('.container_custom_downlad');
|
| 412 |
+
let info = document.querySelector('.info');
|
| 413 |
+
|
| 414 |
+
downloadContainer.classList.toggle('expanded');
|
| 415 |
+
info.classList.toggle('showed');
|
| 416 |
+
}
|
| 417 |
+
</script>
|
| 418 |
+
'''
|
| 419 |
+
|
| 420 |
+
display(HTML(CSS))
|
| 421 |
+
# ==================== CSS JS ====================
|
| 422 |
+
|
| 423 |
+
|
| 424 |
+
# ==================== WIDGETS ====================
|
| 425 |
+
# --- global widgets ---
|
| 426 |
+
style = {'description_width': 'initial'}
|
| 427 |
+
layout = widgets.Layout(min_width='1047px')
|
| 428 |
+
|
| 429 |
+
HR = widgets.HTML('<hr>')
|
| 430 |
+
|
| 431 |
+
# --- MODEL ---
|
| 432 |
+
model_header = widgets.HTML('<div class="header">Выбор Модели<div>')
|
| 433 |
+
model_options = ['none',
|
| 434 |
+
'1.Anime (by XpucT) + INP',
|
| 435 |
+
'2.BluMix [Anime] [V7] + INP',
|
| 436 |
+
'3.Cetus-Mix [Anime] [V4] + INP',
|
| 437 |
+
'4.Counterfeit [Anime] [V3] + INP',
|
| 438 |
+
'5.CuteColor [Anime] [V3]',
|
| 439 |
+
'6.Dark-Sushi-Mix [Anime]',
|
| 440 |
+
'7.Deliberate [Realism] [V6] + INP',
|
| 441 |
+
'8.Meina-Mix [Anime] [V11] + INP',
|
| 442 |
+
'9.Mix-Pro [Anime] [V4] + INP']
|
| 443 |
+
# ---
|
| 444 |
+
Model_widget = widgets.Dropdown(options=model_options, value='4.Counterfeit [Anime] [V3] + INP', description='Модель:', style=style, layout=layout)
|
| 445 |
+
Model_Num_widget = widgets.Text(description='Номер Модели:', placeholder='Введите номера моделей для скачивания через запятую/пробел.', style=style, layout=layout)
|
| 446 |
+
Inpainting_Model_widget = widgets.Checkbox(value=False, description='Inpainting Модели', style=style)
|
| 447 |
+
|
| 448 |
+
''' Display Model'''
|
| 449 |
+
all_model_box = widgets.VBox([model_header, Model_widget, Model_Num_widget, Inpainting_Model_widget]).add_class("container").add_class("image_1")
|
| 450 |
+
display(all_model_box)
|
| 451 |
+
|
| 452 |
+
# --- VAE ---
|
| 453 |
+
vae_header = widgets.HTML('<div class="header" >Выбор VAE</div>')
|
| 454 |
+
vae_options = ['none',
|
| 455 |
+
'1.Anime.vae',
|
| 456 |
+
'2.Anything.vae',
|
| 457 |
+
'3.Blessed2.vae',
|
| 458 |
+
'4.ClearVae.vae',
|
| 459 |
+
'5.WD.vae']
|
| 460 |
+
Vae_widget = widgets.Dropdown(options=vae_options, value='3.Blessed2.vae', description='Vae:', style=style, layout=layout)
|
| 461 |
+
Vae_Num_widget = widgets.Text(description='Номер Vae:', placeholder='Введите номера vae для скачивания через запятую/пробел.', style=style, layout=layout)
|
| 462 |
+
|
| 463 |
+
''' Display Vae'''
|
| 464 |
+
all_vae_box= widgets.VBox([vae_header, Vae_widget, Vae_Num_widget]).add_class("container").add_class("image_2")
|
| 465 |
+
display(all_vae_box)
|
| 466 |
+
|
| 467 |
+
# --- ADDITIONAL ---
|
| 468 |
+
additional_header = widgets.HTML('<div class="header">Дополнительно</div>')
|
| 469 |
+
latest_webui_widget = widgets.Checkbox(value=True, description='Обновить WebUI', style=style)
|
| 470 |
+
latest_exstensions_widget = widgets.Checkbox(value=True, description='Обновить Расширения', style=style)
|
| 471 |
+
temporary_files_widget = widgets.Checkbox(value=True, description='Временные Файлы', style=style)
|
| 472 |
+
detailed_download_widget = widgets.Dropdown(options=['off', 'on'], value='off', description='Подробная Загрузка:', style=style)
|
| 473 |
+
latest_changes_widget = HBox([latest_webui_widget, latest_exstensions_widget, temporary_files_widget, detailed_download_widget], layout=widgets.Layout(justify_content='space-between'))
|
| 474 |
+
controlnet_options = ['none', 'ALL', '1.canny',
|
| 475 |
+
'2.openpose', '3.depth',
|
| 476 |
+
'4.normal_map', '5.mlsd',
|
| 477 |
+
'6.lineart', '7.soft_edge',
|
| 478 |
+
'8.scribble', '9.segmentation',
|
| 479 |
+
'10.shuffle', '11.tile',
|
| 480 |
+
'12.inpaint', '13.instruct_p2p']
|
| 481 |
+
# ---
|
| 482 |
+
controlnet_widget = widgets.Dropdown(options=controlnet_options, value='none', description='ControlNet:', style=style, layout=layout)
|
| 483 |
+
controlnet_Num_widget = widgets.Text(description='Номер ControlNet:', placeholder='Введите номера моделей ControlNet для скачивания через запятую/пробел.', style=style, layout=layout)
|
| 484 |
+
commit_hash_widget = widgets.Text(description='Commit Hash:', style=style, layout=layout)
|
| 485 |
+
optional_huggingface_token_widget = widgets.Text(description='Токен HuggingFace:', style=style, layout=layout)
|
| 486 |
+
ngrok_token_widget = widgets.Text(description='Токен Ngrok:', style=style, layout=widgets.Layout(width='1047px'))
|
| 487 |
+
ngrock_button = widgets.HTML('<a href="https://dashboard.ngrok.com/get-started/your-authtoken" target="_blank">Получить Ngrok Токен</a>').add_class("button_ngrok")
|
| 488 |
+
ngrok_widget = widgets.HBox([ngrok_token_widget, ngrock_button], style=style, layout=layout)
|
| 489 |
+
zrok_token_widget = widgets.Text(description='Zrok Token:', style=style, layout=widgets.Layout(width='1047px'))
|
| 490 |
+
zrok_button = widgets.HTML('<a href="https://colab.research.google.com/drive/1d2sjWDJi_GYBUavrHSuQyHTDuLy36WpU" target="_blank">Зарегать Zrok Токен</a>').add_class("button_ngrok")
|
| 491 |
+
zrok_widget = widgets.HBox([zrok_token_widget, zrok_button], style=style, layout=layout)
|
| 492 |
+
# ---
|
| 493 |
+
commandline_arguments_options = "--listen --enable-insecure-extension-access --theme dark --no-half-vae --disable-console-progressbars --xformers"
|
| 494 |
+
commandline_arguments_widget = widgets.Text(description='Аргументы:', value=commandline_arguments_options, style=style, layout=layout)
|
| 495 |
+
|
| 496 |
+
''' Display Additional'''
|
| 497 |
+
additional_widget_list = [additional_header, latest_changes_widget, HR, controlnet_widget, controlnet_Num_widget, commit_hash_widget, optional_huggingface_token_widget, ngrok_widget, zrok_widget, HR, commandline_arguments_widget]
|
| 498 |
+
all_additional_box = widgets.VBox(additional_widget_list).add_class("container").add_class("image_3")
|
| 499 |
+
display(all_additional_box)
|
| 500 |
+
|
| 501 |
+
# --- CUSTOM DOWNLOAD ---
|
| 502 |
+
custom_download_header_popup = widgets.HTML('''
|
| 503 |
+
<style>
|
| 504 |
+
/* Color */
|
| 505 |
+
.sample_label {color: #dbafff;}
|
| 506 |
+
.braces {color: #ffff00;}
|
| 507 |
+
.extension {color: #eb934b;}
|
| 508 |
+
.file_name {color: #ffffd8;}
|
| 509 |
+
</style>
|
| 510 |
+
|
| 511 |
+
<div class="header" style="cursor: pointer;" onclick="toggleContainer()">Кастомная Загрузка</div>
|
| 512 |
+
<!-- PopUp window -->
|
| 513 |
+
<div class="info" id="info_dl">INFO</div>
|
| 514 |
+
<div class="popup">
|
| 515 |
+
Разделите несколько URL-адресов запятой/пробелом. Для <span class="file_name">пользовательского имени</span> файла/расширения укажите его через <span class="braces">[]</span>
|
| 516 |
+
после URL без пробелов.
|
| 517 |
+
<span style="color: #ff9999">Для файлов обязательно укажите</span> - <span class="extension">Расширение Файла.</span>
|
| 518 |
+
<div class="sample">
|
| 519 |
+
<span class="sample_label">Пример для Файла:</span>
|
| 520 |
+
https://civitai.com/api/download/models/229782<span class="braces">[</span><span class="file_name">Detailer</span><span class="extension">.safetensors</span><span class="braces">]</span>
|
| 521 |
+
<br>
|
| 522 |
+
<span class="sample_label">Пример для Расширения:</span>
|
| 523 |
+
https://github.com/hako-mikan/sd-webui-regional-prompter<span class="braces">[</span><span class="file_name">Regional-Prompter</span><span class="braces">]</span>
|
| 524 |
+
</div>
|
| 525 |
+
</div>
|
| 526 |
+
''')
|
| 527 |
+
# ---
|
| 528 |
+
Model_url_widget = widgets.Text(description='Model:', style=style, layout=layout)
|
| 529 |
+
Vae_url_widget = widgets.Text(description='Vae:', style=style, layout=layout)
|
| 530 |
+
LoRA_url_widget = widgets.Text(description='LoRa:', style=style, layout=layout)
|
| 531 |
+
Embedding_url_widget = widgets.Text(description='Embedding:', style=style, layout=layout)
|
| 532 |
+
Extensions_url_widget = widgets.Text(description='Extensions:', style=style, layout=layout)
|
| 533 |
+
custom_file_urls_widget = widgets.Text(description='Файл (txt):', style=style, layout=layout)
|
| 534 |
+
|
| 535 |
+
''' Display CustomDl'''
|
| 536 |
+
all_custom_box = widgets.VBox([
|
| 537 |
+
custom_download_header_popup, Model_url_widget, Vae_url_widget, LoRA_url_widget, Embedding_url_widget, Extensions_url_widget, custom_file_urls_widget
|
| 538 |
+
]).add_class("container").add_class("image_4").add_class("container_custom_downlad")
|
| 539 |
+
display(all_custom_box)
|
| 540 |
+
|
| 541 |
+
# --- Save Button ---
|
| 542 |
+
save_button = widgets.Button(description='Сохранить').add_class("button_save")
|
| 543 |
+
display(save_button)
|
| 544 |
+
|
| 545 |
+
|
| 546 |
+
# ============ Load / Save - Settings V2 ============
|
| 547 |
+
SETTINGS_FILE = f'{root_path}/settings.json'
|
| 548 |
+
|
| 549 |
+
settings_keys = [
|
| 550 |
+
'Model', 'Model_Num', 'Inpainting_Model',
|
| 551 |
+
'Vae', 'Vae_Num',
|
| 552 |
+
'latest_webui', 'latest_exstensions', 'temporary_files', 'detailed_download',
|
| 553 |
+
'controlnet', 'controlnet_Num', 'commit_hash', 'optional_huggingface_token',
|
| 554 |
+
'ngrok_token', 'zrok_token', 'commandline_arguments',
|
| 555 |
+
'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url', 'Extensions_url', 'custom_file_urls'
|
| 556 |
+
]
|
| 557 |
+
|
| 558 |
+
def save_settings():
|
| 559 |
+
settings = {key: globals()[f"{key}_widget"].value for key in settings_keys}
|
| 560 |
+
with open(SETTINGS_FILE, 'w') as f:
|
| 561 |
+
json.dump(settings, f, indent=2)
|
| 562 |
+
|
| 563 |
+
def load_settings():
|
| 564 |
+
if os.path.exists(SETTINGS_FILE):
|
| 565 |
+
with open(SETTINGS_FILE, 'r') as f:
|
| 566 |
+
settings = json.load(f)
|
| 567 |
+
for key in settings_keys:
|
| 568 |
+
globals()[f"{key}_widget"].value = settings.get(key)
|
| 569 |
+
|
| 570 |
+
def save_data(button):
|
| 571 |
+
save_settings()
|
| 572 |
+
|
| 573 |
+
# --- uhh - hide... ---
|
| 574 |
+
widgets_list = [all_model_box, all_vae_box, all_additional_box, all_custom_box, save_button]
|
| 575 |
+
for widget in widgets_list:
|
| 576 |
+
widget.add_class("hide")
|
| 577 |
+
time.sleep(0.5)
|
| 578 |
+
|
| 579 |
+
widgets.Widget.close_all()
|
| 580 |
+
|
| 581 |
+
settings = load_settings()
|
| 582 |
+
save_button.on_click(save_data)
|