NagisaNao commited on
Commit
88bad94
1 Parent(s): 0540f3c

test ⚡️

Browse files
CSS/auto_cleaner.css ADDED
@@ -0,0 +1,187 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* General Styles */
2
+
3
+ hr {
4
+ border-color: grey;
5
+ background-color: grey;
6
+ opacity: 0.25;
7
+ }
8
+
9
+ .instruction_AC {
10
+ font-family: cursive;
11
+ font-size: 18px;
12
+ color: grey;
13
+ user-select: none;
14
+ cursor: default;
15
+ }
16
+
17
+
18
+ /* Container style */
19
+
20
+ .container_AC {
21
+ position: relative;
22
+ background-color: #232323;
23
+ width: 800px;
24
+ height: auto;
25
+ padding: 15px;
26
+ border-radius: 15px;
27
+ box-shadow: 0 0 50px rgba(0, 0, 0, 0.3);
28
+ margin-bottom: 5px;
29
+ overflow: visible;
30
+ }
31
+
32
+ .container_AC::before {
33
+ position: absolute;
34
+ top: 5px;
35
+ right: 10px;
36
+ content: "AutoCleanerV3.7";
37
+ font-weight: bold;
38
+ font-size: 24px;
39
+ color: rgba(0, 0, 0, 0.2);
40
+ }
41
+
42
+ .container_AC::after {
43
+ position: absolute;
44
+ top: 30px;
45
+ right: 10px;
46
+ content: "ANXETY";
47
+ font-weight: bold;
48
+ font-size: 18px;
49
+ color: rgba(0, 0, 0, 0.2);
50
+ }
51
+
52
+ .custom-select-multiple_AC select {
53
+ padding: 10px;
54
+ font-family: cursive;
55
+ border: 1px solid #262626 !important;
56
+ border-radius: 10px;
57
+ color: white;
58
+ background-color: #1c1c1c;
59
+ box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
60
+ }
61
+
62
+ .output_AC {
63
+ padding: 10px;
64
+ height: auto;
65
+ border: 1px solid #262626;
66
+ border-radius: 10px;
67
+ background-color: #1c1c1c;
68
+ box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
69
+ width: auto;
70
+ box-sizing: border-box;
71
+ }
72
+
73
+ .output_message_AC {
74
+ font-family: cursive;
75
+ color: white !important;
76
+ font-size: 14px;
77
+ user-select: none;
78
+ cursor: default
79
+ }
80
+
81
+
82
+ .storage_info_AC {
83
+ padding: 5px 20px;
84
+ height: auto;
85
+ border: 1px solid #262626;
86
+ border-radius: 10px;
87
+ background-color: #1c1c1c;
88
+ box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
89
+ width: auto;
90
+ font-family: cursive;
91
+ color: #B2B2B2 !important;
92
+ font-size: 14px;
93
+ user-select: none;
94
+ cursor: default
95
+ }
96
+
97
+
98
+ /* Button and storage info layout */
99
+ .lower_information_panel_AC {
100
+ display: flex;
101
+ align-items: center;
102
+ justify-content: space-between;
103
+ }
104
+
105
+
106
+ /* Button style */
107
+
108
+ .button_AC {
109
+ width: auto;
110
+ font-family: cursive;
111
+ color: white !important;
112
+ font-size: 14px;
113
+ font-weight: bold;
114
+ height: 35px;
115
+ border-radius: 15px;
116
+ background-image: radial-gradient(circle at top left, purple 10%, violet 90%);
117
+ background-size: 200% 200%;
118
+ background-position: left bottom;
119
+ transition: background 0.5s ease-in-out, transform 0.3s ease;
120
+ }
121
+
122
+ .button_AC:hover {
123
+ cursor: pointer;
124
+ background-size: 200% 200%;
125
+ background-position: right bottom;
126
+ transform: translateY(1px);
127
+ }
128
+
129
+ .button_execute_AC:hover {
130
+ background-image: radial-gradient(circle at top left, purple 10%, #93ac47 90%);
131
+ }
132
+
133
+ .button_clear_AC:hover {
134
+ background-image: radial-gradient(circle at top left, purple 10%, #fc3468 90%);
135
+ }
136
+
137
+ .button_execute_AC:active,
138
+ .button_clear_AC:active {
139
+ filter: brightness(0.75);
140
+ }
141
+
142
+ .jupyter-widgets.lm-Widget:focus {
143
+ outline: none;
144
+ }
145
+
146
+
147
+ /* Animation of elements */
148
+
149
+ /* Emergence */
150
+ .container_AC {
151
+ animation-name: slideInTopBlur;
152
+ animation-duration: 0.7s;
153
+ animation-fill-mode: forwards;
154
+ }
155
+
156
+ @keyframes slideInTopBlur {
157
+ 0% {
158
+ transform: translate3d(0, 50%, 0) scale(0.85) rotate3d(1, 0, 0, -85deg);
159
+ filter: blur(5px) grayscale(1) brightness(0.5);
160
+ opacity: 0;
161
+ }
162
+ 100% {
163
+ transform: translate3d(0, 0, 0) scale(1) rotate3d(1, 0, 0, 0deg);
164
+ filter: blur(0) grayscale(0) brightness(1);
165
+ opacity: 1;
166
+ }
167
+ }
168
+
169
+ /* Leaving */
170
+ .container_AC.hide {
171
+ animation-name: slideOutTopBlur;
172
+ animation-duration: 0.3s;
173
+ animation-fill-mode: forwards;
174
+ }
175
+
176
+ @keyframes slideOutTopBlur {
177
+ 0% {
178
+ transform: translate3d(0, 0, 0) scale(1);
179
+ filter: blur(0) grayscale(0) brightness(1);
180
+ opacity: 1;
181
+ }
182
+ 100% {
183
+ transform: translate3d(0, -100%, 0);
184
+ filter: blur(5px) grayscale(1) brightness(0);
185
+ opacity: 0;
186
+ }
187
+ }
CSS/main_widgets.css ADDED
@@ -0,0 +1,333 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* General Styles */
2
+ .header {
3
+ font-family: cursive;
4
+ font-size: 20px;
5
+ font-weight: bold;
6
+ color: #ff8cee;
7
+ margin-bottom: 15px;
8
+ user-select: none;
9
+ cursor: default;
10
+ display: inline-block;
11
+ }
12
+
13
+ hr {
14
+ border-color: grey;
15
+ background-color: grey;
16
+ opacity: 0.25;
17
+ }
18
+
19
+ a {
20
+ text-decoration: none;
21
+ color: inherit;
22
+ }
23
+
24
+
25
+ /* Container style */
26
+
27
+ .container {
28
+ position: relative;
29
+ background-color: #232323;
30
+ width: 1080px;
31
+ padding: 10px 15px;
32
+ border-radius: 15px;
33
+ box-shadow: 0 0 50px rgba(0, 0, 0, 0.3);
34
+ margin-bottom: 5px;
35
+ overflow: hidden;
36
+ }
37
+
38
+ .container::after {
39
+ position: absolute;
40
+ top: 5px;
41
+ right: 10px;
42
+ content: "ANXETY";
43
+ font-weight: bold;
44
+ font-size: 24px;
45
+ color: rgba(0, 0, 0, 0.2);
46
+ }
47
+
48
+ /* background img */
49
+ .container::before {
50
+ content: "";
51
+ position: absolute;
52
+ top: 0;
53
+ left: 0;
54
+ right: 0;
55
+ bottom: 0;
56
+ background-image: var(--img_background);
57
+ background-size: var(--img_scale);
58
+ background-repeat: var(--img_mode);
59
+ opacity: var(--img_opacity);
60
+ mix-blend-mode: screen;
61
+ pointer-events: none;
62
+ filter: blur(var(--img_blur));
63
+ z-index: -1;
64
+ }
65
+
66
+ .image_1::before {
67
+ background-position: var(--image_x) calc(-120px - var(--image_y));
68
+ }
69
+ .image_2::before {
70
+ background-position: var(--image_x) calc(-290px - var(--image_y));
71
+ }
72
+ .image_3::before {
73
+ background-position: var(--image_x) calc(-430px - var(--image_y));
74
+ }
75
+ .image_4::before {
76
+ background-position: var(--image_x) calc(var(--img_height_dif) - var(--image_y));
77
+ }
78
+
79
+ .container_custom_downlad {
80
+ height: 55px;
81
+ transition: all 0.5s;
82
+ }
83
+
84
+ .container_custom_downlad.expanded {
85
+ height: 270px;
86
+ }
87
+
88
+
89
+ /* Element text style */
90
+
91
+ .widget-html,
92
+ .widget-button,
93
+ .widget-text label,
94
+ .widget-checkbox label,
95
+ .widget-dropdown label,
96
+ .widget-dropdown select,
97
+ .widget-text input[type="text"] {
98
+ font-family: cursive;
99
+ font-size: 14px;
100
+ color: white !important;
101
+ user-select: none;
102
+ }
103
+
104
+ .widget-text input[type="text"]::placeholder {
105
+ color: grey;
106
+ }
107
+
108
+
109
+ /* Input field styles */
110
+
111
+ .widget-dropdown select,
112
+ .widget-text input[type="text"] {
113
+ height: 30px;
114
+ background-color: var(--bg-field-color);
115
+ border: 1px solid #262626;
116
+ border-radius: 10px;
117
+ box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
118
+ transition: all 0.3s ease-in-out;
119
+ backdrop-filter: blur(var(--bg-field-blur-level));
120
+ }
121
+
122
+ .widget-dropdown select:focus,
123
+ .widget-text input[type="text"]:focus {
124
+ border-color: #006ee5;
125
+ }
126
+
127
+ .widget-dropdown select:hover,
128
+ .widget-text input[type="text"]:hover {
129
+ transform: scale(1.003);
130
+ background-color: var(--bg-field-color-hover);
131
+ box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
132
+ }
133
+
134
+ .widget-dropdown option {
135
+ background-color: #1c1c1c;
136
+ }
137
+
138
+
139
+ /* Slider Checkbox style */
140
+
141
+ .widget-checkbox input[type="checkbox"] {
142
+ appearance: none;
143
+ position: relative;
144
+ top: 4px; /* Why is he taller?! */
145
+ width: 40px;
146
+ height: 20px;
147
+ border: none;
148
+ border-radius: 10px;
149
+ background-color: #20b2aa;
150
+ cursor: pointer;
151
+ box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.3);
152
+ transition: background-color 0.3s ease;
153
+ }
154
+ .widget-checkbox input[type="checkbox"]:checked {
155
+ background-color: #2196F3;
156
+ }
157
+
158
+ .widget-checkbox input[type="checkbox"]:before {
159
+ content: '';
160
+ position: absolute;
161
+ top: 50%;
162
+ left: 3px;
163
+ width: 16px;
164
+ height: 16px;
165
+ border-radius: inherit;
166
+ background-color: white;
167
+ box-shadow: 0 0 8px rgba(0, 0, 0, 0.3);
168
+ transform: translateY(-50%);
169
+ transition: left 0.3s ease;
170
+ }
171
+ .widget-checkbox input[type="checkbox"]:checked:before {
172
+ left: 21px;
173
+ }
174
+
175
+
176
+ /* Button styles */
177
+
178
+ .button_save {
179
+ font-size: 15px;
180
+ font-weight: bold;
181
+ width: 120px;
182
+ height: 35px;
183
+ border-radius: 15px;
184
+ background-image: radial-gradient(circle at top left, purple 10%, violet 90%);
185
+ background-size: 200% 200%;
186
+ background-position: left bottom;
187
+ transition: background 0.5s ease-in-out, transform 0.3s ease;
188
+ }
189
+
190
+ .button_save:hover {
191
+ cursor: pointer;
192
+ background-image: radial-gradient(circle at top left, purple 10%, #93ac47 90%);
193
+ background-size: 200% 200%;
194
+ background-position: right bottom;
195
+ transform: translateY(1px);
196
+ }
197
+
198
+ .button_ngrok {
199
+ font-size: 12px;
200
+ height: 30px;
201
+ border-radius: 10px;
202
+ padding: 1px 12px;
203
+ background-image: radial-gradient(circle at top left, purple 10%, violet 90%);
204
+ background-size: 200% 200%;
205
+ background-position: left bottom;
206
+ transition: background 0.5s ease-in-out, transform 0.3s ease;
207
+ white-space: nowrap;
208
+ }
209
+
210
+ .button_ngrok:hover {
211
+ cursor: pointer;
212
+ background-image: radial-gradient(circle at top left, purple 10%, #1D94BB 90%);
213
+ background-size: 200% 200%;
214
+ background-position: right bottom;
215
+ transform: translateY(1px);
216
+ }
217
+
218
+ .button_save:active,
219
+ .button_ngrok:active {
220
+ filter: brightness(0.75) !important;
221
+ }
222
+
223
+ /* Removes ugly stroke from widget buttons. */
224
+ .jupyter-widgets.lm-Widget:focus {
225
+ outline: none;
226
+ }
227
+
228
+
229
+ /* Popup style of `INFO` window */
230
+
231
+ .info {
232
+ position: absolute;
233
+ top: -5px;
234
+ right: 95px;
235
+ color: grey;
236
+ font-family: cursive;
237
+ font-size: 14px;
238
+ font-weight: normal;
239
+ user-select: none;
240
+ pointer-events: none;
241
+ opacity: 0;
242
+ transition: opacity 0.3s ease-in-out;
243
+ display: inline-block;
244
+ }
245
+
246
+ .popup {
247
+ position: absolute;
248
+ top: 120px;
249
+ z-index: 999;
250
+ width: auto;
251
+ padding: 10px;
252
+ text-align: center;
253
+ background-color: rgba(255, 255, 255, 0.05);
254
+ backdrop-filter: blur(20px);
255
+ border: 1px solid rgba(255, 255, 255, 0.45);
256
+ border-radius: 8px;
257
+ box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
258
+ opacity: 0;
259
+ color: #fff;
260
+ font-size: 16px;
261
+ font-family: cursive;
262
+ user-select: none;
263
+ cursor: default;
264
+ pointer-events: none;
265
+ transform: rotate(-5deg);
266
+ transition: top 0.3s ease-in-out, opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
267
+ }
268
+
269
+ .sample {
270
+ display: inline-block;
271
+ margin-top: 25px;
272
+ padding: 10px 100px;
273
+ background-color: rgba(255, 255, 255, 0.2);
274
+ color: #c6e2ff;
275
+ border: 2px solid rgba(255, 255, 255, 0.2);
276
+ border-radius: 8px;
277
+ box-shadow: 0 0 10px rgba(255, 255, 255, 0.2), inset 0 0 25px rgba(255, 255, 255, 0.2);
278
+ }
279
+
280
+ .info.showed {
281
+ opacity: 1;
282
+ pointer-events: auto;
283
+ }
284
+
285
+ .info:hover + .popup {
286
+ top: 35px;
287
+ opacity: 1;
288
+ pointer-events: initial;
289
+ transform: rotate(0deg);
290
+ }
291
+
292
+
293
+ /* Animation of elements */
294
+
295
+ .container,
296
+ .button_save {
297
+ animation-name: showedWidgets;
298
+ animation-duration: 1s;
299
+ animation-fill-mode: forwards;
300
+ }
301
+
302
+ .container.hide,
303
+ .button_save.hide {
304
+ animation-name: hideWidgets;
305
+ animation-duration: 0.5s;
306
+ animation-fill-mode: forwards;
307
+ }
308
+
309
+ @keyframes showedWidgets {
310
+ 0% {
311
+ transform: translate3d(-65%, 15%, 0) scale(0) rotate(15deg);
312
+ filter: blur(25px) grayscale(1) brightness(0.3);
313
+ opacity: 0;
314
+ }
315
+ 100% {
316
+ transform: translate3d(0, 0, 0) scale(1) rotate(0deg);
317
+ filter: blur(0) grayscale(0) brightness(1);
318
+ opacity: 1;
319
+ }
320
+ }
321
+
322
+ @keyframes hideWidgets {
323
+ 0% {
324
+ transform: translate3d(0, 0, 0) scale(1) rotate3d(1, 0, 0, 0deg);
325
+ filter: blur(0) grayscale(0) brightness(1);
326
+ opacity: 1;
327
+ }
328
+ 100% {
329
+ transform: translate3d(0, 5%, 0) scale(0.9) rotate3d(1, 0, 0, 90deg);
330
+ filter: blur(15px) grayscale(1) brightness(0.5);
331
+ opacity: 0;
332
+ }
333
+ }
files_cells/notebooks/en/auto_cleaner_en.ipynb ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "nbformat": 4,
3
+ "nbformat_minor": 0,
4
+ "metadata": {
5
+ "colab": {
6
+ "provenance": []
7
+ },
8
+ "kernelspec": {
9
+ "name": "python3",
10
+ "display_name": "Python 3"
11
+ },
12
+ "language_info": {
13
+ "name": "python"
14
+ }
15
+ },
16
+ "cells": [
17
+ {
18
+ "cell_type": "code",
19
+ "source": [
20
+ "##~ AutoCleaner V3.6 CODE | BY: ANXETY ~##\n",
21
+ "\n",
22
+ "import os\n",
23
+ "import time\n",
24
+ "import ipywidgets as widgets\n",
25
+ "from ipywidgets import Label, Button, VBox, HBox\n",
26
+ "from IPython.display import display, HTML, Javascript\n",
27
+ "\n",
28
+ "\n",
29
+ "# ================= DETECT ENV =================\n",
30
+ "def detect_environment():\n",
31
+ " free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024 ** 3) <= 20)\n",
32
+ " environments = {\n",
33
+ " 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
34
+ " 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\")\n",
35
+ " }\n",
36
+ " for env_var, (environment, path) in environments.items():\n",
37
+ " if env_var in os.environ:\n",
38
+ " return environment, path, free_plan\n",
39
+ "\n",
40
+ "env, root_path, free_plan = detect_environment()\n",
41
+ "webui_path = f\"{root_path}/sdw\"\n",
42
+ "\n",
43
+ "\n",
44
+ "# ==================== CSS ====================\n",
45
+ "# Main CSS\n",
46
+ "css_file_path = f\"{root_path}/CSS/auto_cleaner.css\"\n",
47
+ "with open(css_file_path , \"r\") as f:\n",
48
+ " CSS_AC = f.read()\n",
49
+ "display(HTML(f\"<style>{CSS_AC}</style>\"))\n",
50
+ "\n",
51
+ "\n",
52
+ "# ================ AutoCleaner function ================\n",
53
+ "directories = {\n",
54
+ " \"Images\": f\"{webui_path}/output\",\n",
55
+ " \"Models\": f\"{webui_path}/models/Stable-diffusion/\",\n",
56
+ " \"Vae\": f\"{webui_path}/models/VAE/\",\n",
57
+ " \"LoRa\": f\"{webui_path}/models/Lora/\",\n",
58
+ " \"ControlNet Models\": f\"{webui_path}/models/ControlNet/\"\n",
59
+ "}\n",
60
+ "\n",
61
+ "\"\"\" functions \"\"\"\n",
62
+ "def clean_directory(directory):\n",
63
+ " deleted_files = 0\n",
64
+ " image_dir = directories['Images']\n",
65
+ "\n",
66
+ " for root, dirs, files in os.walk(directory):\n",
67
+ " for file in files:\n",
68
+ " file_path = os.path.join(root, file)\n",
69
+ "\n",
70
+ " if file.endswith(\".txt\"):\n",
71
+ " continue\n",
72
+ " if file.endswith((\".safetensors\", \".pt\")) or root == image_dir: # fix for image counter\n",
73
+ " deleted_files += 1\n",
74
+ "\n",
75
+ " os.remove(file_path)\n",
76
+ " return deleted_files\n",
77
+ "\n",
78
+ "def update_memory_info():\n",
79
+ " disk_space = psutil.disk_usage(os.getcwd())\n",
80
+ " total = disk_space.total / (1024 ** 3)\n",
81
+ " used = disk_space.used / (1024 ** 3)\n",
82
+ " free = disk_space.free / (1024 ** 3)\n",
83
+ "\n",
84
+ " storage_info.value = f'''\n",
85
+ " <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>\n",
86
+ " '''\n",
87
+ "\n",
88
+ "def on_execute_button_press(button):\n",
89
+ " selected_cleaners = auto_cleaner_widget.value\n",
90
+ " deleted_files_dict = {}\n",
91
+ "\n",
92
+ " for option in selected_cleaners:\n",
93
+ " if option in directories:\n",
94
+ " deleted_files_dict[option] = clean_directory(directories[option])\n",
95
+ "\n",
96
+ " output.clear_output()\n",
97
+ "\n",
98
+ " with output:\n",
99
+ " for message in generate_messages(deleted_files_dict):\n",
100
+ " message_widget = HTML(f'<p class=\"output_message_AC\">{message}</p>')\n",
101
+ " display(message_widget)\n",
102
+ "\n",
103
+ " update_memory_info()\n",
104
+ "\n",
105
+ "def on_clear_button_press(button):\n",
106
+ " container.add_class(\"hide\")\n",
107
+ " time.sleep(0.5)\n",
108
+ " widgets.Widget.close_all()\n",
109
+ "\n",
110
+ "def generate_messages(deleted_files_dict):\n",
111
+ " messages = []\n",
112
+ " word_variants = {\n",
113
+ " \"Images\": \"Images\",\n",
114
+ " \"Models\": \"Models\",\n",
115
+ " \"Vae\": \"Vae\",\n",
116
+ " \"LoRa\": \"LoRa\",\n",
117
+ " \"ControlNet Models\": \"ControlNet Models\"\n",
118
+ " }\n",
119
+ " for key, value in deleted_files_dict.items():\n",
120
+ " object_word = word_variants.get(key)\n",
121
+ " messages.append(f\"Deleted {value} {object_word}\")\n",
122
+ " return messages\n",
123
+ "# ================ AutoCleaner function ================\n",
124
+ "\n",
125
+ "\n",
126
+ "# --- storage memory ---\n",
127
+ "import psutil\n",
128
+ "disk_space = psutil.disk_usage(os.getcwd())\n",
129
+ "total = disk_space.total / (1024 ** 3)\n",
130
+ "used = disk_space.used / (1024 ** 3)\n",
131
+ "free = disk_space.free / (1024 ** 3)\n",
132
+ "\n",
133
+ "\n",
134
+ "# UI Code\n",
135
+ "AutoCleaner_options = AutoCleaner_options = list(directories.keys())\n",
136
+ "instruction_label = widgets.HTML('''\n",
137
+ "<span class=\"instruction_AC\">Use <span style=\"color: #B2B2B2;\">ctrl</span> or <span style=\"color: #B2B2B2;\">shift</span> for multiple selections.</span>\n",
138
+ "''')\n",
139
+ "auto_cleaner_widget = widgets.SelectMultiple(options=AutoCleaner_options, layout=widgets.Layout(width='auto')).add_class(\"custom-select-multiple_AC\")\n",
140
+ "output = widgets.Output().add_class(\"output_AC\")\n",
141
+ "# ---\n",
142
+ "execute_button = Button(description='Execute Cleaning').add_class(\"button_execute_AC\").add_class(\"button_AC\")\n",
143
+ "execute_button.on_click(on_execute_button_press)\n",
144
+ "clear_button = Button(description='Hide Widget').add_class(\"button_clear_AC\").add_class(\"button_AC\")\n",
145
+ "clear_button.on_click(on_clear_button_press)\n",
146
+ "# ---\n",
147
+ "storage_info = widgets.HTML(f'''\n",
148
+ "<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>\n",
149
+ "''')\n",
150
+ "# ---\n",
151
+ "buttons = widgets.HBox([execute_button, clear_button])\n",
152
+ "lower_information_panel = widgets.HBox([buttons, storage_info]).add_class(\"lower_information_panel_AC\")\n",
153
+ "\n",
154
+ "container = VBox([instruction_label, widgets.HTML('<hr>'), auto_cleaner_widget, output, widgets.HTML('<hr>'), lower_information_panel]).add_class(\"container_AC\")\n",
155
+ "\n",
156
+ "display(container)"
157
+ ],
158
+ "metadata": {
159
+ "id": "I22dFg7F2j3G"
160
+ },
161
+ "execution_count": null,
162
+ "outputs": []
163
+ }
164
+ ]
165
+ }
files_cells/notebooks/en/downloading_en.ipynb CHANGED
@@ -25,21 +25,19 @@
25
  "from urllib.parse import urlparse, parse_qs\n",
26
  "\n",
27
  "\n",
28
- "# ================= DETECT ENV =================\n",
29
  "def detect_environment():\n",
30
  " free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024 ** 3) <= 20)\n",
31
  " environments = {\n",
32
  " 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
33
  " 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\")\n",
34
  " }\n",
35
- "\n",
36
  " for env_var, (environment, path) in environments.items():\n",
37
  " if env_var in os.environ:\n",
38
  " return environment, path, free_plan\n",
39
  "\n",
40
  "env, root_path, free_plan = detect_environment()\n",
41
  "webui_path = f\"{root_path}/sdw\"\n",
42
- "# ----------------------------------------------\n",
43
  "\n",
44
  "\n",
45
  "# ================ LIBRARIES V2 ================\n",
@@ -90,12 +88,6 @@
90
  " time.sleep(2)\n",
91
  " clear_output()\n",
92
  "\n",
93
- "## dl special files\n",
94
- "with capture.capture_output() as cap:\n",
95
- " !mkdir -p {root_path}/file_cell/special\n",
96
- " !wget https://huggingface.co/NagisaNao/fast_repo/resolve/main/special/dl_display_results.py -O {root_path}/file_cell/special/dl_display_results.py\n",
97
- "del cap\n",
98
- "\n",
99
  "\n",
100
  "# ================= loading settings V4 =================\n",
101
  "def load_settings(path):\n",
@@ -106,16 +98,17 @@
106
  "\n",
107
  "settings = load_settings(f'{root_path}/settings.json')\n",
108
  "\n",
109
- "variables = [\n",
110
- " 'Model', 'Model_Num', 'Inpainting_Model',\n",
111
- " 'Vae', 'Vae_Num',\n",
112
- " 'latest_webui', 'latest_exstensions', 'change_webui', 'detailed_download',\n",
113
- " 'controlnet', 'controlnet_Num', 'commit_hash', 'optional_huggingface_token',\n",
114
  " 'ngrok_token', 'zrok_token', 'commandline_arguments',\n",
115
- " 'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url', 'Extensions_url', 'custom_file_urls'\n",
 
116
  "]\n",
117
  "\n",
118
- "locals().update({key: settings.get(key) for key in variables})\n",
119
  "\n",
120
  "\n",
121
  "# ================= OTHER =================\n",
@@ -251,17 +244,7 @@
251
  " ]\n",
252
  "}\n",
253
  "\n",
254
- "# 1-4 (fp16/cleaned)\n",
255
  "vae_list = {\n",
256
- " ## vae broke - the author's an asshole\n",
257
- " # \"1.Anime.vae\": [\n",
258
- " # {\"url\": \"https://civitai.com/api/download/models/131654\", \"name\": \"Anime.vae.safetensors\"},\n",
259
- " # {\"url\": \"https://civitai.com/api/download/models/131658\", \"name\": \"vae-ft-mse.vae.safetensors\"}\n",
260
- " # ],\n",
261
- " # \"2.Anything.vae\": [{\"url\": \"https://civitai.com/api/download/models/131656\", \"name\": \"Anything.vae.safetensors\"}],\n",
262
- " # \"3.Blessed2.vae\": [{\"url\": \"https://civitai.com/api/download/models/142467\", \"name\": \"Blessed2.vae.safetensors\"}],\n",
263
- " # \"4.ClearVae.vae\": [{\"url\": \"https://civitai.com/api/download/models/133362\", \"name\": \"ClearVae_23.vae.safetensors\"}],\n",
264
- "\n",
265
  " \"1.Anime.vae\": [{\"url\": \"https://civitai.com/api/download/models/311162\", \"name\": \"vae-ft-mse-840000-ema-pruned.vae.safetensors\"}],\n",
266
  " \"2.Anything.vae\": [{\"url\": \"https://civitai.com/api/download/models/119279\", \"name\": \"Anything.vae.safetensors\"}],\n",
267
  " \"3.Blessed2.vae\": [{\"url\": \"https://huggingface.co/NoCrypt/blessed_vae/resolve/main/blessed2.vae.pt\", \"name\": \"Blessed2.vae.safetensors\"}],\n",
@@ -342,7 +325,7 @@
342
  "directories = [value for key, value in prefixes.items()] # for unpucking zip files\n",
343
  "!mkdir -p {\" \".join(directories)}\n",
344
  "\n",
345
- "hf_token = optional_huggingface_token if optional_huggingface_token else \"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\"\n",
346
  "user_header = f\"\\\"Authorization: Bearer {hf_token}\\\"\"\n",
347
  "\n",
348
  "''' Formatted Info Output '''\n",
@@ -541,14 +524,14 @@
541
  "def handle_submodels(selection, num_selection, model_dict, dst_dir, url):\n",
542
  " submodels = add_submodels(selection, num_selection, model_dict, dst_dir)\n",
543
  " for submodel in submodels:\n",
544
- " if not Inpainting_Model and \"inpainting\" in submodel['name']:\n",
545
  " continue\n",
546
  " url += f\"{submodel['url']} {submodel['dst_dir']} {submodel['name']}, \"\n",
547
  " return url\n",
548
  "\n",
549
- "url = handle_submodels(Model, Model_Num, model_list, models_dir, url)\n",
550
- "url = handle_submodels(Vae, Vae_Num, vae_list, vaes_dir, url)\n",
551
- "url = handle_submodels(controlnet, controlnet_Num, controlnet_list, control_dir, url)\n",
552
  "\n",
553
  "''' file.txt - added urls '''\n",
554
  "\n",
@@ -635,40 +618,8 @@
635
  "## List Models and stuff V2\n",
636
  "if detailed_download == \"off\":\n",
637
  " print(\"\\n\\n\\033[33mIf you don't see any downloaded files, enable the 'Detailed Downloads' feature in the widget.\")\n",
638
- " get_ipython().run_line_magic('run', '{root_path}/file_cell/special/dl_display_results.py') # display widgets result\n",
639
  "\n",
640
- "else:\n",
641
- " if any(not file.endswith('.txt') for file in os.listdir(models_dir)):\n",
642
- " print(\"\\n\\033[33m➤ Models\\033[0m\")\n",
643
- " !find {models_dir}/ -mindepth 1 -name '*.safetensors' -printf '%f\\n'\n",
644
- " if any(not file.endswith('.txt') for file in os.listdir(vaes_dir)):\n",
645
- " print(\"\\n\\033[33m➤ VAEs\\033[0m\")\n",
646
- " !find {vaes_dir}/ -mindepth 1 -name '*.safetensors' -printf '%f\\n'\n",
647
- " if any(not file.endswith('.txt') and not os.path.isdir(os.path.join(embeddings_dir, file)) for file in os.listdir(embeddings_dir)):\n",
648
- " print(\"\\n\\033[33m➤ Embeddings\\033[0m\")\n",
649
- " !find {embeddings_dir}/ -mindepth 1 -maxdepth 1 \\( -name '*.pt' -or -name '*.safetensors' \\) -printf '%f\\n'\n",
650
- " if any(not file.endswith('.txt') for file in os.listdir(loras_dir)):\n",
651
- " print(\"\\n\\033[33m➤ LoRAs\\033[0m\")\n",
652
- " !find {loras_dir}/ -mindepth 1 -name '*.safetensors' -printf '%f\\n'\n",
653
- " print(f\"\\n\\033[33m➤ Extensions\\033[0m\")\n",
654
- " !find {extensions_dir}/ -mindepth 1 -maxdepth 1 ! -name '*.txt' -printf '%f\\n'\n",
655
- " if any(not file.endswith(('.txt', '.yaml')) for file in os.listdir(control_dir)):\n",
656
- " print(\"\\n\\033[33m➤ ControlNet\\033[0m\")\n",
657
- " !find {control_dir}/ -mindepth 1 ! -name '*.yaml' -printf '%f\\n' | sed 's/^[^_]*_[^_]*_[^_]*_\\([^_]*\\)_fp16\\.safetensors$/\\1/'\n",
658
- "\n",
659
- "\n",
660
- "# === OTHER ===\n",
661
- "# Downlaod discord tags UmiWildcards\n",
662
- "files_umi = [\n",
663
- " \"https://huggingface.co/NagisaNao/fast_repo/resolve/main/extensions/UmiWildacrd/discord/200_pan_gen.txt\",\n",
664
- " \"https://huggingface.co/NagisaNao/fast_repo/resolve/main/extensions/UmiWildacrd/discord/150_bra_gen.txt\"\n",
665
- "]\n",
666
- "save_dir_path = f\"{webui_path}/extensions/Umi-AI-Wildcards/wildcards/discord\"\n",
667
- "\n",
668
- "with capture.capture_output() as cap:\n",
669
- " for file in files_umi:\n",
670
- " !aria2c --optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -j5 -x16 -s16 -k1M -c -d {save_dir_path} {file}\n",
671
- "del cap"
672
  ]
673
  }
