ai202388 commited on
Commit
992aa22
·
verified ·
1 Parent(s): ea02f96

Upload 2 files

Browse files
Files changed (2) hide show
  1. launch_cn.py +54 -0
  2. widgets_cn.py +582 -0
launch_cn.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ##~ WIDGET CODE | Special for SageMaker | BY: ANXETY ~##
2
+
3
+ import os
4
+ import re
5
+ import time
6
+ import json
7
+ import requests
8
+ from datetime import timedelta
9
+
10
+
11
+ root_path = "/home/studio-lab-user/content"
12
+ webui_path = f"{root_path}/sdw"
13
+
14
+
15
+ def load_settings():
16
+ SETTINGS_FILE = f'{root_path}/settings.json'
17
+ if os.path.exists(SETTINGS_FILE):
18
+ with open(SETTINGS_FILE, 'r') as f:
19
+ settings = json.load(f)
20
+ return settings
21
+
22
+ settings = load_settings()
23
+ ngrok_token = settings['ngrok_token']
24
+ zrok_token = settings['zrok_token']
25
+ commandline_arguments = settings['commandline_arguments']
26
+
27
+
28
+ # automatic fixing path V2
29
+ get_ipython().system('sed -i \'s|"tagger_hf_cache_dir": ".*"|"tagger_hf_cache_dir": "{webui_path}/models/interrogators/"|\' {webui_path}/config.json')
30
+ get_ipython().system('sed -i \'s|"additional_networks_extra_lora_path": ".*"|"additional_networks_extra_lora_path": "{webui_path}/models/Lora/"|\' {webui_path}/config.json')
31
+ get_ipython().system('sed -i \'s|"ad_extra_models_dir": ".*"|"ad_extra_models_dir": "{webui_path}/models/adetailer/"|\' {webui_path}/config.json')
32
+ # ---
33
+ get_ipython().system('sed -i \'s/"sd_vae":.*/"sd_vae": "None",/; s/"sd_model_checkpoint":.*/"sd_model_checkpoint": "None",/; s/"sd_checkpoint_hash":.*/"sd_checkpoint_hash": "None",/\' {webui_path}/config.json')
34
+
35
+
36
+ get_ipython().run_line_magic('cd', '{webui_path}')
37
+ commandline_arguments += f" --port=1769"
38
+
39
+ if ngrok_token or zrok_token:
40
+ if ngrok_token:
41
+ commandline_arguments += ' --ngrok ' + ngrok_token
42
+
43
+ if zrok_token:
44
+ get_ipython().system(f'python ~/content/special/zrok3.py {zrok_token} {commandline_arguments}')
45
+
46
+ else:
47
+ get_ipython().system(f'COMMANDLINE_ARGS="{commandline_arguments}" python launch.py')
48
+
49
+ start_colab = float(open(f'{webui_path}/static/colabTimer.txt', 'r').read())
50
+ time_since_start = str(timedelta(seconds=time.time()-start_colab)).split('.')[0]
51
+ print(f"\n⌚️ \033[0mВы проводите эту сессию в течение - \033[33m{time_since_start}\033[0m\n\n")
52
+
53
+ else:
54
+ print("Not found tokens: Zrok/Ngrok")
widgets_cn.py ADDED
@@ -0,0 +1,582 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ##~ WIDGET CODE | Special for SageMaker | BY: ANXETY ~##
2
+
3
+ import os
4
+ import json
5
+ import time
6
+ import ipywidgets as widgets
7
+ from ipywidgets import widgets, Layout, Label, Button, VBox, HBox
8
+ from IPython.display import display, HTML, Javascript, clear_output
9
+
10
+
11
+ root_path = "/home/studio-lab-user/content"
12
+ webui_path = f"{root_path}/sdw"
13
+
14
+
15
+ # ==================== CSS JS ====================
16
+ # custom background images V1.5
17
+ import argparse
18
+ parser = argparse.ArgumentParser(description='This script processes an background image.')
19
+ parser.add_argument('-i', '--image', type=str, help='URL of the image to process', metavar='')
20
+ parser.add_argument('-o', '--opacity', type=float, help='Opacity level for the image, between 0 and 1', metavar='', default=0.3)
21
+ parser.add_argument('-b', '--blur', type=str, help='Blur level for the image', metavar='', default=0)
22
+ parser.add_argument('-y', type=int, help='Y coordinate for the image in px', metavar='', default=0)
23
+ parser.add_argument('-x', type=int, help='X coordinate for the image in px', metavar='', default=0)
24
+ parser.add_argument('-s', '--scale', type=int, help='Scale image in %%', metavar='', default=100)
25
+ parser.add_argument('-m', '--mode',action='store_true', help='Removes repetitive image tiles')
26
+ parser.add_argument('-t', '--transparent', action='store_true', help='Makes input/selection fields 35%% more transparent')
27
+ parser.add_argument('-bf', '--blur-fields', type=str, help='Background blur level for input/selection fields', metavar='', default=2)
28
+ args = parser.parse_args()
29
+ """---"""
30
+ url_img = args.image
31
+ opacity_img = args.opacity
32
+ blur_img = args.blur
33
+ y_img = args.y
34
+ x_img = args.x
35
+ scale_img = args.scale
36
+ blur_fields = args.blur_fields
37
+
38
+ ## ---
39
+ fix_heigh_img = "-810px"
40
+
41
+ """ transperent fields """
42
+ t_bg_alpha = "1" if not args.transparent else "0.65"
43
+
44
+ """ mode img - repeats """
45
+ mode_img = "repeat" if not args.mode else "no-repeat"
46
+ ## ---
47
+
48
+ container_background = f'''
49
+ <style>
50
+ :root {{
51
+ /* for background container*/
52
+ --img_background: url({url_img});
53
+ --img_opacity: {opacity_img};
54
+ --img_blur: {blur_img}px;
55
+ --image_y: {y_img}px;
56
+ --image_x: {x_img}px;
57
+ --img_scale: {scale_img}%;
58
+ --img_mode: {mode_img};
59
+ --img_height_dif: {fix_heigh_img};
60
+
61
+ /* for fields */
62
+ --bg-field-color: rgba(28, 28, 28, {t_bg_alpha}); /* -> #1c1c1c */
63
+ --bg-field-color-hover: rgba(38, 38, 38, {t_bg_alpha}); /* -> #262626; */
64
+ --bg-field-blur-level: {blur_fields}px;
65
+ }}
66
+ '''
67
+
68
+ display(HTML(container_background))
69
+ # ---
70
+
71
+ CSS = '''
72
+ <style>
73
+ /* General Styles */
74
+ .header {
75
+ font-family: cursive;
76
+ font-size: 20px;
77
+ font-weight: bold;
78
+ color: #ff8cee;
79
+ margin-bottom: 15px;
80
+ user-select: none;
81
+ cursor: default;
82
+ display: inline-block;
83
+ }
84
+
85
+ hr {
86
+ border-color: grey;
87
+ background-color: grey;
88
+ opacity: 0.25;
89
+ }
90
+
91
+ a {
92
+ text-decoration: none;
93
+ color: inherit;
94
+ }
95
+
96
+
97
+ /* Container style */
98
+
99
+ .container {
100
+ position: relative;
101
+ background-color: #232323;
102
+ width: 1080px;
103
+ padding: 10px 15px;
104
+ border-radius: 15px;
105
+ box-shadow: 0 0 50px rgba(0, 0, 0, 0.3);
106
+ margin-bottom: 5px;
107
+ overflow: hidden;
108
+ }
109
+
110
+ .container::after {
111
+ position: absolute;
112
+ top: 5px;
113
+ right: 10px;
114
+ content: "ANXETY";
115
+ font-weight: bold;
116
+ font-size: 24px;
117
+ color: rgba(0, 0, 0, 0.2);
118
+ }
119
+
120
+ /* background img */
121
+ .container::before {
122
+ content: "";
123
+ position: absolute;
124
+ top: 0;
125
+ left: 0;
126
+ right: 0;
127
+ bottom: 0;
128
+ background-image: var(--img_background);
129
+ background-size: var(--img_scale);
130
+ background-repeat: var(--img_mode);
131
+ opacity: var(--img_opacity);
132
+ mix-blend-mode: screen;
133
+ pointer-events: none;
134
+ filter: blur(var(--img_blur));
135
+ z-index: -1;
136
+ }
137
+
138
+ .image_1::before {
139
+ background-position: var(--image_x) calc(-120px - var(--image_y));
140
+ }
141
+ .image_2::before {
142
+ background-position: var(--image_x) calc(-290px - var(--image_y));
143
+ }
144
+ .image_3::before {
145
+ background-position: var(--image_x) calc(-430px - var(--image_y));
146
+ }
147
+ .image_4::before {
148
+ background-position: var(--image_x) calc(var(--img_height_dif) - var(--image_y));
149
+ }
150
+
151
+ .container_custom_downlad {
152
+ height: 55px;
153
+ transition: all 0.5s;
154
+ }
155
+
156
+ .container_custom_downlad.expanded {
157
+ height: 270px;
158
+ }
159
+
160
+
161
+ /* Element text style */
162
+
163
+ .widget-html,
164
+ .widget-button,
165
+ .widget-text label,
166
+ .widget-checkbox label,
167
+ .widget-dropdown label,
168
+ .widget-dropdown select,
169
+ .widget-text input[type="text"] {
170
+ font-family: cursive;
171
+ font-size: 14px;
172
+ color: white !important;
173
+ user-select: none;
174
+ }
175
+
176
+ .widget-text input[type="text"]::placeholder {
177
+ color: grey;
178
+ }
179
+
180
+
181
+ /* Input field styles */
182
+
183
+ .widget-dropdown select,
184
+ .widget-text input[type="text"] {
185
+ height: 30px;
186
+ background-color: var(--bg-field-color);
187
+ border: 1px solid #262626;
188
+ border-radius: 10px;
189
+ box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
190
+ transition: all 0.3s ease-in-out;
191
+ backdrop-filter: blur(var(--bg-field-blur-level));
192
+ }
193
+
194
+ .widget-dropdown select:focus,
195
+ .widget-text input[type="text"]:focus {
196
+ border-color: #006ee5;
197
+ }
198
+
199
+ .widget-dropdown select:hover,
200
+ .widget-text input[type="text"]:hover {
201
+ transform: scale(1.003);
202
+ background-color: var(--bg-field-color-hover);
203
+ box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
204
+ }
205
+
206
+ .widget-dropdown option {
207
+ background-color: #1c1c1c;
208
+ }
209
+
210
+
211
+ /* Slider Checkbox style */
212
+
213
+ .widget-checkbox input[type="checkbox"] {
214
+ appearance: none;
215
+ position: relative;
216
+ top: 4px; /* Why is he taller?! */
217
+ width: 40px;
218
+ height: 20px;
219
+ border: none;
220
+ border-radius: 10px;
221
+ background-color: #20b2aa;
222
+ cursor: pointer;
223
+ box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.3);
224
+ transition: background-color 0.3s ease;
225
+ }
226
+ .widget-checkbox input[type="checkbox"]:checked {
227
+ background-color: #2196F3;
228
+ }
229
+
230
+ .widget-checkbox input[type="checkbox"]:before {
231
+ content: '';
232
+ position: absolute;
233
+ top: 50%;
234
+ left: 3px;
235
+ width: 16px;
236
+ height: 16px;
237
+ border-radius: inherit;
238
+ background-color: white;
239
+ box-shadow: 0 0 8px rgba(0, 0, 0, 0.3);
240
+ transform: translateY(-50%);
241
+ transition: left 0.3s ease;
242
+ }
243
+ .widget-checkbox input[type="checkbox"]:checked:before {
244
+ left: 21px;
245
+ }
246
+
247
+
248
+ /* Button styles */
249
+
250
+ .button_save {
251
+ font-size: 15px;
252
+ font-weight: bold;
253
+ width: 120px;
254
+ height: 35px;
255
+ border-radius: 15px;
256
+ background-image: radial-gradient(circle at top left, purple 10%, violet 90%);
257
+ background-size: 200% 200%;
258
+ background-position: left bottom;
259
+ transition: background 0.5s ease-in-out, transform 0.3s ease;
260
+ }
261
+
262
+ .button_save:hover {
263
+ cursor: pointer;
264
+ background-image: radial-gradient(circle at top left, purple 10%, #93ac47 90%);
265
+ background-size: 200% 200%;
266
+ background-position: right bottom;
267
+ transform: translateY(1px);
268
+ }
269
+
270
+ .button_ngrok {
271
+ font-size: 12px;
272
+ height: 30px;
273
+ border-radius: 10px;
274
+ padding: 1px 12px;
275
+ background-image: radial-gradient(circle at top left, purple 10%, violet 90%);
276
+ background-size: 200% 200%;
277
+ background-position: left bottom;
278
+ transition: background 0.5s ease-in-out, transform 0.3s ease;
279
+ white-space: nowrap;
280
+ }
281
+
282
+ .button_ngrok:hover {
283
+ cursor: pointer;
284
+ background-image: radial-gradient(circle at top left, purple 10%, #1D94BB 90%);
285
+ background-size: 200% 200%;
286
+ background-position: right bottom;
287
+ transform: translateY(1px);
288
+ }
289
+
290
+ .button_save:active,
291
+ .button_ngrok:active {
292
+ filter: brightness(0.75) !important;
293
+ }
294
+
295
+ /* Removes ugly stroke from widget buttons. */
296
+ .jupyter-widgets.lm-Widget:focus {
297
+ outline: none;
298
+ }
299
+
300
+
301
+ /* Popup style of `INFO` window */
302
+
303
+ .info {
304
+ position: absolute;
305
+ top: -5px;
306
+ right: 95px;
307
+ color: grey;
308
+ font-family: cursive;
309
+ font-size: 14px;
310
+ font-weight: normal;
311
+ user-select: none;
312
+ pointer-events: none;
313
+ opacity: 0;
314
+ transition: opacity 0.3s ease-in-out;
315
+ display: inline-block;
316
+ }
317
+
318
+ .popup {
319
+ position: absolute;
320
+ top: 120px;
321
+ z-index: 999;
322
+ width: auto;
323
+ padding: 10px;
324
+ text-align: center;
325
+ background-color: rgba(255, 255, 255, 0.05);
326
+ backdrop-filter: blur(20px);
327
+ border: 1px solid rgba(255, 255, 255, 0.45);
328
+ border-radius: 8px;
329
+ box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
330
+ opacity: 0;
331
+ color: #fff;
332
+ font-size: 16px;
333
+ font-family: cursive;
334
+ user-select: none;
335
+ cursor: default;
336
+ pointer-events: none;
337
+ transform: rotate(-5deg);
338
+ transition: top 0.3s ease-in-out, opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
339
+ }
340
+
341
+ .sample {
342
+ display: inline-block;
343
+ margin-top: 25px;
344
+ padding: 10px 100px;
345
+ background-color: rgba(255, 255, 255, 0.2);
346
+ color: #c6e2ff;
347
+ border: 2px solid rgba(255, 255, 255, 0.2);
348
+ border-radius: 8px;
349
+ box-shadow: 0 0 10px rgba(255, 255, 255, 0.2), inset 0 0 25px rgba(255, 255, 255, 0.2);
350
+ }
351
+
352
+ .info.showed {
353
+ opacity: 1;
354
+ pointer-events: auto;
355
+ }
356
+
357
+ .info:hover + .popup {
358
+ top: 35px;
359
+ opacity: 1;
360
+ pointer-events: initial;
361
+ transform: rotate(0deg);
362
+ }
363
+
364
+
365
+ /* Animation of elements */
366
+
367
+ .container,
368
+ .button_save {
369
+ animation-name: showedWidgets;
370
+ animation-duration: 1s;
371
+ animation-fill-mode: forwards;
372
+ }
373
+
374
+ .container.hide,
375
+ .button_save.hide {
376
+ animation-name: hideWidgets;
377
+ animation-duration: 0.5s;
378
+ animation-fill-mode: forwards;
379
+ }
380
+
381
+ @keyframes showedWidgets {
382
+ 0% {
383
+ transform: translate3d(-65%, 15%, 0) scale(0) rotate(15deg);
384
+ filter: blur(25px) grayscale(1) brightness(0.3);
385
+ opacity: 0;
386
+ }
387
+ 100% {
388
+ transform: translate3d(0, 0, 0) scale(1) rotate(0deg);
389
+ filter: blur(0) grayscale(0) brightness(1);
390
+ opacity: 1;
391
+ }
392
+ }
393
+
394
+ @keyframes hideWidgets {
395
+ 0% {
396
+ transform: translate3d(0, 0, 0) scale(1) rotate3d(1, 0, 0, 0deg);
397
+ filter: blur(0) grayscale(0) brightness(1);
398
+ opacity: 1;
399
+ }
400
+ 100% {
401
+ transform: translate3d(0, 5%, 0) scale(0.9) rotate3d(1, 0, 0, 90deg);
402
+ filter: blur(15px) grayscale(1) brightness(0.5);
403
+ opacity: 0;
404
+ }
405
+ }
406
+ </style>
407
+
408
+ <!-- TOGGLE 'CustomDL' SCRIPT -->
409
+ <script>
410
+ function toggleContainer() {
411
+ let downloadContainer = document.querySelector('.container_custom_downlad');
412
+ let info = document.querySelector('.info');
413
+
414
+ downloadContainer.classList.toggle('expanded');
415
+ info.classList.toggle('showed');
416
+ }
417
+ </script>
418
+ '''
419
+
420
+ display(HTML(CSS))
421
+ # ==================== CSS JS ====================
422
+
423
+
424
+ # ==================== WIDGETS ====================
425
+ # --- global widgets ---
426
+ style = {'description_width': 'initial'}
427
+ layout = widgets.Layout(min_width='1047px')
428
+
429
+ HR = widgets.HTML('<hr>')
430
+
431
+ # --- MODEL ---
432
+ model_header = widgets.HTML('<div class="header">Model Selection<div>')
433
+ model_options = ['none',
434
+ '1.Anime (by XpucT) + INP',
435
+ '2.BluMix [Anime] [V7] + INP',
436
+ '3.Cetus-Mix [Anime] [V4] + INP',
437
+ '4.Counterfeit [Anime] [V3] + INP',
438
+ '5.CuteColor [Anime] [V3]',
439
+ '6.Dark-Sushi-Mix [Anime]',
440
+ '7.Deliberate [Realism] [V6] + INP',
441
+ '8.Meina-Mix [Anime] [V11] + INP',
442
+ '9.Mix-Pro [Anime] [V4] + INP']
443
+ # ---
444
+ Model_widget = widgets.Dropdown(options=model_options, value='4.Counterfeit [Anime] [V3] + INP', description='Model:', style=style, layout=layout)
445
+ Model_Num_widget = widgets.Text(description='Model Number:', placeholder='Enter the model numbers to be downloaded using comma/space.', style=style, layout=layout)
446
+ Inpainting_Model_widget = widgets.Checkbox(value=False, description='Inpainting Models', style=style)
447
+
448
+ ''' Display Model'''
449
+ all_model_box = widgets.VBox([model_header, Model_widget, Model_Num_widget, Inpainting_Model_widget]).add_class("container").add_class("image_1")
450
+ display(all_model_box)
451
+
452
+ # --- VAE ---
453
+ vae_header = widgets.HTML('<div class="header" >VAE Selection</div>')
454
+ vae_options = ['none',
455
+ '1.Anime.vae',
456
+ '2.Anything.vae',
457
+ '3.Blessed2.vae',
458
+ '4.ClearVae.vae',
459
+ '5.WD.vae']
460
+ Vae_widget = widgets.Dropdown(options=vae_options, value='3.Blessed2.vae', description='Vae:', style=style, layout=layout)
461
+ Vae_Num_widget = widgets.Text(description='Vae Number:', placeholder='Enter the vae numbers to be downloaded using comma/space.', style=style, layout=layout)
462
+
463
+ ''' Display Vae'''
464
+ all_vae_box= widgets.VBox([vae_header, Vae_widget, Vae_Num_widget]).add_class("container").add_class("image_2")
465
+ display(all_vae_box)
466
+
467
+ # --- ADDITIONAL ---
468
+ additional_header = widgets.HTML('<div class="header">Additional</div>')
469
+ latest_webui_widget = widgets.Checkbox(value=True, description='Update WebUI', style=style)
470
+ latest_exstensions_widget = widgets.Checkbox(value=True, description='Update Extensions', style=style)
471
+ detailed_download_widget = widgets.Dropdown(options=['off', 'on'], value='off', description='Detailed Download:', style=style)
472
+ latest_changes_widget = HBox([latest_webui_widget, latest_exstensions_widget, detailed_download_widget], layout=widgets.Layout(justify_content='space-between'))
473
+ controlnet_options = ['none', 'ALL', '1.canny',
474
+ '2.openpose', '3.depth',
475
+ '4.normal_map', '5.mlsd',
476
+ '6.lineart', '7.soft_edge',
477
+ '8.scribble', '9.segmentation',
478
+ '10.shuffle', '11.tile',
479
+ '12.inpaint', '13.instruct_p2p']
480
+ # ---
481
+ controlnet_widget = widgets.Dropdown(options=controlnet_options, value='none', description='ControlNet:', style=style, layout=layout)
482
+ controlnet_Num_widget = widgets.Text(description='ControlNet Number:', placeholder='Enter the ControlNet model numbers to be downloaded using comma/space.', style=style, layout=layout)
483
+ commit_hash_widget = widgets.Text(description='Commit Hash:', style=style, layout=layout)
484
+ optional_huggingface_token_widget = widgets.Text(description='HuggingFace Token:', style=style, layout=layout)
485
+ ngrok_token_widget = widgets.Text(description='Ngrok Token:', style=style, layout=widgets.Layout(width='1047px'))
486
+ ngrock_button = widgets.HTML('<a href="https://dashboard.ngrok.com/get-started/your-authtoken" target="_blank">Get Ngrok Token</a>').add_class("button_ngrok")
487
+ ngrok_widget = widgets.HBox([ngrok_token_widget, ngrock_button], style=style, layout=layout)
488
+ zrok_token_widget = widgets.Text(description='Zrok Token:', style=style, layout=widgets.Layout(width='1047px'))
489
+ zrok_button = widgets.HTML('<a href="https://colab.research.google.com/drive/1d2sjWDJi_GYBUavrHSuQyHTDuLy36WpU" target="_blank">Reg Zrok Token</a>').add_class("button_ngrok")
490
+ zrok_widget = widgets.HBox([zrok_token_widget, zrok_button], style=style, layout=layout)
491
+ # ---
492
+ commandline_arguments_options = "--listen --enable-insecure-extension-access --theme dark --no-half-vae --disable-console-progressbars --xformers"
493
+ commandline_arguments_widget = widgets.Text(description='Arguments:', value=commandline_arguments_options, style=style, layout=layout)
494
+
495
+ ''' Display Additional'''
496
+ 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]
497
+ all_additional_box = widgets.VBox(additional_widget_list).add_class("container").add_class("image_3")
498
+ display(all_additional_box)
499
+
500
+ # --- CUSTOM DOWNLOAD ---
501
+ custom_download_header_popup = widgets.HTML('''
502
+ <style>
503
+ /* Term Colors */
504
+ .sample_label {color: #dbafff;}
505
+ .braces {color: #ffff00;}
506
+ .extension {color: #eb934b;}
507
+ .file_name {color: #ffffd8;}
508
+ </style>
509
+
510
+ <div class="header" style="cursor: pointer;" onclick="toggleContainer()">Custom Download</div>
511
+ <!-- PopUp Window -->
512
+ <div class="info">INFO</div>
513
+ <div class="popup">
514
+ Separate multiple URLs with a comma/space. For a <span class="file_name">custom name</span> file/extension, specify it with <span class="braces">[]</span>
515
+ after the URL without spaces.
516
+ <span style="color: #ff9999">For files, be sure to specify</span> - <span class="extension">Filename Extension.</span>
517
+ <div class="sample">
518
+ <span class="sample_label">Example for File:</span>
519
+ https://civitai.com/api/download/models/229782<span class="braces">[</span><span class="file_name">Detailer</span><span class="extension">.safetensors</span><span class="braces">]</span>
520
+ <br>
521
+ <span class="sample_label">Example for Extension:</span>
522
+ https://github.com/hako-mikan/sd-webui-regional-prompter<span class="braces">[</span><span class="file_name">Regional-Prompter</span><span class="braces">]</span>
523
+ </div>
524
+ </div>
525
+ ''')
526
+ # ---
527
+ Model_url_widget = widgets.Text(description='Model:', style=style, layout=layout)
528
+ Vae_url_widget = widgets.Text(description='Vae:', style=style, layout=layout)
529
+ LoRA_url_widget = widgets.Text(description='LoRa:', style=style, layout=layout)
530
+ Embedding_url_widget = widgets.Text(description='Embedding:', style=style, layout=layout)
531
+ Extensions_url_widget = widgets.Text(description='Extensions:', style=style, layout=layout)
532
+ custom_file_urls_widget = widgets.Text(description='File (txt):', style=style, layout=layout)
533
+
534
+ ''' Display CustomDl'''
535
+ all_custom_box = widgets.VBox([
536
+ custom_download_header_popup, Model_url_widget, Vae_url_widget, LoRA_url_widget, Embedding_url_widget, Extensions_url_widget, custom_file_urls_widget
537
+ ]).add_class("container").add_class("image_4").add_class("container_custom_downlad")
538
+ display(all_custom_box)
539
+
540
+ # --- Save Button ---
541
+ save_button = widgets.Button(description='Save').add_class("button_save")
542
+ display(save_button)
543
+
544
+
545
+ # ============ Load / Save - Settings V2 ============
546
+ SETTINGS_FILE = f'{root_path}/settings.json'
547
+
548
+ settings_keys = [
549
+ 'Model', 'Model_Num', 'Inpainting_Model',
550
+ 'Vae', 'Vae_Num',
551
+ 'latest_webui', 'latest_exstensions', 'detailed_download',
552
+ 'controlnet', 'controlnet_Num', 'commit_hash', 'optional_huggingface_token',
553
+ 'ngrok_token', 'zrok_token', 'commandline_arguments',
554
+ 'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url', 'Extensions_url', 'custom_file_urls'
555
+ ]
556
+
557
+ def save_settings():
558
+ settings = {key: globals()[f"{key}_widget"].value for key in settings_keys}
559
+ with open(SETTINGS_FILE, 'w') as f:
560
+ json.dump(settings, f, indent=2)
561
+
562
+ def load_settings():
563
+ if os.path.exists(SETTINGS_FILE):
564
+ with open(SETTINGS_FILE, 'r') as f:
565
+ settings = json.load(f)
566
+ for key in settings_keys:
567
+ globals()[f"{key}_widget"].value = settings.get(key)
568
+
569
+ def save_data(button):
570
+ save_settings()
571
+
572
+ # --- uhh - hide... ---
573
+ widgets_list = [all_model_box, all_vae_box, all_additional_box, all_custom_box, save_button]
574
+ for widget in widgets_list:
575
+ widget.add_class("hide")
576
+ time.sleep(0.5)
577
+
578
+ widgets.Widget.close_all()
579
+
580
+ settings = load_settings()
581
+ save_button.on_click(save_data)
582
+