NagisaNao commited on
Commit
5039ac3
·
verified ·
1 Parent(s): 15e1cc6
files_cells/notebooks/en/downloading_en.ipynb CHANGED
@@ -104,7 +104,7 @@
104
  "## dl special files\n",
105
  "with capture.capture_output() as cap:\n",
106
  " !mkdir -p {root_path}/file_cell/special\n",
107
- " !wget https://huggingface.co/NagisaNao/test/resolve/main/files_cells/special/python/dl_display_results.py -O {root_path}/file_cell/special/dl_display_results.py\n",
108
  "del cap\n",
109
  "\n",
110
  "\n",
 
104
  "## dl special files\n",
105
  "with capture.capture_output() as cap:\n",
106
  " !mkdir -p {root_path}/file_cell/special\n",
107
+ " !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",
108
  "del cap\n",
109
  "\n",
110
  "\n",
files_cells/notebooks/en/widgets_en.ipynb CHANGED
@@ -496,7 +496,7 @@
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",
 
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",
files_cells/notebooks/ru/downloading_ru.ipynb CHANGED
@@ -104,7 +104,7 @@
104
  "## dl special files\n",
105
  "with capture.capture_output() as cap:\n",
106
  " !mkdir -p {root_path}/file_cell/special\n",
107
- " !wget https://huggingface.co/NagisaNao/test/resolve/main/files_cells/special/python/dl_display_results.py -O {root_path}/file_cell/special/dl_display_results.py\n",
108
  "del cap\n",
109
  "\n",
110
  "\n",
 
104
  "## dl special files\n",
105
  "with capture.capture_output() as cap:\n",
106
  " !mkdir -p {root_path}/file_cell/special\n",
107
+ " !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",
108
  "del cap\n",
109
  "\n",
110
  "\n",
files_cells/notebooks/ru/widgets_ru.ipynb CHANGED
@@ -496,7 +496,7 @@
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",
 
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",
files_cells/python/en/downloading_en.py CHANGED
@@ -85,7 +85,7 @@ if not os.path.exists(flag_file):
85
  ## dl special files
86
  with capture.capture_output() as cap:
87
  get_ipython().system('mkdir -p {root_path}/file_cell/special')
88
- get_ipython().system('wget https://huggingface.co/NagisaNao/test/resolve/main/files_cells/special/python/dl_display_results.py -O {root_path}/file_cell/special/dl_display_results.py')
89
  del cap
90
 
91
 
 
85
  ## dl special files
86
  with capture.capture_output() as cap:
87
  get_ipython().system('mkdir -p {root_path}/file_cell/special')
88
+ 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')
89
  del cap
90
 
91
 