674
  ],
 
25
  "from urllib.parse import urlparse, parse_qs\n",
26
  "\n",
27
  "\n",
28
+ "# ================= DETECT ENV =================\n",
29
  "def detect_environment():\n",
30
  " free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024 ** 3) <= 20)\n",
31
  " environments = {\n",
32
  " 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
33
  " 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\")\n",
34
  " }\n",
 
35
  " for env_var, (environment, path) in environments.items():\n",
36
  " if env_var in os.environ:\n",
37
  " return environment, path, free_plan\n",
38
  "\n",
39
  "env, root_path, free_plan = detect_environment()\n",
40
  "webui_path = f\"{root_path}/sdw\"\n",
 
41
  "\n",
42
  "\n",
43
  "# ================ LIBRARIES V2 ================\n",
 
88
  " time.sleep(2)\n",
89
  " clear_output()\n",
90
  "\n",
 
 
 
 
 
 
91
  "\n",
92
  "# ================= loading settings V4 =================\n",
93
  "def load_settings(path):\n",
 
98
  "\n",
99
  "settings = load_settings(f'{root_path}/settings.json')\n",
100
  "\n",
101
+ "VARIABLES = [\n",
102
+ " 'model', 'model_num', 'inpainting_model',\n",
103
+ " 'vae', 'vae_num', 'latest_webui', 'latest_exstensions',\n",
104
+ " 'change_webui', 'detailed_download', 'controlnet',\n",
105
+ " 'controlnet_num', 'commit_hash', 'huggingface_token',\n",
106
  " 'ngrok_token', 'zrok_token', 'commandline_arguments',\n",
107
+ " 'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url',\n",
108
+ " 'Extensions_url', 'custom_file_urls'\n",
109
  "]\n",
110
  "\n",
111
+ "locals().update({key: settings.get(key) for key in VARIABLES})\n",
112
  "\n",
113
  "\n",
114
  "# ================= OTHER =================\n",
 
244
  " ]\n",
245
  "}\n",
246
  "\n",
 
247
  "vae_list = {\n",
 
 
 
 
 
 
 
 
 
248
  " \"1.Anime.vae\": [{\"url\": \"https://civitai.com/api/download/models/311162\", \"name\": \"vae-ft-mse-840000-ema-pruned.vae.safetensors\"}],\n",
249
  " \"2.Anything.vae\": [{\"url\": \"https://civitai.com/api/download/models/119279\", \"name\": \"Anything.vae.safetensors\"}],\n",
250
  " \"3.Blessed2.vae\": [{\"url\": \"https://huggingface.co/NoCrypt/blessed_vae/resolve/main/blessed2.vae.pt\", \"name\": \"Blessed2.vae.safetensors\"}],\n",
 
325
  "directories = [value for key, value in prefixes.items()] # for unpucking zip files\n",
326
  "!mkdir -p {\" \".join(directories)}\n",
327
  "\n",
328
+ "hf_token = huggingface_token if huggingface_token else \"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\"\n",
329
  "user_header = f\"\\\"Authorization: Bearer {hf_token}\\\"\"\n",
330
  "\n",
331
  "''' Formatted Info Output '''\n",
 
524
  "def handle_submodels(selection, num_selection, model_dict, dst_dir, url):\n",
525
  " submodels = add_submodels(selection, num_selection, model_dict, dst_dir)\n",
526
  " for submodel in submodels:\n",
527
+ " if not inpainting_model and \"inpainting\" in submodel['name']:\n",
528
  " continue\n",
529
  " url += f\"{submodel['url']} {submodel['dst_dir']} {submodel['name']}, \"\n",
530
  " return url\n",
531
  "\n",
532
+ "url = handle_submodels(model, model_num, model_list, models_dir, url)\n",
533
+ "url = handle_submodels(vae, vae_num, vae_list, vaes_dir, url)\n",
534
+ "url = handle_submodels(controlnet, controlnet_num, controlnet_list, control_dir, url)\n",
535
  "\n",
536
  "''' file.txt - added urls '''\n",
537
  "\n",
 
618
  "## List Models and stuff V2\n",
619
  "if detailed_download == \"off\":\n",
620
  " print(\"\\n\\n\\033[33mIf you don't see any downloaded files, enable the 'Detailed Downloads' feature in the widget.\")\n",
 
621
  "\n",
622
+ "%run {root_path}/file_cell/special/dl_display_results.py # display widgets result"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
623
  ]
624
  }
625
  ],
files_cells/notebooks/en/widgets_en.ipynb CHANGED
@@ -16,6 +16,11 @@
16
  "cells": [
17
  {
18
  "cell_type": "code",
 
 
 
 
 
19
  "source": [
20
  "##~ WIDGET CODE | BY: ANXETY ~##\n",
21
  "\n",
@@ -27,27 +32,24 @@
27
  "from IPython.display import display, HTML, Javascript, clear_output\n",
28
  "\n",
29
  "\n",
30
- "# ================= DETECT ENV =================\n",
31
  "def detect_environment():\n",
32
  " free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024 ** 3) <= 20)\n",
33
  " environments = {\n",
34
  " 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
35
  " 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\")\n",
36
  " }\n",
37
- "\n",
38
  " for env_var, (environment, path) in environments.items():\n",
39
  " if env_var in os.environ:\n",
40
  " return environment, path, free_plan\n",
41
  "\n",
42
  "env, root_path, free_plan = detect_environment()\n",
43
  "webui_path = f\"{root_path}/sdw\"\n",
44
- "\n",
45
  "!mkdir -p {root_path}\n",
46
- "# ----------------------------------------------\n",
47
  "\n",
48
  "\n",
49
  "# ==================== CSS JS ====================\n",
50
- "# custom background images V1.5\n",
51
  "import argparse\n",
52
  "parser = argparse.ArgumentParser(description='This script processes an background image.')\n",
53
  "parser.add_argument('-i', '--image', type=str, help='URL of the image to process', metavar='')\n",
@@ -59,8 +61,9 @@
59
  "parser.add_argument('-m', '--mode', action='store_true', help='Removes repetitive image tiles')\n",
60
  "parser.add_argument('-t', '--transparent', action='store_true', help='Makes input/selection fields 35%% more transparent')\n",
61
  "parser.add_argument('-bf', '--blur-fields', type=str, help='Background blur level for input/selection fields', metavar='', default=2)\n",
 
62
  "args = parser.parse_args()\n",
63
- "\"\"\"---\"\"\"\n",
64
  "url_img = args.image\n",
65
  "opacity_img = args.opacity\n",
66
  "blur_img = args.blur\n",
@@ -78,7 +81,6 @@
78
  "\n",
79
  "\"\"\" mode img - repeats \"\"\"\n",
80
  "mode_img = \"repeat\" if not args.mode else \"no-repeat\"\n",
81
- "## ---\n",
82
  "\n",
83
  "container_background = f'''\n",
84
  "<style>\n",
@@ -101,345 +103,15 @@
101
  "'''\n",
102
  "\n",
103
  "display(HTML(container_background))\n",
104
- "# ---\n",
105
- "\n",
106
- "CSS = '''\n",
107
- "<style>\n",
108
- "/* General Styles */\n",
109
- ".header {\n",
110
- " font-family: cursive;\n",
111
- " font-size: 20px;\n",
112
- " font-weight: bold;\n",
113
- " color: #ff8cee;\n",
114
- " margin-bottom: 15px;\n",
115
- " user-select: none;\n",
116
- " cursor: default;\n",
117
- " display: inline-block;\n",
118
- "}\n",
119
- "\n",
120
- "hr {\n",
121
- " border-color: grey;\n",
122
- " background-color: grey;\n",
123
- " opacity: 0.25;\n",
124
- "}\n",
125
- "\n",
126
- "a {\n",
127
- " text-decoration: none;\n",
128
- " color: inherit;\n",
129
- "}\n",
130
- "\n",
131
- "\n",
132
- "/* Container style */\n",
133
- "\n",
134
- ".container {\n",
135
- " position: relative;\n",
136
- " background-color: #232323;\n",
137
- " width: 1080px;\n",
138
- " padding: 10px 15px;\n",
139
- " border-radius: 15px;\n",
140
- " box-shadow: 0 0 50px rgba(0, 0, 0, 0.3);\n",
141
- " margin-bottom: 5px;\n",
142
- " overflow: hidden;\n",
143
- "}\n",
144
- "\n",
145
- ".container::after {\n",
146
- " position: absolute;\n",
147
- " top: 5px;\n",
148
- " right: 10px;\n",
149
- " content: \"ANXETY\";\n",
150
- " font-weight: bold;\n",
151
- " font-size: 24px;\n",
152
- " color: rgba(0, 0, 0, 0.2);\n",
153
- "}\n",
154
- "\n",
155
- "/* background img */\n",
156
- ".container::before {\n",
157
- " content: \"\";\n",
158
- " position: absolute;\n",
159
- " top: 0;\n",
160
- " left: 0;\n",
161
- " right: 0;\n",
162
- " bottom: 0;\n",
163
- " background-image: var(--img_background);\n",
164
- " background-size: var(--img_scale);\n",
165
- " background-repeat: var(--img_mode);\n",
166
- " opacity: var(--img_opacity);\n",
167
- " mix-blend-mode: screen;\n",
168
- " pointer-events: none;\n",
169
- " filter: blur(var(--img_blur));\n",
170
- " z-index: -1;\n",
171
- "}\n",
172
- "\n",
173
- ".image_1::before {\n",
174
- " background-position: var(--image_x) calc(-120px - var(--image_y));\n",
175
- "}\n",
176
- ".image_2::before {\n",
177
- " background-position: var(--image_x) calc(-290px - var(--image_y));\n",
178
- "}\n",
179
- ".image_3::before {\n",
180
- " background-position: var(--image_x) calc(-430px - var(--image_y));\n",
181
- "}\n",
182
- ".image_4::before {\n",
183
- " background-position: var(--image_x) calc(var(--img_height_dif) - var(--image_y));\n",
184
- "}\n",
185
- "\n",
186
- ".container_custom_downlad {\n",
187
- " height: 55px;\n",
188
- " transition: all 0.5s;\n",
189
- "}\n",
190
- "\n",
191
- ".container_custom_downlad.expanded {\n",
192
- " height: 270px;\n",
193
- "}\n",
194
- "\n",
195
- "\n",
196
- "/* Element text style */\n",
197
- "\n",
198
- ".widget-html,\n",
199
- ".widget-button,\n",
200
- ".widget-text label,\n",
201
- ".widget-checkbox label,\n",
202
- ".widget-dropdown label,\n",
203
- ".widget-dropdown select,\n",
204
- ".widget-text input[type=\"text\"] {\n",
205
- " font-family: cursive;\n",
206
- " font-size: 14px;\n",
207
- " color: white !important;\n",
208
- " user-select: none;\n",
209
- "}\n",
210
- "\n",
211
- ".widget-text input[type=\"text\"]::placeholder {\n",
212
- " color: grey;\n",
213
- "}\n",
214
- "\n",
215
- "\n",
216
- "/* Input field styles */\n",
217
- "\n",
218
- ".widget-dropdown select,\n",
219
- ".widget-text input[type=\"text\"] {\n",
220
- " height: 30px;\n",
221
- " background-color: var(--bg-field-color);\n",
222
- " border: 1px solid #262626;\n",
223
- " border-radius: 10px;\n",
224
- " box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);\n",
225
- " transition: all 0.3s ease-in-out;\n",
226
- " backdrop-filter: blur(var(--bg-field-blur-level));\n",
227
- "}\n",
228
- "\n",
229
- ".widget-dropdown select:focus,\n",
230
- ".widget-text input[type=\"text\"]:focus {\n",
231
- " border-color: #006ee5;\n",
232
- "}\n",
233
- "\n",
234
- ".widget-dropdown select:hover,\n",
235
- ".widget-text input[type=\"text\"]:hover {\n",
236
- " transform: scale(1.003);\n",
237
- " background-color: var(--bg-field-color-hover);\n",
238
- " box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);\n",
239
- "}\n",
240
- "\n",
241
- ".widget-dropdown option {\n",
242
- " background-color: #1c1c1c;\n",
243
- "}\n",
244
- "\n",
245
- "\n",
246
- "/* Slider Checkbox style */\n",
247
- "\n",
248
- ".widget-checkbox input[type=\"checkbox\"] {\n",
249
- " appearance: none;\n",
250
- " position: relative;\n",
251
- " top: 4px; /* Why is he taller?! */\n",
252
- " width: 40px;\n",
253
- " height: 20px;\n",
254
- " border: none;\n",
255
- " border-radius: 10px;\n",
256
- " background-color: #20b2aa;\n",
257
- " cursor: pointer;\n",
258
- " box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.3);\n",
259
- " transition: background-color 0.3s ease;\n",
260
- "}\n",
261
- ".widget-checkbox input[type=\"checkbox\"]:checked {\n",
262
- " background-color: #2196F3;\n",
263
- "}\n",
264
- "\n",
265
- ".widget-checkbox input[type=\"checkbox\"]:before {\n",
266
- " content: '';\n",
267
- " position: absolute;\n",
268
- " top: 50%;\n",
269
- " left: 3px;\n",
270
- " width: 16px;\n",
271
- " height: 16px;\n",
272
- " border-radius: inherit;\n",
273
- " background-color: white;\n",
274
- " box-shadow: 0 0 8px rgba(0, 0, 0, 0.3);\n",
275
- " transform: translateY(-50%);\n",
276
- " transition: left 0.3s ease;\n",
277
- "}\n",
278
- ".widget-checkbox input[type=\"checkbox\"]:checked:before {\n",
279
- " left: 21px;\n",
280
- "}\n",
281
- "\n",
282
- "\n",
283
- "/* Button styles */\n",
284
- "\n",
285
- ".button_save {\n",
286
- " font-size: 15px;\n",
287
- " font-weight: bold;\n",
288
- " width: 120px;\n",
289
- " height: 35px;\n",
290
- " border-radius: 15px;\n",
291
- " background-image: radial-gradient(circle at top left, purple 10%, violet 90%);\n",
292
- " background-size: 200% 200%;\n",
293
- " background-position: left bottom;\n",
294
- " transition: background 0.5s ease-in-out, transform 0.3s ease;\n",
295
- "}\n",
296
- "\n",
297
- ".button_save:hover {\n",
298
- " cursor: pointer;\n",
299
- " background-image: radial-gradient(circle at top left, purple 10%, #93ac47 90%);\n",
300
- " background-size: 200% 200%;\n",
301
- " background-position: right bottom;\n",
302
- " transform: translateY(1px);\n",
303
- "}\n",
304
  "\n",
305
- ".button_ngrok {\n",
306
- " font-size: 12px;\n",
307
- " height: 30px;\n",
308
- " border-radius: 10px;\n",
309
- " padding: 1px 12px;\n",
310
- " background-image: radial-gradient(circle at top left, purple 10%, violet 90%);\n",
311
- " background-size: 200% 200%;\n",
312
- " background-position: left bottom;\n",
313
- " transition: background 0.5s ease-in-out, transform 0.3s ease;\n",
314
- " white-space: nowrap;\n",
315
- "}\n",
316
- "\n",
317
- ".button_ngrok:hover {\n",
318
- " cursor: pointer;\n",
319
- " background-image: radial-gradient(circle at top left, purple 10%, #1D94BB 90%);\n",
320
- " background-size: 200% 200%;\n",
321
- " background-position: right bottom;\n",
322
- " transform: translateY(1px);\n",
323
- "}\n",
324
- "\n",
325
- ".button_save:active,\n",
326
- ".button_ngrok:active {\n",
327
- " filter: brightness(0.75) !important;\n",
328
- "}\n",
329
- "\n",
330
- "/* Removes ugly stroke from widget buttons. */\n",
331
- ".jupyter-widgets.lm-Widget:focus {\n",
332
- " outline: none;\n",
333
- "}\n",
334
- "\n",
335
- "\n",
336
- "/* Popup style of `INFO` window */\n",
337
- "\n",
338
- ".info {\n",
339
- " position: absolute;\n",
340
- " top: -5px;\n",
341
- " right: 95px;\n",
342
- " color: grey;\n",
343
- " font-family: cursive;\n",
344
- " font-size: 14px;\n",
345
- " font-weight: normal;\n",
346
- " user-select: none;\n",
347
- " pointer-events: none;\n",
348
- " opacity: 0;\n",
349
- " transition: opacity 0.3s ease-in-out;\n",
350
- " display: inline-block;\n",
351
- "}\n",
352
- "\n",
353
- ".popup {\n",
354
- " position: absolute;\n",
355
- " top: 120px;\n",
356
- " z-index: 999;\n",
357
- " width: auto;\n",
358
- " padding: 10px;\n",
359
- " text-align: center;\n",
360
- " background-color: rgba(255, 255, 255, 0.05);\n",
361
- " backdrop-filter: blur(20px);\n",
362
- " border: 1px solid rgba(255, 255, 255, 0.45);\n",
363
- " border-radius: 8px;\n",
364
- " box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);\n",
365
- " opacity: 0;\n",
366
- " color: #fff;\n",
367
- " font-size: 16px;\n",
368
- " font-family: cursive;\n",
369
- " user-select: none;\n",
370
- " cursor: default;\n",
371
- " pointer-events: none;\n",
372
- " transform: rotate(-5deg);\n",
373
- " transition: top 0.3s ease-in-out, opacity 0.3s ease-in-out, transform 0.3s ease-in-out;\n",
374
- "}\n",
375
- "\n",
376
- ".sample {\n",
377
- " display: inline-block;\n",
378
- " margin-top: 25px;\n",
379
- " padding: 10px 100px;\n",
380
- " background-color: rgba(255, 255, 255, 0.2);\n",
381
- " color: #c6e2ff;\n",
382
- " border: 2px solid rgba(255, 255, 255, 0.2);\n",
383
- " border-radius: 8px;\n",
384
- " box-shadow: 0 0 10px rgba(255, 255, 255, 0.2), inset 0 0 25px rgba(255, 255, 255, 0.2);\n",
385
- "}\n",
386
- "\n",
387
- ".info.showed {\n",
388
- " opacity: 1;\n",
389
- " pointer-events: auto;\n",
390
- "}\n",
391
- "\n",
392
- ".info:hover + .popup {\n",
393
- " top: 35px;\n",
394
- " opacity: 1;\n",
395
- " pointer-events: initial;\n",
396
- " transform: rotate(0deg);\n",
397
- "}\n",
398
- "\n",
399
- "\n",
400
- "/* Animation of elements */\n",
401
- "\n",
402
- ".container,\n",
403
- ".button_save {\n",
404
- " animation-name: showedWidgets;\n",
405
- " animation-duration: 1s;\n",
406
- " animation-fill-mode: forwards;\n",
407
- "}\n",
408
- "\n",
409
- ".container.hide,\n",
410
- ".button_save.hide {\n",
411
- " animation-name: hideWidgets;\n",
412
- " animation-duration: 0.5s;\n",
413
- " animation-fill-mode: forwards;\n",
414
- "}\n",
415
- "\n",
416
- "@keyframes showedWidgets {\n",
417
- " 0% {\n",
418
- " transform: translate3d(-65%, 15%, 0) scale(0) rotate(15deg);\n",
419
- " filter: blur(25px) grayscale(1) brightness(0.3);\n",
420
- " opacity: 0;\n",
421
- " }\n",
422
- " 100% {\n",
423
- " transform: translate3d(0, 0, 0) scale(1) rotate(0deg);\n",
424
- " filter: blur(0) grayscale(0) brightness(1);\n",
425
- " opacity: 1;\n",
426
- " }\n",
427
- "}\n",
428
- "\n",
429
- "@keyframes hideWidgets {\n",
430
- " 0% {\n",
431
- " transform: translate3d(0, 0, 0) scale(1) rotate3d(1, 0, 0, 0deg);\n",
432
- " filter: blur(0) grayscale(0) brightness(1);\n",
433
- " opacity: 1;\n",
434
- " }\n",
435
- " 100% {\n",
436
- " transform: translate3d(0, 5%, 0) scale(0.9) rotate3d(1, 0, 0, 90deg);\n",
437
- " filter: blur(15px) grayscale(1) brightness(0.5);\n",
438
- " opacity: 0;\n",
439
- " }\n",
440
- "}\n",
441
- "</style>\n",
442
  "\n",
 
 
443
  "<!-- TOGGLE 'CustomDL' SCRIPT -->\n",
444
  "<script>\n",
445
  "function toggleContainer() {\n",
@@ -451,20 +123,58 @@
451
  "}\n",
452
  "</script>\n",
453
  "'''\n",
 
454
  "\n",
455
- "display(HTML(CSS))\n",
456
- "# ==================== CSS JS ====================\n",
457
  "\n",
 
 
 
 
458
  "\n",
459
- "# ==================== WIDGETS ====================\n",
460
- "# --- global widgets ---\n",
461
- "style = {'description_width': 'initial'}\n",
462
- "layout = widgets.Layout(min_width='1047px')\n",
 
463
  "\n",
464
- "HR = widgets.HTML('<hr>')\n",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
465
  "\n",
466
  "# --- MODEL ---\n",
467
- "model_header = widgets.HTML('<div class=\"header\">Model Selection<div>')\n",
468
  "model_options = ['none',\n",
469
  " '1.Anime (by XpucT) + INP',\n",
470
  " '2.BluMix [Anime] [V7] + INP',\n",
@@ -475,37 +185,37 @@
475
  " '7.Deliberate [Realism] [V6] + INP',\n",
476
  " '8.Meina-Mix [Anime] [V11] + INP',\n",
477
  " '9.Mix-Pro [Anime] [V4] + INP']\n",
478
- "# ---\n",
479
- "Model_widget = widgets.Dropdown(options=model_options, value='4.Counterfeit [Anime] [V3] + INP', description='Model:', style=style, layout=layout)\n",
480
- "Model_Num_widget = widgets.Text(description='Model Number:', placeholder='Enter the model numbers to be downloaded using comma/space.', style=style, layout=layout)\n",
481
- "Inpainting_Model_widget = widgets.Checkbox(value=False, description='Inpainting Models', style=style)\n",
482
  "\n",
483
- "''' Display Model'''\n",
484
- "all_model_box = widgets.VBox([model_header, Model_widget, Model_Num_widget, Inpainting_Model_widget]).add_class(\"container\").add_class(\"image_1\")\n",
485
- "display(all_model_box)\n",
486
  "\n",
487
  "# --- VAE ---\n",
488
- "vae_header = widgets.HTML('<div class=\"header\">VAE Selection</div>')\n",
489
  "vae_options = ['none',\n",
490
  " '1.Anime.vae',\n",
491
  " '2.Anything.vae',\n",
492
  " '3.Blessed2.vae',\n",
493
  " '4.ClearVae.vae',\n",
494
  " '5.WD.vae']\n",
495
- "Vae_widget = widgets.Dropdown(options=vae_options, value='3.Blessed2.vae', description='Vae:', style=style, layout=layout)\n",
496
- "Vae_Num_widget = widgets.Text(description='Vae Number:', placeholder='Enter the vae numbers to be downloaded using comma/space.', style=style, layout=layout)\n",
497
  "\n",
498
- "''' Display Vae'''\n",
499
- "all_vae_box = widgets.VBox([vae_header, Vae_widget, Vae_Num_widget]).add_class(\"container\").add_class(\"image_2\")\n",
500
- "display(all_vae_box)\n",
501
  "\n",
502
  "# --- ADDITIONAL ---\n",
503
- "additional_header = widgets.HTML('<div class=\"header\">Additional</div>')\n",
504
- "latest_webui_widget = widgets.Checkbox(value=True, description='Update WebUI', style=style)\n",
505
- "latest_exstensions_widget = widgets.Checkbox(value=True, description='Update Extensions', style=style)\n",
506
- "change_webui_widget = widgets.Dropdown(options=['A1111', 'Forge'], value='A1111', description='Change WebUI:', style=style)\n",
507
- "detailed_download_widget = widgets.Dropdown(options=['off', 'on'], value='off', description='Detailed Download:', style=style)\n",
508
- "latest_changes_widget = HBox([latest_webui_widget, latest_exstensions_widget, change_webui_widget, detailed_download_widget], layout=widgets.Layout(justify_content='space-between'))\n",
 
509
  "controlnet_options = ['none', 'ALL', '1.canny',\n",
510
  " '2.openpose', '3.depth',\n",
511
  " '4.normal_map', '5.mlsd',\n",
@@ -513,33 +223,45 @@
513
  " '8.scribble', '9.segmentation',\n",
514
  " '10.shuffle', '11.tile',\n",
515
  " '12.inpaint', '13.instruct_p2p']\n",
516
- "# ---\n",
517
- "controlnet_widget = widgets.Dropdown(options=controlnet_options, value='none', description='ControlNet:', style=style, layout=layout)\n",
518
- "controlnet_Num_widget = widgets.Text(description='ControlNet Number:', placeholder='Enter the ControlNet model numbers to be downloaded using comma/space.', style=style, layout=layout)\n",
519
- "commit_hash_widget = widgets.Text(description='Commit Hash:', style=style, layout=layout)\n",
520
- "optional_huggingface_token_widget = widgets.Text(description='HuggingFace Token:', style=style, layout=layout)\n",
521
- "ngrok_token_widget = widgets.Text(description='Ngrok Token:', style=style, layout=widgets.Layout(width='1047px'))\n",
522
- "ngrock_button = widgets.HTML('<a href=\"https://dashboard.ngrok.com/get-started/your-authtoken\" target=\"_blank\">Get Ngrok Token</a>').add_class(\"button_ngrok\")\n",
523
- "ngrok_widget = widgets.HBox([ngrok_token_widget, ngrock_button], style=style, layout=layout)\n",
524
- "zrok_token_widget = widgets.Text(description='Zrok Token:', style=style, layout=widgets.Layout(width='1047px'))\n",
525
- "zrok_button = widgets.HTML('<a href=\"https://colab.research.google.com/drive/1d2sjWDJi_GYBUavrHSuQyHTDuLy36WpU\" target=\"_blank\">Reg Zrok Token</a>').add_class(\"button_ngrok\")\n",
526
- "zrok_widget = widgets.HBox([zrok_token_widget, zrok_button], style=style, layout=layout)\n",
527
- "# ---\n",
 
528
  "commandline_arguments_options = \"--listen --enable-insecure-extension-access --theme dark --no-half-vae --disable-console-progressbars --xformers\"\n",
529
- "commandline_arguments_widget = widgets.Text(description='Arguments:', value=commandline_arguments_options, style=style, layout=layout)\n",
 
 
 
 
 
 
 
 
 
 
 
 
 
530
  "\n",
531
- "''' Display Additional'''\n",
532
- "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]\n",
533
  "if free_plan and env == \"Google Colab\": # remove ngrok from colab\n",
534
  " additional_widget_list.remove(ngrok_widget)\n",
535
  "if os.path.exists(webui_path): # remove selection after selection ;3\n",
536
- " latest_changes_widget.children = [widget for widget in latest_changes_widget.children if widget != change_webui_widget]\n",
537
- "# ```\n",
538
- "all_additional_box = widgets.VBox(additional_widget_list).add_class(\"container\").add_class(\"image_3\")\n",
539
- "display(all_additional_box)\n",
540
  "\n",
541
  "# --- CUSTOM DOWNLOAD ---\n",
542
- "custom_download_header_popup = widgets.HTML('''\n",
543
  "<style>\n",
544
  "/* Term Colors */\n",
545
  ".sample_label {color: #dbafff;}\n",
@@ -564,39 +286,40 @@
564
  " </div>\n",
565
  "</div>\n",
566
  "''')\n",
567
- "# ---\n",
568
- "Model_url_widget = widgets.Text(description='Model:', style=style, layout=layout)\n",
569
- "Vae_url_widget = widgets.Text(description='Vae:', style=style, layout=layout)\n",
570
- "LoRA_url_widget = widgets.Text(description='LoRa:', style=style, layout=layout)\n",
571
- "Embedding_url_widget = widgets.Text(description='Embedding:', style=style, layout=layout)\n",
572
- "Extensions_url_widget = widgets.Text(description='Extensions:', style=style, layout=layout)\n",
573
- "custom_file_urls_widget = widgets.Text(description='File (txt):', style=style, layout=layout)\n",
574
- "\n",
575
- "''' Display CustomDl'''\n",
576
- "all_custom_box = widgets.VBox([\n",
577
  " custom_download_header_popup, Model_url_widget, Vae_url_widget, LoRA_url_widget, Embedding_url_widget, Extensions_url_widget, custom_file_urls_widget\n",
578
- " ]).add_class(\"container\").add_class(\"image_4\").add_class(\"container_custom_downlad\")\n",
579
- "display(all_custom_box)\n",
580
  "\n",
581
  "# --- Save Button ---\n",
582
- "save_button = widgets.Button(description='Save').add_class(\"button_save\")\n",
583
- "display(save_button)\n",
584
  "\n",
585
  "\n",
586
  "# ============ Load / Save - Settings V2 ============\n",
587
  "SETTINGS_FILE = f'{root_path}/settings.json'\n",
588
  "\n",
589
- "settings_keys = [\n",
590
- " 'Model', 'Model_Num', 'Inpainting_Model',\n",
591
- " 'Vae', 'Vae_Num',\n",
592
- " 'latest_webui', 'latest_exstensions', 'change_webui', 'detailed_download',\n",
593
- " 'controlnet', 'controlnet_Num', 'commit_hash', 'optional_huggingface_token',\n",
594
  " 'ngrok_token', 'zrok_token', 'commandline_arguments',\n",
595
- " 'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url', 'Extensions_url', 'custom_file_urls'\n",
 
596
  "]\n",
597
  "\n",
598
  "def save_settings():\n",
599
- " settings = {key: globals()[f\"{key}_widget\"].value for key in settings_keys}\n",
600
  " with open(SETTINGS_FILE, 'w') as f:\n",
601
  " json.dump(settings, f, indent=2)\n",
602
  "\n",
@@ -604,28 +327,23 @@
604
  " if os.path.exists(SETTINGS_FILE):\n",
605
  " with open(SETTINGS_FILE, 'r') as f:\n",
606
  " settings = json.load(f)\n",
607
- " for key in settings_keys:\n",
608
- " globals()[f\"{key}_widget\"].value = settings.get(key)\n",
609
- "\n",
610
- "def save_data(button):\n",
611
- " save_settings()\n",
612
  "\n",
613
- " # --- uhh - hide... ---\n",
614
  " widgets_list = [all_model_box, all_vae_box, all_additional_box, all_custom_box, save_button]\n",
615
  " for widget in widgets_list:\n",
616
  " widget.add_class(\"hide\")\n",
617
  " time.sleep(0.5)\n",
618
- "\n",
619
  " widgets.Widget.close_all()\n",
620
  "\n",
621
- "settings = load_settings()\n",
 
 
 
 
622
  "save_button.on_click(save_data)"
623
- ],
624
- "metadata": {
625
- "id": "2lJmbqrs3Mu8"
626
- },
627
- "execution_count": null,
628
- "outputs": []
629
  }
630
  ]
