🐛 Just in case
Browse files- files_cells/python/en/auto_cleaner_en.py +138 -138
- files_cells/python/en/downloading_en.py +1 -1
- files_cells/python/en/widgets_en.py +322 -322
- files_cells/python/ru/auto_cleaner_ru.py +138 -138
- files_cells/python/ru/downloading_ru.py +1 -1
- files_cells/python/ru/widgets_ru.py +322 -322
files_cells/python/en/auto_cleaner_en.py
CHANGED
@@ -1,138 +1,138 @@
|
|
1 |
-
##~ AutoCleaner V3.6 CODE | BY: ANXETY ~##
|
2 |
-
|
3 |
-
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, Javascript
|
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")
|
16 |
-
}
|
17 |
-
for env_var, (environment, path) in environments.items():
|
18 |
-
if env_var in os.environ:
|
19 |
-
return environment, path, free_plan
|
20 |
-
|
21 |
-
env, root_path, free_plan = detect_environment()
|
22 |
-
webui_path = f"{root_path}/sdw"
|
23 |
-
|
24 |
-
|
25 |
-
# ==================== CSS ====================
|
26 |
-
# Main CSS
|
27 |
-
css_file_path = f"{root_path}/CSS/auto_cleaner.css"
|
28 |
-
with open(css_file_path , "r") as f:
|
29 |
-
CSS_AC = f.read()
|
30 |
-
display(HTML(f"<style>{CSS_AC}</style>"))
|
31 |
-
|
32 |
-
|
33 |
-
# ================ AutoCleaner function ================
|
34 |
-
directories = {
|
35 |
-
"Images": f"{webui_path}/output",
|
36 |
-
"Models": f"{webui_path}/models/Stable-diffusion/",
|
37 |
-
"Vae": f"{webui_path}/models/VAE/",
|
38 |
-
"LoRa": f"{webui_path}/models/Lora/",
|
39 |
-
"ControlNet Models": f"{webui_path}/models/ControlNet/"
|
40 |
-
}
|
41 |
-
|
42 |
-
""" functions """
|
43 |
-
def clean_directory(directory):
|
44 |
-
deleted_files = 0
|
45 |
-
image_dir = directories['Images']
|
46 |
-
|
47 |
-
for root, dirs, files in os.walk(directory):
|
48 |
-
for file in files:
|
49 |
-
file_path = os.path.join(root, file)
|
50 |
-
|
51 |
-
if file.endswith(".txt"):
|
52 |
-
continue
|
53 |
-
if file.endswith((".safetensors", ".pt")) or root == image_dir: # fix for image counter
|
54 |
-
deleted_files += 1
|
55 |
-
|
56 |
-
os.remove(file_path)
|
57 |
-
return deleted_files
|
58 |
-
|
59 |
-
def update_memory_info():
|
60 |
-
disk_space = psutil.disk_usage(os.getcwd())
|
61 |
-
total = disk_space.total / (1024 ** 3)
|
62 |
-
used = disk_space.used / (1024 ** 3)
|
63 |
-
free = disk_space.free / (1024 ** 3)
|
64 |
-
|
65 |
-
storage_info.value = f'''
|
66 |
-
<div class="storage_info_AC">Total storage: {total:.2f} GB <span style="color: #555">|</span> Used: {used:.2f} GB <span style="color: #555">|</span> Free: {free:.2f} GB</div>
|
67 |
-
'''
|
68 |
-
|
69 |
-
def on_execute_button_press(button):
|
70 |
-
selected_cleaners = auto_cleaner_widget.value
|
71 |
-
deleted_files_dict = {}
|
72 |
-
|
73 |
-
for option in selected_cleaners:
|
74 |
-
if option in directories:
|
75 |
-
deleted_files_dict[option] = clean_directory(directories[option])
|
76 |
-
|
77 |
-
output.clear_output()
|
78 |
-
|
79 |
-
with output:
|
80 |
-
for message in generate_messages(deleted_files_dict):
|
81 |
-
message_widget = HTML(f'<p class="output_message_AC">{message}</p>')
|
82 |
-
display(message_widget)
|
83 |
-
|
84 |
-
update_memory_info()
|
85 |
-
|
86 |
-
def on_clear_button_press(button):
|
87 |
-
container.add_class("hide")
|
88 |
-
time.sleep(0.5)
|
89 |
-
widgets.Widget.close_all()
|
90 |
-
|
91 |
-
def generate_messages(deleted_files_dict):
|
92 |
-
messages = []
|
93 |
-
word_variants = {
|
94 |
-
"Images": "Images",
|
95 |
-
"Models": "Models",
|
96 |
-
"Vae": "Vae",
|
97 |
-
"LoRa": "LoRa",
|
98 |
-
"ControlNet Models": "ControlNet Models"
|
99 |
-
}
|
100 |
-
for key, value in deleted_files_dict.items():
|
101 |
-
object_word = word_variants.get(key)
|
102 |
-
messages.append(f"Deleted {value} {object_word}")
|
103 |
-
return messages
|
104 |
-
# ================ AutoCleaner function ================
|
105 |
-
|
106 |
-
|
107 |
-
# --- storage memory ---
|
108 |
-
import psutil
|
109 |
-
disk_space = psutil.disk_usage(os.getcwd())
|
110 |
-
total = disk_space.total / (1024 ** 3)
|
111 |
-
used = disk_space.used / (1024 ** 3)
|
112 |
-
free = disk_space.free / (1024 ** 3)
|
113 |
-
|
114 |
-
|
115 |
-
# UI Code
|
116 |
-
AutoCleaner_options = AutoCleaner_options = list(directories.keys())
|
117 |
-
instruction_label = widgets.HTML('''
|
118 |
-
<span class="instruction_AC">Use <span style="color: #B2B2B2;">ctrl</span> or <span style="color: #B2B2B2;">shift</span> for multiple selections.</span>
|
119 |
-
''')
|
120 |
-
auto_cleaner_widget = widgets.SelectMultiple(options=AutoCleaner_options, layout=widgets.Layout(width='auto')).add_class("custom-select-multiple_AC")
|
121 |
-
output = widgets.Output().add_class("output_AC")
|
122 |
-
# ---
|
123 |
-
execute_button = Button(description='Execute Cleaning').add_class("button_execute_AC").add_class("button_AC")
|
124 |
-
execute_button.on_click(on_execute_button_press)
|
125 |
-
clear_button = Button(description='Hide Widget').add_class("button_clear_AC").add_class("button_AC")
|
126 |
-
clear_button.on_click(on_clear_button_press)
|
127 |
-
# ---
|
128 |
-
storage_info = widgets.HTML(f'''
|
129 |
-
<div class="storage_info_AC">Total storage: {total:.2f} GB <span style="color: #555">|</span> Used: {used:.2f} GB <span style="color: #555">|</span> Free: {free:.2f} GB</div>
|
130 |
-
''')
|
131 |
-
# ---
|
132 |
-
buttons = widgets.HBox([execute_button, clear_button])
|
133 |
-
lower_information_panel = widgets.HBox([buttons, storage_info]).add_class("lower_information_panel_AC")
|
134 |
-
|
135 |
-
container = VBox([instruction_label, widgets.HTML('<hr>'), auto_cleaner_widget, output, widgets.HTML('<hr>'), lower_information_panel]).add_class("container_AC")
|
136 |
-
|
137 |
-
display(container)
|
138 |
-
|
|
|
1 |
+
##~ AutoCleaner V3.6 CODE | BY: ANXETY ~##
|
2 |
+
|
3 |
+
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, Javascript
|
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")
|
16 |
+
}
|
17 |
+
for env_var, (environment, path) in environments.items():
|
18 |
+
if env_var in os.environ:
|
19 |
+
return environment, path, free_plan
|
20 |
+
|
21 |
+
env, root_path, free_plan = detect_environment()
|
22 |
+
webui_path = f"{root_path}/sdw"
|
23 |
+
|
24 |
+
|
25 |
+
# ==================== CSS ====================
|
26 |
+
# Main CSS
|
27 |
+
css_file_path = f"{root_path}/CSS/auto_cleaner.css"
|
28 |
+
with open(css_file_path , "r") as f:
|
29 |
+
CSS_AC = f.read()
|
30 |
+
display(HTML(f"<style>{CSS_AC}</style>"))
|
31 |
+
|
32 |
+
|
33 |
+
# ================ AutoCleaner function ================
|
34 |
+
directories = {
|
35 |
+
"Images": f"{webui_path}/output",
|
36 |
+
"Models": f"{webui_path}/models/Stable-diffusion/",
|
37 |
+
"Vae": f"{webui_path}/models/VAE/",
|
38 |
+
"LoRa": f"{webui_path}/models/Lora/",
|
39 |
+
"ControlNet Models": f"{webui_path}/models/ControlNet/"
|
40 |
+
}
|
41 |
+
|
42 |
+
""" functions """
|
43 |
+
def clean_directory(directory):
|
44 |
+
deleted_files = 0
|
45 |
+
image_dir = directories['Images']
|
46 |
+
|
47 |
+
for root, dirs, files in os.walk(directory):
|
48 |
+
for file in files:
|
49 |
+
file_path = os.path.join(root, file)
|
50 |
+
|
51 |
+
if file.endswith(".txt"):
|
52 |
+
continue
|
53 |
+
if file.endswith((".safetensors", ".pt")) or root == image_dir: # fix for image counter
|
54 |
+
deleted_files += 1
|
55 |
+
|
56 |
+
os.remove(file_path)
|
57 |
+
return deleted_files
|
58 |
+
|
59 |
+
def update_memory_info():
|
60 |
+
disk_space = psutil.disk_usage(os.getcwd())
|
61 |
+
total = disk_space.total / (1024 ** 3)
|
62 |
+
used = disk_space.used / (1024 ** 3)
|
63 |
+
free = disk_space.free / (1024 ** 3)
|
64 |
+
|
65 |
+
storage_info.value = f'''
|
66 |
+
<div class="storage_info_AC">Total storage: {total:.2f} GB <span style="color: #555">|</span> Used: {used:.2f} GB <span style="color: #555">|</span> Free: {free:.2f} GB</div>
|
67 |
+
'''
|
68 |
+
|
69 |
+
def on_execute_button_press(button):
|
70 |
+
selected_cleaners = auto_cleaner_widget.value
|
71 |
+
deleted_files_dict = {}
|
72 |
+
|
73 |
+
for option in selected_cleaners:
|
74 |
+
if option in directories:
|
75 |
+
deleted_files_dict[option] = clean_directory(directories[option])
|
76 |
+
|
77 |
+
output.clear_output()
|
78 |
+
|
79 |
+
with output:
|
80 |
+
for message in generate_messages(deleted_files_dict):
|
81 |
+
message_widget = HTML(f'<p class="output_message_AC">{message}</p>')
|
82 |
+
display(message_widget)
|
83 |
+
|
84 |
+
update_memory_info()
|
85 |
+
|
86 |
+
def on_clear_button_press(button):
|
87 |
+
container.add_class("hide")
|
88 |
+
time.sleep(0.5)
|
89 |
+
widgets.Widget.close_all()
|
90 |
+
|
91 |
+
def generate_messages(deleted_files_dict):
|
92 |
+
messages = []
|
93 |
+
word_variants = {
|
94 |
+
"Images": "Images",
|
95 |
+
"Models": "Models",
|
96 |
+
"Vae": "Vae",
|
97 |
+
"LoRa": "LoRa",
|
98 |
+
"ControlNet Models": "ControlNet Models"
|
99 |
+
}
|
100 |
+
for key, value in deleted_files_dict.items():
|
101 |
+
object_word = word_variants.get(key)
|
102 |
+
messages.append(f"Deleted {value} {object_word}")
|
103 |
+
return messages
|
104 |
+
# ================ AutoCleaner function ================
|
105 |
+
|
106 |
+
|
107 |
+
# --- storage memory ---
|
108 |
+
import psutil
|
109 |
+
disk_space = psutil.disk_usage(os.getcwd())
|
110 |
+
total = disk_space.total / (1024 ** 3)
|
111 |
+
used = disk_space.used / (1024 ** 3)
|
112 |
+
free = disk_space.free / (1024 ** 3)
|
113 |
+
|
114 |
+
|
115 |
+
# UI Code
|
116 |
+
AutoCleaner_options = AutoCleaner_options = list(directories.keys())
|
117 |
+
instruction_label = widgets.HTML('''
|
118 |
+
<span class="instruction_AC">Use <span style="color: #B2B2B2;">ctrl</span> or <span style="color: #B2B2B2;">shift</span> for multiple selections.</span>
|
119 |
+
''')
|
120 |
+
auto_cleaner_widget = widgets.SelectMultiple(options=AutoCleaner_options, layout=widgets.Layout(width='auto')).add_class("custom-select-multiple_AC")
|
121 |
+
output = widgets.Output().add_class("output_AC")
|
122 |
+
# ---
|
123 |
+
execute_button = Button(description='Execute Cleaning').add_class("button_execute_AC").add_class("button_AC")
|
124 |
+
execute_button.on_click(on_execute_button_press)
|
125 |
+
clear_button = Button(description='Hide Widget').add_class("button_clear_AC").add_class("button_AC")
|
126 |
+
clear_button.on_click(on_clear_button_press)
|
127 |
+
# ---
|
128 |
+
storage_info = widgets.HTML(f'''
|
129 |
+
<div class="storage_info_AC">Total storage: {total:.2f} GB <span style="color: #555">|</span> Used: {used:.2f} GB <span style="color: #555">|</span> Free: {free:.2f} GB</div>
|
130 |
+
''')
|
131 |
+
# ---
|
132 |
+
buttons = widgets.HBox([execute_button, clear_button])
|
133 |
+
lower_information_panel = widgets.HBox([buttons, storage_info]).add_class("lower_information_panel_AC")
|
134 |
+
|
135 |
+
container = VBox([instruction_label, widgets.HTML('<hr>'), auto_cleaner_widget, output, widgets.HTML('<hr>'), lower_information_panel]).add_class("container_AC")
|
136 |
+
|
137 |
+
display(container)
|
138 |
+
|
files_cells/python/en/downloading_en.py
CHANGED
@@ -66,7 +66,7 @@ if not os.path.exists(flag_file):
|
|
66 |
with capture.capture_output() as cap:
|
67 |
get_ipython().system('curl -s -OL https://github.com/DEX-1101/sd-webui-notebook/raw/main/res/new_tunnel --output-dir {root_path}')
|
68 |
get_ipython().system('curl -s -Lo /usr/bin/cl https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 && chmod +x /usr/bin/cl')
|
69 |
-
get_ipython().system('curl -sLO https://github.com/openziti/zrok/releases/download/v0.4.
|
70 |
del cap
|
71 |
|
72 |
clear_output()
|
|
|
66 |
with capture.capture_output() as cap:
|
67 |
get_ipython().system('curl -s -OL https://github.com/DEX-1101/sd-webui-notebook/raw/main/res/new_tunnel --output-dir {root_path}')
|
68 |
get_ipython().system('curl -s -Lo /usr/bin/cl https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 && chmod +x /usr/bin/cl')
|
69 |
+
get_ipython().system('curl -sLO https://github.com/openziti/zrok/releases/download/v0.4.32/zrok_0.4.32_linux_amd64.tar.gz && tar -xzf zrok_0.4.32_linux_amd64.tar.gz -C /usr/bin && rm -f zrok_0.4.32_linux_amd64.tar.gz')
|
70 |
del cap
|
71 |
|
72 |
clear_output()
|
files_cells/python/en/widgets_en.py
CHANGED
@@ -1,322 +1,322 @@
|
|
1 |
-
##~ WIDGET CODE | BY: 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 |
-
# ================= 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")
|
17 |
-
}
|
18 |
-
for env_var, (environment, path) in environments.items():
|
19 |
-
if env_var in os.environ:
|
20 |
-
return environment, path, free_plan
|
21 |
-
|
22 |
-
env, root_path, free_plan = detect_environment()
|
23 |
-
webui_path = f"{root_path}/sdw"
|
24 |
-
get_ipython().system('mkdir -p {root_path}')
|
25 |
-
|
26 |
-
|
27 |
-
# ==================== CSS JS ====================
|
28 |
-
##~ custom background images V1.5 ~##
|
29 |
-
import argparse
|
30 |
-
parser = argparse.ArgumentParser(description='This script processes an background image.')
|
31 |
-
parser.add_argument('-i', '--image', type=str, help='URL of the image to process', metavar='')
|
32 |
-
parser.add_argument('-o', '--opacity', type=float, help='Opacity level for the image, between 0 and 1', metavar='', default=0.3)
|
33 |
-
parser.add_argument('-b', '--blur', type=str, help='Blur level for the image', metavar='', default=0)
|
34 |
-
parser.add_argument('-y', type=int, help='Y coordinate for the image in px', metavar='', default=0)
|
35 |
-
parser.add_argument('-x', type=int, help='X coordinate for the image in px', metavar='', default=0)
|
36 |
-
parser.add_argument('-s', '--scale', type=int, help='Scale image in %%', metavar='', default=100)
|
37 |
-
parser.add_argument('-m', '--mode', action='store_true', help='Removes repetitive image tiles')
|
38 |
-
parser.add_argument('-t', '--transparent', action='store_true', help='Makes input/selection fields 35%% more transparent')
|
39 |
-
parser.add_argument('-bf', '--blur-fields', type=str, help='Background blur level for input/selection fields', metavar='', default=2)
|
40 |
-
|
41 |
-
args = parser.parse_args()
|
42 |
-
|
43 |
-
url_img = args.image
|
44 |
-
opacity_img = args.opacity
|
45 |
-
blur_img = args.blur
|
46 |
-
y_img = args.y
|
47 |
-
x_img = args.x
|
48 |
-
scale_img = args.scale
|
49 |
-
blur_fields = args.blur_fields
|
50 |
-
|
51 |
-
## ---
|
52 |
-
""" WTF KAGGLE - WHAT THE FUCK IS THE DIFFERENCE OF 35 PIXELS!?!?!? """
|
53 |
-
fix_heigh_img = "-810px" if env == "Kaggle" else "-775px"
|
54 |
-
|
55 |
-
""" transperent fields """
|
56 |
-
t_bg_alpha = "1" if not args.transparent else "0.65"
|
57 |
-
|
58 |
-
""" mode img - repeats """
|
59 |
-
mode_img = "repeat" if not args.mode else "no-repeat"
|
60 |
-
|
61 |
-
container_background = f'''
|
62 |
-
<style>
|
63 |
-
:root {{
|
64 |
-
/* for background container*/
|
65 |
-
--img_background: url({url_img});
|
66 |
-
--img_opacity: {opacity_img};
|
67 |
-
--img_blur: {blur_img}px;
|
68 |
-
--image_y: {y_img}px;
|
69 |
-
--image_x: {x_img}px;
|
70 |
-
--img_scale: {scale_img}%;
|
71 |
-
--img_mode: {mode_img};
|
72 |
-
--img_height_dif: {fix_heigh_img};
|
73 |
-
|
74 |
-
/* for fields */
|
75 |
-
--bg-field-color: rgba(28, 28, 28, {t_bg_alpha}); /* -> #1c1c1c */
|
76 |
-
--bg-field-color-hover: rgba(38, 38, 38, {t_bg_alpha}); /* -> #262626; */
|
77 |
-
--bg-field-blur-level: {blur_fields}px;
|
78 |
-
}}
|
79 |
-
'''
|
80 |
-
|
81 |
-
display(HTML(container_background))
|
82 |
-
|
83 |
-
# Main CSS
|
84 |
-
css_file_path = f"{root_path}/CSS/main_widgets.css"
|
85 |
-
with open(css_file_path , "r") as f:
|
86 |
-
CSS = f.read()
|
87 |
-
display(HTML(f"<style>{CSS}</style>"))
|
88 |
-
|
89 |
-
# Main JS
|
90 |
-
JS = '''
|
91 |
-
<!-- TOGGLE 'CustomDL' SCRIPT -->
|
92 |
-
<script>
|
93 |
-
function toggleContainer() {
|
94 |
-
let downloadContainer = document.querySelector('.container_custom_downlad');
|
95 |
-
let info = document.querySelector('.info');
|
96 |
-
|
97 |
-
downloadContainer.classList.toggle('expanded');
|
98 |
-
info.classList.toggle('showed');
|
99 |
-
}
|
100 |
-
</script>
|
101 |
-
'''
|
102 |
-
display(HTML(JS))
|
103 |
-
|
104 |
-
# ==================== WIDGETS V2 ====================
|
105 |
-
HR = widgets.HTML('<hr>')
|
106 |
-
|
107 |
-
class WidgetFactory:
|
108 |
-
def __init__(self, style=None, layout=None):
|
109 |
-
self.style = style if style else {'description_width': 'initial'}
|
110 |
-
self.layout = layout if layout else widgets.Layout(max_width='1080px', width='100%')
|
111 |
-
|
112 |
-
def create_html(self, content, class_name=None):
|
113 |
-
html_widget = widgets.HTML(content)
|
114 |
-
if class_name:
|
115 |
-
html_widget.add_class(class_name)
|
116 |
-
return html_widget
|
117 |
-
|
118 |
-
def create_header(self, name):
|
119 |
-
return widgets.HTML(f'<div class="header">{name}<div>')
|
120 |
-
|
121 |
-
def create_dropdown(self, options, value, description):
|
122 |
-
return widgets.Dropdown(options=options, value=value, description=description, style=self.style, layout=self.layout)
|
123 |
-
|
124 |
-
def create_text(self, description, placeholder='', value=''):
|
125 |
-
return widgets.Text(description=description, placeholder=placeholder, value=value, style=self.style, layout=self.layout)
|
126 |
-
|
127 |
-
def create_checkbox(self, value, description):
|
128 |
-
return widgets.Checkbox(value=value, description=description, style=self.style, layout=self.layout)
|
129 |
-
|
130 |
-
def create_button(self, description, class_name=None):
|
131 |
-
button = widgets.Button(description=description)
|
132 |
-
if class_name:
|
133 |
-
button.add_class(class_name)
|
134 |
-
return button
|
135 |
-
|
136 |
-
def create_hbox(self, children):
|
137 |
-
return widgets.HBox(children)
|
138 |
-
|
139 |
-
def create_vbox(self, children, class_names=None):
|
140 |
-
vbox = widgets.VBox(children)
|
141 |
-
if class_names:
|
142 |
-
for class_name in class_names:
|
143 |
-
vbox.add_class(class_name)
|
144 |
-
return vbox
|
145 |
-
|
146 |
-
def display(self, widget):
|
147 |
-
display(widget)
|
148 |
-
|
149 |
-
# Instantiate the factory
|
150 |
-
factory = WidgetFactory()
|
151 |
-
|
152 |
-
# --- MODEL ---
|
153 |
-
model_header = factory.create_header('Model Selection')
|
154 |
-
model_options = ['none',
|
155 |
-
'1.Anime (by XpucT) + INP',
|
156 |
-
'2.BluMix [Anime] [V7] + INP',
|
157 |
-
'3.Cetus-Mix [Anime] [V4] + INP',
|
158 |
-
'4.Counterfeit [Anime] [V3] + INP',
|
159 |
-
'5.CuteColor [Anime] [V3]',
|
160 |
-
'6.Dark-Sushi-Mix [Anime]',
|
161 |
-
'7.Deliberate [Realism] [V6] + INP',
|
162 |
-
'8.Meina-Mix [Anime] [V11] + INP',
|
163 |
-
'9.Mix-Pro [Anime] [V4] + INP']
|
164 |
-
model_widget = factory.create_dropdown(model_options, '4.Counterfeit [Anime] [V3] + INP', 'Model:')
|
165 |
-
model_num_widget = factory.create_text('Model Number:', 'Enter the model numbers to be downloaded using comma/space.')
|
166 |
-
inpainting_model_widget = factory.create_checkbox(False, 'Inpainting Models')
|
167 |
-
|
168 |
-
# Display Model
|
169 |
-
all_model_box = factory.create_vbox([model_header, model_widget, model_num_widget, inpainting_model_widget], class_names=["container", "image_1"])
|
170 |
-
factory.display(all_model_box)
|
171 |
-
|
172 |
-
# --- VAE ---
|
173 |
-
vae_header = factory.create_header('VAE Selection')
|
174 |
-
vae_options = ['none',
|
175 |
-
'1.Anime.vae',
|
176 |
-
'2.Anything.vae',
|
177 |
-
'3.Blessed2.vae',
|
178 |
-
'4.ClearVae.vae',
|
179 |
-
'5.WD.vae']
|
180 |
-
vae_widget = factory.create_dropdown(vae_options, '3.Blessed2.vae', 'Vae:')
|
181 |
-
vae_num_widget = factory.create_text('Vae Number:', 'Enter the vae numbers to be downloaded using comma/space.')
|
182 |
-
|
183 |
-
# Display Vae
|
184 |
-
all_vae_box = factory.create_vbox([vae_header, vae_widget, vae_num_widget], class_names=["container", "image_2"])
|
185 |
-
factory.display(all_vae_box)
|
186 |
-
|
187 |
-
# --- ADDITIONAL ---
|
188 |
-
additional_header = factory.create_header('Additional')
|
189 |
-
latest_webui_widget = factory.create_checkbox(True, 'Update WebUI')
|
190 |
-
latest_exstensions_widget = factory.create_checkbox(True, 'Update Extensions')
|
191 |
-
change_webui_widget = factory.create_dropdown(['A1111', 'Forge'], 'A1111', 'Change WebUI:')
|
192 |
-
detailed_download_widget = factory.create_dropdown(['off', 'on'], 'off', 'Detailed Download:')
|
193 |
-
choose_changes_widget = factory.create_hbox([latest_webui_widget, latest_exstensions_widget, change_webui_widget, detailed_download_widget])
|
194 |
-
|
195 |
-
controlnet_options = ['none', 'ALL', '1.canny',
|
196 |
-
'2.openpose', '3.depth',
|
197 |
-
'4.normal_map', '5.mlsd',
|
198 |
-
'6.lineart', '7.soft_edge',
|
199 |
-
'8.scribble', '9.segmentation',
|
200 |
-
'10.shuffle', '11.tile',
|
201 |
-
'12.inpaint', '13.instruct_p2p']
|
202 |
-
controlnet_widget = factory.create_dropdown(controlnet_options, 'none', 'ControlNet:')
|
203 |
-
controlnet_num_widget = factory.create_text('ControlNet Number:', 'Enter the ControlNet model numbers to be downloaded using comma/space.')
|
204 |
-
commit_hash_widget = factory.create_text('Commit Hash:')
|
205 |
-
huggingface_token_widget = factory.create_text('HuggingFace Token:')
|
206 |
-
|
207 |
-
ngrok_token_widget = factory.create_text('Ngrok Token:')
|
208 |
-
ngrock_button = factory.create_html('<a href="https://dashboard.ngrok.com/get-started/your-authtoken" target="_blank">Получить Ngrok Токен</a>', class_name="button_ngrok")
|
209 |
-
ngrok_widget = factory.create_hbox([ngrok_token_widget, ngrock_button])
|
210 |
-
|
211 |
-
zrok_token_widget = factory.create_text('Zrok Token:')
|
212 |
-
zrok_button = factory.create_html('<a href="https://colab.research.google.com/drive/1d2sjWDJi_GYBUavrHSuQyHTDuLy36WpU" target="_blank">Зарегать Zrok Токен</a>', class_name="button_ngrok")
|
213 |
-
zrok_widget = factory.create_hbox([zrok_token_widget, zrok_button])
|
214 |
-
|
215 |
-
commandline_arguments_options = "--listen --enable-insecure-extension-access --theme dark --no-half-vae --disable-console-progressbars --xformers"
|
216 |
-
commandline_arguments_widget = factory.create_text('Arguments:', value=commandline_arguments_options)
|
217 |
-
|
218 |
-
# Display Additional
|
219 |
-
additional_widget_list = [additional_header,
|
220 |
-
choose_changes_widget,
|
221 |
-
HR,
|
222 |
-
controlnet_widget,
|
223 |
-
controlnet_num_widget,
|
224 |
-
commit_hash_widget,
|
225 |
-
huggingface_token_widget,
|
226 |
-
ngrok_widget,
|
227 |
-
zrok_widget,
|
228 |
-
HR,
|
229 |
-
commandline_arguments_widget]
|
230 |
-
|
231 |
-
if free_plan and env == "Google Colab": # remove ngrok from colab
|
232 |
-
additional_widget_list.remove(ngrok_widget)
|
233 |
-
if os.path.exists(webui_path): # remove selection after selection ;3
|
234 |
-
choose_changes_widget.children = [widget for widget in choose_changes_widget.children if widget != change_webui_widget]
|
235 |
-
|
236 |
-
all_additional_box = factory.create_vbox(additional_widget_list, class_names=["container", "image_3"])
|
237 |
-
factory.display(all_additional_box)
|
238 |
-
|
239 |
-
# --- CUSTOM DOWNLOAD ---
|
240 |
-
custom_download_header_popup = factory.create_html('''
|
241 |
-
<style>
|
242 |
-
/* Term Colors */
|
243 |
-
.sample_label {color: #dbafff;}
|
244 |
-
.braces {color: #ffff00;}
|
245 |
-
.extension {color: #eb934b;}
|
246 |
-
.file_name {color: #ffffd8;}
|
247 |
-
</style>
|
248 |
-
|
249 |
-
<div class="header" style="cursor: pointer;" onclick="toggleContainer()">Custom Download</div>
|
250 |
-
<!-- PopUp Window -->
|
251 |
-
<div class="info">INFO</div>
|
252 |
-
<div class="popup">
|
253 |
-
Separate multiple URLs with a comma/space. For a <span class="file_name">custom name</span> file/extension, specify it with <span class="braces">[]</span>
|
254 |
-
after the URL without spaces.
|
255 |
-
<span style="color: #ff9999">For files, be sure to specify</span> - <span class="extension">Filename Extension.</span>
|
256 |
-
<div class="sample">
|
257 |
-
<span class="sample_label">Example for File:</span>
|
258 |
-
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>
|
259 |
-
<br>
|
260 |
-
<span class="sample_label">Example for Extension:</span>
|
261 |
-
https://github.com/hako-mikan/sd-webui-regional-prompter<span class="braces">[</span><span class="file_name">Regional-Prompter</span><span class="braces">]</span>
|
262 |
-
</div>
|
263 |
-
</div>
|
264 |
-
''')
|
265 |
-
|
266 |
-
Model_url_widget = factory.create_text('Model:')
|
267 |
-
Vae_url_widget = factory.create_text('Vae:')
|
268 |
-
LoRA_url_widget = factory.create_text('LoRa:')
|
269 |
-
Embedding_url_widget = factory.create_text('Embedding:')
|
270 |
-
Extensions_url_widget = factory.create_text('Extensions:')
|
271 |
-
custom_file_urls_widget = factory.create_text('File (txt):')
|
272 |
-
|
273 |
-
# Display CustomDl
|
274 |
-
all_custom_box = factory.create_vbox([
|
275 |
-
custom_download_header_popup, Model_url_widget, Vae_url_widget, LoRA_url_widget, Embedding_url_widget, Extensions_url_widget, custom_file_urls_widget
|
276 |
-
], class_names=["container", "image_4", "container_custom_downlad"])
|
277 |
-
factory.display(all_custom_box)
|
278 |
-
|
279 |
-
# --- Save Button ---
|
280 |
-
save_button = factory.create_button('Save', class_name="button_save")
|
281 |
-
factory.display(save_button)
|
282 |
-
|
283 |
-
|
284 |
-
# ============ Load / Save - Settings V2 ============
|
285 |
-
SETTINGS_FILE = f'{root_path}/settings.json'
|
286 |
-
|
287 |
-
SETTINGS_KEYS = [
|
288 |
-
'model', 'model_num', 'inpainting_model',
|
289 |
-
'vae', 'vae_num', 'latest_webui', 'latest_exstensions',
|
290 |
-
'change_webui', 'detailed_download', 'controlnet',
|
291 |
-
'controlnet_num', 'commit_hash', 'huggingface_token',
|
292 |
-
'ngrok_token', 'zrok_token', 'commandline_arguments',
|
293 |
-
'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url',
|
294 |
-
'Extensions_url', 'custom_file_urls'
|
295 |
-
]
|
296 |
-
|
297 |
-
def save_settings():
|
298 |
-
settings = {key: globals()[f"{key}_widget"].value for key in SETTINGS_KEYS}
|
299 |
-
with open(SETTINGS_FILE, 'w') as f:
|
300 |
-
json.dump(settings, f, indent=2)
|
301 |
-
|
302 |
-
def load_settings():
|
303 |
-
if os.path.exists(SETTINGS_FILE):
|
304 |
-
with open(SETTINGS_FILE, 'r') as f:
|
305 |
-
settings = json.load(f)
|
306 |
-
for key in SETTINGS_KEYS:
|
307 |
-
globals()[f"{key}_widget"].value = settings.get(key, "")
|
308 |
-
|
309 |
-
def hide_widgets():
|
310 |
-
widgets_list = [all_model_box, all_vae_box, all_additional_box, all_custom_box, save_button]
|
311 |
-
for widget in widgets_list:
|
312 |
-
widget.add_class("hide")
|
313 |
-
time.sleep(0.5)
|
314 |
-
widgets.Widget.close_all()
|
315 |
-
|
316 |
-
def save_data(button):
|
317 |
-
save_settings()
|
318 |
-
hide_widgets()
|
319 |
-
|
320 |
-
load_settings()
|
321 |
-
save_button.on_click(save_data)
|
322 |
-
|
|
|
1 |
+
##~ WIDGET CODE | BY: 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 |
+
# ================= 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")
|
17 |
+
}
|
18 |
+
for env_var, (environment, path) in environments.items():
|
19 |
+
if env_var in os.environ:
|
20 |
+
return environment, path, free_plan
|
21 |
+
|
22 |
+
env, root_path, free_plan = detect_environment()
|
23 |
+
webui_path = f"{root_path}/sdw"
|
24 |
+
get_ipython().system('mkdir -p {root_path}')
|
25 |
+
|
26 |
+
|
27 |
+
# ==================== CSS JS ====================
|
28 |
+
##~ custom background images V1.5 ~##
|
29 |
+
import argparse
|
30 |
+
parser = argparse.ArgumentParser(description='This script processes an background image.')
|
31 |
+
parser.add_argument('-i', '--image', type=str, help='URL of the image to process', metavar='')
|
32 |
+
parser.add_argument('-o', '--opacity', type=float, help='Opacity level for the image, between 0 and 1', metavar='', default=0.3)
|
33 |
+
parser.add_argument('-b', '--blur', type=str, help='Blur level for the image', metavar='', default=0)
|
34 |
+
parser.add_argument('-y', type=int, help='Y coordinate for the image in px', metavar='', default=0)
|
35 |
+
parser.add_argument('-x', type=int, help='X coordinate for the image in px', metavar='', default=0)
|
36 |
+
parser.add_argument('-s', '--scale', type=int, help='Scale image in %%', metavar='', default=100)
|
37 |
+
parser.add_argument('-m', '--mode', action='store_true', help='Removes repetitive image tiles')
|
38 |
+
parser.add_argument('-t', '--transparent', action='store_true', help='Makes input/selection fields 35%% more transparent')
|
39 |
+
parser.add_argument('-bf', '--blur-fields', type=str, help='Background blur level for input/selection fields', metavar='', default=2)
|
40 |
+
|
41 |
+
args = parser.parse_args()
|
42 |
+
|
43 |
+
url_img = args.image
|
44 |
+
opacity_img = args.opacity
|
45 |
+
blur_img = args.blur
|
46 |
+
y_img = args.y
|
47 |
+
x_img = args.x
|
48 |
+
scale_img = args.scale
|
49 |
+
blur_fields = args.blur_fields
|
50 |
+
|
51 |
+
## ---
|
52 |
+
""" WTF KAGGLE - WHAT THE FUCK IS THE DIFFERENCE OF 35 PIXELS!?!?!? """
|
53 |
+
fix_heigh_img = "-810px" if env == "Kaggle" else "-775px"
|
54 |
+
|
55 |
+
""" transperent fields """
|
56 |
+
t_bg_alpha = "1" if not args.transparent else "0.65"
|
57 |
+
|
58 |
+
""" mode img - repeats """
|
59 |
+
mode_img = "repeat" if not args.mode else "no-repeat"
|
60 |
+
|
61 |
+
container_background = f'''
|
62 |
+
<style>
|
63 |
+
:root {{
|
64 |
+
/* for background container*/
|
65 |
+
--img_background: url({url_img});
|
66 |
+
--img_opacity: {opacity_img};
|
67 |
+
--img_blur: {blur_img}px;
|
68 |
+
--image_y: {y_img}px;
|
69 |
+
--image_x: {x_img}px;
|
70 |
+
--img_scale: {scale_img}%;
|
71 |
+
--img_mode: {mode_img};
|
72 |
+
--img_height_dif: {fix_heigh_img};
|
73 |
+
|
74 |
+
/* for fields */
|
75 |
+
--bg-field-color: rgba(28, 28, 28, {t_bg_alpha}); /* -> #1c1c1c */
|
76 |
+
--bg-field-color-hover: rgba(38, 38, 38, {t_bg_alpha}); /* -> #262626; */
|
77 |
+
--bg-field-blur-level: {blur_fields}px;
|
78 |
+
}}
|
79 |
+
'''
|
80 |
+
|
81 |
+
display(HTML(container_background))
|
82 |
+
|
83 |
+
# Main CSS
|
84 |
+
css_file_path = f"{root_path}/CSS/main_widgets.css"
|
85 |
+
with open(css_file_path , "r") as f:
|
86 |
+
CSS = f.read()
|
87 |
+
display(HTML(f"<style>{CSS}</style>"))
|
88 |
+
|
89 |
+
# Main JS
|
90 |
+
JS = '''
|
91 |
+
<!-- TOGGLE 'CustomDL' SCRIPT -->
|
92 |
+
<script>
|
93 |
+
function toggleContainer() {
|
94 |
+
let downloadContainer = document.querySelector('.container_custom_downlad');
|
95 |
+
let info = document.querySelector('.info');
|
96 |
+
|
97 |
+
downloadContainer.classList.toggle('expanded');
|
98 |
+
info.classList.toggle('showed');
|
99 |
+
}
|
100 |
+
</script>
|
101 |
+
'''
|
102 |
+
display(HTML(JS))
|
103 |
+
|
104 |
+
# ==================== WIDGETS V2 ====================
|
105 |
+
HR = widgets.HTML('<hr>')
|
106 |
+
|
107 |
+
class WidgetFactory:
|
108 |
+
def __init__(self, style=None, layout=None):
|
109 |
+
self.style = style if style else {'description_width': 'initial'}
|
110 |
+
self.layout = layout if layout else widgets.Layout(max_width='1080px', width='100%')
|
111 |
+
|
112 |
+
def create_html(self, content, class_name=None):
|
113 |
+
html_widget = widgets.HTML(content)
|
114 |
+
if class_name:
|
115 |
+
html_widget.add_class(class_name)
|
116 |
+
return html_widget
|
117 |
+
|
118 |
+
def create_header(self, name):
|
119 |
+
return widgets.HTML(f'<div class="header">{name}<div>')
|
120 |
+
|
121 |
+
def create_dropdown(self, options, value, description):
|
122 |
+
return widgets.Dropdown(options=options, value=value, description=description, style=self.style, layout=self.layout)
|
123 |
+
|
124 |
+
def create_text(self, description, placeholder='', value=''):
|
125 |
+
return widgets.Text(description=description, placeholder=placeholder, value=value, style=self.style, layout=self.layout)
|
126 |
+
|
127 |
+
def create_checkbox(self, value, description):
|
128 |
+
return widgets.Checkbox(value=value, description=description, style=self.style, layout=self.layout)
|
129 |
+
|
130 |
+
def create_button(self, description, class_name=None):
|
131 |
+
button = widgets.Button(description=description)
|
132 |
+
if class_name:
|
133 |
+
button.add_class(class_name)
|
134 |
+
return button
|
135 |
+
|
136 |
+
def create_hbox(self, children):
|
137 |
+
return widgets.HBox(children)
|
138 |
+
|
139 |
+
def create_vbox(self, children, class_names=None):
|
140 |
+
vbox = widgets.VBox(children)
|
141 |
+
if class_names:
|
142 |
+
for class_name in class_names:
|
143 |
+
vbox.add_class(class_name)
|
144 |
+
return vbox
|
145 |
+
|
146 |
+
def display(self, widget):
|
147 |
+
display(widget)
|
148 |
+
|
149 |
+
# Instantiate the factory
|
150 |
+
factory = WidgetFactory()
|
151 |
+
|
152 |
+
# --- MODEL ---
|
153 |
+
model_header = factory.create_header('Model Selection')
|
154 |
+
model_options = ['none',
|
155 |
+
'1.Anime (by XpucT) + INP',
|
156 |
+
'2.BluMix [Anime] [V7] + INP',
|
157 |
+
'3.Cetus-Mix [Anime] [V4] + INP',
|
158 |
+
'4.Counterfeit [Anime] [V3] + INP',
|
159 |
+
'5.CuteColor [Anime] [V3]',
|
160 |
+
'6.Dark-Sushi-Mix [Anime]',
|
161 |
+
'7.Deliberate [Realism] [V6] + INP',
|
162 |
+
'8.Meina-Mix [Anime] [V11] + INP',
|
163 |
+
'9.Mix-Pro [Anime] [V4] + INP']
|
164 |
+
model_widget = factory.create_dropdown(model_options, '4.Counterfeit [Anime] [V3] + INP', 'Model:')
|
165 |
+
model_num_widget = factory.create_text('Model Number:', 'Enter the model numbers to be downloaded using comma/space.')
|
166 |
+
inpainting_model_widget = factory.create_checkbox(False, 'Inpainting Models')
|
167 |
+
|
168 |
+
# Display Model
|
169 |
+
all_model_box = factory.create_vbox([model_header, model_widget, model_num_widget, inpainting_model_widget], class_names=["container", "image_1"])
|
170 |
+
factory.display(all_model_box)
|
171 |
+
|
172 |
+
# --- VAE ---
|
173 |
+
vae_header = factory.create_header('VAE Selection')
|
174 |
+
vae_options = ['none',
|
175 |
+
'1.Anime.vae',
|
176 |
+
'2.Anything.vae',
|
177 |
+
'3.Blessed2.vae',
|
178 |
+
'4.ClearVae.vae',
|
179 |
+
'5.WD.vae']
|
180 |
+
vae_widget = factory.create_dropdown(vae_options, '3.Blessed2.vae', 'Vae:')
|
181 |
+
vae_num_widget = factory.create_text('Vae Number:', 'Enter the vae numbers to be downloaded using comma/space.')
|
182 |
+
|
183 |
+
# Display Vae
|
184 |
+
all_vae_box = factory.create_vbox([vae_header, vae_widget, vae_num_widget], class_names=["container", "image_2"])
|
185 |
+
factory.display(all_vae_box)
|
186 |
+
|
187 |
+
# --- ADDITIONAL ---
|
188 |
+
additional_header = factory.create_header('Additional')
|
189 |
+
latest_webui_widget = factory.create_checkbox(True, 'Update WebUI')
|
190 |
+
latest_exstensions_widget = factory.create_checkbox(True, 'Update Extensions')
|
191 |
+
change_webui_widget = factory.create_dropdown(['A1111', 'Forge'], 'A1111', 'Change WebUI:')
|
192 |
+
detailed_download_widget = factory.create_dropdown(['off', 'on'], 'off', 'Detailed Download:')
|
193 |
+
choose_changes_widget = factory.create_hbox([latest_webui_widget, latest_exstensions_widget, change_webui_widget, detailed_download_widget])
|
194 |
+
|
195 |
+
controlnet_options = ['none', 'ALL', '1.canny',
|
196 |
+
'2.openpose', '3.depth',
|
197 |
+
'4.normal_map', '5.mlsd',
|
198 |
+
'6.lineart', '7.soft_edge',
|
199 |
+
'8.scribble', '9.segmentation',
|
200 |
+
'10.shuffle', '11.tile',
|
201 |
+
'12.inpaint', '13.instruct_p2p']
|
202 |
+
controlnet_widget = factory.create_dropdown(controlnet_options, 'none', 'ControlNet:')
|
203 |
+
controlnet_num_widget = factory.create_text('ControlNet Number:', 'Enter the ControlNet model numbers to be downloaded using comma/space.')
|
204 |
+
commit_hash_widget = factory.create_text('Commit Hash:')
|
205 |
+
huggingface_token_widget = factory.create_text('HuggingFace Token:')
|
206 |
+
|
207 |
+
ngrok_token_widget = factory.create_text('Ngrok Token:')
|
208 |
+
ngrock_button = factory.create_html('<a href="https://dashboard.ngrok.com/get-started/your-authtoken" target="_blank">Получить Ngrok Токен</a>', class_name="button_ngrok")
|
209 |
+
ngrok_widget = factory.create_hbox([ngrok_token_widget, ngrock_button])
|
210 |
+
|
211 |
+
zrok_token_widget = factory.create_text('Zrok Token:')
|
212 |
+
zrok_button = factory.create_html('<a href="https://colab.research.google.com/drive/1d2sjWDJi_GYBUavrHSuQyHTDuLy36WpU" target="_blank">Зарегать Zrok Токен</a>', class_name="button_ngrok")
|
213 |
+
zrok_widget = factory.create_hbox([zrok_token_widget, zrok_button])
|
214 |
+
|
215 |
+
commandline_arguments_options = "--listen --enable-insecure-extension-access --theme dark --no-half-vae --disable-console-progressbars --xformers"
|
216 |
+
commandline_arguments_widget = factory.create_text('Arguments:', value=commandline_arguments_options)
|
217 |
+
|
218 |
+
# Display Additional
|
219 |
+
additional_widget_list = [additional_header,
|
220 |
+
choose_changes_widget,
|
221 |
+
HR,
|
222 |
+
controlnet_widget,
|
223 |
+
controlnet_num_widget,
|
224 |
+
commit_hash_widget,
|
225 |
+
huggingface_token_widget,
|
226 |
+
ngrok_widget,
|
227 |
+
zrok_widget,
|
228 |
+
HR,
|
229 |
+
commandline_arguments_widget]
|
230 |
+
|
231 |
+
if free_plan and env == "Google Colab": # remove ngrok from colab
|
232 |
+
additional_widget_list.remove(ngrok_widget)
|
233 |
+
if os.path.exists(webui_path): # remove selection after selection ;3
|
234 |
+
choose_changes_widget.children = [widget for widget in choose_changes_widget.children if widget != change_webui_widget]
|
235 |
+
|
236 |
+
all_additional_box = factory.create_vbox(additional_widget_list, class_names=["container", "image_3"])
|
237 |
+
factory.display(all_additional_box)
|
238 |
+
|
239 |
+
# --- CUSTOM DOWNLOAD ---
|
240 |
+
custom_download_header_popup = factory.create_html('''
|
241 |
+
<style>
|
242 |
+
/* Term Colors */
|
243 |
+
.sample_label {color: #dbafff;}
|
244 |
+
.braces {color: #ffff00;}
|
245 |
+
.extension {color: #eb934b;}
|
246 |
+
.file_name {color: #ffffd8;}
|
247 |
+
</style>
|
248 |
+
|
249 |
+
<div class="header" style="cursor: pointer;" onclick="toggleContainer()">Custom Download</div>
|
250 |
+
<!-- PopUp Window -->
|
251 |
+
<div class="info">INFO</div>
|
252 |
+
<div class="popup">
|
253 |
+
Separate multiple URLs with a comma/space. For a <span class="file_name">custom name</span> file/extension, specify it with <span class="braces">[]</span>
|
254 |
+
after the URL without spaces.
|
255 |
+
<span style="color: #ff9999">For files, be sure to specify</span> - <span class="extension">Filename Extension.</span>
|
256 |
+
<div class="sample">
|
257 |
+
<span class="sample_label">Example for File:</span>
|
258 |
+
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>
|
259 |
+
<br>
|
260 |
+
<span class="sample_label">Example for Extension:</span>
|
261 |
+
https://github.com/hako-mikan/sd-webui-regional-prompter<span class="braces">[</span><span class="file_name">Regional-Prompter</span><span class="braces">]</span>
|
262 |
+
</div>
|
263 |
+
</div>
|
264 |
+
''')
|
265 |
+
|
266 |
+
Model_url_widget = factory.create_text('Model:')
|
267 |
+
Vae_url_widget = factory.create_text('Vae:')
|
268 |
+
LoRA_url_widget = factory.create_text('LoRa:')
|
269 |
+
Embedding_url_widget = factory.create_text('Embedding:')
|
270 |
+
Extensions_url_widget = factory.create_text('Extensions:')
|
271 |
+
custom_file_urls_widget = factory.create_text('File (txt):')
|
272 |
+
|
273 |
+
# Display CustomDl
|
274 |
+
all_custom_box = factory.create_vbox([
|
275 |
+
custom_download_header_popup, Model_url_widget, Vae_url_widget, LoRA_url_widget, Embedding_url_widget, Extensions_url_widget, custom_file_urls_widget
|
276 |
+
], class_names=["container", "image_4", "container_custom_downlad"])
|
277 |
+
factory.display(all_custom_box)
|
278 |
+
|
279 |
+
# --- Save Button ---
|
280 |
+
save_button = factory.create_button('Save', class_name="button_save")
|
281 |
+
factory.display(save_button)
|
282 |
+
|
283 |
+
|
284 |
+
# ============ Load / Save - Settings V2 ============
|
285 |
+
SETTINGS_FILE = f'{root_path}/settings.json'
|
286 |
+
|
287 |
+
SETTINGS_KEYS = [
|
288 |
+
'model', 'model_num', 'inpainting_model',
|
289 |
+
'vae', 'vae_num', 'latest_webui', 'latest_exstensions',
|
290 |
+
'change_webui', 'detailed_download', 'controlnet',
|
291 |
+
'controlnet_num', 'commit_hash', 'huggingface_token',
|
292 |
+
'ngrok_token', 'zrok_token', 'commandline_arguments',
|
293 |
+
'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url',
|
294 |
+
'Extensions_url', 'custom_file_urls'
|
295 |
+
]
|
296 |
+
|
297 |
+
def save_settings():
|
298 |
+
settings = {key: globals()[f"{key}_widget"].value for key in SETTINGS_KEYS}
|
299 |
+
with open(SETTINGS_FILE, 'w') as f:
|
300 |
+
json.dump(settings, f, indent=2)
|
301 |
+
|
302 |
+
def load_settings():
|
303 |
+
if os.path.exists(SETTINGS_FILE):
|
304 |
+
with open(SETTINGS_FILE, 'r') as f:
|
305 |
+
settings = json.load(f)
|
306 |
+
for key in SETTINGS_KEYS:
|
307 |
+
globals()[f"{key}_widget"].value = settings.get(key, "")
|
308 |
+
|
309 |
+
def hide_widgets():
|
310 |
+
widgets_list = [all_model_box, all_vae_box, all_additional_box, all_custom_box, save_button]
|
311 |
+
for widget in widgets_list:
|
312 |
+
widget.add_class("hide")
|
313 |
+
time.sleep(0.5)
|
314 |
+
widgets.Widget.close_all()
|
315 |
+
|
316 |
+
def save_data(button):
|
317 |
+
save_settings()
|
318 |
+
hide_widgets()
|
319 |
+
|
320 |
+
load_settings()
|
321 |
+
save_button.on_click(save_data)
|
322 |
+
|
files_cells/python/ru/auto_cleaner_ru.py
CHANGED
@@ -1,138 +1,138 @@
|
|
1 |
-
##~ AutoCleaner V3.7 CODE | BY: ANXETY ~##
|
2 |
-
|
3 |
-
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 |
-
# ================= 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")
|
16 |
-
}
|
17 |
-
for env_var, (environment, path) in environments.items():
|
18 |
-
if env_var in os.environ:
|
19 |
-
return environment, path, free_plan
|
20 |
-
|
21 |
-
env, root_path, free_plan = detect_environment()
|
22 |
-
webui_path = f"{root_path}/sdw"
|
23 |
-
|
24 |
-
|
25 |
-
# ==================== CSS ====================
|
26 |
-
# Main CSS
|
27 |
-
css_file_path = f"{root_path}/CSS/auto_cleaner.css"
|
28 |
-
with open(css_file_path , "r") as f:
|
29 |
-
CSS_AC = f.read()
|
30 |
-
display(HTML(f"<style>{CSS_AC}</style>"))
|
31 |
-
|
32 |
-
|
33 |
-
# ================ AutoCleaner function ================
|
34 |
-
directories = {
|
35 |
-
"Изображения": f"{webui_path}/output",
|
36 |
-
"Модели": f"{webui_path}/models/Stable-diffusion/",
|
37 |
-
"Vae": f"{webui_path}/models/VAE/",
|
38 |
-
"LoRa": f"{webui_path}/models/Lora/",
|
39 |
-
"ControlNet Модели": f"{webui_path}/models/ControlNet/"
|
40 |
-
}
|
41 |
-
|
42 |
-
""" functions """
|
43 |
-
def clean_directory(directory):
|
44 |
-
deleted_files = 0
|
45 |
-
image_dir = directories['Изображения']
|
46 |
-
|
47 |
-
for root, dirs, files in os.walk(directory):
|
48 |
-
for file in files:
|
49 |
-
file_path = os.path.join(root, file)
|
50 |
-
|
51 |
-
if file.endswith(".txt"):
|
52 |
-
continue
|
53 |
-
if file.endswith((".safetensors", ".pt")) or root == image_dir: # fix for image counter
|
54 |
-
deleted_files += 1
|
55 |
-
|
56 |
-
os.remove(file_path)
|
57 |
-
return deleted_files
|
58 |
-
|
59 |
-
def update_memory_info():
|
60 |
-
disk_space = psutil.disk_usage(os.getcwd())
|
61 |
-
total = disk_space.total / (1024 ** 3)
|
62 |
-
used = disk_space.used / (1024 ** 3)
|
63 |
-
free = disk_space.free / (1024 ** 3)
|
64 |
-
|
65 |
-
storage_info.value = f'''
|
66 |
-
<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>
|
67 |
-
'''
|
68 |
-
|
69 |
-
def on_execute_button_press(button):
|
70 |
-
selected_cleaners = auto_cleaner_widget.value
|
71 |
-
deleted_files_dict = {}
|
72 |
-
|
73 |
-
for option in selected_cleaners:
|
74 |
-
if option in directories:
|
75 |
-
deleted_files_dict[option] = clean_directory(directories[option])
|
76 |
-
|
77 |
-
output.clear_output()
|
78 |
-
|
79 |
-
with output:
|
80 |
-
for message in generate_messages(deleted_files_dict):
|
81 |
-
message_widget = HTML(f'<p class="output_message_AC">{message}</p>')
|
82 |
-
display(message_widget)
|
83 |
-
|
84 |
-
update_memory_info()
|
85 |
-
|
86 |
-
def on_clear_button_press(button):
|
87 |
-
container.add_class("hide")
|
88 |
-
time.sleep(0.5)
|
89 |
-
widgets.Widget.close_all()
|
90 |
-
|
91 |
-
def generate_messages(deleted_files_dict):
|
92 |
-
messages = []
|
93 |
-
word_variants = {
|
94 |
-
"Изображения": "Изображений",
|
95 |
-
"Модели": "Моделей",
|
96 |
-
"Vae": "Vae",
|
97 |
-
"LoRa": "LoRa",
|
98 |
-
"ControlNet Модели": "ControlNet Моделей"
|
99 |
-
}
|
100 |
-
for key, value in deleted_files_dict.items():
|
101 |
-
object_word = word_variants.get(key)
|
102 |
-
messages.append(f"Удалено {value} {object_word}")
|
103 |
-
return messages
|
104 |
-
|
105 |
-
|
106 |
-
# --- storage memory ---
|
107 |
-
import psutil
|
108 |
-
disk_space = psutil.disk_usage(os.getcwd())
|
109 |
-
total = disk_space.total / (1024 ** 3)
|
110 |
-
used = disk_space.used / (1024 ** 3)
|
111 |
-
free = disk_space.free / (1024 ** 3)
|
112 |
-
|
113 |
-
|
114 |
-
# ================ Widgets ================
|
115 |
-
# UI Code
|
116 |
-
AutoCleaner_options = AutoCleaner_options = list(directories.keys())
|
117 |
-
instruction_label = widgets.HTML('''
|
118 |
-
<span class="instruction_AC">Используйте <span style="color: #B2B2B2;">ctrl</span> или <span style="color: #B2B2B2;">shift</span> для множественного выбора.</span>
|
119 |
-
''')
|
120 |
-
auto_cleaner_widget = widgets.SelectMultiple(options=AutoCleaner_options, layout=widgets.Layout(width="auto")).add_class("custom-select-multiple_AC")
|
121 |
-
output = widgets.Output().add_class("output_AC")
|
122 |
-
|
123 |
-
execute_button = Button(description='Выполнить Очистку').add_class("button_execute_AC").add_class("button_AC")
|
124 |
-
execute_button.on_click(on_execute_button_press)
|
125 |
-
clear_button = Button(description='Скрыть Виджет').add_class("button_clear_AC").add_class("button_AC")
|
126 |
-
clear_button.on_click(on_clear_button_press)
|
127 |
-
|
128 |
-
storage_info = widgets.HTML(f'''
|
129 |
-
<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>
|
130 |
-
''')
|
131 |
-
|
132 |
-
buttons = widgets.HBox([execute_button, clear_button])
|
133 |
-
lower_information_panel = widgets.HBox([buttons, storage_info]).add_class("lower_information_panel_AC")
|
134 |
-
|
135 |
-
container = VBox([instruction_label, widgets.HTML('<hr>'), auto_cleaner_widget, output, widgets.HTML('<hr>'), lower_information_panel]).add_class("container_AC")
|
136 |
-
|
137 |
-
display(container)
|
138 |
-
|
|
|
1 |
+
##~ AutoCleaner V3.7 CODE | BY: ANXETY ~##
|
2 |
+
|
3 |
+
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 |
+
# ================= 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")
|
16 |
+
}
|
17 |
+
for env_var, (environment, path) in environments.items():
|
18 |
+
if env_var in os.environ:
|
19 |
+
return environment, path, free_plan
|
20 |
+
|
21 |
+
env, root_path, free_plan = detect_environment()
|
22 |
+
webui_path = f"{root_path}/sdw"
|
23 |
+
|
24 |
+
|
25 |
+
# ==================== CSS ====================
|
26 |
+
# Main CSS
|
27 |
+
css_file_path = f"{root_path}/CSS/auto_cleaner.css"
|
28 |
+
with open(css_file_path , "r") as f:
|
29 |
+
CSS_AC = f.read()
|
30 |
+
display(HTML(f"<style>{CSS_AC}</style>"))
|
31 |
+
|
32 |
+
|
33 |
+
# ================ AutoCleaner function ================
|
34 |
+
directories = {
|
35 |
+
"Изображения": f"{webui_path}/output",
|
36 |
+
"Модели": f"{webui_path}/models/Stable-diffusion/",
|
37 |
+
"Vae": f"{webui_path}/models/VAE/",
|
38 |
+
"LoRa": f"{webui_path}/models/Lora/",
|
39 |
+
"ControlNet Модели": f"{webui_path}/models/ControlNet/"
|
40 |
+
}
|
41 |
+
|
42 |
+
""" functions """
|
43 |
+
def clean_directory(directory):
|
44 |
+
deleted_files = 0
|
45 |
+
image_dir = directories['Изображения']
|
46 |
+
|
47 |
+
for root, dirs, files in os.walk(directory):
|
48 |
+
for file in files:
|
49 |
+
file_path = os.path.join(root, file)
|
50 |
+
|
51 |
+
if file.endswith(".txt"):
|
52 |
+
continue
|
53 |
+
if file.endswith((".safetensors", ".pt")) or root == image_dir: # fix for image counter
|
54 |
+
deleted_files += 1
|
55 |
+
|
56 |
+
os.remove(file_path)
|
57 |
+
return deleted_files
|
58 |
+
|
59 |
+
def update_memory_info():
|
60 |
+
disk_space = psutil.disk_usage(os.getcwd())
|
61 |
+
total = disk_space.total / (1024 ** 3)
|
62 |
+
used = disk_space.used / (1024 ** 3)
|
63 |
+
free = disk_space.free / (1024 ** 3)
|
64 |
+
|
65 |
+
storage_info.value = f'''
|
66 |
+
<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>
|
67 |
+
'''
|
68 |
+
|
69 |
+
def on_execute_button_press(button):
|
70 |
+
selected_cleaners = auto_cleaner_widget.value
|
71 |
+
deleted_files_dict = {}
|
72 |
+
|
73 |
+
for option in selected_cleaners:
|
74 |
+
if option in directories:
|
75 |
+
deleted_files_dict[option] = clean_directory(directories[option])
|
76 |
+
|
77 |
+
output.clear_output()
|
78 |
+
|
79 |
+
with output:
|
80 |
+
for message in generate_messages(deleted_files_dict):
|
81 |
+
message_widget = HTML(f'<p class="output_message_AC">{message}</p>')
|
82 |
+
display(message_widget)
|
83 |
+
|
84 |
+
update_memory_info()
|
85 |
+
|
86 |
+
def on_clear_button_press(button):
|
87 |
+
container.add_class("hide")
|
88 |
+
time.sleep(0.5)
|
89 |
+
widgets.Widget.close_all()
|
90 |
+
|
91 |
+
def generate_messages(deleted_files_dict):
|
92 |
+
messages = []
|
93 |
+
word_variants = {
|
94 |
+
"Изображения": "Изображений",
|
95 |
+
"Модели": "Моделей",
|
96 |
+
"Vae": "Vae",
|
97 |
+
"LoRa": "LoRa",
|
98 |
+
"ControlNet Модели": "ControlNet Моделей"
|
99 |
+
}
|
100 |
+
for key, value in deleted_files_dict.items():
|
101 |
+
object_word = word_variants.get(key)
|
102 |
+
messages.append(f"Удалено {value} {object_word}")
|
103 |
+
return messages
|
104 |
+
|
105 |
+
|
106 |
+
# --- storage memory ---
|
107 |
+
import psutil
|
108 |
+
disk_space = psutil.disk_usage(os.getcwd())
|
109 |
+
total = disk_space.total / (1024 ** 3)
|
110 |
+
used = disk_space.used / (1024 ** 3)
|
111 |
+
free = disk_space.free / (1024 ** 3)
|
112 |
+
|
113 |
+
|
114 |
+
# ================ Widgets ================
|
115 |
+
# UI Code
|
116 |
+
AutoCleaner_options = AutoCleaner_options = list(directories.keys())
|
117 |
+
instruction_label = widgets.HTML('''
|
118 |
+
<span class="instruction_AC">Используйте <span style="color: #B2B2B2;">ctrl</span> или <span style="color: #B2B2B2;">shift</span> для множественного выбора.</span>
|
119 |
+
''')
|
120 |
+
auto_cleaner_widget = widgets.SelectMultiple(options=AutoCleaner_options, layout=widgets.Layout(width="auto")).add_class("custom-select-multiple_AC")
|
121 |
+
output = widgets.Output().add_class("output_AC")
|
122 |
+
|
123 |
+
execute_button = Button(description='Выполнить Очистку').add_class("button_execute_AC").add_class("button_AC")
|
124 |
+
execute_button.on_click(on_execute_button_press)
|
125 |
+
clear_button = Button(description='Скрыть Виджет').add_class("button_clear_AC").add_class("button_AC")
|
126 |
+
clear_button.on_click(on_clear_button_press)
|
127 |
+
|
128 |
+
storage_info = widgets.HTML(f'''
|
129 |
+
<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>
|
130 |
+
''')
|
131 |
+
|
132 |
+
buttons = widgets.HBox([execute_button, clear_button])
|
133 |
+
lower_information_panel = widgets.HBox([buttons, storage_info]).add_class("lower_information_panel_AC")
|
134 |
+
|
135 |
+
container = VBox([instruction_label, widgets.HTML('<hr>'), auto_cleaner_widget, output, widgets.HTML('<hr>'), lower_information_panel]).add_class("container_AC")
|
136 |
+
|
137 |
+
display(container)
|
138 |
+
|
files_cells/python/ru/downloading_ru.py
CHANGED
@@ -66,7 +66,7 @@ if not os.path.exists(flag_file):
|
|
66 |
with capture.capture_output() as cap:
|
67 |
get_ipython().system('curl -s -OL https://github.com/DEX-1101/sd-webui-notebook/raw/main/res/new_tunnel --output-dir {root_path}')
|
68 |
get_ipython().system('curl -s -Lo /usr/bin/cl https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 && chmod +x /usr/bin/cl')
|
69 |
-
get_ipython().system('curl -sLO https://github.com/openziti/zrok/releases/download/v0.4.
|
70 |
del cap
|
71 |
|
72 |
clear_output()
|
|
|
66 |
with capture.capture_output() as cap:
|
67 |
get_ipython().system('curl -s -OL https://github.com/DEX-1101/sd-webui-notebook/raw/main/res/new_tunnel --output-dir {root_path}')
|
68 |
get_ipython().system('curl -s -Lo /usr/bin/cl https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 && chmod +x /usr/bin/cl')
|
69 |
+
get_ipython().system('curl -sLO https://github.com/openziti/zrok/releases/download/v0.4.32/zrok_0.4.32_linux_amd64.tar.gz && tar -xzf zrok_0.4.32_linux_amd64.tar.gz -C /usr/bin && rm -f zrok_0.4.32_linux_amd64.tar.gz')
|
70 |
del cap
|
71 |
|
72 |
clear_output()
|
files_cells/python/ru/widgets_ru.py
CHANGED
@@ -1,322 +1,322 @@
|
|
1 |
-
##~ WIDGET CODE | BY: 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 |
-
# ================= 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")
|
17 |
-
}
|
18 |
-
for env_var, (environment, path) in environments.items():
|
19 |
-
if env_var in os.environ:
|
20 |
-
return environment, path, free_plan
|
21 |
-
|
22 |
-
env, root_path, free_plan = detect_environment()
|
23 |
-
webui_path = f"{root_path}/sdw"
|
24 |
-
get_ipython().system('mkdir -p {root_path}')
|
25 |
-
|
26 |
-
|
27 |
-
# ==================== CSS JS ====================
|
28 |
-
##~ custom background images V1.5 ~##
|
29 |
-
import argparse
|
30 |
-
parser = argparse.ArgumentParser(description='This script processes an background image.')
|
31 |
-
parser.add_argument('-i', '--image', type=str, help='URL of the image to process', metavar='')
|
32 |
-
parser.add_argument('-o', '--opacity', type=float, help='Opacity level for the image, between 0 and 1', metavar='', default=0.3)
|
33 |
-
parser.add_argument('-b', '--blur', type=str, help='Blur level for the image', metavar='', default=0)
|
34 |
-
parser.add_argument('-y', type=int, help='Y coordinate for the image in px', metavar='', default=0)
|
35 |
-
parser.add_argument('-x', type=int, help='X coordinate for the image in px', metavar='', default=0)
|
36 |
-
parser.add_argument('-s', '--scale', type=int, help='Scale image in %%', metavar='', default=100)
|
37 |
-
parser.add_argument('-m', '--mode', action='store_true', help='Removes repetitive image tiles')
|
38 |
-
parser.add_argument('-t', '--transparent', action='store_true', help='Makes input/selection fields 35%% more transparent')
|
39 |
-
parser.add_argument('-bf', '--blur-fields', type=str, help='Background blur level for input/selection fields', metavar='', default=2)
|
40 |
-
|
41 |
-
args = parser.parse_args()
|
42 |
-
|
43 |
-
url_img = args.image
|
44 |
-
opacity_img = args.opacity
|
45 |
-
blur_img = args.blur
|
46 |
-
y_img = args.y
|
47 |
-
x_img = args.x
|
48 |
-
scale_img = args.scale
|
49 |
-
blur_fields = args.blur_fields
|
50 |
-
|
51 |
-
## ---
|
52 |
-
""" WTF KAGGLE - WHAT THE FUCK IS THE DIFFERENCE OF 35 PIXELS!?!?!? """
|
53 |
-
fix_heigh_img = "-810px" if env == "Kaggle" else "-775px"
|
54 |
-
|
55 |
-
""" transperent fields """
|
56 |
-
t_bg_alpha = "1" if not args.transparent else "0.65"
|
57 |
-
|
58 |
-
""" mode img - repeats """
|
59 |
-
mode_img = "repeat" if not args.mode else "no-repeat"
|
60 |
-
|
61 |
-
container_background = f'''
|
62 |
-
<style>
|
63 |
-
:root {{
|
64 |
-
/* for background container*/
|
65 |
-
--img_background: url({url_img});
|
66 |
-
--img_opacity: {opacity_img};
|
67 |
-
--img_blur: {blur_img}px;
|
68 |
-
--image_y: {y_img}px;
|
69 |
-
--image_x: {x_img}px;
|
70 |
-
--img_scale: {scale_img}%;
|
71 |
-
--img_mode: {mode_img};
|
72 |
-
--img_height_dif: {fix_heigh_img};
|
73 |
-
|
74 |
-
/* for fields */
|
75 |
-
--bg-field-color: rgba(28, 28, 28, {t_bg_alpha}); /* -> #1c1c1c */
|
76 |
-
--bg-field-color-hover: rgba(38, 38, 38, {t_bg_alpha}); /* -> #262626; */
|
77 |
-
--bg-field-blur-level: {blur_fields}px;
|
78 |
-
}}
|
79 |
-
'''
|
80 |
-
|
81 |
-
display(HTML(container_background))
|
82 |
-
|
83 |
-
# Main CSS
|
84 |
-
css_file_path = f"{root_path}/CSS/main_widgets.css"
|
85 |
-
with open(css_file_path , "r") as f:
|
86 |
-
CSS = f.read()
|
87 |
-
display(HTML(f"<style>{CSS}</style>"))
|
88 |
-
|
89 |
-
# Main JS
|
90 |
-
JS = '''
|
91 |
-
<!-- TOGGLE 'CustomDL' SCRIPT -->
|
92 |
-
<script>
|
93 |
-
function toggleContainer() {
|
94 |
-
let downloadContainer = document.querySelector('.container_custom_downlad');
|
95 |
-
let info = document.querySelector('.info');
|
96 |
-
|
97 |
-
downloadContainer.classList.toggle('expanded');
|
98 |
-
info.classList.toggle('showed');
|
99 |
-
}
|
100 |
-
</script>
|
101 |
-
'''
|
102 |
-
display(HTML(JS))
|
103 |
-
|
104 |
-
# ==================== WIDGETS V2 ====================
|
105 |
-
HR = widgets.HTML('<hr>')
|
106 |
-
|
107 |
-
class WidgetFactory:
|
108 |
-
def __init__(self, style=None, layout=None):
|
109 |
-
self.style = style if style else {'description_width': 'initial'}
|
110 |
-
self.layout = layout if layout else widgets.Layout(max_width='1080px', width='100%')
|
111 |
-
|
112 |
-
def create_html(self, content, class_name=None):
|
113 |
-
html_widget = widgets.HTML(content)
|
114 |
-
if class_name:
|
115 |
-
html_widget.add_class(class_name)
|
116 |
-
return html_widget
|
117 |
-
|
118 |
-
def create_header(self, name):
|
119 |
-
return widgets.HTML(f'<div class="header">{name}<div>')
|
120 |
-
|
121 |
-
def create_dropdown(self, options, value, description):
|
122 |
-
return widgets.Dropdown(options=options, value=value, description=description, style=self.style, layout=self.layout)
|
123 |
-
|
124 |
-
def create_text(self, description, placeholder='', value=''):
|
125 |
-
return widgets.Text(description=description, placeholder=placeholder, value=value, style=self.style, layout=self.layout)
|
126 |
-
|
127 |
-
def create_checkbox(self, value, description):
|
128 |
-
return widgets.Checkbox(value=value, description=description, style=self.style, layout=self.layout)
|
129 |
-
|
130 |
-
def create_button(self, description, class_name=None):
|
131 |
-
button = widgets.Button(description=description)
|
132 |
-
if class_name:
|
133 |
-
button.add_class(class_name)
|
134 |
-
return button
|
135 |
-
|
136 |
-
def create_hbox(self, children):
|
137 |
-
return widgets.HBox(children)
|
138 |
-
|
139 |
-
def create_vbox(self, children, class_names=None):
|
140 |
-
vbox = widgets.VBox(children)
|
141 |
-
if class_names:
|
142 |
-
for class_name in class_names:
|
143 |
-
vbox.add_class(class_name)
|
144 |
-
return vbox
|
145 |
-
|
146 |
-
def display(self, widget):
|
147 |
-
display(widget)
|
148 |
-
|
149 |
-
# Instantiate the factory
|
150 |
-
factory = WidgetFactory()
|
151 |
-
|
152 |
-
# --- MODEL ---
|
153 |
-
model_header = factory.create_header('Выбор Модели')
|
154 |
-
model_options = ['none',
|
155 |
-
'1.Anime (by XpucT) + INP',
|
156 |
-
'2.BluMix [Anime] [V7] + INP',
|
157 |
-
'3.Cetus-Mix [Anime] [V4] + INP',
|
158 |
-
'4.Counterfeit [Anime] [V3] + INP',
|
159 |
-
'5.CuteColor [Anime] [V3]',
|
160 |
-
'6.Dark-Sushi-Mix [Anime]',
|
161 |
-
'7.Deliberate [Realism] [V6] + INP',
|
162 |
-
'8.Meina-Mix [Anime] [V11] + INP',
|
163 |
-
'9.Mix-Pro [Anime] [V4] + INP']
|
164 |
-
model_widget = factory.create_dropdown(model_options, '4.Counterfeit [Anime] [V3] + INP', 'Модель:')
|
165 |
-
model_num_widget = factory.create_text('Номер Модели:', 'Введите номера моделей для скачивания через запятую/пробел.')
|
166 |
-
inpainting_model_widget = factory.create_checkbox(False, 'Inpainting Модели')
|
167 |
-
|
168 |
-
# Display Model
|
169 |
-
all_model_box = factory.create_vbox([model_header, model_widget, model_num_widget, inpainting_model_widget], class_names=["container", "image_1"])
|
170 |
-
factory.display(all_model_box)
|
171 |
-
|
172 |
-
# --- VAE ---
|
173 |
-
vae_header = factory.create_header('Выбор VAE')
|
174 |
-
vae_options = ['none',
|
175 |
-
'1.Anime.vae',
|
176 |
-
'2.Anything.vae',
|
177 |
-
'3.Blessed2.vae',
|
178 |
-
'4.ClearVae.vae',
|
179 |
-
'5.WD.vae']
|
180 |
-
vae_widget = factory.create_dropdown(vae_options, '3.Blessed2.vae', 'Vae:')
|
181 |
-
vae_num_widget = factory.create_text('Номер Vae:', 'Введите номера vae для скачивания через запятую/пробел.')
|
182 |
-
|
183 |
-
# Display Vae
|
184 |
-
all_vae_box = factory.create_vbox([vae_header, vae_widget, vae_num_widget], class_names=["container", "image_2"])
|
185 |
-
factory.display(all_vae_box)
|
186 |
-
|
187 |
-
# --- ADDITIONAL ---
|
188 |
-
additional_header = factory.create_header('Дополнительно')
|
189 |
-
latest_webui_widget = factory.create_checkbox(True, 'Обновить WebUI')
|
190 |
-
latest_exstensions_widget = factory.create_checkbox(True, 'Обновить Расширения')
|
191 |
-
change_webui_widget = factory.create_dropdown(['A1111', 'Forge'], 'A1111', 'Изменить WebUI:')
|
192 |
-
detailed_download_widget = factory.create_dropdown(['off', 'on'], 'off', 'Подробная Загрузка:')
|
193 |
-
choose_changes_widget = factory.create_hbox([latest_webui_widget, latest_exstensions_widget, change_webui_widget, detailed_download_widget])
|
194 |
-
|
195 |
-
controlnet_options = ['none', 'ALL', '1.canny',
|
196 |
-
'2.openpose', '3.depth',
|
197 |
-
'4.normal_map', '5.mlsd',
|
198 |
-
'6.lineart', '7.soft_edge',
|
199 |
-
'8.scribble', '9.segmentation',
|
200 |
-
'10.shuffle', '11.tile',
|
201 |
-
'12.inpaint', '13.instruct_p2p']
|
202 |
-
controlnet_widget = factory.create_dropdown(controlnet_options, 'none', 'ControlNet:')
|
203 |
-
controlnet_num_widget = factory.create_text('Номер ControlNet:', 'Введите номера моделей ControlNet для скачивания через запятую/пробел.')
|
204 |
-
commit_hash_widget = factory.create_text('Commit Hash:')
|
205 |
-
huggingface_token_widget = factory.create_text('Токен HuggingFace:')
|
206 |
-
|
207 |
-
ngrok_token_widget = factory.create_text('Токен Ngrok:')
|
208 |
-
ngrock_button = factory.create_html('<a href="https://dashboard.ngrok.com/get-started/your-authtoken" target="_blank">Получить Ngrok Токен</a>', class_name="button_ngrok")
|
209 |
-
ngrok_widget = factory.create_hbox([ngrok_token_widget, ngrock_button])
|
210 |
-
|
211 |
-
zrok_token_widget = factory.create_text('Токен Zrok:')
|
212 |
-
zrok_button = factory.create_html('<a href="https://colab.research.google.com/drive/1d2sjWDJi_GYBUavrHSuQyHTDuLy36WpU" target="_blank">Зарегать Zrok Токен</a>', class_name="button_ngrok")
|
213 |
-
zrok_widget = factory.create_hbox([zrok_token_widget, zrok_button])
|
214 |
-
|
215 |
-
commandline_arguments_options = "--listen --enable-insecure-extension-access --theme dark --no-half-vae --disable-console-progressbars --xformers"
|
216 |
-
commandline_arguments_widget = factory.create_text('Аргументы:', value=commandline_arguments_options)
|
217 |
-
|
218 |
-
# Display Additional
|
219 |
-
additional_widget_list = [additional_header,
|
220 |
-
choose_changes_widget,
|
221 |
-
HR,
|
222 |
-
controlnet_widget,
|
223 |
-
controlnet_num_widget,
|
224 |
-
commit_hash_widget,
|
225 |
-
huggingface_token_widget,
|
226 |
-
ngrok_widget,
|
227 |
-
zrok_widget,
|
228 |
-
HR,
|
229 |
-
commandline_arguments_widget]
|
230 |
-
|
231 |
-
if free_plan and env == "Google Colab": # remove ngrok from colab
|
232 |
-
additional_widget_list.remove(ngrok_widget)
|
233 |
-
if os.path.exists(webui_path): # remove selection after selection ;3
|
234 |
-
choose_changes_widget.children = [widget for widget in choose_changes_widget.children if widget != change_webui_widget]
|
235 |
-
|
236 |
-
all_additional_box = factory.create_vbox(additional_widget_list, class_names=["container", "image_3"])
|
237 |
-
factory.display(all_additional_box)
|
238 |
-
|
239 |
-
# --- CUSTOM DOWNLOAD ---
|
240 |
-
custom_download_header_popup = factory.create_html('''
|
241 |
-
<style>
|
242 |
-
/* Term Colors */
|
243 |
-
.sample_label {color: #dbafff;}
|
244 |
-
.braces {color: #ffff00;}
|
245 |
-
.extension {color: #eb934b;}
|
246 |
-
.file_name {color: #ffffd8;}
|
247 |
-
</style>
|
248 |
-
|
249 |
-
<div class="header" style="cursor: pointer;" onclick="toggleContainer()">Кастомная Загрузка</div>
|
250 |
-
<!-- PopUp Window -->
|
251 |
-
<div class="info" id="info_dl">INFO</div>
|
252 |
-
<div class="popup">
|
253 |
-
|
254 |
-
после URL без пробелов.
|
255 |
-
<span style="color: #ff9999">Для файлов обязательно укажите</span> - <span class="extension">Расширение Файла.</span>
|
256 |
-
<div class="sample">
|
257 |
-
<span class="sample_label">Пример для Файла:</span>
|
258 |
-
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>
|
259 |
-
<br>
|
260 |
-
<span class="sample_label">Пример для Расширения:</span>
|
261 |
-
https://github.com/hako-mikan/sd-webui-regional-prompter<span class="braces">[</span><span class="file_name">Regional-Prompter</span><span class="braces">]</span>
|
262 |
-
</div>
|
263 |
-
</div>
|
264 |
-
''')
|
265 |
-
|
266 |
-
Model_url_widget = factory.create_text('Model:')
|
267 |
-
Vae_url_widget = factory.create_text('Vae:')
|
268 |
-
LoRA_url_widget = factory.create_text('LoRa:')
|
269 |
-
Embedding_url_widget = factory.create_text('Embedding:')
|
270 |
-
Extensions_url_widget = factory.create_text('Extensions:')
|
271 |
-
custom_file_urls_widget = factory.create_text('Файл (txt):')
|
272 |
-
|
273 |
-
# Display CustomDl
|
274 |
-
all_custom_box = factory.create_vbox([
|
275 |
-
custom_download_header_popup, Model_url_widget, Vae_url_widget, LoRA_url_widget, Embedding_url_widget, Extensions_url_widget, custom_file_urls_widget
|
276 |
-
], class_names=["container", "image_4", "container_custom_downlad"])
|
277 |
-
factory.display(all_custom_box)
|
278 |
-
|
279 |
-
# --- Save Button ---
|
280 |
-
save_button = factory.create_button('Сохранить', class_name="button_save")
|
281 |
-
factory.display(save_button)
|
282 |
-
|
283 |
-
|
284 |
-
# ============ Load / Save - Settings V2 ============
|
285 |
-
SETTINGS_FILE = f'{root_path}/settings.json'
|
286 |
-
|
287 |
-
SETTINGS_KEYS = [
|
288 |
-
'model', 'model_num', 'inpainting_model',
|
289 |
-
'vae', 'vae_num', 'latest_webui', 'latest_exstensions',
|
290 |
-
'change_webui', 'detailed_download', 'controlnet',
|
291 |
-
'controlnet_num', 'commit_hash', 'huggingface_token',
|
292 |
-
'ngrok_token', 'zrok_token', 'commandline_arguments',
|
293 |
-
'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url',
|
294 |
-
'Extensions_url', 'custom_file_urls'
|
295 |
-
]
|
296 |
-
|
297 |
-
def save_settings():
|
298 |
-
settings = {key: globals()[f"{key}_widget"].value for key in SETTINGS_KEYS}
|
299 |
-
with open(SETTINGS_FILE, 'w') as f:
|
300 |
-
json.dump(settings, f, indent=2)
|
301 |
-
|
302 |
-
def load_settings():
|
303 |
-
if os.path.exists(SETTINGS_FILE):
|
304 |
-
with open(SETTINGS_FILE, 'r') as f:
|
305 |
-
settings = json.load(f)
|
306 |
-
for key in SETTINGS_KEYS:
|
307 |
-
globals()[f"{key}_widget"].value = settings.get(key, "")
|
308 |
-
|
309 |
-
def hide_widgets():
|
310 |
-
widgets_list = [all_model_box, all_vae_box, all_additional_box, all_custom_box, save_button]
|
311 |
-
for widget in widgets_list:
|
312 |
-
widget.add_class("hide")
|
313 |
-
time.sleep(0.5)
|
314 |
-
widgets.Widget.close_all()
|
315 |
-
|
316 |
-
def save_data(button):
|
317 |
-
save_settings()
|
318 |
-
hide_widgets()
|
319 |
-
|
320 |
-
load_settings()
|
321 |
-
save_button.on_click(save_data)
|
322 |
-
|
|
|
1 |
+
##~ WIDGET CODE | BY: 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 |
+
# ================= 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")
|
17 |
+
}
|
18 |
+
for env_var, (environment, path) in environments.items():
|
19 |
+
if env_var in os.environ:
|
20 |
+
return environment, path, free_plan
|
21 |
+
|
22 |
+
env, root_path, free_plan = detect_environment()
|
23 |
+
webui_path = f"{root_path}/sdw"
|
24 |
+
get_ipython().system('mkdir -p {root_path}')
|
25 |
+
|
26 |
+
|
27 |
+
# ==================== CSS JS ====================
|
28 |
+
##~ custom background images V1.5 ~##
|
29 |
+
import argparse
|
30 |
+
parser = argparse.ArgumentParser(description='This script processes an background image.')
|
31 |
+
parser.add_argument('-i', '--image', type=str, help='URL of the image to process', metavar='')
|
32 |
+
parser.add_argument('-o', '--opacity', type=float, help='Opacity level for the image, between 0 and 1', metavar='', default=0.3)
|
33 |
+
parser.add_argument('-b', '--blur', type=str, help='Blur level for the image', metavar='', default=0)
|
34 |
+
parser.add_argument('-y', type=int, help='Y coordinate for the image in px', metavar='', default=0)
|
35 |
+
parser.add_argument('-x', type=int, help='X coordinate for the image in px', metavar='', default=0)
|
36 |
+
parser.add_argument('-s', '--scale', type=int, help='Scale image in %%', metavar='', default=100)
|
37 |
+
parser.add_argument('-m', '--mode', action='store_true', help='Removes repetitive image tiles')
|
38 |
+
parser.add_argument('-t', '--transparent', action='store_true', help='Makes input/selection fields 35%% more transparent')
|
39 |
+
parser.add_argument('-bf', '--blur-fields', type=str, help='Background blur level for input/selection fields', metavar='', default=2)
|
40 |
+
|
41 |
+
args = parser.parse_args()
|
42 |
+
|
43 |
+
url_img = args.image
|
44 |
+
opacity_img = args.opacity
|
45 |
+
blur_img = args.blur
|
46 |
+
y_img = args.y
|
47 |
+
x_img = args.x
|
48 |
+
scale_img = args.scale
|
49 |
+
blur_fields = args.blur_fields
|
50 |
+
|
51 |
+
## ---
|
52 |
+
""" WTF KAGGLE - WHAT THE FUCK IS THE DIFFERENCE OF 35 PIXELS!?!?!? """
|
53 |
+
fix_heigh_img = "-810px" if env == "Kaggle" else "-775px"
|
54 |
+
|
55 |
+
""" transperent fields """
|
56 |
+
t_bg_alpha = "1" if not args.transparent else "0.65"
|
57 |
+
|
58 |
+
""" mode img - repeats """
|
59 |
+
mode_img = "repeat" if not args.mode else "no-repeat"
|
60 |
+
|
61 |
+
container_background = f'''
|
62 |
+
<style>
|
63 |
+
:root {{
|
64 |
+
/* for background container*/
|
65 |
+
--img_background: url({url_img});
|
66 |
+
--img_opacity: {opacity_img};
|
67 |
+
--img_blur: {blur_img}px;
|
68 |
+
--image_y: {y_img}px;
|
69 |
+
--image_x: {x_img}px;
|
70 |
+
--img_scale: {scale_img}%;
|
71 |
+
--img_mode: {mode_img};
|
72 |
+
--img_height_dif: {fix_heigh_img};
|
73 |
+
|
74 |
+
/* for fields */
|
75 |
+
--bg-field-color: rgba(28, 28, 28, {t_bg_alpha}); /* -> #1c1c1c */
|
76 |
+
--bg-field-color-hover: rgba(38, 38, 38, {t_bg_alpha}); /* -> #262626; */
|
77 |
+
--bg-field-blur-level: {blur_fields}px;
|
78 |
+
}}
|
79 |
+
'''
|
80 |
+
|
81 |
+
display(HTML(container_background))
|
82 |
+
|
83 |
+
# Main CSS
|
84 |
+
css_file_path = f"{root_path}/CSS/main_widgets.css"
|
85 |
+
with open(css_file_path , "r") as f:
|
86 |
+
CSS = f.read()
|
87 |
+
display(HTML(f"<style>{CSS}</style>"))
|
88 |
+
|
89 |
+
# Main JS
|
90 |
+
JS = '''
|
91 |
+
<!-- TOGGLE 'CustomDL' SCRIPT -->
|
92 |
+
<script>
|
93 |
+
function toggleContainer() {
|
94 |
+
let downloadContainer = document.querySelector('.container_custom_downlad');
|
95 |
+
let info = document.querySelector('.info');
|
96 |
+
|
97 |
+
downloadContainer.classList.toggle('expanded');
|
98 |
+
info.classList.toggle('showed');
|
99 |
+
}
|
100 |
+
</script>
|
101 |
+
'''
|
102 |
+
display(HTML(JS))
|
103 |
+
|
104 |
+
# ==================== WIDGETS V2 ====================
|
105 |
+
HR = widgets.HTML('<hr>')
|
106 |
+
|
107 |
+
class WidgetFactory:
|
108 |
+
def __init__(self, style=None, layout=None):
|
109 |
+
self.style = style if style else {'description_width': 'initial'}
|
110 |
+
self.layout = layout if layout else widgets.Layout(max_width='1080px', width='100%')
|
111 |
+
|
112 |
+
def create_html(self, content, class_name=None):
|
113 |
+
html_widget = widgets.HTML(content)
|
114 |
+
if class_name:
|
115 |
+
html_widget.add_class(class_name)
|
116 |
+
return html_widget
|
117 |
+
|
118 |
+
def create_header(self, name):
|
119 |
+
return widgets.HTML(f'<div class="header">{name}<div>')
|
120 |
+
|
121 |
+
def create_dropdown(self, options, value, description):
|
122 |
+
return widgets.Dropdown(options=options, value=value, description=description, style=self.style, layout=self.layout)
|
123 |
+
|
124 |
+
def create_text(self, description, placeholder='', value=''):
|
125 |
+
return widgets.Text(description=description, placeholder=placeholder, value=value, style=self.style, layout=self.layout)
|
126 |
+
|
127 |
+
def create_checkbox(self, value, description):
|
128 |
+
return widgets.Checkbox(value=value, description=description, style=self.style, layout=self.layout)
|
129 |
+
|
130 |
+
def create_button(self, description, class_name=None):
|
131 |
+
button = widgets.Button(description=description)
|
132 |
+
if class_name:
|
133 |
+
button.add_class(class_name)
|
134 |
+
return button
|
135 |
+
|
136 |
+
def create_hbox(self, children):
|
137 |
+
return widgets.HBox(children)
|
138 |
+
|
139 |
+
def create_vbox(self, children, class_names=None):
|
140 |
+
vbox = widgets.VBox(children)
|
141 |
+
if class_names:
|
142 |
+
for class_name in class_names:
|
143 |
+
vbox.add_class(class_name)
|
144 |
+
return vbox
|
145 |
+
|
146 |
+
def display(self, widget):
|
147 |
+
display(widget)
|
148 |
+
|
149 |
+
# Instantiate the factory
|
150 |
+
factory = WidgetFactory()
|
151 |
+
|
152 |
+
# --- MODEL ---
|
153 |
+
model_header = factory.create_header('Выбор Модели')
|
154 |
+
model_options = ['none',
|
155 |
+
'1.Anime (by XpucT) + INP',
|
156 |
+
'2.BluMix [Anime] [V7] + INP',
|
157 |
+
'3.Cetus-Mix [Anime] [V4] + INP',
|
158 |
+
'4.Counterfeit [Anime] [V3] + INP',
|
159 |
+
'5.CuteColor [Anime] [V3]',
|
160 |
+
'6.Dark-Sushi-Mix [Anime]',
|
161 |
+
'7.Deliberate [Realism] [V6] + INP',
|
162 |
+
'8.Meina-Mix [Anime] [V11] + INP',
|
163 |
+
'9.Mix-Pro [Anime] [V4] + INP']
|
164 |
+
model_widget = factory.create_dropdown(model_options, '4.Counterfeit [Anime] [V3] + INP', 'Модель:')
|
165 |
+
model_num_widget = factory.create_text('Номер Модели:', 'Введите номера моделей для скачивания через запятую/пробел.')
|
166 |
+
inpainting_model_widget = factory.create_checkbox(False, 'Inpainting Модели')
|
167 |
+
|
168 |
+
# Display Model
|
169 |
+
all_model_box = factory.create_vbox([model_header, model_widget, model_num_widget, inpainting_model_widget], class_names=["container", "image_1"])
|
170 |
+
factory.display(all_model_box)
|
171 |
+
|
172 |
+
# --- VAE ---
|
173 |
+
vae_header = factory.create_header('Выбор VAE')
|
174 |
+
vae_options = ['none',
|
175 |
+
'1.Anime.vae',
|
176 |
+
'2.Anything.vae',
|
177 |
+
'3.Blessed2.vae',
|
178 |
+
'4.ClearVae.vae',
|
179 |
+
'5.WD.vae']
|
180 |
+
vae_widget = factory.create_dropdown(vae_options, '3.Blessed2.vae', 'Vae:')
|
181 |
+
vae_num_widget = factory.create_text('Номер Vae:', 'Введите номера vae для скачивания через запятую/пробел.')
|
182 |
+
|
183 |
+
# Display Vae
|
184 |
+
all_vae_box = factory.create_vbox([vae_header, vae_widget, vae_num_widget], class_names=["container", "image_2"])
|
185 |
+
factory.display(all_vae_box)
|
186 |
+
|
187 |
+
# --- ADDITIONAL ---
|
188 |
+
additional_header = factory.create_header('Дополнительно')
|
189 |
+
latest_webui_widget = factory.create_checkbox(True, 'Обновить WebUI')
|
190 |
+
latest_exstensions_widget = factory.create_checkbox(True, 'Обновить Расширения')
|
191 |
+
change_webui_widget = factory.create_dropdown(['A1111', 'Forge'], 'A1111', 'Изменить WebUI:')
|
192 |
+
detailed_download_widget = factory.create_dropdown(['off', 'on'], 'off', 'Подробная Загрузка:')
|
193 |
+
choose_changes_widget = factory.create_hbox([latest_webui_widget, latest_exstensions_widget, change_webui_widget, detailed_download_widget])
|
194 |
+
|
195 |
+
controlnet_options = ['none', 'ALL', '1.canny',
|
196 |
+
'2.openpose', '3.depth',
|
197 |
+
'4.normal_map', '5.mlsd',
|
198 |
+
'6.lineart', '7.soft_edge',
|
199 |
+
'8.scribble', '9.segmentation',
|
200 |
+
'10.shuffle', '11.tile',
|
201 |
+
'12.inpaint', '13.instruct_p2p']
|
202 |
+
controlnet_widget = factory.create_dropdown(controlnet_options, 'none', 'ControlNet:')
|
203 |
+
controlnet_num_widget = factory.create_text('Номер ControlNet:', 'Введите номера моделей ControlNet для скачивания через запятую/пробел.')
|
204 |
+
commit_hash_widget = factory.create_text('Commit Hash:')
|
205 |
+
huggingface_token_widget = factory.create_text('Токен HuggingFace:')
|
206 |
+
|
207 |
+
ngrok_token_widget = factory.create_text('Токен Ngrok:')
|
208 |
+
ngrock_button = factory.create_html('<a href="https://dashboard.ngrok.com/get-started/your-authtoken" target="_blank">Получить Ngrok Токен</a>', class_name="button_ngrok")
|
209 |
+
ngrok_widget = factory.create_hbox([ngrok_token_widget, ngrock_button])
|
210 |
+
|
211 |
+
zrok_token_widget = factory.create_text('Токен Zrok:')
|
212 |
+
zrok_button = factory.create_html('<a href="https://colab.research.google.com/drive/1d2sjWDJi_GYBUavrHSuQyHTDuLy36WpU" target="_blank">Зарегать Zrok Токен</a>', class_name="button_ngrok")
|
213 |
+
zrok_widget = factory.create_hbox([zrok_token_widget, zrok_button])
|
214 |
+
|
215 |
+
commandline_arguments_options = "--listen --enable-insecure-extension-access --theme dark --no-half-vae --disable-console-progressbars --xformers"
|
216 |
+
commandline_arguments_widget = factory.create_text('Аргументы:', value=commandline_arguments_options)
|
217 |
+
|
218 |
+
# Display Additional
|
219 |
+
additional_widget_list = [additional_header,
|
220 |
+
choose_changes_widget,
|
221 |
+
HR,
|
222 |
+
controlnet_widget,
|
223 |
+
controlnet_num_widget,
|
224 |
+
commit_hash_widget,
|
225 |
+
huggingface_token_widget,
|
226 |
+
ngrok_widget,
|
227 |
+
zrok_widget,
|
228 |
+
HR,
|
229 |
+
commandline_arguments_widget]
|
230 |
+
|
231 |
+
if free_plan and env == "Google Colab": # remove ngrok from colab
|
232 |
+
additional_widget_list.remove(ngrok_widget)
|
233 |
+
if os.path.exists(webui_path): # remove selection after selection ;3
|
234 |
+
choose_changes_widget.children = [widget for widget in choose_changes_widget.children if widget != change_webui_widget]
|
235 |
+
|
236 |
+
all_additional_box = factory.create_vbox(additional_widget_list, class_names=["container", "image_3"])
|
237 |
+
factory.display(all_additional_box)
|
238 |
+
|
239 |
+
# --- CUSTOM DOWNLOAD ---
|
240 |
+
custom_download_header_popup = factory.create_html('''
|
241 |
+
<style>
|
242 |
+
/* Term Colors */
|
243 |
+
.sample_label {color: #dbafff;}
|
244 |
+
.braces {color: #ffff00;}
|
245 |
+
.extension {color: #eb934b;}
|
246 |
+
.file_name {color: #ffffd8;}
|
247 |
+
</style>
|
248 |
+
|
249 |
+
<div class="header" style="cursor: pointer;" onclick="toggleContainer()">Кастомная Загрузка</div>
|
250 |
+
<!-- PopUp Window -->
|
251 |
+
<div class="info" id="info_dl">INFO</div>
|
252 |
+
<div class="popup">
|
253 |
+
��азделите несколько URL-адресов запятой/пробелом. Для <span class="file_name">пользовательского имени</span> файла/расширения укажите его через <span class="braces">[]</span>
|
254 |
+
после URL без пробелов.
|
255 |
+
<span style="color: #ff9999">Для файлов обязательно укажите</span> - <span class="extension">Расширение Файла.</span>
|
256 |
+
<div class="sample">
|
257 |
+
<span class="sample_label">Пример для Файла:</span>
|
258 |
+
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>
|
259 |
+
<br>
|
260 |
+
<span class="sample_label">Пример для Расширения:</span>
|
261 |
+
https://github.com/hako-mikan/sd-webui-regional-prompter<span class="braces">[</span><span class="file_name">Regional-Prompter</span><span class="braces">]</span>
|
262 |
+
</div>
|
263 |
+
</div>
|
264 |
+
''')
|
265 |
+
|
266 |
+
Model_url_widget = factory.create_text('Model:')
|
267 |
+
Vae_url_widget = factory.create_text('Vae:')
|
268 |
+
LoRA_url_widget = factory.create_text('LoRa:')
|
269 |
+
Embedding_url_widget = factory.create_text('Embedding:')
|
270 |
+
Extensions_url_widget = factory.create_text('Extensions:')
|
271 |
+
custom_file_urls_widget = factory.create_text('Файл (txt):')
|
272 |
+
|
273 |
+
# Display CustomDl
|
274 |
+
all_custom_box = factory.create_vbox([
|
275 |
+
custom_download_header_popup, Model_url_widget, Vae_url_widget, LoRA_url_widget, Embedding_url_widget, Extensions_url_widget, custom_file_urls_widget
|
276 |
+
], class_names=["container", "image_4", "container_custom_downlad"])
|
277 |
+
factory.display(all_custom_box)
|
278 |
+
|
279 |
+
# --- Save Button ---
|
280 |
+
save_button = factory.create_button('Сохранить', class_name="button_save")
|
281 |
+
factory.display(save_button)
|
282 |
+
|
283 |
+
|
284 |
+
# ============ Load / Save - Settings V2 ============
|
285 |
+
SETTINGS_FILE = f'{root_path}/settings.json'
|
286 |
+
|
287 |
+
SETTINGS_KEYS = [
|
288 |
+
'model', 'model_num', 'inpainting_model',
|
289 |
+
'vae', 'vae_num', 'latest_webui', 'latest_exstensions',
|
290 |
+
'change_webui', 'detailed_download', 'controlnet',
|
291 |
+
'controlnet_num', 'commit_hash', 'huggingface_token',
|
292 |
+
'ngrok_token', 'zrok_token', 'commandline_arguments',
|
293 |
+
'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url',
|
294 |
+
'Extensions_url', 'custom_file_urls'
|
295 |
+
]
|
296 |
+
|
297 |
+
def save_settings():
|
298 |
+
settings = {key: globals()[f"{key}_widget"].value for key in SETTINGS_KEYS}
|
299 |
+
with open(SETTINGS_FILE, 'w') as f:
|
300 |
+
json.dump(settings, f, indent=2)
|
301 |
+
|
302 |
+
def load_settings():
|
303 |
+
if os.path.exists(SETTINGS_FILE):
|
304 |
+
with open(SETTINGS_FILE, 'r') as f:
|
305 |
+
settings = json.load(f)
|
306 |
+
for key in SETTINGS_KEYS:
|
307 |
+
globals()[f"{key}_widget"].value = settings.get(key, "")
|
308 |
+
|
309 |
+
def hide_widgets():
|
310 |
+
widgets_list = [all_model_box, all_vae_box, all_additional_box, all_custom_box, save_button]
|
311 |
+
for widget in widgets_list:
|
312 |
+
widget.add_class("hide")
|
313 |
+
time.sleep(0.5)
|
314 |
+
widgets.Widget.close_all()
|
315 |
+
|
316 |
+
def save_data(button):
|
317 |
+
save_settings()
|
318 |
+
hide_widgets()
|
319 |
+
|
320 |
+
load_settings()
|
321 |
+
save_button.on_click(save_data)
|
322 |
+
|