files_cells/python/en/widgets_en.py CHANGED
@@ -477,7 +477,7 @@ Vae_widget = widgets.Dropdown(options=vae_options, value='3.Blessed2.vae', descr
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 ---
 
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 ---
files_cells/python/ru/downloading_ru.py CHANGED
@@ -85,7 +85,7 @@ if not os.path.exists(flag_file):
85
  ## dl special files
86
  with capture.capture_output() as cap:
87
  get_ipython().system('mkdir -p {root_path}/file_cell/special')
88
- get_ipython().system('wget https://huggingface.co/NagisaNao/test/resolve/main/files_cells/special/python/dl_display_results.py -O {root_path}/file_cell/special/dl_display_results.py')
89
  del cap
90
 
91
 
 
85
  ## dl special files
86
  with capture.capture_output() as cap:
87
  get_ipython().system('mkdir -p {root_path}/file_cell/special')
88
+ 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')
89
  del cap
90
 
91
 
files_cells/python/ru/widgets_ru.py CHANGED
@@ -477,7 +477,7 @@ Vae_widget = widgets.Dropdown(options=vae_options, value='3.Blessed2.vae', descr
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 ---
 
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 ---
special/dl_display_results.py ADDED
@@ -0,0 +1,220 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ adetailer_dir = f"{webui_path}/models/adetailer"
37
+
38
+
39
+ # ==================== CSS ====================
40
+ CSS = """
41
+ <style>
42
+ /* General Styles */
43
+ .header_dl,
44
+ .header_outputs_dl {
45
+ font-family: cursive;
46
+ font-size: 20px;
47
+ font-weight: bold;
48
+ text-align: center;
49
+ }
50
+ .header_dl {
51
+ color: #AC8FA5;
52
+ margin-bottom: 15px;
53
+ }
54
+ .header_outputs_dl {
55
+ color: #0083C0;
56
+ }
57
+
58
+ hr {
59
+ border-color: grey;
60
+ background-color: grey;
61
+ opacity: 0.25;
62
+ width: 1000px;
63
+ }
64
+
65
+ /* Element text style */
66
+ .widget-html {
67
+ font-family: cursive;
68
+ font-size: 14px;
69
+ color: white !important;
70
+ user-select: none;
71
+ }
72
+
73
+
74
+ /* Container style */
75
+ .container_dl {
76
+ position: relative;
77
+ display: flex;
78
+ flex: auto;
79
+ align-items: center;
80
+ position: relative;
81
+ background-color: #232323;
82
+ width: 1200px;
83
+ height: auto;
84
+ margin: 40px 10px 10px 10px;
85
+ padding: 10px 15px;
86
+ border-radius: 15px;
87
+ box-shadow: 0 0 50px rgba(0, 0, 0, 0.3), inset 0 0 10px rgba(0, 0, 0, 0.3);
88
+ transition: all 0.5s ease-in-out;
89
+ }
90
+ .container_dl::after {
91
+ position: absolute;
92
+ top: 5px;
93
+ right: 10px;
94
+ content: "ANXETY";
95
+ font-weight: bold;
96
+ font-size: 24px;
97
+ color: rgba(0, 0, 0, 0.2);
98
+ }
99
+
100
+ .result_output_dl {
101
+ flex-wrap: wrap;
102
+ box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.3);
103
+ border-radius: 8px;
104
+ background-color: #1f1f1f;
105
+ width: 95%;
106
+ padding: 10px 15px;
107
+ }
108
+
109
+ .outputs_dl {
110
+ display: flex;
111
+ flex: auto;
112
+ flex-wrap: wrap;
113
+ background-color: #181818;
114
+ padding: 10px 15px;
115
+ border-radius: 15px;
116
+ box-shadow: 0 0 8px rgba(0, 0, 0, 0.3), inset 0 0 10px rgba(0, 0, 0, 0.3);
117
+ color: #c1c1c1;
118
+ margin: 8px;
119
+ transition: all 0.15s ease-in-out;
120
+ }
121
+
122
+ /* setting the height of "outputs" containers */
123
+ .outputs_dl { max-height: 400px; }
124
+ .extension { height: 300px; }
125
+
126
+
127
+ /* Animation of elements */
128
+
129
+ .container_dl,
130
+ .outputs_dl {
131
+ animation: showedResult 1s;
132
+ }
133
+ .items_dl {
134
+ animation: showedText 1s;
135
+ }
136
+
137
+ @keyframes showedResult {
138
+ 0% {
139
+ transform: translate3d(0, 15%, 0) scale(0.98);
140
+ opacity: 0;
141
+ }
142
+ 100% {
143
+ transform: translate3d(0, 0, 0) scale(1);
144
+ opacity: 1;
145
+ }
146
+ }
147
+
148
+ @keyframes showedText {
149
+ 0% {
150
+ transform: translate3d(-30%, 0, 0);
151
+ opacity: 0;
152
+ }
153
+ 100% {
154
+ transform: translate3d(0, 0, 0);
155
+ opacity: 1;
156
+ }
157
+ }
158
+ </style>
159
+ """
160
+
161
+ display(HTML(CSS))
162
+ # ==================== CSS ====================
163
+
164
+
165
+ # ==================== WIDGETS ====================
166
+ # --- global widgets ---
167
+ HR = widgets.HTML('<hr>')
168
+
169
+ header_widget = widgets.HTML(value='''
170
+ <div class="header_dl">DOWNLOAD RESULTS <span style="color: grey; opacity: 0.25;">| v0.2.5</span></div>
171
+ ''')
172
+
173
+ # Adding content to "outputs_widgets_list"
174
+ def output_container_generator(header, items):
175
+ header_widget = widgets.HTML(value=f'<div class="header_outputs_dl">{header} ➤</div>')
176
+ content = [widgets.HTML(value=f'<div class="items_dl">{item}</div>') for item in items]
177
+ container_widget = widgets.VBox([header_widget] + content).add_class("outputs_dl")
178
+ return container_widget
179
+
180
+ # Models
181
+ models_list = [file for file in os.listdir(models_dir) if not file.endswith('.txt')]
182
+ models_widget = output_container_generator('Models', models_list).add_class("model")
183
+ # Vaes
184
+ vaes_list = [file for file in os.listdir(vaes_dir) if not file.endswith('.txt')]
185
+ vaes_widget = output_container_generator('VAEs', vaes_list).add_class("vae")
186
+ # Embeddings
187
+ embeddings_list = [file for file in os.listdir(embeddings_dir) if not file.endswith('.txt') and not os.path.isdir(os.path.join(embeddings_dir, file))]
188
+ embeddings_widget = output_container_generator('Embeddings', embeddings_list).add_class("embedding")
189
+ # LoRAs
190
+ loras_list = [file for file in os.listdir(loras_dir) if not file.endswith('.txt')]
191
+ loras_widget = output_container_generator('LoRAs', loras_list).add_class("lora")
192
+ # Extensions
193
+ extensions_list = [folder for folder in os.listdir(extensions_dir) if os.path.isdir(os.path.join(extensions_dir, folder))]
194
+ extensions_widget = output_container_generator('Extensions', extensions_list).add_class("extension")
195
+ # ControlNet
196
+ # controlnets_list = [file for file in os.listdir(control_dir) if not file.endswith(('.txt', '.yaml'))]
197
+ filter_name = re.compile(r'^[^_]*_[^_]*_[^_]*_(.*)_fp16\.safetensors$')
198
+ controlnets_list = [
199
+ filter_name.match(file).group(1) if filter_name.match(file) else file
200
+ for file in os.listdir(control_dir)
201
+ if not file.endswith(('.txt', '.yaml'))
202
+ ]
203
+ controlnets_widget = output_container_generator('ControlNets', controlnets_list).add_class("controlnet")
204
+
205
+
206
+ ## Sorting and Output
207
+ widgets_dict = {
208
+ models_widget: models_list,
209
+ vaes_widget: vaes_list,
210
+ embeddings_widget: embeddings_list,
211
+ loras_widget: loras_list,
212
+ extensions_widget: extensions_list,
213
+ controlnets_widget: controlnets_list
214
+ }
215
+ outputs_widgets_list = [widget for widget, widget_list in widgets_dict.items() if widget_list]
216
+ result_output_widget = widgets.HBox(outputs_widgets_list).add_class("result_output_dl")
217
+
218
+ container_widget = widgets.VBox([header_widget, HR, result_output_widget, HR]).add_class("container_dl")
219
+
220
+ display(container_widget)