631
  }
 
16
  "cells": [
17
  {
18
  "cell_type": "code",
19
+ "execution_count": null,
20
+ "metadata": {
21
+ "id": "JKTCrY9LU7Oq"
22
+ },
23
+ "outputs": [],
24
  "source": [
25
  "##~ WIDGET CODE | BY: ANXETY ~##\n",
26
  "\n",
 
32
  "from IPython.display import display, HTML, Javascript, clear_output\n",
33
  "\n",
34
  "\n",
35
+ "# ================= DETECT ENV =================\n",
36
  "def detect_environment():\n",
37
  " free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024 ** 3) <= 20)\n",
38
  " environments = {\n",
39
  " 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
40
  " 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\")\n",
41
  " }\n",
 
42
  " for env_var, (environment, path) in environments.items():\n",
43
  " if env_var in os.environ:\n",
44
  " return environment, path, free_plan\n",
45
  "\n",
46
  "env, root_path, free_plan = detect_environment()\n",
47
  "webui_path = f\"{root_path}/sdw\"\n",
 
48
  "!mkdir -p {root_path}\n",
 
49
  "\n",
50
  "\n",
51
  "# ==================== CSS JS ====================\n",
52
+ "##~ custom background images V1.5 ~##\n",
53
  "import argparse\n",
54
  "parser = argparse.ArgumentParser(description='This script processes an background image.')\n",
55
  "parser.add_argument('-i', '--image', type=str, help='URL of the image to process', metavar='')\n",
 
61
  "parser.add_argument('-m', '--mode', action='store_true', help='Removes repetitive image tiles')\n",
62
  "parser.add_argument('-t', '--transparent', action='store_true', help='Makes input/selection fields 35%% more transparent')\n",
63
  "parser.add_argument('-bf', '--blur-fields', type=str, help='Background blur level for input/selection fields', metavar='', default=2)\n",
64
+ "\n",
65
  "args = parser.parse_args()\n",
66
+ "\n",
67
  "url_img = args.image\n",
68
  "opacity_img = args.opacity\n",
69
  "blur_img = args.blur\n",
 
81
  "\n",
82
  "\"\"\" mode img - repeats \"\"\"\n",
83
  "mode_img = \"repeat\" if not args.mode else \"no-repeat\"\n",
 
84
  "\n",
85
  "container_background = f'''\n",
86
  "<style>\n",
 
103
  "'''\n",
104
  "\n",
105
  "display(HTML(container_background))\n",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  "\n",
107
+ "# Main CSS\n",
108
+ "css_file_path = f\"{root_path}/CSS/main_widgets.css\"\n",
109
+ "with open(css_file_path , \"r\") as f:\n",
110
+ " CSS = f.read()\n",
111
+ "display(HTML(f\"<style>{CSS}</style>\"))\n",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  "\n",
113
+ "# Main JS\n",
114
+ "JS = '''\n",
115
  "<!-- TOGGLE 'CustomDL' SCRIPT -->\n",
116
  "<script>\n",
117
  "function toggleContainer() {\n",
 
123
  "}\n",
124
  "</script>\n",
125
  "'''\n",
126
+ "display(HTML(JS))\n",
127
  "\n",
128
+ "# ==================== WIDGETS V2 ====================\n",
129
+ "HR = widgets.HTML('<hr>')\n",
130
  "\n",
131
+ "class WidgetFactory:\n",
132
+ " def __init__(self, style=None, layout=None):\n",
133
+ " self.style = style if style else {'description_width': 'initial'}\n",
134
+ " self.layout = layout if layout else widgets.Layout(max_width='1080px', width='100%')\n",
135
  "\n",
136
+ " def create_html(self, content, class_name=None):\n",
137
+ " html_widget = widgets.HTML(content)\n",
138
+ " if class_name:\n",
139
+ " html_widget.add_class(class_name)\n",
140
+ " return html_widget\n",
141
  "\n",
142
+ " def create_header(self, name):\n",
143
+ " return widgets.HTML(f'<div class=\"header\">{name}<div>')\n",
144
+ "\n",
145
+ " def create_dropdown(self, options, value, description):\n",
146
+ " return widgets.Dropdown(options=options, value=value, description=description, style=self.style, layout=self.layout)\n",
147
+ "\n",
148
+ " def create_text(self, description, placeholder='', value=''):\n",
149
+ " return widgets.Text(description=description, placeholder=placeholder, value=value, style=self.style, layout=self.layout)\n",
150
+ "\n",
151
+ " def create_checkbox(self, value, description):\n",
152
+ " return widgets.Checkbox(value=value, description=description, style=self.style, layout=self.layout)\n",
153
+ "\n",
154
+ " def create_button(self, description, class_name=None):\n",
155
+ " button = widgets.Button(description=description)\n",
156
+ " if class_name:\n",
157
+ " button.add_class(class_name)\n",
158
+ " return button\n",
159
+ "\n",
160
+ " def create_hbox(self, children):\n",
161
+ " return widgets.HBox(children)\n",
162
+ "\n",
163
+ " def create_vbox(self, children, class_names=None):\n",
164
+ " vbox = widgets.VBox(children)\n",
165
+ " if class_names:\n",
166
+ " for class_name in class_names:\n",
167
+ " vbox.add_class(class_name)\n",
168
+ " return vbox\n",
169
+ "\n",
170
+ " def display(self, widget):\n",
171
+ " display(widget)\n",
172
+ "\n",
173
+ "# Instantiate the factory\n",
174
+ "factory = WidgetFactory()\n",
175
  "\n",
176
  "# --- MODEL ---\n",
177
+ "model_header = factory.create_header('Model Selection')\n",
178
  "model_options = ['none',\n",
179
  " '1.Anime (by XpucT) + INP',\n",
180
  " '2.BluMix [Anime] [V7] + INP',\n",
 
185
  " '7.Deliberate [Realism] [V6] + INP',\n",
186
  " '8.Meina-Mix [Anime] [V11] + INP',\n",
187
  " '9.Mix-Pro [Anime] [V4] + INP']\n",
188
+ "model_widget = factory.create_dropdown(model_options, '4.Counterfeit [Anime] [V3] + INP', 'Model:')\n",
189
+ "model_num_widget = factory.create_text('Model Number:', 'Enter the model numbers to be downloaded using comma/space.')\n",
190
+ "inpainting_model_widget = factory.create_checkbox(False, 'Inpainting Models')\n",
 
191
  "\n",
192
+ "# Display Model\n",
193
+ "all_model_box = factory.create_vbox([model_header, model_widget, model_num_widget, inpainting_model_widget], class_names=[\"container\", \"image_1\"])\n",
194
+ "factory.display(all_model_box)\n",
195
  "\n",
196
  "# --- VAE ---\n",
197
+ "vae_header = factory.create_header('VAE Selection')\n",
198
  "vae_options = ['none',\n",
199
  " '1.Anime.vae',\n",
200
  " '2.Anything.vae',\n",
201
  " '3.Blessed2.vae',\n",
202
  " '4.ClearVae.vae',\n",
203
  " '5.WD.vae']\n",
204
+ "vae_widget = factory.create_dropdown(vae_options, '3.Blessed2.vae', 'Vae:')\n",
205
+ "vae_num_widget = factory.create_text('Vae Number:', 'Enter the vae numbers to be downloaded using comma/space.')\n",
206
  "\n",
207
+ "# Display Vae\n",
208
+ "all_vae_box = factory.create_vbox([vae_header, vae_widget, vae_num_widget], class_names=[\"container\", \"image_2\"])\n",
209
+ "factory.display(all_vae_box)\n",
210
  "\n",
211
  "# --- ADDITIONAL ---\n",
212
+ "additional_header = factory.create_header('Additional')\n",
213
+ "latest_webui_widget = factory.create_checkbox(True, 'Update WebUI')\n",
214
+ "latest_exstensions_widget = factory.create_checkbox(True, 'Update Extensions')\n",
215
+ "change_webui_widget = factory.create_dropdown(['A1111', 'Forge'], 'A1111', 'Change WebUI:')\n",
216
+ "detailed_download_widget = factory.create_dropdown(['off', 'on'], 'off', 'Detailed Download:')\n",
217
+ "choose_changes_widget = factory.create_hbox([latest_webui_widget, latest_exstensions_widget, change_webui_widget, detailed_download_widget])\n",
218
+ "\n",
219
  "controlnet_options = ['none', 'ALL', '1.canny',\n",
220
  " '2.openpose', '3.depth',\n",
221
  " '4.normal_map', '5.mlsd',\n",
 
223
  " '8.scribble', '9.segmentation',\n",
224
  " '10.shuffle', '11.tile',\n",
225
  " '12.inpaint', '13.instruct_p2p']\n",
226
+ "controlnet_widget = factory.create_dropdown(controlnet_options, 'none', 'ControlNet:')\n",
227
+ "controlnet_num_widget = factory.create_text('ControlNet Number:', 'Enter the ControlNet model numbers to be downloaded using comma/space.')\n",
228
+ "commit_hash_widget = factory.create_text('Commit Hash:')\n",
229
+ "huggingface_token_widget = factory.create_text('HuggingFace Token:')\n",
230
+ "\n",
231
+ "ngrok_token_widget = factory.create_text('Ngrok Token:')\n",
232
+ "ngrock_button = factory.create_html('<a href=\"https://dashboard.ngrok.com/get-started/your-authtoken\" target=\"_blank\">Получить Ngrok Токен</a>', class_name=\"button_ngrok\")\n",
233
+ "ngrok_widget = factory.create_hbox([ngrok_token_widget, ngrock_button])\n",
234
+ "\n",
235
+ "zrok_token_widget = factory.create_text('Zrok Token:')\n",
236
+ "zrok_button = factory.create_html('<a href=\"https://colab.research.google.com/drive/1d2sjWDJi_GYBUavrHSuQyHTDuLy36WpU\" target=\"_blank\">Зарегать Zrok Токен</a>', class_name=\"button_ngrok\")\n",
237
+ "zrok_widget = factory.create_hbox([zrok_token_widget, zrok_button])\n",
238
+ "\n",
239
  "commandline_arguments_options = \"--listen --enable-insecure-extension-access --theme dark --no-half-vae --disable-console-progressbars --xformers\"\n",
240
+ "commandline_arguments_widget = factory.create_text('Arguments:', value=commandline_arguments_options)\n",
241
+ "\n",
242
+ "# Display Additional\n",
243
+ "additional_widget_list = [additional_header,\n",
244
+ " choose_changes_widget,\n",
245
+ " HR,\n",
246
+ " controlnet_widget,\n",
247
+ " controlnet_num_widget,\n",
248
+ " commit_hash_widget,\n",
249
+ " huggingface_token_widget,\n",
250
+ " ngrok_widget,\n",
251
+ " zrok_widget,\n",
252
+ " HR,\n",
253
+ " commandline_arguments_widget]\n",
254
  "\n",
 
 
255
  "if free_plan and env == \"Google Colab\": # remove ngrok from colab\n",
256
  " additional_widget_list.remove(ngrok_widget)\n",
257
  "if os.path.exists(webui_path): # remove selection after selection ;3\n",
258
+ " choose_changes_widget.children = [widget for widget in choose_changes_widget.children if widget != change_webui_widget]\n",
259
+ "\n",
260
+ "all_additional_box = factory.create_vbox(additional_widget_list, class_names=[\"container\", \"image_3\"])\n",
261
+ "factory.display(all_additional_box)\n",
262
  "\n",
263
  "# --- CUSTOM DOWNLOAD ---\n",
264
+ "custom_download_header_popup = factory.create_html('''\n",
265
  "<style>\n",
266
  "/* Term Colors */\n",
267
  ".sample_label {color: #dbafff;}\n",
 
286
  " </div>\n",
287
  "</div>\n",
288
  "''')\n",
289
+ "\n",
290
+ "Model_url_widget = factory.create_text('Model:')\n",
291
+ "Vae_url_widget = factory.create_text('Vae:')\n",
292
+ "LoRA_url_widget = factory.create_text('LoRa:')\n",
293
+ "Embedding_url_widget = factory.create_text('Embedding:')\n",
294
+ "Extensions_url_widget = factory.create_text('Extensions:')\n",
295
+ "custom_file_urls_widget = factory.create_text('File (txt):')\n",
296
+ "\n",
297
+ "# Display CustomDl\n",
298
+ "all_custom_box = factory.create_vbox([\n",
299
  " custom_download_header_popup, Model_url_widget, Vae_url_widget, LoRA_url_widget, Embedding_url_widget, Extensions_url_widget, custom_file_urls_widget\n",
300
+ "], class_names=[\"container\", \"image_4\", \"container_custom_downlad\"])\n",
301
+ "factory.display(all_custom_box)\n",
302
  "\n",
303
  "# --- Save Button ---\n",
304
+ "save_button = factory.create_button('Save', class_name=\"button_save\")\n",
305
+ "factory.display(save_button)\n",
306
  "\n",
307
  "\n",
308
  "# ============ Load / Save - Settings V2 ============\n",
309
  "SETTINGS_FILE = f'{root_path}/settings.json'\n",
310
  "\n",
311
+ "SETTINGS_KEYS = [\n",
312
+ " 'model', 'model_num', 'inpainting_model',\n",
313
+ " 'vae', 'vae_num', 'latest_webui', 'latest_exstensions',\n",
314
+ " 'change_webui', 'detailed_download', 'controlnet',\n",
315
+ " 'controlnet_num', 'commit_hash', 'huggingface_token',\n",
316
  " 'ngrok_token', 'zrok_token', 'commandline_arguments',\n",
317
+ " 'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url',\n",
318
+ " 'Extensions_url', 'custom_file_urls'\n",
319
  "]\n",
320
  "\n",
321
  "def save_settings():\n",
322
+ " settings = {key: globals()[f\"{key}_widget\"].value for key in SETTINGS_KEYS}\n",
323
  " with open(SETTINGS_FILE, 'w') as f:\n",
324
  " json.dump(settings, f, indent=2)\n",
325
  "\n",
 
327
  " if os.path.exists(SETTINGS_FILE):\n",
328
  " with open(SETTINGS_FILE, 'r') as f:\n",
329
  " settings = json.load(f)\n",
330
+ " for key in SETTINGS_KEYS:\n",
331
+ " globals()[f\"{key}_widget\"].value = settings.get(key, \"\")\n",
 
 
 
332
  "\n",
333
+ "def hide_widgets():\n",
334
  " widgets_list = [all_model_box, all_vae_box, all_additional_box, all_custom_box, save_button]\n",
335
  " for widget in widgets_list:\n",
336
  " widget.add_class(\"hide\")\n",
337
  " time.sleep(0.5)\n",
 
338
  " widgets.Widget.close_all()\n",
339
  "\n",
340
+ "def save_data(button):\n",
341
+ " save_settings()\n",
342
+ " hide_widgets()\n",
343
+ "\n",
344
+ "load_settings()\n",
345
  "save_button.on_click(save_data)"
346
+ ]
 
 
 
 
 
347
  }
348
  ]
349
  }
files_cells/notebooks/ru/auto_cleaner_ru.ipynb ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "nbformat": 4,
3
+ "nbformat_minor": 0,
4
+ "metadata": {
5
+ "colab": {
6
+ "provenance": []
7
+ },
8
+ "kernelspec": {
9
+ "name": "python3",
10
+ "display_name": "Python 3"
11
+ },
12
+ "language_info": {
13
+ "name": "python"
14
+ }
15
+ },
16
+ "cells": [
17
+ {
18
+ "cell_type": "code",
19
+ "execution_count": null,
20
+ "metadata": {
21
+ "id": "JKTCrY9LU7Oq"
22
+ },
23
+ "outputs": [],
24
+ "source": [
25
+ "##~ AutoCleaner V3.7 CODE | BY: ANXETY ~##\n",
26
+ "\n",
27
+ "import os\n",
28
+ "import time\n",
29
+ "import ipywidgets as widgets\n",
30
+ "from ipywidgets import Label, Button, VBox, HBox\n",
31
+ "from IPython.display import display, HTML\n",
32
+ "\n",
33
+ "\n",
34
+ "# ================= DETECT ENV =================\n",
35
+ "def detect_environment():\n",
36
+ " free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024 ** 3) <= 20)\n",
37
+ " environments = {\n",
38
+ " 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
39
+ " 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\")\n",
40
+ " }\n",
41
+ " for env_var, (environment, path) in environments.items():\n",
42
+ " if env_var in os.environ:\n",
43
+ " return environment, path, free_plan\n",
44
+ "\n",
45
+ "env, root_path, free_plan = detect_environment()\n",
46
+ "webui_path = f\"{root_path}/sdw\"\n",
47
+ "\n",
48
+ "\n",
49
+ "# ==================== CSS ====================\n",
50
+ "# Main CSS\n",
51
+ "css_file_path = f\"{root_path}/CSS/auto_cleaner.css\"\n",
52
+ "with open(css_file_path , \"r\") as f:\n",
53
+ " CSS_AC = f.read()\n",
54
+ "display(HTML(f\"<style>{CSS_AC}</style>\"))\n",
55
+ "\n",
56
+ "\n",
57
+ "# ================ AutoCleaner function ================\n",
58
+ "directories = {\n",
59
+ " \"Изображения\": f\"{webui_path}/output\",\n",
60
+ " \"Модели\": f\"{webui_path}/models/Stable-diffusion/\",\n",
61
+ " \"Vae\": f\"{webui_path}/models/VAE/\",\n",
62
+ " \"LoRa\": f\"{webui_path}/models/Lora/\",\n",
63
+ " \"ControlNet Модели\": f\"{webui_path}/models/ControlNet/\"\n",
64
+ "}\n",
65
+ "\n",
66
+ "\"\"\" functions \"\"\"\n",
67
+ "def clean_directory(directory):\n",
68
+ " deleted_files = 0\n",
69
+ " image_dir = directories['Изображения']\n",
70
+ "\n",
71
+ " for root, dirs, files in os.walk(directory):\n",
72
+ " for file in files:\n",
73
+ " file_path = os.path.join(root, file)\n",
74
+ "\n",
75
+ " if file.endswith(\".txt\"):\n",
76
+ " continue\n",
77
+ " if file.endswith((\".safetensors\", \".pt\")) or root == image_dir: # fix for image counter\n",
78
+ " deleted_files += 1\n",
79
+ "\n",
80
+ " os.remove(file_path)\n",
81
+ " return deleted_files\n",
82
+ "\n",
83
+ "def update_memory_info():\n",
84
+ " disk_space = psutil.disk_usage(os.getcwd())\n",
85
+ " total = disk_space.total / (1024 ** 3)\n",
86
+ " used = disk_space.used / (1024 ** 3)\n",
87
+ " free = disk_space.free / (1024 ** 3)\n",
88
+ "\n",
89
+ " storage_info.value = f'''\n",
90
+ " <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>\n",
91
+ " '''\n",
92
+ "\n",
93
+ "def on_execute_button_press(button):\n",
94
+ " selected_cleaners = auto_cleaner_widget.value\n",
95
+ " deleted_files_dict = {}\n",
96
+ "\n",
97
+ " for option in selected_cleaners:\n",
98
+ " if option in directories:\n",
99
+ " deleted_files_dict[option] = clean_directory(directories[option])\n",
100
+ "\n",
101
+ " output.clear_output()\n",
102
+ "\n",
103
+ " with output:\n",
104
+ " for message in generate_messages(deleted_files_dict):\n",
105
+ " message_widget = HTML(f'<p class=\"output_message_AC\">{message}</p>')\n",
106
+ " display(message_widget)\n",
107
+ "\n",
108
+ " update_memory_info()\n",
109
+ "\n",
110
+ "def on_clear_button_press(button):\n",
111
+ " container.add_class(\"hide\")\n",
112
+ " time.sleep(0.5)\n",
113
+ " widgets.Widget.close_all()\n",
114
+ "\n",
115
+ "def generate_messages(deleted_files_dict):\n",
116
+ " messages = []\n",
117
+ " word_variants = {\n",
118
+ " \"Изображения\": \"Изображений\",\n",
119
+ " \"Модели\": \"Моделей\",\n",
120
+ " \"Vae\": \"Vae\",\n",
121
+ " \"LoRa\": \"LoRa\",\n",
122
+ " \"ControlNet Модели\": \"ControlNet Моделей\"\n",
123
+ " }\n",
124
+ " for key, value in deleted_files_dict.items():\n",
125
+ " object_word = word_variants.get(key)\n",
126
+ " messages.append(f\"Удалено {value} {object_word}\")\n",
127
+ " return messages\n",
128
+ "\n",
129
+ "\n",
130
+ "# --- storage memory ---\n",
131
+ "import psutil\n",
132
+ "disk_space = psutil.disk_usage(os.getcwd())\n",
133
+ "total = disk_space.total / (1024 ** 3)\n",
134
+ "used = disk_space.used / (1024 ** 3)\n",
135
+ "free = disk_space.free / (1024 ** 3)\n",
136
+ "\n",
137
+ "\n",
138
+ "# ================ Widgets ================\n",
139
+ "# UI Code\n",
140
+ "AutoCleaner_options = AutoCleaner_options = list(directories.keys())\n",
141
+ "instruction_label = widgets.HTML('''\n",
142
+ "<span class=\"instruction_AC\">Используйте <span style=\"color: #B2B2B2;\">ctrl</span> или <span style=\"color: #B2B2B2;\">shift</span> для множественного выбора.</span>\n",
143
+ "''')\n",
144
+ "auto_cleaner_widget = widgets.SelectMultiple(options=AutoCleaner_options, layout=widgets.Layout(width=\"auto\")).add_class(\"custom-select-multiple_AC\")\n",
145
+ "output = widgets.Output().add_class(\"output_AC\")\n",
146
+ "\n",
147
+ "execute_button = Button(description='Выполнить Очистку').add_class(\"button_execute_AC\").add_class(\"button_AC\")\n",
148
+ "execute_button.on_click(on_execute_button_press)\n",
149
+ "clear_button = Button(description='Скрыть Виджет').add_class(\"button_clear_AC\").add_class(\"button_AC\")\n",
150
+ "clear_button.on_click(on_clear_button_press)\n",
151
+ "\n",
152
+ "storage_info = widgets.HTML(f'''\n",
153
+ "<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>\n",
154
+ "''')\n",
155
+ "\n",
156
+ "buttons = widgets.HBox([execute_button, clear_button])\n",
157
+ "lower_information_panel = widgets.HBox([buttons, storage_info]).add_class(\"lower_information_panel_AC\")\n",
158
+ "\n",
159
+ "container = VBox([instruction_label, widgets.HTML('<hr>'), auto_cleaner_widget, output, widgets.HTML('<hr>'), lower_information_panel]).add_class(\"container_AC\")\n",
160
+ "\n",
161
+ "display(container)"
162
+ ]
163
+ }
164
+ ]
165
+ }
files_cells/notebooks/ru/downloading_ru.ipynb CHANGED
@@ -25,21 +25,19 @@
25
  "from urllib.parse import urlparse, parse_qs\n",
26
  "\n",
27
  "\n",
28
- "# ================= DETECT ENV =================\n",
29
  "def detect_environment():\n",
30
  " free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024 ** 3) <= 20)\n",
31
  " environments = {\n",
32
  " 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
33
  " 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\")\n",
34
  " }\n",
35
- "\n",
36
  " for env_var, (environment, path) in environments.items():\n",
37
  " if env_var in os.environ:\n",
38
  " return environment, path, free_plan\n",
39
  "\n",
40
  "env, root_path, free_plan = detect_environment()\n",
41
  "webui_path = f\"{root_path}/sdw\"\n",
42
- "# ----------------------------------------------\n",
43
  "\n",
44
  "\n",
45
  "# ================ LIBRARIES V2 ================\n",
@@ -90,12 +88,6 @@
90
  " time.sleep(2)\n",
91
  " clear_output()\n",
92
  "\n",
93
- "## dl special files\n",
94
- "with capture.capture_output() as cap:\n",
95
- " !mkdir -p {root_path}/file_cell/special\n",
96
- " !wget https://huggingface.co/NagisaNao/fast_repo/resolve/main/special/dl_display_results.py -O {root_path}/file_cell/special/dl_display_results.py\n",
97
- "del cap\n",
98
- "\n",
99
  "\n",
100
  "# ================= loading settings V4 =================\n",
101
  "def load_settings(path):\n",
@@ -106,16 +98,17 @@
106
  "\n",
107
  "settings = load_settings(f'{root_path}/settings.json')\n",
108
  "\n",
109
- "variables = [\n",
110
- " 'Model', 'Model_Num', 'Inpainting_Model',\n",
111
- " 'Vae', 'Vae_Num',\n",
112
- " 'latest_webui', 'latest_exstensions', 'change_webui', 'detailed_download',\n",
113
- " 'controlnet', 'controlnet_Num', 'commit_hash', 'optional_huggingface_token',\n",
114
  " 'ngrok_token', 'zrok_token', 'commandline_arguments',\n",
115
- " 'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url', 'Extensions_url', 'custom_file_urls'\n",
 
116
  "]\n",
117
  "\n",
118
- "locals().update({key: settings.get(key) for key in variables})\n",
119
  "\n",
120
  "\n",
121
  "# ================= OTHER =================\n",
@@ -251,17 +244,7 @@
251
  " ]\n",
252
  "}\n",
253
  "\n",
254
- "# 1-4 (fp16/cleaned)\n",
255
  "vae_list = {\n",
256
- " ## vae broke - the author's an asshole\n",
257
- " # \"1.Anime.vae\": [\n",
258
- " # {\"url\": \"https://civitai.com/api/download/models/131654\", \"name\": \"Anime.vae.safetensors\"},\n",
259
- " # {\"url\": \"https://civitai.com/api/download/models/131658\", \"name\": \"vae-ft-mse.vae.safetensors\"}\n",
260
- " # ],\n",
261
- " # \"2.Anything.vae\": [{\"url\": \"https://civitai.com/api/download/models/131656\", \"name\": \"Anything.vae.safetensors\"}],\n",
262
- " # \"3.Blessed2.vae\": [{\"url\": \"https://civitai.com/api/download/models/142467\", \"name\": \"Blessed2.vae.safetensors\"}],\n",
263
- " # \"4.ClearVae.vae\": [{\"url\": \"https://civitai.com/api/download/models/133362\", \"name\": \"ClearVae_23.vae.safetensors\"}],\n",
264
- "\n",
265
  " \"1.Anime.vae\": [{\"url\": \"https://civitai.com/api/download/models/311162\", \"name\": \"vae-ft-mse-840000-ema-pruned.vae.safetensors\"}],\n",
266
  " \"2.Anything.vae\": [{\"url\": \"https://civitai.com/api/download/models/119279\", \"name\": \"Anything.vae.safetensors\"}],\n",
267
  " \"3.Blessed2.vae\": [{\"url\": \"https://huggingface.co/NoCrypt/blessed_vae/resolve/main/blessed2.vae.pt\", \"name\": \"Blessed2.vae.safetensors\"}],\n",
@@ -342,7 +325,7 @@
342
  "directories = [value for key, value in prefixes.items()] # for unpucking zip files\n",
343
  "!mkdir -p {\" \".join(directories)}\n",
344
  "\n",
345
- "hf_token = optional_huggingface_token if optional_huggingface_token else \"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\"\n",
346
  "user_header = f\"\\\"Authorization: Bearer {hf_token}\\\"\"\n",
347
  "\n",
348
  "''' Formatted Info Output '''\n",
@@ -541,14 +524,14 @@
541
  "def handle_submodels(selection, num_selection, model_dict, dst_dir, url):\n",
542
  " submodels = add_submodels(selection, num_selection, model_dict, dst_dir)\n",
543
  " for submodel in submodels:\n",
544
- " if not Inpainting_Model and \"inpainting\" in submodel['name']:\n",
545
  " continue\n",
546
  " url += f\"{submodel['url']} {submodel['dst_dir']} {submodel['name']}, \"\n",
547
  " return url\n",
548
  "\n",
549
- "url = handle_submodels(Model, Model_Num, model_list, models_dir, url)\n",
550
- "url = handle_submodels(Vae, Vae_Num, vae_list, vaes_dir, url)\n",
551
- "url = handle_submodels(controlnet, controlnet_Num, controlnet_list, control_dir, url)\n",
552
  "\n",
553
  "''' file.txt - added urls '''\n",
554
  "\n",
@@ -635,40 +618,8 @@
635
  "## List Models and stuff V2\n",
636
  "if detailed_download == \"off\":\n",
637
  " print(\"\\n\\n\\033[33mЕсли вы не видете каких-то скаченных файлов, включите в виджетах функцию 'Подробная Загрузка'.\")\n",
638
- " get_ipython().run_line_magic('run', '{root_path}/file_cell/special/dl_display_results.py') # display widgets result\n",
639
  "\n",
640
- "else:\n",
641
- " if any(not file.endswith('.txt') for file in os.listdir(models_dir)):\n",
642
- " print(\"\\n\\033[33m➤ Models\\033[0m\")\n",
643
- " !find {models_dir}/ -mindepth 1 -name '*.safetensors' -printf '%f\\n'\n",
644
- " if any(not file.endswith('.txt') for file in os.listdir(vaes_dir)):\n",
645
- " print(\"\\n\\033[33m➤ VAEs\\033[0m\")\n",
646
- " !find {vaes_dir}/ -mindepth 1 -name '*.safetensors' -printf '%f\\n'\n",
647
- " if any(not file.endswith('.txt') and not os.path.isdir(os.path.join(embeddings_dir, file)) for file in os.listdir(embeddings_dir)):\n",
648
- " print(\"\\n\\033[33m➤ Embeddings\\033[0m\")\n",
649
- " !find {embeddings_dir}/ -mindepth 1 -maxdepth 1 \\( -name '*.pt' -or -name '*.safetensors' \\) -printf '%f\\n'\n",
650
- " if any(not file.endswith('.txt') for file in os.listdir(loras_dir)):\n",
651
- " print(\"\\n\\033[33m➤ LoRAs\\033[0m\")\n",
652
- " !find {loras_dir}/ -mindepth 1 -name '*.safetensors' -printf '%f\\n'\n",
653
- " print(f\"\\n\\033[33m➤ Extensions\\033[0m\")\n",
654
- " !find {extensions_dir}/ -mindepth 1 -maxdepth 1 ! -name '*.txt' -printf '%f\\n'\n",
655
- " if any(not file.endswith(('.txt', '.yaml')) for file in os.listdir(control_dir)):\n",
656
- " print(\"\\n\\033[33m➤ ControlNet\\033[0m\")\n",
657
- " !find {control_dir}/ -mindepth 1 ! -name '*.yaml' -printf '%f\\n' | sed 's/^[^_]*_[^_]*_[^_]*_\\([^_]*\\)_fp16\\.safetensors$/\\1/'\n",
658
- "\n",
659
- "\n",
660
- "# === OTHER ===\n",
661
- "# Downlaod discord tags UmiWildcards\n",
662
- "files_umi = [\n",
663
- " \"https://huggingface.co/NagisaNao/fast_repo/resolve/main/extensions/UmiWildacrd/discord/200_pan_gen.txt\",\n",
664
- " \"https://huggingface.co/NagisaNao/fast_repo/resolve/main/extensions/UmiWildacrd/discord/150_bra_gen.txt\"\n",
665
- "]\n",
666
- "save_dir_path = f\"{webui_path}/extensions/Umi-AI-Wildcards/wildcards/discord\"\n",
667
- "\n",
668
- "with capture.capture_output() as cap:\n",
669
- " for file in files_umi:\n",
670
- " !aria2c --optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -j5 -x16 -s16 -k1M -c -d {save_dir_path} {file}\n",
671
- "del cap"
672
  ]
673
  }
674
  ],
 
25
  "from urllib.parse import urlparse, parse_qs\n",
26
  "\n",
27
  "\n",
28
+ "# ================= DETECT ENV =================\n",
29
  "def detect_environment():\n",
30
  " free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024 ** 3) <= 20)\n",
31
  " environments = {\n",
32
  " 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
33
  " 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\")\n",
34
  " }\n",
 
35
  " for env_var, (environment, path) in environments.items():\n",
36
  " if env_var in os.environ:\n",
37
  " return environment, path, free_plan\n",
38
  "\n",
39
  "env, root_path, free_plan = detect_environment()\n",
40
  "webui_path = f\"{root_path}/sdw\"\n",
 
41
  "\n",
42
  "\n",
43
  "# ================ LIBRARIES V2 ================\n",
 
88
  " time.sleep(2)\n",
89
  " clear_output()\n",
90
  "\n",
 
 
 
 
 
 
91
  "\n",
92
  "# ================= loading settings V4 =================\n",
93
  "def load_settings(path):\n",
 
98
  "\n",
99
  "settings = load_settings(f'{root_path}/settings.json')\n",
100
  "\n",
101
+ "VARIABLES = [\n",
102
+ " 'model', 'model_num', 'inpainting_model',\n",
103
+ " 'vae', 'vae_num', 'latest_webui', 'latest_exstensions',\n",
104
+ " 'change_webui', 'detailed_download', 'controlnet',\n",
105
+ " 'controlnet_num', 'commit_hash', 'huggingface_token',\n",
106
  " 'ngrok_token', 'zrok_token', 'commandline_arguments',\n",
107
+ " 'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url',\n",
108
+ " 'Extensions_url', 'custom_file_urls'\n",
109
  "]\n",
110
  "\n",
111
+ "locals().update({key: settings.get(key) for key in VARIABLES})\n",
112
  "\n",
113
  "\n",
114
  "# ================= OTHER =================\n",
 
244
  " ]\n",
245
  "}\n",
246
  "\n",
 
247
  "vae_list = {\n",
 
 
 
 
 
 
 
 
 
248
  " \"1.Anime.vae\": [{\"url\": \"https://civitai.com/api/download/models/311162\", \"name\": \"vae-ft-mse-840000-ema-pruned.vae.safetensors\"}],\n",
249
  " \"2.Anything.vae\": [{\"url\": \"https://civitai.com/api/download/models/119279\", \"name\": \"Anything.vae.safetensors\"}],\n",
250
  " \"3.Blessed2.vae\": [{\"url\": \"https://huggingface.co/NoCrypt/blessed_vae/resolve/main/blessed2.vae.pt\", \"name\": \"Blessed2.vae.safetensors\"}],\n",
 
325
  "directories = [value for key, value in prefixes.items()] # for unpucking zip files\n",
326
  "!mkdir -p {\" \".join(directories)}\n",
327
  "\n",
328
+ "hf_token = huggingface_token if huggingface_token else \"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\"\n",
329
  "user_header = f\"\\\"Authorization: Bearer {hf_token}\\\"\"\n",
330
  "\n",
331
  "''' Formatted Info Output '''\n",
 
524
  "def handle_submodels(selection, num_selection, model_dict, dst_dir, url):\n",
525
  " submodels = add_submodels(selection, num_selection, model_dict, dst_dir)\n",
526
  " for submodel in submodels:\n",
527
+ " if not inpainting_model and \"inpainting\" in submodel['name']:\n",
528
  " continue\n",
529
  " url += f\"{submodel['url']} {submodel['dst_dir']} {submodel['name']}, \"\n",
530
  " return url\n",
531
  "\n",
532
+ "url = handle_submodels(model, model_num, model_list, models_dir, url)\n",
533
+ "url = handle_submodels(vae, vae_num, vae_list, vaes_dir, url)\n",
534
+ "url = handle_submodels(controlnet, controlnet_num, controlnet_list, control_dir, url)\n",
535
  "\n",
536
  "''' file.txt - added urls '''\n",
537
  "\n",
 
618
  "## List Models and stuff V2\n",
619
  "if detailed_download == \"off\":\n",
620
  " print(\"\\n\\n\\033[33mЕсли вы не видете каких-то скаченных файлов, включите в виджетах функцию 'Подробная Загрузка'.\")\n",
 
621
  "\n",
622
+ "%run {root_path}/file_cell/special/dl_display_results.py # display widgets result"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
623
  ]
624
  }
625
  ],
files_cells/notebooks/ru/widgets_ru.ipynb CHANGED
@@ -16,6 +16,11 @@
16
  "cells": [
17
  {
18
  "cell_type": "code",
 
 
 
 
 
19
  "source": [
20
  "##~ WIDGET CODE | BY: ANXETY ~##\n",
21
  "\n",
@@ -27,27 +32,24 @@
27
  "from IPython.display import display, HTML, Javascript, clear_output\n",
28
  "\n",
29
  "\n",
30
- "# ================= DETECT ENV =================\n",
31
  "def detect_environment():\n",
32
  " free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024 ** 3) <= 20)\n",
33
  " environments = {\n",
34
  " 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
35
  " 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\")\n",
36
  " }\n",
37
- "\n",
38
  " for env_var, (environment, path) in environments.items():\n",
39
  " if env_var in os.environ:\n",
40
  " return environment, path, free_plan\n",
41
  "\n",
42
  "env, root_path, free_plan = detect_environment()\n",
43
  "webui_path = f\"{root_path}/sdw\"\n",
44
- "\n",
45
  "!mkdir -p {root_path}\n",
46
- "# ----------------------------------------------\n",
47
  "\n",
48
  "\n",
49
  "# ==================== CSS JS ====================\n",
50
- "# custom background images V1.5\n",
51
  "import argparse\n",
52
  "parser = argparse.ArgumentParser(description='This script processes an background image.')\n",
53
  "parser.add_argument('-i', '--image', type=str, help='URL of the image to process', metavar='')\n",
@@ -59,8 +61,9 @@
59
  "parser.add_argument('-m', '--mode', action='store_true', help='Removes repetitive image tiles')\n",
60
  "parser.add_argument('-t', '--transparent', action='store_true', help='Makes input/selection fields 35%% more transparent')\n",
61
  "parser.add_argument('-bf', '--blur-fields', type=str, help='Background blur level for input/selection fields', metavar='', default=2)\n",
 
62
  "args = parser.parse_args()\n",
63
- "\"\"\"---\"\"\"\n",
64
  "url_img = args.image\n",
65
  "opacity_img = args.opacity\n",
66
  "blur_img = args.blur\n",
@@ -78,7 +81,6 @@
78
  "\n",
79
  "\"\"\" mode img - repeats \"\"\"\n",
80
  "mode_img = \"repeat\" if not args.mode else \"no-repeat\"\n",
81
- "## ---\n",
82
  "\n",
83
  "container_background = f'''\n",
84
  "<style>\n",
@@ -101,345 +103,15 @@
101
  "'''\n",
102
  "\n",
103
  "display(HTML(container_background))\n",
104
- "# ---\n",
105
- "\n",
106
- "CSS = '''\n",
107
- "<style>\n",
108
- "/* General Styles */\n",
109
- ".header {\n",
110
- " font-family: cursive;\n",
111
- " font-size: 20px;\n",
112
- " font-weight: bold;\n",
113
- " color: #ff8cee;\n",
114
- " margin-bottom: 15px;\n",
115
- " user-select: none;\n",
116
- " cursor: default;\n",
117
- " display: inline-block;\n",
118
- "}\n",
119
- "\n",
120
- "hr {\n",
121
- " border-color: grey;\n",
122
- " background-color: grey;\n",
123
- " opacity: 0.25;\n",
124
- "}\n",
125
- "\n",
126
- "a {\n",
127
- " text-decoration: none;\n",
128
- " color: inherit;\n",
129
- "}\n",
130
- "\n",
131
- "\n",
132
- "/* Container style */\n",
133
- "\n",
134
- ".container {\n",
135
- " position: relative;\n",
136
- " background-color: #232323;\n",
137
- " width: 1080px;\n",
138
- " padding: 10px 15px;\n",
139
- " border-radius: 15px;\n",
140
- " box-shadow: 0 0 50px rgba(0, 0, 0, 0.3);\n",
141
- " margin-bottom: 5px;\n",
142
- " overflow: hidden;\n",
143
- "}\n",
144
- "\n",
145
- ".container::after {\n",
146
- " position: absolute;\n",
147
- " top: 5px;\n",
148
- " right: 10px;\n",
149
- " content: \"ANXETY\";\n",
150
- " font-weight: bold;\n",
151
- " font-size: 24px;\n",
152
- " color: rgba(0, 0, 0, 0.2);\n",
153
- "}\n",
154
- "\n",
155
- "/* background img */\n",
156
- ".container::before {\n",
157
- " content: \"\";\n",
158
- " position: absolute;\n",
159
- " top: 0;\n",
160
- " left: 0;\n",
161
- " right: 0;\n",
162
- " bottom: 0;\n",
163
- " background-image: var(--img_background);\n",
164
- " background-size: var(--img_scale);\n",
165
- " background-repeat: var(--img_mode);\n",
166
- " opacity: var(--img_opacity);\n",
167
- " mix-blend-mode: screen;\n",
168
- " pointer-events: none;\n",
169
- " filter: blur(var(--img_blur));\n",
170
- " z-index: -1;\n",
171
- "}\n",
172
- "\n",
173
- ".image_1::before {\n",
174
- " background-position: var(--image_x) calc(-120px - var(--image_y));\n",
175
- "}\n",
176
- ".image_2::before {\n",
177
- " background-position: var(--image_x) calc(-290px - var(--image_y));\n",
178
- "}\n",
179
- ".image_3::before {\n",
180
- " background-position: var(--image_x) calc(-430px - var(--image_y));\n",
181
- "}\n",
182
- ".image_4::before {\n",
183
- " background-position: var(--image_x) calc(var(--img_height_dif) - var(--image_y));\n",
184
- "}\n",
185
- "\n",
186
- ".container_custom_downlad {\n",
187
- " height: 55px;\n",
188
- " transition: all 0.5s;\n",
189
- "}\n",
190
- "\n",
191
- ".container_custom_downlad.expanded {\n",
192
- " height: 270px;\n",
193
- "}\n",
194
- "\n",
195
- "\n",
196
- "/* Element text style */\n",
197
- "\n",
198
- ".widget-html,\n",
199
- ".widget-button,\n",
200
- ".widget-text label,\n",
201
- ".widget-checkbox label,\n",
202
- ".widget-dropdown label,\n",
203
- ".widget-dropdown select,\n",
204
- ".widget-text input[type=\"text\"] {\n",
205
- " font-family: cursive;\n",
206
- " font-size: 14px;\n",
207
- " color: white !important;\n",
208
- " user-select: none;\n",
209
- "}\n",
210
- "\n",
211
- ".widget-text input[type=\"text\"]::placeholder {\n",
212
- " color: grey;\n",
213
- "}\n",
214
- "\n",
215
- "\n",
216
- "/* Input field styles */\n",
217
- "\n",
218
- ".widget-dropdown select,\n",
219
- ".widget-text input[type=\"text\"] {\n",
220
- " height: 30px;\n",
221
- " background-color: var(--bg-field-color);\n",
222
- " border: 1px solid #262626;\n",
223
- " border-radius: 10px;\n",
224
- " box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);\n",
225
- " transition: all 0.3s ease-in-out;\n",
226
- " backdrop-filter: blur(var(--bg-field-blur-level));\n",
227
- "}\n",
228
- "\n",
229
- ".widget-dropdown select:focus,\n",
230
- ".widget-text input[type=\"text\"]:focus {\n",
231
- " border-color: #006ee5;\n",
232
- "}\n",
233
- "\n",
234
- ".widget-dropdown select:hover,\n",
235
- ".widget-text input[type=\"text\"]:hover {\n",
236
- " transform: scale(1.003);\n",
237
- " background-color: var(--bg-field-color-hover);\n",
238
- " box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);\n",
239
- "}\n",
240
- "\n",
241
- ".widget-dropdown option {\n",
242
- " background-color: #1c1c1c;\n",
243
- "}\n",
244
- "\n",
245
- "\n",
246
- "/* Slider Checkbox style */\n",
247
- "\n",
248
- ".widget-checkbox input[type=\"checkbox\"] {\n",
249
- " appearance: none;\n",
250
- " position: relative;\n",
251
- " top: 4px; /* Why is he taller?! */\n",
252
- " width: 40px;\n",
253
- " height: 20px;\n",
254
- " border: none;\n",
255
- " border-radius: 10px;\n",
256
- " background-color: #20b2aa;\n",
257
- " cursor: pointer;\n",
258
- " box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.3);\n",
259
- " transition: background-color 0.3s ease;\n",
260
- "}\n",
261
- ".widget-checkbox input[type=\"checkbox\"]:checked {\n",
262
- " background-color: #2196F3;\n",
263
- "}\n",
264
- "\n",
265
- ".widget-checkbox input[type=\"checkbox\"]:before {\n",
266
- " content: '';\n",
267
- " position: absolute;\n",
268
- " top: 50%;\n",
269
- " left: 3px;\n",
270
- " width: 16px;\n",
271
- " height: 16px;\n",
272
- " border-radius: inherit;\n",
273
- " background-color: white;\n",
274
- " box-shadow: 0 0 8px rgba(0, 0, 0, 0.3);\n",
275
- " transform: translateY(-50%);\n",
276
- " transition: left 0.3s ease;\n",
277
- "}\n",
278
- ".widget-checkbox input[type=\"checkbox\"]:checked:before {\n",
279
- " left: 21px;\n",
280
- "}\n",
281
- "\n",
282
- "\n",
283
- "/* Button styles */\n",
284
- "\n",
285
- ".button_save {\n",
286
- " font-size: 15px;\n",
287
- " font-weight: bold;\n",
288
- " width: 120px;\n",
289
- " height: 35px;\n",
290
- " border-radius: 15px;\n",
291
- " background-image: radial-gradient(circle at top left, purple 10%, violet 90%);\n",
292
- " background-size: 200% 200%;\n",
293
- " background-position: left bottom;\n",
294
- " transition: background 0.5s ease-in-out, transform 0.3s ease;\n",
295
- "}\n",
296
- "\n",
297
- ".button_save:hover {\n",
298
- " cursor: pointer;\n",
299
- " background-image: radial-gradient(circle at top left, purple 10%, #93ac47 90%);\n",
300
- " background-size: 200% 200%;\n",
301
- " background-position: right bottom;\n",
302
- " transform: translateY(1px);\n",
303
- "}\n",
304
  "\n",
305
- ".button_ngrok {\n",
306
- " font-size: 12px;\n",
307
- " height: 30px;\n",
308
- " border-radius: 10px;\n",
309
- " padding: 1px 12px;\n",
310
- " background-image: radial-gradient(circle at top left, purple 10%, violet 90%);\n",
311
- " background-size: 200% 200%;\n",
312
- " background-position: left bottom;\n",
313
- " transition: background 0.5s ease-in-out, transform 0.3s ease;\n",
314
- " white-space: nowrap;\n",
315
- "}\n",
316
- "\n",
317
- ".button_ngrok:hover {\n",
318
- " cursor: pointer;\n",
319
- " background-image: radial-gradient(circle at top left, purple 10%, #1D94BB 90%);\n",
320
- " background-size: 200% 200%;\n",
321
- " background-position: right bottom;\n",
322
- " transform: translateY(1px);\n",
323
- "}\n",
324
- "\n",
325
- ".button_save:active,\n",
326
- ".button_ngrok:active {\n",
327
- " filter: brightness(0.75) !important;\n",
328
- "}\n",
329
- "\n",
330
- "/* Removes ugly stroke from widget buttons. */\n",
331
- ".jupyter-widgets.lm-Widget:focus {\n",
332
- " outline: none;\n",
333
- "}\n",
334
- "\n",
335
- "\n",
336
- "/* Popup style of `INFO` window */\n",
337
- "\n",
338
- ".info {\n",
339
- " position: absolute;\n",
340
- " top: -5px;\n",
341
- " right: 95px;\n",
342
- " color: grey;\n",
343
- " font-family: cursive;\n",
344
- " font-size: 14px;\n",
345
- " font-weight: normal;\n",
346
- " user-select: none;\n",
347
- " pointer-events: none;\n",
348
- " opacity: 0;\n",
349
- " transition: opacity 0.3s ease-in-out;\n",
350
- " display: inline-block;\n",
351
- "}\n",
352
- "\n",
353
- ".popup {\n",
354
- " position: absolute;\n",
355
- " top: 120px;\n",
356
- " z-index: 999;\n",
357
- " width: auto;\n",
358
- " padding: 10px;\n",
359
- " text-align: center;\n",
360
- " background-color: rgba(255, 255, 255, 0.05);\n",
361
- " backdrop-filter: blur(20px);\n",
362
- " border: 1px solid rgba(255, 255, 255, 0.45);\n",
363
- " border-radius: 8px;\n",
364
- " box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);\n",
365
- " opacity: 0;\n",
366
- " color: #fff;\n",
367
- " font-size: 16px;\n",
368
- " font-family: cursive;\n",
369
- " user-select: none;\n",
370
- " cursor: default;\n",
371
- " pointer-events: none;\n",
372
- " transform: rotate(-5deg);\n",
373
- " transition: top 0.3s ease-in-out, opacity 0.3s ease-in-out, transform 0.3s ease-in-out;\n",
374
- "}\n",
375
- "\n",
376
- ".sample {\n",
377
- " display: inline-block;\n",
378
- " margin-top: 25px;\n",
379
- " padding: 10px 100px;\n",
380
- " background-color: rgba(255, 255, 255, 0.2);\n",
381
- " color: #c6e2ff;\n",
382
- " border: 2px solid rgba(255, 255, 255, 0.2);\n",
383
- " border-radius: 8px;\n",
384
- " box-shadow: 0 0 10px rgba(255, 255, 255, 0.2), inset 0 0 25px rgba(255, 255, 255, 0.2);\n",
385
- "}\n",
386
- "\n",
387
- ".info.showed {\n",
388
- " opacity: 1;\n",
389
- " pointer-events: auto;\n",
390
- "}\n",
391
- "\n",
392
- ".info:hover + .popup {\n",
393
- " top: 35px;\n",
394
- " opacity: 1;\n",
395
- " pointer-events: initial;\n",
396
- " transform: rotate(0deg);\n",
397
- "}\n",
398
- "\n",
399
- "\n",
400
- "/* Animation of elements */\n",
401
- "\n",
402
- ".container,\n",
403
- ".button_save {\n",
404
- " animation-name: showedWidgets;\n",
405
- " animation-duration: 1s;\n",
406
- " animation-fill-mode: forwards;\n",
407
- "}\n",
408
- "\n",
409
- ".container.hide,\n",
410
- ".button_save.hide {\n",
411
- " animation-name: hideWidgets;\n",
412
- " animation-duration: 0.5s;\n",
413
- " animation-fill-mode: forwards;\n",
414
- "}\n",
415
- "\n",
416
- "@keyframes showedWidgets {\n",
417
- " 0% {\n",
418
- " transform: translate3d(-65%, 15%, 0) scale(0) rotate(15deg);\n",
419
- " filter: blur(25px) grayscale(1) brightness(0.3);\n",
420
- " opacity: 0;\n",
421
- " }\n",
422
- " 100% {\n",
423
- " transform: translate3d(0, 0, 0) scale(1) rotate(0deg);\n",
424
- " filter: blur(0) grayscale(0) brightness(1);\n",
425
- " opacity: 1;\n",
426
- " }\n",
427
- "}\n",
428
- "\n",
429
- "@keyframes hideWidgets {\n",
430
- " 0% {\n",
431
- " transform: translate3d(0, 0, 0) scale(1) rotate3d(1, 0, 0, 0deg);\n",
432
- " filter: blur(0) grayscale(0) brightness(1);\n",
433
- " opacity: 1;\n",
434
- " }\n",
435
- " 100% {\n",
436
- " transform: translate3d(0, 5%, 0) scale(0.9) rotate3d(1, 0, 0, 90deg);\n",
437
- " filter: blur(15px) grayscale(1) brightness(0.5);\n",
438
- " opacity: 0;\n",
439
- " }\n",
440
- "}\n",
441
- "</style>\n",
442
  "\n",
 
 
443
  "<!-- TOGGLE 'CustomDL' SCRIPT -->\n",
444
  "<script>\n",
445
  "function toggleContainer() {\n",
@@ -451,20 +123,58 @@
451
  "}\n",
452
  "</script>\n",
453
  "'''\n",
 
454
  "\n",
455
- "display(HTML(CSS))\n",
456
- "# ==================== CSS JS ====================\n",
457
  "\n",
 
 
 
 
458
  "\n",
459
- "# ==================== WIDGETS ====================\n",
460
- "# --- global widgets ---\n",
461
- "style = {'description_width': 'initial'}\n",
462
- "layout = widgets.Layout(min_width='1047px')\n",
 
463
  "\n",
464
- "HR = widgets.HTML('<hr>')\n",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
465
  "\n",
466
  "# --- MODEL ---\n",
467
- "model_header = widgets.HTML('<div class=\"header\">Выбор Модели<div>')\n",
468
  "model_options = ['none',\n",
469
  " '1.Anime (by XpucT) + INP',\n",
470
  " '2.BluMix [Anime] [V7] + INP',\n",
@@ -475,37 +185,37 @@
475
  " '7.Deliberate [Realism] [V6] + INP',\n",
476
  " '8.Meina-Mix [Anime] [V11] + INP',\n",
477
  " '9.Mix-Pro [Anime] [V4] + INP']\n",
478
- "# ---\n",
479
- "Model_widget = widgets.Dropdown(options=model_options, value='4.Counterfeit [Anime] [V3] + INP', description='Модель:', style=style, layout=layout)\n",
480
- "Model_Num_widget = widgets.Text(description='Номер Модели:', placeholder='Введите номера моделей для скачивания через запятую/пробел.', style=style, layout=layout)\n",
481
- "Inpainting_Model_widget = widgets.Checkbox(value=False, description='Inpainting Модели', style=style)\n",
482
  "\n",
483
- "''' Display Model'''\n",
484
- "all_model_box = widgets.VBox([model_header, Model_widget, Model_Num_widget, Inpainting_Model_widget]).add_class(\"container\").add_class(\"image_1\")\n",
485
- "display(all_model_box)\n",
486
  "\n",
487
  "# --- VAE ---\n",
488
- "vae_header = widgets.HTML('<div class=\"header\">Выбор VAE</div>')\n",
489
  "vae_options = ['none',\n",
490
  " '1.Anime.vae',\n",
491
  " '2.Anything.vae',\n",
492
  " '3.Blessed2.vae',\n",
493
  " '4.ClearVae.vae',\n",
494
  " '5.WD.vae']\n",
495
- "Vae_widget = widgets.Dropdown(options=vae_options, value='3.Blessed2.vae', description='Vae:', style=style, layout=layout)\n",
496
- "Vae_Num_widget = widgets.Text(description='Номер Vae:', placeholder='Введите номера vae для скачивания через запятую/пробел.', style=style, layout=layout)\n",
497
  "\n",
498
- "''' Display Vae'''\n",
499
- "all_vae_box = widgets.VBox([vae_header, Vae_widget, Vae_Num_widget]).add_class(\"container\").add_class(\"image_2\")\n",
500
- "display(all_vae_box)\n",
501
  "\n",
502
  "# --- ADDITIONAL ---\n",
503
- "additional_header = widgets.HTML('<div class=\"header\">Дополнительно</div>')\n",
504
- "latest_webui_widget = widgets.Checkbox(value=True, description='Обновить WebUI', style=style)\n",
505
- "latest_exstensions_widget = widgets.Checkbox(value=True, description='Обновить Расширения', style=style)\n",
506
- "change_webui_widget = widgets.Dropdown(options=['A1111', 'Forge'], value='A1111', description='Изменить WebUI:', style=style)\n",
507
- "detailed_download_widget = widgets.Dropdown(options=['off', 'on'], value='off', description='Подробная Загрузка:', style=style)\n",
508
- "latest_changes_widget = HBox([latest_webui_widget, latest_exstensions_widget, change_webui_widget, detailed_download_widget], layout=widgets.Layout(justify_content='space-between'))\n",
 
509
  "controlnet_options = ['none', 'ALL', '1.canny',\n",
510
  " '2.openpose', '3.depth',\n",
511
  " '4.normal_map', '5.mlsd',\n",
@@ -513,33 +223,45 @@
513
  " '8.scribble', '9.segmentation',\n",
514
  " '10.shuffle', '11.tile',\n",
515
  " '12.inpaint', '13.instruct_p2p']\n",
516
- "# ---\n",
517
- "controlnet_widget = widgets.Dropdown(options=controlnet_options, value='none', description='ControlNet:', style=style, layout=layout)\n",
518
- "controlnet_Num_widget = widgets.Text(description='Номер ControlNet:', placeholder='Введите номера моделей ControlNet для скачивания через запятую/пробел.', style=style, layout=layout)\n",
519
- "commit_hash_widget = widgets.Text(description='Commit Hash:', style=style, layout=layout)\n",
520
- "optional_huggingface_token_widget = widgets.Text(description='Токен HuggingFace:', style=style, layout=layout)\n",
521
- "ngrok_token_widget = widgets.Text(description='Токен Ngrok:', style=style, layout=widgets.Layout(width='1047px'))\n",
522
- "ngrock_button = widgets.HTML('<a href=\"https://dashboard.ngrok.com/get-started/your-authtoken\" target=\"_blank\">Получить Ngrok Токен</a>').add_class(\"button_ngrok\")\n",
523
- "ngrok_widget = widgets.HBox([ngrok_token_widget, ngrock_button], style=style, layout=layout)\n",
524
- "zrok_token_widget = widgets.Text(description='Токен Zrok:', style=style, layout=widgets.Layout(width='1047px'))\n",
525
- "zrok_button = widgets.HTML('<a href=\"https://colab.research.google.com/drive/1d2sjWDJi_GYBUavrHSuQyHTDuLy36WpU\" target=\"_blank\">Зарегать Zrok Токен</a>').add_class(\"button_ngrok\")\n",
526
- "zrok_widget = widgets.HBox([zrok_token_widget, zrok_button], style=style, layout=layout)\n",
527
- "# ---\n",
 
528
  "commandline_arguments_options = \"--listen --enable-insecure-extension-access --theme dark --no-half-vae --disable-console-progressbars --xformers\"\n",
529
- "commandline_arguments_widget = widgets.Text(description='Аргументы:', value=commandline_arguments_options, style=style, layout=layout)\n",
 
 
 
 
 
 
 
 
 
 
 
 
 
530
  "\n",
531
- "''' Display Additional'''\n",
532
- "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]\n",
533
  "if free_plan and env == \"Google Colab\": # remove ngrok from colab\n",
534
  " additional_widget_list.remove(ngrok_widget)\n",
535
  "if os.path.exists(webui_path): # remove selection after selection ;3\n",
536
- " latest_changes_widget.children = [widget for widget in latest_changes_widget.children if widget != change_webui_widget]\n",
537
- "# ```\n",
538
- "all_additional_box = widgets.VBox(additional_widget_list).add_class(\"container\").add_class(\"image_3\")\n",
539
- "display(all_additional_box)\n",
540
  "\n",
541
  "# --- CUSTOM DOWNLOAD ---\n",
542
- "custom_download_header_popup = widgets.HTML('''\n",
543
  "<style>\n",
544
  "/* Term Colors */\n",
545
  ".sample_label {color: #dbafff;}\n",
@@ -564,39 +286,40 @@
564
  " </div>\n",
565
  "</div>\n",
566
  "''')\n",
567
- "# ---\n",
568
- "Model_url_widget = widgets.Text(description='Model:', style=style, layout=layout)\n",
569
- "Vae_url_widget = widgets.Text(description='Vae:', style=style, layout=layout)\n",
570
- "LoRA_url_widget = widgets.Text(description='LoRa:', style=style, layout=layout)\n",
571
- "Embedding_url_widget = widgets.Text(description='Embedding:', style=style, layout=layout)\n",
572
- "Extensions_url_widget = widgets.Text(description='Extensions:', style=style, layout=layout)\n",
573
- "custom_file_urls_widget = widgets.Text(description='Файл (txt):', style=style, layout=layout)\n",
574
- "\n",
575
- "''' Display CustomDl'''\n",
576
- "all_custom_box = widgets.VBox([\n",
577
  " custom_download_header_popup, Model_url_widget, Vae_url_widget, LoRA_url_widget, Embedding_url_widget, Extensions_url_widget, custom_file_urls_widget\n",
578
- " ]).add_class(\"container\").add_class(\"image_4\").add_class(\"container_custom_downlad\")\n",
579
- "display(all_custom_box)\n",
580
  "\n",
581
  "# --- Save Button ---\n",
582
- "save_button = widgets.Button(description='Сохранить').add_class(\"button_save\")\n",
583
- "display(save_button)\n",
584
  "\n",
585
  "\n",
586
  "# ============ Load / Save - Settings V2 ============\n",
587
  "SETTINGS_FILE = f'{root_path}/settings.json'\n",
588
  "\n",
589
- "settings_keys = [\n",
590
- " 'Model', 'Model_Num', 'Inpainting_Model',\n",
591
- " 'Vae', 'Vae_Num',\n",
592
- " 'latest_webui', 'latest_exstensions', 'change_webui', 'detailed_download',\n",
593
- " 'controlnet', 'controlnet_Num', 'commit_hash', 'optional_huggingface_token',\n",
594
  " 'ngrok_token', 'zrok_token', 'commandline_arguments',\n",
595
- " 'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url', 'Extensions_url', 'custom_file_urls'\n",
 
596
  "]\n",
597
  "\n",
598
  "def save_settings():\n",
599
- " settings = {key: globals()[f\"{key}_widget\"].value for key in settings_keys}\n",
600
  " with open(SETTINGS_FILE, 'w') as f:\n",
601
  " json.dump(settings, f, indent=2)\n",
602
  "\n",
@@ -604,28 +327,23 @@
604
  " if os.path.exists(SETTINGS_FILE):\n",
605
  " with open(SETTINGS_FILE, 'r') as f:\n",
606
  " settings = json.load(f)\n",
607
- " for key in settings_keys:\n",
608
- " globals()[f\"{key}_widget\"].value = settings.get(key)\n",
609
- "\n",
610
- "def save_data(button):\n",
611
- " save_settings()\n",
612
  "\n",
613
- " # --- uhh - hide... ---\n",
614
  " widgets_list = [all_model_box, all_vae_box, all_additional_box, all_custom_box, save_button]\n",
615
  " for widget in widgets_list:\n",
616
  " widget.add_class(\"hide\")\n",
617
  " time.sleep(0.5)\n",
618
- "\n",
619
  " widgets.Widget.close_all()\n",
620
  "\n",
621
- "settings = load_settings()\n",
 
 
 
 
622
  "save_button.on_click(save_data)"
623
- ],
624
- "metadata": {
625
- "id": "2lJmbqrs3Mu8"
626
- },
627
- "execution_count": null,
628
- "outputs": []
629
  }
630
  ]
631
  }
 
16
  "cells": [
17
  {
18
  "cell_type": "code",
19
+ "execution_count": null,
20
+ "metadata": {
21
+ "id": "JKTCrY9LU7Oq"
22
+ },
23
+ "outputs": [],
24
  "source": [
25
  "##~ WIDGET CODE | BY: ANXETY ~##\n",
26
  "\n",
 
32
  "from IPython.display import display, HTML, Javascript, clear_output\n",
33
  "\n",
34
  "\n",
35
+ "# ================= DETECT ENV =================\n",
36
  "def detect_environment():\n",
37
  " free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024 ** 3) <= 20)\n",
38
  " environments = {\n",
39
  " 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
40
  " 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\")\n",
41
  " }\n",
 
42
  " for env_var, (environment, path) in environments.items():\n",
43
  " if env_var in os.environ:\n",
44
  " return environment, path, free_plan\n",
45
  "\n",
46
  "env, root_path, free_plan = detect_environment()\n",
47
  "webui_path = f\"{root_path}/sdw\"\n",
 
48
  "!mkdir -p {root_path}\n",
 
49
  "\n",
50
  "\n",
51
  "# ==================== CSS JS ====================\n",
52
+ "##~ custom background images V1.5 ~##\n",
53
  "import argparse\n",
54
  "parser = argparse.ArgumentParser(description='This script processes an background image.')\n",
55
  "parser.add_argument('-i', '--image', type=str, help='URL of the image to process', metavar='')\n",
 
61
  "parser.add_argument('-m', '--mode', action='store_true', help='Removes repetitive image tiles')\n",
62
  "parser.add_argument('-t', '--transparent', action='store_true', help='Makes input/selection fields 35%% more transparent')\n",
63
  "parser.add_argument('-bf', '--blur-fields', type=str, help='Background blur level for input/selection fields', metavar='', default=2)\n",
64
+ "\n",
65
  "args = parser.parse_args()\n",
66
+ "\n",
67
  "url_img = args.image\n",
68
  "opacity_img = args.opacity\n",
69
  "blur_img = args.blur\n",
 
81
  "\n",
82
  "\"\"\" mode img - repeats \"\"\"\n",
83
  "mode_img = \"repeat\" if not args.mode else \"no-repeat\"\n",
 
84
  "\n",
85
  "container_background = f'''\n",
86
  "<style>\n",
 
103
  "'''\n",
104
  "\n",
105
  "display(HTML(container_background))\n",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  "\n",
107
+ "# Main CSS\n",
108
+ "css_file_path = f\"{root_path}/CSS/main_widgets.css\"\n",
109
+ "with open(css_file_path , \"r\") as f:\n",
110
+ " CSS = f.read()\n",
111
+ "display(HTML(f\"<style>{CSS}</style>\"))\n",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  "\n",
113
+ "# Main JS\n",
114
+ "JS = '''\n",
115
  "<!-- TOGGLE 'CustomDL' SCRIPT -->\n",
116
  "<script>\n",
117
  "function toggleContainer() {\n",
 
123
  "}\n",
124
  "</script>\n",
125
  "'''\n",
126
+ "display(HTML(JS))\n",
127
  "\n",
128
+ "# ==================== WIDGETS V2 ====================\n",
129
+ "HR = widgets.HTML('<hr>')\n",
130
  "\n",
131
+ "class WidgetFactory:\n",
132
+ " def __init__(self, style=None, layout=None):\n",
133
+ " self.style = style if style else {'description_width': 'initial'}\n",
134
+ " self.layout = layout if layout else widgets.Layout(max_width='1080px', width='100%')\n",
135
  "\n",
136
+ " def create_html(self, content, class_name=None):\n",
137
+ " html_widget = widgets.HTML(content)\n",
138
+ " if class_name:\n",
139
+ " html_widget.add_class(class_name)\n",
140
+ " return html_widget\n",
141
  "\n",
142
+ " def create_header(self, name):\n",
143
+ " return widgets.HTML(f'<div class=\"header\">{name}<div>')\n",
144
+ "\n",
145
+ " def create_dropdown(self, options, value, description):\n",
146
+ " return widgets.Dropdown(options=options, value=value, description=description, style=self.style, layout=self.layout)\n",
147
+ "\n",
148
+ " def create_text(self, description, placeholder='', value=''):\n",
149
+ " return widgets.Text(description=description, placeholder=placeholder, value=value, style=self.style, layout=self.layout)\n",
150
+ "\n",
151
+ " def create_checkbox(self, value, description):\n",
152
+ " return widgets.Checkbox(value=value, description=description, style=self.style, layout=self.layout)\n",
153
+ "\n",
154
+ " def create_button(self, description, class_name=None):\n",
155
+ " button = widgets.Button(description=description)\n",
156
+ " if class_name:\n",
157
+ " button.add_class(class_name)\n",
158
+ " return button\n",
159
+ "\n",
160
+ " def create_hbox(self, children):\n",
161
+ " return widgets.HBox(children)\n",
162
+ "\n",
163
+ " def create_vbox(self, children, class_names=None):\n",
164
+ " vbox = widgets.VBox(children)\n",
165
+ " if class_names:\n",
166
+ " for class_name in class_names:\n",
167
+ " vbox.add_class(class_name)\n",
168
+ " return vbox\n",
169
+ "\n",
170
+ " def display(self, widget):\n",
171
+ " display(widget)\n",
172
+ "\n",
173
+ "# Instantiate the factory\n",
174
+ "factory = WidgetFactory()\n",
175
  "\n",
176
  "# --- MODEL ---\n",
177
+ "model_header = factory.create_header('Выбор Модели')\n",
178
  "model_options = ['none',\n",
179
  " '1.Anime (by XpucT) + INP',\n",
180
  " '2.BluMix [Anime] [V7] + INP',\n",
 
185
  " '7.Deliberate [Realism] [V6] + INP',\n",
186
  " '8.Meina-Mix [Anime] [V11] + INP',\n",
187
  " '9.Mix-Pro [Anime] [V4] + INP']\n",
188
+ "model_widget = factory.create_dropdown(model_options, '4.Counterfeit [Anime] [V3] + INP', 'Модель:')\n",
189
+ "model_num_widget = factory.create_text('Номер Модели:', 'Введите номера моделей для скачивания через запятую/пробел.')\n",
190
+ "inpainting_model_widget = factory.create_checkbox(False, 'Inpainting Модели')\n",
 
191
  "\n",
192
+ "# Display Model\n",
193
+ "all_model_box = factory.create_vbox([model_header, model_widget, model_num_widget, inpainting_model_widget], class_names=[\"container\", \"image_1\"])\n",
194
+ "factory.display(all_model_box)\n",
195
  "\n",
196
  "# --- VAE ---\n",
197
+ "vae_header = factory.create_header('Выбор VAE')\n",
198
  "vae_options = ['none',\n",
199
  " '1.Anime.vae',\n",
200
  " '2.Anything.vae',\n",
201
  " '3.Blessed2.vae',\n",
202
  " '4.ClearVae.vae',\n",
203
  " '5.WD.vae']\n",
204
+ "vae_widget = factory.create_dropdown(vae_options, '3.Blessed2.vae', 'Vae:')\n",
205
+ "vae_num_widget = factory.create_text('Номер Vae:', 'Введите номера vae для скачивания через запятую/пробел.')\n",
206
  "\n",
207
+ "# Display Vae\n",
208
+ "all_vae_box = factory.create_vbox([vae_header, vae_widget, vae_num_widget], class_names=[\"container\", \"image_2\"])\n",
209
+ "factory.display(all_vae_box)\n",
210
  "\n",
211
  "# --- ADDITIONAL ---\n",
212
+ "additional_header = factory.create_header('Дополнительно')\n",
213
+ "latest_webui_widget = factory.create_checkbox(True, 'Обновить WebUI')\n",
214
+ "latest_exstensions_widget = factory.create_checkbox(True, 'Обновить Расширения')\n",
215
+ "change_webui_widget = factory.create_dropdown(['A1111', 'Forge'], 'A1111', 'Изменить WebUI:')\n",
216
+ "detailed_download_widget = factory.create_dropdown(['off', 'on'], 'off', 'Подробная Загрузка:')\n",
217
+ "choose_changes_widget = factory.create_hbox([latest_webui_widget, latest_exstensions_widget, change_webui_widget, detailed_download_widget])\n",
218
+ "\n",
219
  "controlnet_options = ['none', 'ALL', '1.canny',\n",
220
  " '2.openpose', '3.depth',\n",
221
  " '4.normal_map', '5.mlsd',\n",
 
223
  " '8.scribble', '9.segmentation',\n",
224
  " '10.shuffle', '11.tile',\n",
225
  " '12.inpaint', '13.instruct_p2p']\n",
226
+ "controlnet_widget = factory.create_dropdown(controlnet_options, 'none', 'ControlNet:')\n",
227
+ "controlnet_num_widget = factory.create_text('Номер ControlNet:', 'Введите но��ера моделей ControlNet для скачивания через запятую/пробел.')\n",
228
+ "commit_hash_widget = factory.create_text('Commit Hash:')\n",
229
+ "huggingface_token_widget = factory.create_text('Токен HuggingFace:')\n",
230
+ "\n",
231
+ "ngrok_token_widget = factory.create_text('Токен Ngrok:')\n",
232
+ "ngrock_button = factory.create_html('<a href=\"https://dashboard.ngrok.com/get-started/your-authtoken\" target=\"_blank\">Получить Ngrok Токен</a>', class_name=\"button_ngrok\")\n",
233
+ "ngrok_widget = factory.create_hbox([ngrok_token_widget, ngrock_button])\n",
234
+ "\n",
235
+ "zrok_token_widget = factory.create_text('Токен Zrok:')\n",
236
+ "zrok_button = factory.create_html('<a href=\"https://colab.research.google.com/drive/1d2sjWDJi_GYBUavrHSuQyHTDuLy36WpU\" target=\"_blank\">Зарегать Zrok Токен</a>', class_name=\"button_ngrok\")\n",
237
+ "zrok_widget = factory.create_hbox([zrok_token_widget, zrok_button])\n",
238
+ "\n",
239
  "commandline_arguments_options = \"--listen --enable-insecure-extension-access --theme dark --no-half-vae --disable-console-progressbars --xformers\"\n",
240
+ "commandline_arguments_widget = factory.create_text('Аргументы:', value=commandline_arguments_options)\n",
241
+ "\n",
242
+ "# Display Additional\n",
243
+ "additional_widget_list = [additional_header,\n",
244
+ " choose_changes_widget,\n",
245
+ " HR,\n",
246
+ " controlnet_widget,\n",
247
+ " controlnet_num_widget,\n",
248
+ " commit_hash_widget,\n",
249
+ " huggingface_token_widget,\n",
250
+ " ngrok_widget,\n",
251
+ " zrok_widget,\n",
252
+ " HR,\n",
253
+ " commandline_arguments_widget]\n",
254
  "\n",
 
 
255
  "if free_plan and env == \"Google Colab\": # remove ngrok from colab\n",
256
  " additional_widget_list.remove(ngrok_widget)\n",
257
  "if os.path.exists(webui_path): # remove selection after selection ;3\n",
258
+ " choose_changes_widget.children = [widget for widget in choose_changes_widget.children if widget != change_webui_widget]\n",
259
+ "\n",
260
+ "all_additional_box = factory.create_vbox(additional_widget_list, class_names=[\"container\", \"image_3\"])\n",
261
+ "factory.display(all_additional_box)\n",
262
  "\n",
263
  "# --- CUSTOM DOWNLOAD ---\n",
264
+ "custom_download_header_popup = factory.create_html('''\n",
265
  "<style>\n",
266
  "/* Term Colors */\n",
267
  ".sample_label {color: #dbafff;}\n",
 
286
  " </div>\n",
287
  "</div>\n",
288
  "''')\n",
289
+ "\n",
290
+ "Model_url_widget = factory.create_text('Model:')\n",
291
+ "Vae_url_widget = factory.create_text('Vae:')\n",
292
+ "LoRA_url_widget = factory.create_text('LoRa:')\n",
293
+ "Embedding_url_widget = factory.create_text('Embedding:')\n",
294
+ "Extensions_url_widget = factory.create_text('Extensions:')\n",
295
+ "custom_file_urls_widget = factory.create_text('Файл (txt):')\n",
296
+ "\n",
297
+ "# Display CustomDl\n",
298
+ "all_custom_box = factory.create_vbox([\n",
299
  " custom_download_header_popup, Model_url_widget, Vae_url_widget, LoRA_url_widget, Embedding_url_widget, Extensions_url_widget, custom_file_urls_widget\n",
300
+ "], class_names=[\"container\", \"image_4\", \"container_custom_downlad\"])\n",
301
+ "factory.display(all_custom_box)\n",
302
  "\n",
303
  "# --- Save Button ---\n",
304
+ "save_button = factory.create_button('Сохранить', class_name=\"button_save\")\n",
305
+ "factory.display(save_button)\n",
306
  "\n",
307
  "\n",
308
  "# ============ Load / Save - Settings V2 ============\n",
309
  "SETTINGS_FILE = f'{root_path}/settings.json'\n",
310
  "\n",
311
+ "SETTINGS_KEYS = [\n",
312
+ " 'model', 'model_num', 'inpainting_model',\n",
313
+ " 'vae', 'vae_num', 'latest_webui', 'latest_exstensions',\n",
314
+ " 'change_webui', 'detailed_download', 'controlnet',\n",
315
+ " 'controlnet_num', 'commit_hash', 'huggingface_token',\n",
316
  " 'ngrok_token', 'zrok_token', 'commandline_arguments',\n",
317
+ " 'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url',\n",
318
+ " 'Extensions_url', 'custom_file_urls'\n",
319
  "]\n",
320
  "\n",
321
  "def save_settings():\n",
322
+ " settings = {key: globals()[f\"{key}_widget\"].value for key in SETTINGS_KEYS}\n",
323
  " with open(SETTINGS_FILE, 'w') as f:\n",
324
  " json.dump(settings, f, indent=2)\n",
325
  "\n",
 
327
  " if os.path.exists(SETTINGS_FILE):\n",
328
  " with open(SETTINGS_FILE, 'r') as f:\n",
329
  " settings = json.load(f)\n",
330
+ " for key in SETTINGS_KEYS:\n",
331
+ " globals()[f\"{key}_widget\"].value = settings.get(key, \"\")\n",
 
 
 
332
  "\n",
333
+ "def hide_widgets():\n",
334
  " widgets_list = [all_model_box, all_vae_box, all_additional_box, all_custom_box, save_button]\n",
335
  " for widget in widgets_list:\n",
336
  " widget.add_class(\"hide\")\n",
337
  " time.sleep(0.5)\n",
 
338
  " widgets.Widget.close_all()\n",
339
  "\n",
340
+ "def save_data(button):\n",
341
+ " save_settings()\n",
342
+ " hide_widgets()\n",
343
+ "\n",
344
+ "load_settings()\n",
345
  "save_button.on_click(save_data)"
346
+ ]
 
 
 
 
 
347
  }
348
  ]
349
  }
files_cells/python/en/auto_cleaner_en.py ADDED
@@ -0,0 +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
+
files_cells/python/en/downloading_en.py CHANGED
@@ -15,21 +15,19 @@ from IPython.display import clear_output
15
  from urllib.parse import urlparse, parse_qs
16
 
17
 
18
- # ================= DETECT ENV =================
19
  def detect_environment():
20
  free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024 ** 3) <= 20)
21
  environments = {
22
  'COLAB_GPU': ('Google Colab', "/root" if free_plan else "/content"),
23
  'KAGGLE_URL_BASE': ('Kaggle', "/kaggle/working/content")
24
  }
25
-
26
  for env_var, (environment, path) in environments.items():
27
  if env_var in os.environ:
28
  return environment, path, free_plan
29
 
30
  env, root_path, free_plan = detect_environment()
31
  webui_path = f"{root_path}/sdw"
32
- # ----------------------------------------------
33
 
34
 
35
  # ================ LIBRARIES V2 ================
@@ -80,12 +78,6 @@ if not os.path.exists(flag_file):
80
  time.sleep(2)
81
  clear_output()
82
 
83
- ## dl special files
84
- with capture.capture_output() as cap:
85
- get_ipython().system('mkdir -p {root_path}/file_cell/special')
86
- get_ipython().system('wget https://huggingface.co/NagisaNao/fast_repo/resolve/main/special/dl_display_results.py -O {root_path}/file_cell/special/dl_display_results.py')
87
- del cap
88
-
89
 
90
  # ================= loading settings V4 =================
91
  def load_settings(path):
@@ -96,16 +88,17 @@ def load_settings(path):
96
 
97
  settings = load_settings(f'{root_path}/settings.json')
98
 
99
- variables = [
100
- 'Model', 'Model_Num', 'Inpainting_Model',
101
- 'Vae', 'Vae_Num',
102
- 'latest_webui', 'latest_exstensions', 'change_webui', 'detailed_download',
103
- 'controlnet', 'controlnet_Num', 'commit_hash', 'optional_huggingface_token',
104
  'ngrok_token', 'zrok_token', 'commandline_arguments',
105
- 'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url', 'Extensions_url', 'custom_file_urls'
 
106
  ]
107
 
108
- locals().update({key: settings.get(key) for key in variables})
109
 
110
 
111
  # ================= OTHER =================
@@ -241,17 +234,7 @@ model_list = {
241
  ]
242
  }
243
 
244
- # 1-4 (fp16/cleaned)
245
  vae_list = {
246
- ## vae broke - the author's an asshole
247
- # "1.Anime.vae": [
248
- # {"url": "https://civitai.com/api/download/models/131654", "name": "Anime.vae.safetensors"},
249
- # {"url": "https://civitai.com/api/download/models/131658", "name": "vae-ft-mse.vae.safetensors"}
250
- # ],
251
- # "2.Anything.vae": [{"url": "https://civitai.com/api/download/models/131656", "name": "Anything.vae.safetensors"}],
252
- # "3.Blessed2.vae": [{"url": "https://civitai.com/api/download/models/142467", "name": "Blessed2.vae.safetensors"}],
253
- # "4.ClearVae.vae": [{"url": "https://civitai.com/api/download/models/133362", "name": "ClearVae_23.vae.safetensors"}],
254
-
255
  "1.Anime.vae": [{"url": "https://civitai.com/api/download/models/311162", "name": "vae-ft-mse-840000-ema-pruned.vae.safetensors"}],
256
  "2.Anything.vae": [{"url": "https://civitai.com/api/download/models/119279", "name": "Anything.vae.safetensors"}],
257
  "3.Blessed2.vae": [{"url": "https://huggingface.co/NoCrypt/blessed_vae/resolve/main/blessed2.vae.pt", "name": "Blessed2.vae.safetensors"}],
@@ -332,7 +315,7 @@ extension_repo = []
332
  directories = [value for key, value in prefixes.items()] # for unpucking zip files
333
  get_ipython().system('mkdir -p {" ".join(directories)}')
334
 
335
- hf_token = optional_huggingface_token if optional_huggingface_token else "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"
336
  user_header = f"\"Authorization: Bearer {hf_token}\""
337
 
338
  ''' Formatted Info Output '''
@@ -531,14 +514,14 @@ def add_submodels(selection, num_selection, model_dict, dst_dir):
531
  def handle_submodels(selection, num_selection, model_dict, dst_dir, url):
532
  submodels = add_submodels(selection, num_selection, model_dict, dst_dir)
533
  for submodel in submodels:
534
- if not Inpainting_Model and "inpainting" in submodel['name']:
535
  continue
536
  url += f"{submodel['url']} {submodel['dst_dir']} {submodel['name']}, "
537
  return url
538
 
539
- url = handle_submodels(Model, Model_Num, model_list, models_dir, url)
540
- url = handle_submodels(Vae, Vae_Num, vae_list, vaes_dir, url)
541
- url = handle_submodels(controlnet, controlnet_Num, controlnet_list, control_dir, url)
542
 
543
  ''' file.txt - added urls '''
544
 
@@ -622,38 +605,6 @@ if len(extension_repo) > 0:
622
  ## List Models and stuff V2
623
  if detailed_download == "off":
624
  print("\n\n\033[33mIf you don't see any downloaded files, enable the 'Detailed Downloads' feature in the widget.")
625
- get_ipython().run_line_magic('run', '{root_path}/file_cell/special/dl_display_results.py') # display widgets result
626
 
627
- else:
628
- if any(not file.endswith('.txt') for file in os.listdir(models_dir)):
629
- print("\n\033[33m➤ Models\033[0m")
630
- get_ipython().system("find {models_dir}/ -mindepth 1 -name '*.safetensors' -printf '%f\\n'")
631
- if any(not file.endswith('.txt') for file in os.listdir(vaes_dir)):
632
- print("\n\033[33m➤ VAEs\033[0m")
633
- get_ipython().system("find {vaes_dir}/ -mindepth 1 -name '*.safetensors' -printf '%f\\n'")
634
- if any(not file.endswith('.txt') and not os.path.isdir(os.path.join(embeddings_dir, file)) for file in os.listdir(embeddings_dir)):
635
- print("\n\033[33m➤ Embeddings\033[0m")
636
- get_ipython().system("find {embeddings_dir}/ -mindepth 1 -maxdepth 1 \\( -name '*.pt' -or -name '*.safetensors' \\) -printf '%f\\n'")
637
- if any(not file.endswith('.txt') for file in os.listdir(loras_dir)):
638
- print("\n\033[33m➤ LoRAs\033[0m")
639
- get_ipython().system("find {loras_dir}/ -mindepth 1 -name '*.safetensors' -printf '%f\\n'")
640
- print(f"\n\033[33m➤ Extensions\033[0m")
641
- get_ipython().system("find {extensions_dir}/ -mindepth 1 -maxdepth 1 ! -name '*.txt' -printf '%f\\n'")
642
- if any(not file.endswith(('.txt', '.yaml')) for file in os.listdir(control_dir)):
643
- print("\n\033[33m➤ ControlNet\033[0m")
644
- get_ipython().system("find {control_dir}/ -mindepth 1 ! -name '*.yaml' -printf '%f\\n' | sed 's/^[^_]*_[^_]*_[^_]*_\\([^_]*\\)_fp16\\.safetensors$/\\1/'")
645
-
646
-
647
- # === OTHER ===
648
- # Downlaod discord tags UmiWildcards
649
- files_umi = [
650
- "https://huggingface.co/NagisaNao/fast_repo/resolve/main/extensions/UmiWildacrd/discord/200_pan_gen.txt",
651
- "https://huggingface.co/NagisaNao/fast_repo/resolve/main/extensions/UmiWildacrd/discord/150_bra_gen.txt"
652
- ]
653
- save_dir_path = f"{webui_path}/extensions/Umi-AI-Wildcards/wildcards/discord"
654
-
655
- with capture.capture_output() as cap:
656
- for file in files_umi:
657
- get_ipython().system('aria2c --optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -j5 -x16 -s16 -k1M -c -d {save_dir_path} {file}')
658
- del cap
659
 
 
15
  from urllib.parse import urlparse, parse_qs
16
 
17
 
18
+ # ================= DETECT ENV =================
19
  def detect_environment():
20
  free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024 ** 3) <= 20)
21
  environments = {
22
  'COLAB_GPU': ('Google Colab', "/root" if free_plan else "/content"),
23
  'KAGGLE_URL_BASE': ('Kaggle', "/kaggle/working/content")
24
  }
 
25
  for env_var, (environment, path) in environments.items():
26
  if env_var in os.environ:
27
  return environment, path, free_plan
28
 
29
  env, root_path, free_plan = detect_environment()
30
  webui_path = f"{root_path}/sdw"
 
31
 
32
 
33
  # ================ LIBRARIES V2 ================
 
78
  time.sleep(2)
79
  clear_output()
80
 
 
 
 
 
 
 
81
 
82
  # ================= loading settings V4 =================
83
  def load_settings(path):
 
88
 
89
  settings = load_settings(f'{root_path}/settings.json')
90
 
91
+ VARIABLES = [
92
+ 'model', 'model_num', 'inpainting_model',
93
+ 'vae', 'vae_num', 'latest_webui', 'latest_exstensions',
94
+ 'change_webui', 'detailed_download', 'controlnet',
95
+ 'controlnet_num', 'commit_hash', 'huggingface_token',
96
  'ngrok_token', 'zrok_token', 'commandline_arguments',
97
+ 'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url',
98
+ 'Extensions_url', 'custom_file_urls'
99
  ]
100
 
101
+ locals().update({key: settings.get(key) for key in VARIABLES})
102
 
103
 
104
  # ================= OTHER =================
 
234
  ]
235
  }
236
 
 
237
  vae_list = {
 
 
 
 
 
 
 
 
 
238
  "1.Anime.vae": [{"url": "https://civitai.com/api/download/models/311162", "name": "vae-ft-mse-840000-ema-pruned.vae.safetensors"}],
239
  "2.Anything.vae": [{"url": "https://civitai.com/api/download/models/119279", "name": "Anything.vae.safetensors"}],
240
  "3.Blessed2.vae": [{"url": "https://huggingface.co/NoCrypt/blessed_vae/resolve/main/blessed2.vae.pt", "name": "Blessed2.vae.safetensors"}],
 
315
  directories = [value for key, value in prefixes.items()] # for unpucking zip files
316
  get_ipython().system('mkdir -p {" ".join(directories)}')
317
 
318
+ hf_token = huggingface_token if huggingface_token else "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"
319
  user_header = f"\"Authorization: Bearer {hf_token}\""
320
 
321
  ''' Formatted Info Output '''
 
514
  def handle_submodels(selection, num_selection, model_dict, dst_dir, url):
515
  submodels = add_submodels(selection, num_selection, model_dict, dst_dir)
516
  for submodel in submodels:
517
+ if not inpainting_model and "inpainting" in submodel['name']:
518
  continue
519
  url += f"{submodel['url']} {submodel['dst_dir']} {submodel['name']}, "
520
  return url
521
 
522
+ url = handle_submodels(model, model_num, model_list, models_dir, url)
523
+ url = handle_submodels(vae, vae_num, vae_list, vaes_dir, url)
524
+ url = handle_submodels(controlnet, controlnet_num, controlnet_list, control_dir, url)
525
 
526
  ''' file.txt - added urls '''
527
 
 
605
  ## List Models and stuff V2
606
  if detailed_download == "off":
607
  print("\n\n\033[33mIf you don't see any downloaded files, enable the 'Detailed Downloads' feature in the widget.")
 
608
 
609
+ get_ipython().run_line_magic('run', '{root_path}/file_cell/special/dl_display_results.py # display widgets result')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
610
 
files_cells/python/en/widgets_en.py CHANGED
@@ -8,27 +8,24 @@ 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
-
19
  for env_var, (environment, path) in environments.items():
20
  if env_var in os.environ:
21
  return environment, path, free_plan
22
 
23
  env, root_path, free_plan = detect_environment()
24
  webui_path = f"{root_path}/sdw"
25
-
26
  get_ipython().system('mkdir -p {root_path}')
27
- # ----------------------------------------------
28
 
29
 
30
  # ==================== CSS JS ====================
31
- # custom background images V1.5
32
  import argparse
33
  parser = argparse.ArgumentParser(description='This script processes an background image.')
34
  parser.add_argument('-i', '--image', type=str, help='URL of the image to process', metavar='')
@@ -40,8 +37,9 @@ parser.add_argument('-s', '--scale', type=int, help='Scale image in %%', metavar
40
  parser.add_argument('-m', '--mode', action='store_true', help='Removes repetitive image tiles')
41
  parser.add_argument('-t', '--transparent', action='store_true', help='Makes input/selection fields 35%% more transparent')
42
  parser.add_argument('-bf', '--blur-fields', type=str, help='Background blur level for input/selection fields', metavar='', default=2)
 
43
  args = parser.parse_args()
44
- """---"""
45
  url_img = args.image
46
  opacity_img = args.opacity
47
  blur_img = args.blur
@@ -59,7 +57,6 @@ t_bg_alpha = "1" if not args.transparent else "0.65"
59
 
60
  """ mode img - repeats """
61
  mode_img = "repeat" if not args.mode else "no-repeat"
62
- ## ---
63
 
64
  container_background = f'''
65
  <style>
@@ -82,345 +79,15 @@ container_background = f'''
82
  '''
83
 
84
  display(HTML(container_background))
85
- # ---
86
-
87
- CSS = '''
88
- <style>
89
- /* General Styles */
90
- .header {
91
- font-family: cursive;
92
- font-size: 20px;
93
- font-weight: bold;
94
- color: #ff8cee;
95
- margin-bottom: 15px;
96
- user-select: none;
97
- cursor: default;
98
- display: inline-block;
99
- }
100
-
101
- hr {
102
- border-color: grey;
103
- background-color: grey;
104
- opacity: 0.25;
105
- }
106
-
107
- a {
108
- text-decoration: none;
109
- color: inherit;
110
- }
111
-
112
-
113
- /* Container style */
114
-
115
- .container {
116
- position: relative;
117
- background-color: #232323;
118
- width: 1080px;
119
- padding: 10px 15px;
120
- border-radius: 15px;
121
- box-shadow: 0 0 50px rgba(0, 0, 0, 0.3);
122
- margin-bottom: 5px;
123
- overflow: hidden;
124
- }
125
-
126
- .container::after {
127
- position: absolute;
128
- top: 5px;
129
- right: 10px;
130
- content: "ANXETY";
131
- font-weight: bold;
132
- font-size: 24px;
133
- color: rgba(0, 0, 0, 0.2);
134
- }
135
-
136
- /* background img */
137
- .container::before {
138
- content: "";
139
- position: absolute;
140
- top: 0;
141
- left: 0;
142
- right: 0;
143
- bottom: 0;
144
- background-image: var(--img_background);
145
- background-size: var(--img_scale);
146
- background-repeat: var(--img_mode);
147
- opacity: var(--img_opacity);
148
- mix-blend-mode: screen;
149
- pointer-events: none;
150
- filter: blur(var(--img_blur));
151
- z-index: -1;
152
- }
153
-
154
- .image_1::before {
155
- background-position: var(--image_x) calc(-120px - var(--image_y));
156
- }
157
- .image_2::before {
158
- background-position: var(--image_x) calc(-290px - var(--image_y));
159
- }
160
- .image_3::before {
161
- background-position: var(--image_x) calc(-430px - var(--image_y));
162
- }
163
- .image_4::before {
164
- background-position: var(--image_x) calc(var(--img_height_dif) - var(--image_y));
165
- }
166
-
167
- .container_custom_downlad {
168
- height: 55px;
169
- transition: all 0.5s;
170
- }
171
-
172
- .container_custom_downlad.expanded {
173
- height: 270px;
174
- }
175
-
176
-
177
- /* Element text style */
178
-
179
- .widget-html,
180
- .widget-button,
181
- .widget-text label,
182
- .widget-checkbox label,
183
- .widget-dropdown label,
184
- .widget-dropdown select,
185
- .widget-text input[type="text"] {
186
- font-family: cursive;
187
- font-size: 14px;
188
- color: white !important;
189
- user-select: none;
190
- }
191
-
192
- .widget-text input[type="text"]::placeholder {
193
- color: grey;
194
- }
195
-
196
-
197
- /* Input field styles */
198
-
199
- .widget-dropdown select,
200
- .widget-text input[type="text"] {
201
- height: 30px;
202
- background-color: var(--bg-field-color);
203
- border: 1px solid #262626;
204
- border-radius: 10px;
205
- box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
206
- transition: all 0.3s ease-in-out;
207
- backdrop-filter: blur(var(--bg-field-blur-level));
208
- }
209
-
210
- .widget-dropdown select:focus,
211
- .widget-text input[type="text"]:focus {
212
- border-color: #006ee5;
213
- }
214
-
215
- .widget-dropdown select:hover,
216
- .widget-text input[type="text"]:hover {
217
- transform: scale(1.003);
218
- background-color: var(--bg-field-color-hover);
219
- box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
220
- }
221
-
222
- .widget-dropdown option {
223
- background-color: #1c1c1c;
224
- }
225
-
226
-
227
- /* Slider Checkbox style */
228
-
229
- .widget-checkbox input[type="checkbox"] {
230
- appearance: none;
231
- position: relative;
232
- top: 4px; /* Why is he taller?! */
233
- width: 40px;
234
- height: 20px;
235
- border: none;
236
- border-radius: 10px;
237
- background-color: #20b2aa;
238
- cursor: pointer;
239
- box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.3);
240
- transition: background-color 0.3s ease;
241
- }
242
- .widget-checkbox input[type="checkbox"]:checked {
243
- background-color: #2196F3;
244
- }
245
-
246
- .widget-checkbox input[type="checkbox"]:before {
247
- content: '';
248
- position: absolute;
249
- top: 50%;
250
- left: 3px;
251
- width: 16px;
252
- height: 16px;
253
- border-radius: inherit;
254
- background-color: white;
255
- box-shadow: 0 0 8px rgba(0, 0, 0, 0.3);
256
- transform: translateY(-50%);
257
- transition: left 0.3s ease;
258
- }
259
- .widget-checkbox input[type="checkbox"]:checked:before {
260
- left: 21px;
261
- }
262
-
263
-
264
- /* Button styles */
265
-
266
- .button_save {
267
- font-size: 15px;
268
- font-weight: bold;
269
- width: 120px;
270
- height: 35px;
271
- border-radius: 15px;
272
- background-image: radial-gradient(circle at top left, purple 10%, violet 90%);
273
- background-size: 200% 200%;
274
- background-position: left bottom;
275
- transition: background 0.5s ease-in-out, transform 0.3s ease;
276
- }
277
-
278
- .button_save:hover {
279
- cursor: pointer;
280
- background-image: radial-gradient(circle at top left, purple 10%, #93ac47 90%);
281
- background-size: 200% 200%;
282
- background-position: right bottom;
283
- transform: translateY(1px);
284
- }
285
 
286
- .button_ngrok {
287
- font-size: 12px;
288
- height: 30px;
289
- border-radius: 10px;
290
- padding: 1px 12px;
291
- background-image: radial-gradient(circle at top left, purple 10%, violet 90%);
292
- background-size: 200% 200%;
293
- background-position: left bottom;
294
- transition: background 0.5s ease-in-out, transform 0.3s ease;
295
- white-space: nowrap;
296
- }
297
-
298
- .button_ngrok:hover {
299
- cursor: pointer;
300
- background-image: radial-gradient(circle at top left, purple 10%, #1D94BB 90%);
301
- background-size: 200% 200%;
302
- background-position: right bottom;
303
- transform: translateY(1px);
304
- }
305
-
306
- .button_save:active,
307
- .button_ngrok:active {
308
- filter: brightness(0.75) !important;
309
- }
310
-
311
- /* Removes ugly stroke from widget buttons. */
312
- .jupyter-widgets.lm-Widget:focus {
313
- outline: none;
314
- }
315
-
316
-
317
- /* Popup style of `INFO` window */
318
-
319
- .info {
320
- position: absolute;
321
- top: -5px;
322
- right: 95px;
323
- color: grey;
324
- font-family: cursive;
325
- font-size: 14px;
326
- font-weight: normal;
327
- user-select: none;
328
- pointer-events: none;
329
- opacity: 0;
330
- transition: opacity 0.3s ease-in-out;
331
- display: inline-block;
332
- }
333
-
334
- .popup {
335
- position: absolute;
336
- top: 120px;
337
- z-index: 999;
338
- width: auto;
339
- padding: 10px;
340
- text-align: center;
341
- background-color: rgba(255, 255, 255, 0.05);
342
- backdrop-filter: blur(20px);
343
- border: 1px solid rgba(255, 255, 255, 0.45);
344
- border-radius: 8px;
345
- box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
346
- opacity: 0;
347
- color: #fff;
348
- font-size: 16px;
349
- font-family: cursive;
350
- user-select: none;
351
- cursor: default;
352
- pointer-events: none;
353
- transform: rotate(-5deg);
354
- transition: top 0.3s ease-in-out, opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
355
- }
356
-
357
- .sample {
358
- display: inline-block;
359
- margin-top: 25px;
360
- padding: 10px 100px;
361
- background-color: rgba(255, 255, 255, 0.2);
362
- color: #c6e2ff;
363
- border: 2px solid rgba(255, 255, 255, 0.2);
364
- border-radius: 8px;
365
- box-shadow: 0 0 10px rgba(255, 255, 255, 0.2), inset 0 0 25px rgba(255, 255, 255, 0.2);
366
- }
367
-
368
- .info.showed {
369
- opacity: 1;
370
- pointer-events: auto;
371
- }
372
-
373
- .info:hover + .popup {
374
- top: 35px;
375
- opacity: 1;
376
- pointer-events: initial;
377
- transform: rotate(0deg);
378
- }
379
-
380
-
381
- /* Animation of elements */
382
-
383
- .container,
384
- .button_save {
385
- animation-name: showedWidgets;
386
- animation-duration: 1s;
387
- animation-fill-mode: forwards;
388
- }
389
-
390
- .container.hide,
391
- .button_save.hide {
392
- animation-name: hideWidgets;
393
- animation-duration: 0.5s;
394
- animation-fill-mode: forwards;
395
- }
396
-
397
- @keyframes showedWidgets {
398
- 0% {
399
- transform: translate3d(-65%, 15%, 0) scale(0) rotate(15deg);
400
- filter: blur(25px) grayscale(1) brightness(0.3);
401
- opacity: 0;
402
- }
403
- 100% {
404
- transform: translate3d(0, 0, 0) scale(1) rotate(0deg);
405
- filter: blur(0) grayscale(0) brightness(1);
406
- opacity: 1;
407
- }
408
- }
409
-
410
- @keyframes hideWidgets {
411
- 0% {
412
- transform: translate3d(0, 0, 0) scale(1) rotate3d(1, 0, 0, 0deg);
413
- filter: blur(0) grayscale(0) brightness(1);
414
- opacity: 1;
415
- }
416
- 100% {
417
- transform: translate3d(0, 5%, 0) scale(0.9) rotate3d(1, 0, 0, 90deg);
418
- filter: blur(15px) grayscale(1) brightness(0.5);
419
- opacity: 0;
420
- }
421
- }
422
- </style>
423
 
 
 
424
  <!-- TOGGLE 'CustomDL' SCRIPT -->
425
  <script>
426
  function toggleContainer() {
@@ -432,20 +99,58 @@ function toggleContainer() {
432
  }
433
  </script>
434
  '''
 
435
 
436
- display(HTML(CSS))
437
- # ==================== CSS JS ====================
438
 
 
 
 
 
439
 
440
- # ==================== WIDGETS ====================
441
- # --- global widgets ---
442
- style = {'description_width': 'initial'}
443
- layout = widgets.Layout(min_width='1047px')
 
444
 
445
- HR = widgets.HTML('<hr>')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
446
 
447
  # --- MODEL ---
448
- model_header = widgets.HTML('<div class="header">Model Selection<div>')
449
  model_options = ['none',
450
  '1.Anime (by XpucT) + INP',
451
  '2.BluMix [Anime] [V7] + INP',
@@ -456,37 +161,37 @@ model_options = ['none',
456
  '7.Deliberate [Realism] [V6] + INP',
457
  '8.Meina-Mix [Anime] [V11] + INP',
458
  '9.Mix-Pro [Anime] [V4] + INP']
459
- # ---
460
- Model_widget = widgets.Dropdown(options=model_options, value='4.Counterfeit [Anime] [V3] + INP', description='Model:', style=style, layout=layout)
461
- Model_Num_widget = widgets.Text(description='Model Number:', placeholder='Enter the model numbers to be downloaded using comma/space.', style=style, layout=layout)
462
- Inpainting_Model_widget = widgets.Checkbox(value=False, description='Inpainting Models', style=style)
463
 
464
- ''' Display Model'''
465
- all_model_box = widgets.VBox([model_header, Model_widget, Model_Num_widget, Inpainting_Model_widget]).add_class("container").add_class("image_1")
466
- display(all_model_box)
467
 
468
  # --- VAE ---
469
- vae_header = widgets.HTML('<div class="header">VAE Selection</div>')
470
  vae_options = ['none',
471
  '1.Anime.vae',
472
  '2.Anything.vae',
473
  '3.Blessed2.vae',
474
  '4.ClearVae.vae',
475
  '5.WD.vae']
476
- Vae_widget = widgets.Dropdown(options=vae_options, value='3.Blessed2.vae', description='Vae:', style=style, layout=layout)
477
- Vae_Num_widget = widgets.Text(description='Vae Number:', placeholder='Enter the vae numbers to be downloaded using comma/space.', style=style, layout=layout)
478
 
479
- ''' Display Vae'''
480
- all_vae_box = widgets.VBox([vae_header, Vae_widget, Vae_Num_widget]).add_class("container").add_class("image_2")
481
- display(all_vae_box)
482
 
483
  # --- ADDITIONAL ---
484
- additional_header = widgets.HTML('<div class="header">Additional</div>')
485
- latest_webui_widget = widgets.Checkbox(value=True, description='Update WebUI', style=style)
486
- latest_exstensions_widget = widgets.Checkbox(value=True, description='Update Extensions', style=style)
487
- change_webui_widget = widgets.Dropdown(options=['A1111', 'Forge'], value='A1111', description='Change WebUI:', style=style)
488
- detailed_download_widget = widgets.Dropdown(options=['off', 'on'], value='off', description='Detailed Download:', style=style)
489
- latest_changes_widget = HBox([latest_webui_widget, latest_exstensions_widget, change_webui_widget, detailed_download_widget], layout=widgets.Layout(justify_content='space-between'))
 
490
  controlnet_options = ['none', 'ALL', '1.canny',
491
  '2.openpose', '3.depth',
492
  '4.normal_map', '5.mlsd',
@@ -494,33 +199,45 @@ controlnet_options = ['none', 'ALL', '1.canny',
494
  '8.scribble', '9.segmentation',
495
  '10.shuffle', '11.tile',
496
  '12.inpaint', '13.instruct_p2p']
497
- # ---
498
- controlnet_widget = widgets.Dropdown(options=controlnet_options, value='none', description='ControlNet:', style=style, layout=layout)
499
- controlnet_Num_widget = widgets.Text(description='ControlNet Number:', placeholder='Enter the ControlNet model numbers to be downloaded using comma/space.', style=style, layout=layout)
500
- commit_hash_widget = widgets.Text(description='Commit Hash:', style=style, layout=layout)
501
- optional_huggingface_token_widget = widgets.Text(description='HuggingFace Token:', style=style, layout=layout)
502
- ngrok_token_widget = widgets.Text(description='Ngrok Token:', style=style, layout=widgets.Layout(width='1047px'))
503
- ngrock_button = widgets.HTML('<a href="https://dashboard.ngrok.com/get-started/your-authtoken" target="_blank">Get Ngrok Token</a>').add_class("button_ngrok")
504
- ngrok_widget = widgets.HBox([ngrok_token_widget, ngrock_button], style=style, layout=layout)
505
- zrok_token_widget = widgets.Text(description='Zrok Token:', style=style, layout=widgets.Layout(width='1047px'))
506
- zrok_button = widgets.HTML('<a href="https://colab.research.google.com/drive/1d2sjWDJi_GYBUavrHSuQyHTDuLy36WpU" target="_blank">Reg Zrok Token</a>').add_class("button_ngrok")
507
- zrok_widget = widgets.HBox([zrok_token_widget, zrok_button], style=style, layout=layout)
508
- # ---
 
509
  commandline_arguments_options = "--listen --enable-insecure-extension-access --theme dark --no-half-vae --disable-console-progressbars --xformers"
510
- commandline_arguments_widget = widgets.Text(description='Arguments:', value=commandline_arguments_options, style=style, layout=layout)
 
 
 
 
 
 
 
 
 
 
 
 
 
511
 
512
- ''' Display Additional'''
513
- 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]
514
  if free_plan and env == "Google Colab": # remove ngrok from colab
515
  additional_widget_list.remove(ngrok_widget)
516
  if os.path.exists(webui_path): # remove selection after selection ;3
517
- latest_changes_widget.children = [widget for widget in latest_changes_widget.children if widget != change_webui_widget]
518
- # ```
519
- all_additional_box = widgets.VBox(additional_widget_list).add_class("container").add_class("image_3")
520
- display(all_additional_box)
521
 
522
  # --- CUSTOM DOWNLOAD ---
523
- custom_download_header_popup = widgets.HTML('''
524
  <style>
525
  /* Term Colors */
526
  .sample_label {color: #dbafff;}
@@ -545,39 +262,40 @@ custom_download_header_popup = widgets.HTML('''
545
  </div>
546
  </div>
547
  ''')
548
- # ---
549
- Model_url_widget = widgets.Text(description='Model:', style=style, layout=layout)
550
- Vae_url_widget = widgets.Text(description='Vae:', style=style, layout=layout)
551
- LoRA_url_widget = widgets.Text(description='LoRa:', style=style, layout=layout)
552
- Embedding_url_widget = widgets.Text(description='Embedding:', style=style, layout=layout)
553
- Extensions_url_widget = widgets.Text(description='Extensions:', style=style, layout=layout)
554
- custom_file_urls_widget = widgets.Text(description='File (txt):', style=style, layout=layout)
555
-
556
- ''' Display CustomDl'''
557
- all_custom_box = widgets.VBox([
558
  custom_download_header_popup, Model_url_widget, Vae_url_widget, LoRA_url_widget, Embedding_url_widget, Extensions_url_widget, custom_file_urls_widget
559
- ]).add_class("container").add_class("image_4").add_class("container_custom_downlad")
560
- display(all_custom_box)
561
 
562
  # --- Save Button ---
563
- save_button = widgets.Button(description='Save').add_class("button_save")
564
- display(save_button)
565
 
566
 
567
  # ============ Load / Save - Settings V2 ============
568
  SETTINGS_FILE = f'{root_path}/settings.json'
569
 
570
- settings_keys = [
571
- 'Model', 'Model_Num', 'Inpainting_Model',
572
- 'Vae', 'Vae_Num',
573
- 'latest_webui', 'latest_exstensions', 'change_webui', 'detailed_download',
574
- 'controlnet', 'controlnet_Num', 'commit_hash', 'optional_huggingface_token',
575
  'ngrok_token', 'zrok_token', 'commandline_arguments',
576
- 'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url', 'Extensions_url', 'custom_file_urls'
 
577
  ]
578
 
579
  def save_settings():
580
- settings = {key: globals()[f"{key}_widget"].value for key in settings_keys}
581
  with open(SETTINGS_FILE, 'w') as f:
582
  json.dump(settings, f, indent=2)
583
 
@@ -585,20 +303,20 @@ def load_settings():
585
  if os.path.exists(SETTINGS_FILE):
586
  with open(SETTINGS_FILE, 'r') as f:
587
  settings = json.load(f)
588
- for key in settings_keys:
589
- globals()[f"{key}_widget"].value = settings.get(key)
590
 
591
- def save_data(button):
592
- save_settings()
593
-
594
- # --- uhh - hide... ---
595
  widgets_list = [all_model_box, all_vae_box, all_additional_box, all_custom_box, save_button]
596
  for widget in widgets_list:
597
  widget.add_class("hide")
598
  time.sleep(0.5)
599
-
600
  widgets.Widget.close_all()
601
 
602
- settings = load_settings()
 
 
 
 
603
  save_button.on_click(save_data)
604
 
 
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='')
 
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
 
57
 
58
  """ mode img - repeats """
59
  mode_img = "repeat" if not args.mode else "no-repeat"
 
60
 
61
  container_background = f'''
62
  <style>
 
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() {
 
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',
 
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',
 
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;}
 
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
 
 
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 ADDED
@@ -0,0 +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
+
files_cells/python/ru/downloading_ru.py CHANGED
@@ -15,21 +15,19 @@ from IPython.display import clear_output
15
  from urllib.parse import urlparse, parse_qs
16
 
17
 
18
- # ================= DETECT ENV =================
19
  def detect_environment():
20
  free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024 ** 3) <= 20)
21
  environments = {
22
  'COLAB_GPU': ('Google Colab', "/root" if free_plan else "/content"),
23
  'KAGGLE_URL_BASE': ('Kaggle', "/kaggle/working/content")
24
  }
25
-
26
  for env_var, (environment, path) in environments.items():
27
  if env_var in os.environ:
28
  return environment, path, free_plan
29
 
30
  env, root_path, free_plan = detect_environment()
31
  webui_path = f"{root_path}/sdw"
32
- # ----------------------------------------------
33
 
34
 
35
  # ================ LIBRARIES V2 ================
@@ -80,12 +78,6 @@ if not os.path.exists(flag_file):
80
  time.sleep(2)
81
  clear_output()
82
 
83
- ## dl special files
84
- with capture.capture_output() as cap:
85
- get_ipython().system('mkdir -p {root_path}/file_cell/special')
86
- get_ipython().system('wget https://huggingface.co/NagisaNao/fast_repo/resolve/main/special/dl_display_results.py -O {root_path}/file_cell/special/dl_display_results.py')
87
- del cap
88
-
89
 
90
  # ================= loading settings V4 =================
91
  def load_settings(path):
@@ -96,16 +88,17 @@ def load_settings(path):
96
 
97
  settings = load_settings(f'{root_path}/settings.json')
98
 
99
- variables = [
100
- 'Model', 'Model_Num', 'Inpainting_Model',
101
- 'Vae', 'Vae_Num',
102
- 'latest_webui', 'latest_exstensions', 'change_webui', 'detailed_download',
103
- 'controlnet', 'controlnet_Num', 'commit_hash', 'optional_huggingface_token',
104
  'ngrok_token', 'zrok_token', 'commandline_arguments',
105
- 'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url', 'Extensions_url', 'custom_file_urls'
 
106
  ]
107
 
108
- locals().update({key: settings.get(key) for key in variables})
109
 
110
 
111
  # ================= OTHER =================
@@ -241,17 +234,7 @@ model_list = {
241
  ]
242
  }
243
 
244
- # 1-4 (fp16/cleaned)
245
  vae_list = {
246
- ## vae broke - the author's an asshole
247
- # "1.Anime.vae": [
248
- # {"url": "https://civitai.com/api/download/models/131654", "name": "Anime.vae.safetensors"},
249
- # {"url": "https://civitai.com/api/download/models/131658", "name": "vae-ft-mse.vae.safetensors"}
250
- # ],
251
- # "2.Anything.vae": [{"url": "https://civitai.com/api/download/models/131656", "name": "Anything.vae.safetensors"}],
252
- # "3.Blessed2.vae": [{"url": "https://civitai.com/api/download/models/142467", "name": "Blessed2.vae.safetensors"}],
253
- # "4.ClearVae.vae": [{"url": "https://civitai.com/api/download/models/133362", "name": "ClearVae_23.vae.safetensors"}],
254
-
255
  "1.Anime.vae": [{"url": "https://civitai.com/api/download/models/311162", "name": "vae-ft-mse-840000-ema-pruned.vae.safetensors"}],
256
  "2.Anything.vae": [{"url": "https://civitai.com/api/download/models/119279", "name": "Anything.vae.safetensors"}],
257
  "3.Blessed2.vae": [{"url": "https://huggingface.co/NoCrypt/blessed_vae/resolve/main/blessed2.vae.pt", "name": "Blessed2.vae.safetensors"}],
@@ -332,7 +315,7 @@ extension_repo = []
332
  directories = [value for key, value in prefixes.items()] # for unpucking zip files
333
  get_ipython().system('mkdir -p {" ".join(directories)}')
334
 
335
- hf_token = optional_huggingface_token if optional_huggingface_token else "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"
336
  user_header = f"\"Authorization: Bearer {hf_token}\""
337
 
338
  ''' Formatted Info Output '''
@@ -531,14 +514,14 @@ def add_submodels(selection, num_selection, model_dict, dst_dir):
531
  def handle_submodels(selection, num_selection, model_dict, dst_dir, url):
532
  submodels = add_submodels(selection, num_selection, model_dict, dst_dir)
533
  for submodel in submodels:
534
- if not Inpainting_Model and "inpainting" in submodel['name']:
535
  continue
536
  url += f"{submodel['url']} {submodel['dst_dir']} {submodel['name']}, "
537
  return url
538
 
539
- url = handle_submodels(Model, Model_Num, model_list, models_dir, url)
540
- url = handle_submodels(Vae, Vae_Num, vae_list, vaes_dir, url)
541
- url = handle_submodels(controlnet, controlnet_Num, controlnet_list, control_dir, url)
542
 
543
  ''' file.txt - added urls '''
544
 
@@ -622,38 +605,6 @@ if len(extension_repo) > 0:
622
  ## List Models and stuff V2
623
  if detailed_download == "off":
624
  print("\n\n\033[33mЕсли вы не видете каких-то скаченных файлов, включите в виджетах функцию 'Подробная Загрузка'.")
625
- get_ipython().run_line_magic('run', '{root_path}/file_cell/special/dl_display_results.py') # display widgets result
626
 
627
- else:
628
- if any(not file.endswith('.txt') for file in os.listdir(models_dir)):
629
- print("\n\033[33m➤ Models\033[0m")
630
- get_ipython().system("find {models_dir}/ -mindepth 1 -name '*.safetensors' -printf '%f\\n'")
631
- if any(not file.endswith('.txt') for file in os.listdir(vaes_dir)):
632
- print("\n\033[33m➤ VAEs\033[0m")
633
- get_ipython().system("find {vaes_dir}/ -mindepth 1 -name '*.safetensors' -printf '%f\\n'")
634
- if any(not file.endswith('.txt') and not os.path.isdir(os.path.join(embeddings_dir, file)) for file in os.listdir(embeddings_dir)):
635
- print("\n\033[33m➤ Embeddings\033[0m")
636
- get_ipython().system("find {embeddings_dir}/ -mindepth 1 -maxdepth 1 \\( -name '*.pt' -or -name '*.safetensors' \\) -printf '%f\\n'")
637
- if any(not file.endswith('.txt') for file in os.listdir(loras_dir)):
638
- print("\n\033[33m➤ LoRAs\033[0m")
639
- get_ipython().system("find {loras_dir}/ -mindepth 1 -name '*.safetensors' -printf '%f\\n'")
640
- print(f"\n\033[33m➤ Extensions\033[0m")
641
- get_ipython().system("find {extensions_dir}/ -mindepth 1 -maxdepth 1 ! -name '*.txt' -printf '%f\\n'")
642
- if any(not file.endswith(('.txt', '.yaml')) for file in os.listdir(control_dir)):
643
- print("\n\033[33m➤ ControlNet\033[0m")
644
- get_ipython().system("find {control_dir}/ -mindepth 1 ! -name '*.yaml' -printf '%f\\n' | sed 's/^[^_]*_[^_]*_[^_]*_\\([^_]*\\)_fp16\\.safetensors$/\\1/'")
645
-
646
-
647
- # === OTHER ===
648
- # Downlaod discord tags UmiWildcards
649
- files_umi = [
650
- "https://huggingface.co/NagisaNao/fast_repo/resolve/main/extensions/UmiWildacrd/discord/200_pan_gen.txt",
651
- "https://huggingface.co/NagisaNao/fast_repo/resolve/main/extensions/UmiWildacrd/discord/150_bra_gen.txt"
652
- ]
653
- save_dir_path = f"{webui_path}/extensions/Umi-AI-Wildcards/wildcards/discord"
654
-
655
- with capture.capture_output() as cap:
656
- for file in files_umi:
657
- get_ipython().system('aria2c --optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -j5 -x16 -s16 -k1M -c -d {save_dir_path} {file}')
658
- del cap
659
 
 
15
  from urllib.parse import urlparse, parse_qs
16
 
17
 
18
+ # ================= DETECT ENV =================
19
  def detect_environment():
20
  free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024 ** 3) <= 20)
21
  environments = {
22
  'COLAB_GPU': ('Google Colab', "/root" if free_plan else "/content"),
23
  'KAGGLE_URL_BASE': ('Kaggle', "/kaggle/working/content")
24
  }
 
25
  for env_var, (environment, path) in environments.items():
26
  if env_var in os.environ:
27
  return environment, path, free_plan
28
 
29
  env, root_path, free_plan = detect_environment()
30
  webui_path = f"{root_path}/sdw"
 
31
 
32
 
33
  # ================ LIBRARIES V2 ================
 
78
  time.sleep(2)
79
  clear_output()
80
 
 
 
 
 
 
 
81
 
82
  # ================= loading settings V4 =================
83
  def load_settings(path):
 
88
 
89
  settings = load_settings(f'{root_path}/settings.json')
90
 
91
+ VARIABLES = [
92
+ 'model', 'model_num', 'inpainting_model',
93
+ 'vae', 'vae_num', 'latest_webui', 'latest_exstensions',
94
+ 'change_webui', 'detailed_download', 'controlnet',
95
+ 'controlnet_num', 'commit_hash', 'huggingface_token',
96
  'ngrok_token', 'zrok_token', 'commandline_arguments',
97
+ 'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url',
98
+ 'Extensions_url', 'custom_file_urls'
99
  ]
100
 
101
+ locals().update({key: settings.get(key) for key in VARIABLES})
102
 
103
 
104
  # ================= OTHER =================
 
234
  ]
235
  }
236
 
 
237
  vae_list = {
 
 
 
 
 
 
 
 
 
238
  "1.Anime.vae": [{"url": "https://civitai.com/api/download/models/311162", "name": "vae-ft-mse-840000-ema-pruned.vae.safetensors"}],
239
  "2.Anything.vae": [{"url": "https://civitai.com/api/download/models/119279", "name": "Anything.vae.safetensors"}],
240
  "3.Blessed2.vae": [{"url": "https://huggingface.co/NoCrypt/blessed_vae/resolve/main/blessed2.vae.pt", "name": "Blessed2.vae.safetensors"}],
 
315
  directories = [value for key, value in prefixes.items()] # for unpucking zip files
316
  get_ipython().system('mkdir -p {" ".join(directories)}')
317
 
318
+ hf_token = huggingface_token if huggingface_token else "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"
319
  user_header = f"\"Authorization: Bearer {hf_token}\""
320
 
321
  ''' Formatted Info Output '''
 
514
  def handle_submodels(selection, num_selection, model_dict, dst_dir, url):
515
  submodels = add_submodels(selection, num_selection, model_dict, dst_dir)
516
  for submodel in submodels:
517
+ if not inpainting_model and "inpainting" in submodel['name']:
518
  continue
519
  url += f"{submodel['url']} {submodel['dst_dir']} {submodel['name']}, "
520
  return url
521
 
522
+ url = handle_submodels(model, model_num, model_list, models_dir, url)
523
+ url = handle_submodels(vae, vae_num, vae_list, vaes_dir, url)
524
+ url = handle_submodels(controlnet, controlnet_num, controlnet_list, control_dir, url)
525
 
526
  ''' file.txt - added urls '''
527
 
 
605
  ## List Models and stuff V2
606
  if detailed_download == "off":
607
  print("\n\n\033[33mЕсли вы не видете каких-то скаченных файлов, включите в виджетах функцию 'Подробная Загрузка'.")
 
608
 
609
+ get_ipython().run_line_magic('run', '{root_path}/file_cell/special/dl_display_results.py # display widgets result')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
610
 
files_cells/python/ru/widgets_ru.py CHANGED
@@ -8,27 +8,24 @@ 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
-
19
  for env_var, (environment, path) in environments.items():
20
  if env_var in os.environ:
21
  return environment, path, free_plan
22
 
23
  env, root_path, free_plan = detect_environment()
24
  webui_path = f"{root_path}/sdw"
25
-
26
  get_ipython().system('mkdir -p {root_path}')
27
- # ----------------------------------------------
28
 
29
 
30
  # ==================== CSS JS ====================
31
- # custom background images V1.5
32
  import argparse
33
  parser = argparse.ArgumentParser(description='This script processes an background image.')
34
  parser.add_argument('-i', '--image', type=str, help='URL of the image to process', metavar='')
@@ -40,8 +37,9 @@ parser.add_argument('-s', '--scale', type=int, help='Scale image in %%', metavar
40
  parser.add_argument('-m', '--mode', action='store_true', help='Removes repetitive image tiles')
41
  parser.add_argument('-t', '--transparent', action='store_true', help='Makes input/selection fields 35%% more transparent')
42
  parser.add_argument('-bf', '--blur-fields', type=str, help='Background blur level for input/selection fields', metavar='', default=2)
 
43
  args = parser.parse_args()
44
- """---"""
45
  url_img = args.image
46
  opacity_img = args.opacity
47
  blur_img = args.blur
@@ -59,7 +57,6 @@ t_bg_alpha = "1" if not args.transparent else "0.65"
59
 
60
  """ mode img - repeats """
61
  mode_img = "repeat" if not args.mode else "no-repeat"
62
- ## ---
63
 
64
  container_background = f'''
65
  <style>
@@ -82,345 +79,15 @@ container_background = f'''
82
  '''
83
 
84
  display(HTML(container_background))
85
- # ---
86
-
87
- CSS = '''
88
- <style>
89
- /* General Styles */
90
- .header {
91
- font-family: cursive;
92
- font-size: 20px;
93
- font-weight: bold;
94
- color: #ff8cee;
95
- margin-bottom: 15px;
96
- user-select: none;
97
- cursor: default;
98
- display: inline-block;
99
- }
100
-
101
- hr {
102
- border-color: grey;
103
- background-color: grey;
104
- opacity: 0.25;
105
- }
106
-
107
- a {
108
- text-decoration: none;
109
- color: inherit;
110
- }
111
-
112
-
113
- /* Container style */
114
-
115
- .container {
116
- position: relative;
117
- background-color: #232323;
118
- width: 1080px;
119
- padding: 10px 15px;
120
- border-radius: 15px;
121
- box-shadow: 0 0 50px rgba(0, 0, 0, 0.3);
122
- margin-bottom: 5px;
123
- overflow: hidden;
124
- }
125
-
126
- .container::after {
127
- position: absolute;
128
- top: 5px;
129
- right: 10px;
130
- content: "ANXETY";
131
- font-weight: bold;
132
- font-size: 24px;
133
- color: rgba(0, 0, 0, 0.2);
134
- }
135
-
136
- /* background img */
137
- .container::before {
138
- content: "";
139
- position: absolute;
140
- top: 0;
141
- left: 0;
142
- right: 0;
143
- bottom: 0;
144
- background-image: var(--img_background);
145
- background-size: var(--img_scale);
146
- background-repeat: var(--img_mode);
147
- opacity: var(--img_opacity);
148
- mix-blend-mode: screen;
149
- pointer-events: none;
150
- filter: blur(var(--img_blur));
151
- z-index: -1;
152
- }
153
-
154
- .image_1::before {
155
- background-position: var(--image_x) calc(-120px - var(--image_y));
156
- }
157
- .image_2::before {
158
- background-position: var(--image_x) calc(-290px - var(--image_y));
159
- }
160
- .image_3::before {
161
- background-position: var(--image_x) calc(-430px - var(--image_y));
162
- }
163
- .image_4::before {
164
- background-position: var(--image_x) calc(var(--img_height_dif) - var(--image_y));
165
- }
166
-
167
- .container_custom_downlad {
168
- height: 55px;
169
- transition: all 0.5s;
170
- }
171
-
172
- .container_custom_downlad.expanded {
173
- height: 270px;
174
- }
175
-
176
-
177
- /* Element text style */
178
-
179
- .widget-html,
180
- .widget-button,
181
- .widget-text label,
182
- .widget-checkbox label,
183
- .widget-dropdown label,
184
- .widget-dropdown select,
185
- .widget-text input[type="text"] {
186
- font-family: cursive;
187
- font-size: 14px;
188
- color: white !important;
189
- user-select: none;
190
- }
191
-
192
- .widget-text input[type="text"]::placeholder {
193
- color: grey;
194
- }
195
-
196
-
197
- /* Input field styles */
198
-
199
- .widget-dropdown select,
200
- .widget-text input[type="text"] {
201
- height: 30px;
202
- background-color: var(--bg-field-color);
203
- border: 1px solid #262626;
204
- border-radius: 10px;
205
- box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
206
- transition: all 0.3s ease-in-out;
207
- backdrop-filter: blur(var(--bg-field-blur-level));
208
- }
209
-
210
- .widget-dropdown select:focus,
211
- .widget-text input[type="text"]:focus {
212
- border-color: #006ee5;
213
- }
214
-
215
- .widget-dropdown select:hover,
216
- .widget-text input[type="text"]:hover {
217
- transform: scale(1.003);
218
- background-color: var(--bg-field-color-hover);
219
- box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
220
- }
221
-
222
- .widget-dropdown option {
223
- background-color: #1c1c1c;
224
- }
225
-
226
-
227
- /* Slider Checkbox style */
228
-
229
- .widget-checkbox input[type="checkbox"] {
230
- appearance: none;
231
- position: relative;
232
- top: 4px; /* Why is he taller?! */
233
- width: 40px;
234
- height: 20px;
235
- border: none;
236
- border-radius: 10px;
237
- background-color: #20b2aa;
238
- cursor: pointer;
239
- box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.3);
240
- transition: background-color 0.3s ease;
241
- }
242
- .widget-checkbox input[type="checkbox"]:checked {
243
- background-color: #2196F3;
244
- }
245
-
246
- .widget-checkbox input[type="checkbox"]:before {
247
- content: '';
248
- position: absolute;
249
- top: 50%;
250
- left: 3px;
251
- width: 16px;
252
- height: 16px;
253
- border-radius: inherit;
254
- background-color: white;
255
- box-shadow: 0 0 8px rgba(0, 0, 0, 0.3);
256
- transform: translateY(-50%);
257
- transition: left 0.3s ease;
258
- }
259
- .widget-checkbox input[type="checkbox"]:checked:before {
260
- left: 21px;
261
- }
262
-
263
-
264
- /* Button styles */
265
-
266
- .button_save {
267
- font-size: 15px;
268
- font-weight: bold;
269
- width: 120px;
270
- height: 35px;
271
- border-radius: 15px;
272
- background-image: radial-gradient(circle at top left, purple 10%, violet 90%);
273
- background-size: 200% 200%;
274
- background-position: left bottom;
275
- transition: background 0.5s ease-in-out, transform 0.3s ease;
276
- }
277
-
278
- .button_save:hover {
279
- cursor: pointer;
280
- background-image: radial-gradient(circle at top left, purple 10%, #93ac47 90%);
281
- background-size: 200% 200%;
282
- background-position: right bottom;
283
- transform: translateY(1px);
284
- }
285
 
286
- .button_ngrok {
287
- font-size: 12px;
288
- height: 30px;
289
- border-radius: 10px;
290
- padding: 1px 12px;
291
- background-image: radial-gradient(circle at top left, purple 10%, violet 90%);
292
- background-size: 200% 200%;
293
- background-position: left bottom;
294
- transition: background 0.5s ease-in-out, transform 0.3s ease;
295
- white-space: nowrap;
296
- }
297
-
298
- .button_ngrok:hover {
299
- cursor: pointer;
300
- background-image: radial-gradient(circle at top left, purple 10%, #1D94BB 90%);
301
- background-size: 200% 200%;
302
- background-position: right bottom;
303
- transform: translateY(1px);
304
- }
305
-
306
- .button_save:active,
307
- .button_ngrok:active {
308
- filter: brightness(0.75) !important;
309
- }
310
-
311
- /* Removes ugly stroke from widget buttons. */
312
- .jupyter-widgets.lm-Widget:focus {
313
- outline: none;
314
- }
315
-
316
-
317
- /* Popup style of `INFO` window */
318
-
319
- .info {
320
- position: absolute;
321
- top: -5px;
322
- right: 95px;
323
- color: grey;
324
- font-family: cursive;
325
- font-size: 14px;
326
- font-weight: normal;
327
- user-select: none;
328
- pointer-events: none;
329
- opacity: 0;
330
- transition: opacity 0.3s ease-in-out;
331
- display: inline-block;
332
- }
333
-
334
- .popup {
335
- position: absolute;
336
- top: 120px;
337
- z-index: 999;
338
- width: auto;
339
- padding: 10px;
340
- text-align: center;
341
- background-color: rgba(255, 255, 255, 0.05);
342
- backdrop-filter: blur(20px);
343
- border: 1px solid rgba(255, 255, 255, 0.45);
344
- border-radius: 8px;
345
- box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
346
- opacity: 0;
347
- color: #fff;
348
- font-size: 16px;
349
- font-family: cursive;
350
- user-select: none;
351
- cursor: default;
352
- pointer-events: none;
353
- transform: rotate(-5deg);
354
- transition: top 0.3s ease-in-out, opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
355
- }
356
-
357
- .sample {
358
- display: inline-block;
359
- margin-top: 25px;
360
- padding: 10px 100px;
361
- background-color: rgba(255, 255, 255, 0.2);
362
- color: #c6e2ff;
363
- border: 2px solid rgba(255, 255, 255, 0.2);
364
- border-radius: 8px;
365
- box-shadow: 0 0 10px rgba(255, 255, 255, 0.2), inset 0 0 25px rgba(255, 255, 255, 0.2);
366
- }
367
-
368
- .info.showed {
369
- opacity: 1;
370
- pointer-events: auto;
371
- }
372
-
373
- .info:hover + .popup {
374
- top: 35px;
375
- opacity: 1;
376
- pointer-events: initial;
377
- transform: rotate(0deg);
378
- }
379
-
380
-
381
- /* Animation of elements */
382
-
383
- .container,
384
- .button_save {
385
- animation-name: showedWidgets;
386
- animation-duration: 1s;
387
- animation-fill-mode: forwards;
388
- }
389
-
390
- .container.hide,
391
- .button_save.hide {
392
- animation-name: hideWidgets;
393
- animation-duration: 0.5s;
394
- animation-fill-mode: forwards;
395
- }
396
-
397
- @keyframes showedWidgets {
398
- 0% {
399
- transform: translate3d(-65%, 15%, 0) scale(0) rotate(15deg);
400
- filter: blur(25px) grayscale(1) brightness(0.3);
401
- opacity: 0;
402
- }
403
- 100% {
404
- transform: translate3d(0, 0, 0) scale(1) rotate(0deg);
405
- filter: blur(0) grayscale(0) brightness(1);
406
- opacity: 1;
407
- }
408
- }
409
-
410
- @keyframes hideWidgets {
411
- 0% {
412
- transform: translate3d(0, 0, 0) scale(1) rotate3d(1, 0, 0, 0deg);
413
- filter: blur(0) grayscale(0) brightness(1);
414
- opacity: 1;
415
- }
416
- 100% {
417
- transform: translate3d(0, 5%, 0) scale(0.9) rotate3d(1, 0, 0, 90deg);
418
- filter: blur(15px) grayscale(1) brightness(0.5);
419
- opacity: 0;
420
- }
421
- }
422
- </style>
423
 
 
 
424
  <!-- TOGGLE 'CustomDL' SCRIPT -->
425
  <script>
426
  function toggleContainer() {
@@ -432,20 +99,58 @@ function toggleContainer() {
432
  }
433
  </script>
434
  '''
 
435
 
436
- display(HTML(CSS))
437
- # ==================== CSS JS ====================
438
 
 
 
 
 
439
 
440
- # ==================== WIDGETS ====================
441
- # --- global widgets ---
442
- style = {'description_width': 'initial'}
443
- layout = widgets.Layout(min_width='1047px')
 
444
 
445
- HR = widgets.HTML('<hr>')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
446
 
447
  # --- MODEL ---
448
- model_header = widgets.HTML('<div class="header">Выбор Модели<div>')
449
  model_options = ['none',
450
  '1.Anime (by XpucT) + INP',
451
  '2.BluMix [Anime] [V7] + INP',
@@ -456,37 +161,37 @@ model_options = ['none',
456
  '7.Deliberate [Realism] [V6] + INP',
457
  '8.Meina-Mix [Anime] [V11] + INP',
458
  '9.Mix-Pro [Anime] [V4] + INP']
459
- # ---
460
- Model_widget = widgets.Dropdown(options=model_options, value='4.Counterfeit [Anime] [V3] + INP', description='Модель:', style=style, layout=layout)
461
- Model_Num_widget = widgets.Text(description='Номер Модели:', placeholder='Введите номера моделей для скачивания через запятую/пробел.', style=style, layout=layout)
462
- Inpainting_Model_widget = widgets.Checkbox(value=False, description='Inpainting Модели', style=style)
463
 
464
- ''' Display Model'''
465
- all_model_box = widgets.VBox([model_header, Model_widget, Model_Num_widget, Inpainting_Model_widget]).add_class("container").add_class("image_1")
466
- display(all_model_box)
467
 
468
  # --- VAE ---
469
- vae_header = widgets.HTML('<div class="header">Выбор VAE</div>')
470
  vae_options = ['none',
471
  '1.Anime.vae',
472
  '2.Anything.vae',
473
  '3.Blessed2.vae',
474
  '4.ClearVae.vae',
475
  '5.WD.vae']
476
- Vae_widget = widgets.Dropdown(options=vae_options, value='3.Blessed2.vae', description='Vae:', style=style, layout=layout)
477
- Vae_Num_widget = widgets.Text(description='Номер Vae:', placeholder='Введите номера vae для скачивания через запятую/пробел.', style=style, layout=layout)
478
 
479
- ''' Display Vae'''
480
- all_vae_box = widgets.VBox([vae_header, Vae_widget, Vae_Num_widget]).add_class("container").add_class("image_2")
481
- display(all_vae_box)
482
 
483
  # --- ADDITIONAL ---
484
- additional_header = widgets.HTML('<div class="header">Дополнительно</div>')
485
- latest_webui_widget = widgets.Checkbox(value=True, description='Обновить WebUI', style=style)
486
- latest_exstensions_widget = widgets.Checkbox(value=True, description='Обновить Расширения', style=style)
487
- change_webui_widget = widgets.Dropdown(options=['A1111', 'Forge'], value='A1111', description='Изменить WebUI:', style=style)
488
- detailed_download_widget = widgets.Dropdown(options=['off', 'on'], value='off', description='Подробная Загрузка:', style=style)
489
- latest_changes_widget = HBox([latest_webui_widget, latest_exstensions_widget, change_webui_widget, detailed_download_widget], layout=widgets.Layout(justify_content='space-between'))
 
490
  controlnet_options = ['none', 'ALL', '1.canny',
491
  '2.openpose', '3.depth',
492
  '4.normal_map', '5.mlsd',
@@ -494,33 +199,45 @@ controlnet_options = ['none', 'ALL', '1.canny',
494
  '8.scribble', '9.segmentation',
495
  '10.shuffle', '11.tile',
496
  '12.inpaint', '13.instruct_p2p']
497
- # ---
498
- controlnet_widget = widgets.Dropdown(options=controlnet_options, value='none', description='ControlNet:', style=style, layout=layout)
499
- controlnet_Num_widget = widgets.Text(description='Номер ControlNet:', placeholder='Введите номера моделей ControlNet для скачивания через запятую/пробел.', style=style, layout=layout)
500
- commit_hash_widget = widgets.Text(description='Commit Hash:', style=style, layout=layout)
501
- optional_huggingface_token_widget = widgets.Text(description='Токен HuggingFace:', style=style, layout=layout)
502
- ngrok_token_widget = widgets.Text(description='Токен Ngrok:', style=style, layout=widgets.Layout(width='1047px'))
503
- ngrock_button = widgets.HTML('<a href="https://dashboard.ngrok.com/get-started/your-authtoken" target="_blank">Получить Ngrok Токен</a>').add_class("button_ngrok")
504
- ngrok_widget = widgets.HBox([ngrok_token_widget, ngrock_button], style=style, layout=layout)
505
- zrok_token_widget = widgets.Text(description='Токен Zrok:', style=style, layout=widgets.Layout(width='1047px'))
506
- zrok_button = widgets.HTML('<a href="https://colab.research.google.com/drive/1d2sjWDJi_GYBUavrHSuQyHTDuLy36WpU" target="_blank">Зарегать Zrok Токен</a>').add_class("button_ngrok")
507
- zrok_widget = widgets.HBox([zrok_token_widget, zrok_button], style=style, layout=layout)
508
- # ---
 
509
  commandline_arguments_options = "--listen --enable-insecure-extension-access --theme dark --no-half-vae --disable-console-progressbars --xformers"
510
- commandline_arguments_widget = widgets.Text(description='Аргументы:', value=commandline_arguments_options, style=style, layout=layout)
 
 
 
 
 
 
 
 
 
 
 
 
 
511
 
512
- ''' Display Additional'''
513
- 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]
514
  if free_plan and env == "Google Colab": # remove ngrok from colab
515
  additional_widget_list.remove(ngrok_widget)
516
  if os.path.exists(webui_path): # remove selection after selection ;3
517
- latest_changes_widget.children = [widget for widget in latest_changes_widget.children if widget != change_webui_widget]
518
- # ```
519
- all_additional_box = widgets.VBox(additional_widget_list).add_class("container").add_class("image_3")
520
- display(all_additional_box)
521
 
522
  # --- CUSTOM DOWNLOAD ---
523
- custom_download_header_popup = widgets.HTML('''
524
  <style>
525
  /* Term Colors */
526
  .sample_label {color: #dbafff;}
@@ -545,39 +262,40 @@ custom_download_header_popup = widgets.HTML('''
545
  </div>
546
  </div>
547
  ''')
548
- # ---
549
- Model_url_widget = widgets.Text(description='Model:', style=style, layout=layout)
550
- Vae_url_widget = widgets.Text(description='Vae:', style=style, layout=layout)
551
- LoRA_url_widget = widgets.Text(description='LoRa:', style=style, layout=layout)
552
- Embedding_url_widget = widgets.Text(description='Embedding:', style=style, layout=layout)
553
- Extensions_url_widget = widgets.Text(description='Extensions:', style=style, layout=layout)
554
- custom_file_urls_widget = widgets.Text(description='Файл (txt):', style=style, layout=layout)
555
-
556
- ''' Display CustomDl'''
557
- all_custom_box = widgets.VBox([
558
  custom_download_header_popup, Model_url_widget, Vae_url_widget, LoRA_url_widget, Embedding_url_widget, Extensions_url_widget, custom_file_urls_widget
559
- ]).add_class("container").add_class("image_4").add_class("container_custom_downlad")
560
- display(all_custom_box)
561
 
562
  # --- Save Button ---
563
- save_button = widgets.Button(description='Сохранить').add_class("button_save")
564
- display(save_button)
565
 
566
 
567
  # ============ Load / Save - Settings V2 ============
568
  SETTINGS_FILE = f'{root_path}/settings.json'
569
 
570
- settings_keys = [
571
- 'Model', 'Model_Num', 'Inpainting_Model',
572
- 'Vae', 'Vae_Num',
573
- 'latest_webui', 'latest_exstensions', 'change_webui', 'detailed_download',
574
- 'controlnet', 'controlnet_Num', 'commit_hash', 'optional_huggingface_token',
575
  'ngrok_token', 'zrok_token', 'commandline_arguments',
576
- 'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url', 'Extensions_url', 'custom_file_urls'
 
577
  ]
578
 
579
  def save_settings():
580
- settings = {key: globals()[f"{key}_widget"].value for key in settings_keys}
581
  with open(SETTINGS_FILE, 'w') as f:
582
  json.dump(settings, f, indent=2)
583
 
@@ -585,20 +303,20 @@ def load_settings():
585
  if os.path.exists(SETTINGS_FILE):
586
  with open(SETTINGS_FILE, 'r') as f:
587
  settings = json.load(f)
588
- for key in settings_keys:
589
- globals()[f"{key}_widget"].value = settings.get(key)
590
 
591
- def save_data(button):
592
- save_settings()
593
-
594
- # --- uhh - hide... ---
595
  widgets_list = [all_model_box, all_vae_box, all_additional_box, all_custom_box, save_button]
596
  for widget in widgets_list:
597
  widget.add_class("hide")
598
  time.sleep(0.5)
599
-
600
  widgets.Widget.close_all()
601
 
602
- settings = load_settings()
 
 
 
 
603
  save_button.on_click(save_data)
604
 
 
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='')
 
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
 
57
 
58
  """ mode img - repeats """
59
  mode_img = "repeat" if not args.mode else "no-repeat"
 
60
 
61
  container_background = f'''
62
  <style>
 
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() {
 
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',
 
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',
 
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;}
 
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
 
 
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
 
special/dl_display_results.py ADDED
@@ -0,0 +1,228 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ##~ Display Download Results Widgets | by: ANXETY ~##
2
+
3
+ import re
4
+ import os
5
+ import json
6
+ import time
7
+ import ipywidgets as widgets
8
+ from ipywidgets import widgets, Layout, Label, Button, VBox, HBox
9
+ from IPython.display import display, HTML, Javascript, clear_output
10
+
11
+
12
+ # ================= DETECT ENV =================
13
+ def detect_environment():
14
+ free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)
15
+ environments = {
16
+ 'COLAB_GPU': ('Google Colab', "/root" if free_plan else "/content"),
17
+ 'KAGGLE_URL_BASE': ('Kaggle', "/kaggle/working/content")
18
+ }
19
+
20
+ for env_var, (environment, path) in environments.items():
21
+ if env_var in os.environ:
22
+ return environment, path, free_plan
23
+
24
+ env, root_path, free_plan = detect_environment()
25
+ webui_path = f"{root_path}/sdw"
26
+ # ----------------------------------------------
27
+
28
+
29
+ # CONFIG DIR
30
+ models_dir = f"{webui_path}/models/Stable-diffusion"
31
+ vaes_dir = f"{webui_path}/models/VAE"
32
+ embeddings_dir = f"{webui_path}/embeddings"
33
+ loras_dir = f"{webui_path}/models/Lora"
34
+ extensions_dir = f"{webui_path}/extensions"
35
+ control_dir = f"{webui_path}/models/ControlNet"
36
+
37
+
38
+ # ==================== CSS ====================
39
+ CSS = """
40
+ <style>
41
+ /* General Styles */
42
+ .header_dl,
43
+ .header_outputs_dl {
44
+ font-family: cursive;
45
+ font-size: 20px;
46
+ font-weight: bold;
47
+ text-align: center;
48
+ }
49
+ .header_dl {
50
+ color: #AC8FA5;
51
+ margin-bottom: 15px;
52
+ }
53
+ .header_outputs_dl {
54
+ color: #0083C0;
55
+ }
56
+
57
+ hr {
58
+ border-color: grey;
59
+ background-color: grey;
60
+ opacity: 0.25;
61
+ width: 1000px;
62
+ }
63
+
64
+ /* Element text style */
65
+ .widget-html {
66
+ font-family: cursive;
67
+ font-size: 14px;
68
+ color: white !important;
69
+ user-select: none;
70
+ }
71
+
72
+
73
+ /* Container style */
74
+ .container_dl {
75
+ position: relative;
76
+ flex-direction: column;
77
+ align-items: center;
78
+ background-color: #232323;
79
+ width: 1200px;
80
+ height: auto;
81
+ margin: 40px 10px 10px 10px;
82
+ padding: 10px 15px;
83
+ border-radius: 15px;
84
+ box-shadow: 0 0 50px rgba(0, 0, 0, 0.3), inset 0 0 10px rgba(0, 0, 0, 0.3);
85
+ transition: all 0.5s ease-in-out;
86
+ overflow: visible;
87
+ }
88
+ .container_dl::after {
89
+ position: absolute;
90
+ top: 5px;
91
+ right: 10px;
92
+ content: "ANXETY";
93
+ font-weight: bold;
94
+ font-size: 24px;
95
+ color: rgba(0, 0, 0, 0.2);
96
+ }
97
+
98
+ .result_output_dl {
99
+ flex-wrap: wrap;
100
+ box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.3);
101
+ border-radius: 8px;
102
+ background-color: #1F1F1F;
103
+ width: 95%;
104
+ padding: 10px 15px;
105
+ overflow: visible;
106
+ }
107
+ .outputs_dl {
108
+ flex-grow: 1;
109
+ flex-wrap: wrap;
110
+ background-color: #181818;
111
+ padding: 10px 15px;
112
+ border-radius: 15px;
113
+ box-shadow: 0 0 8px rgba(0, 0, 0, 0.3), inset 0 0 10px rgba(0, 0, 0, 0.3);
114
+ color: #C1C1C1;
115
+ margin: 8px;
116
+ transition: all 0.15s ease-in-out;
117
+ }
118
+
119
+ /* good use of space */
120
+ .extension {
121
+ display: grid;
122
+ grid-template-columns: repeat(3, 1fr);
123
+ }
124
+
125
+
126
+ /* Animation of elements */
127
+
128
+ .container_dl,
129
+ .outputs_dl {
130
+ animation: showedResult 1s;
131
+ }
132
+ .items_dl {
133
+ animation: showedText 1s;
134
+ }
135
+
136
+ @keyframes showedResult {
137
+ 0% {
138
+ transform: translate3d(0, 15%, 0);
139
+ opacity: 0;
140
+ }
141
+ 100% {
142
+ transform: translate3d(0, 0, 0);
143
+ opacity: 1;
144
+ }
145
+ }
146
+
147
+ @keyframes showedText {
148
+ 0% {
149
+ transform: translate3d(-30%, 0, 0);
150
+ opacity: 0;
151
+ }
152
+ 100% {
153
+ transform: translate3d(0, 0, 0);
154
+ opacity: 1;
155
+ }
156
+ }
157
+ </style>
158
+ """
159
+
160
+ display(HTML(CSS))
161
+ # ==================== CSS ====================
162
+
163
+
164
+ # ==================== WIDGETS ====================
165
+ # Constants
166
+ HR = widgets.HTML('<hr>')
167
+ HEADER_DL = 'DOWNLOAD RESULTS'
168
+ VERSION = 'v0.31'
169
+
170
+ ## Functions
171
+ def output_container_generator(header, items):
172
+ header_widget = widgets.HTML(value=f'<div class="header_outputs_dl">{header} ➤</div>')
173
+ content_widgets = [widgets.HTML(value=f'<div class="items_dl">{item}</div>') for item in items]
174
+ container_widget = widgets.VBox([header_widget, *content_widgets]).add_class("outputs_dl")
175
+ return container_widget
176
+
177
+ def get_files_list(directory, extensions):
178
+ return [file for file in os.listdir(directory) if file.endswith(extensions)]
179
+
180
+ def get_folders_list(directory):
181
+ return [folder for folder in os.listdir(extensions_dir) if os.path.isdir(os.path.join(extensions_dir, folder))]
182
+
183
+ def get_controlnets_list(directory, filter_pattern):
184
+ filter_name = re.compile(filter_pattern)
185
+ return [
186
+ filter_name.match(file).group(1) if filter_name.match(file) else file
187
+ for file in os.listdir(directory)
188
+ if not file.endswith(('.txt', '.yaml'))
189
+ ]
190
+
191
+ ## Widgets
192
+ header_widget = widgets.HTML(value=f'''
193
+ <div><span class="header_dl">{HEADER_DL}</span> <span style="color: grey; opacity: 0.25;">| {VERSION}</span></div>
194
+ ''')
195
+
196
+ # Models
197
+ models_list = get_files_list(models_dir, '.safetensors')
198
+ models_widget = output_container_generator('Models', models_list)
199
+ # Vaes
200
+ vaes_list = get_files_list(vaes_dir, '.safetensors')
201
+ vaes_widget = output_container_generator('VAEs', vaes_list)
202
+ # Embeddings
203
+ embeddings_list = get_files_list(embeddings_dir, ('.safetensors', '.pt'))
204
+ embeddings_widget = output_container_generator('Embeddings', embeddings_list)
205
+ # LoRAs
206
+ loras_list = get_files_list(loras_dir, '.safetensors')
207
+ loras_widget = output_container_generator('LoRAs', loras_list)
208
+ # Extensions
209
+ extensions_list = get_folders_list(extensions_dir)
210
+ extensions_widget = output_container_generator('Extensions', extensions_list).add_class("extension") # for fix height
211
+ # ControlNet
212
+ controlnets_list = get_controlnets_list(control_dir, r'^[^_]*_[^_]*_[^_]*_(.*)_fp16\.safetensors')
213
+ controlnets_widget = output_container_generator('ControlNets', controlnets_list)
214
+
215
+ ## Sorting and Output
216
+ widgets_dict = {
217
+ models_widget: models_list,
218
+ vaes_widget: vaes_list,
219
+ embeddings_widget: embeddings_list,
220
+ loras_widget: loras_list,
221
+ extensions_widget: extensions_list,
222
+ controlnets_widget: controlnets_list
223
+ }
224
+ outputs_widgets_list = [widget for widget, widget_list in widgets_dict.items() if widget_list]
225
+ result_output_widget = widgets.HBox(outputs_widgets_list).add_class("result_output_dl")
226
+
227
+ container_widget = widgets.VBox([header_widget, HR, result_output_widget, HR]).add_class("container_dl")
228
+ display(container_widget)