NagisaNao commited on
Commit
950e7a7
·
verified ·
1 Parent(s): 8cedbb8

minor changes..

Browse files
Files changed (1) hide show
  1. special/dl_display_results.py +29 -26
special/dl_display_results.py CHANGED
@@ -117,9 +117,6 @@ hr {
117
  transition: all 0.15s ease-in-out;
118
  }
119
 
120
- /* setting the height of "outputs" containers */
121
- .outputs_dl { max-height: 400px; }
122
-
123
  /* good use of space */
124
  .extension {
125
  display: grid;
@@ -166,45 +163,52 @@ display(HTML(CSS))
166
 
167
 
168
  # ==================== WIDGETS ====================
169
- # --- global widgets ---
170
  HR = widgets.HTML('<hr>')
171
 
172
  header_widget = widgets.HTML(value='''
173
- <div class="header_dl">DOWNLOAD RESULTS <span style="color: grey; opacity: 0.25;">| v0.2.8</span></div>
174
  ''')
175
 
176
- # Adding content to "outputs_widgets_list"
177
  def output_container_generator(header, items):
178
  header_widget = widgets.HTML(value=f'<div class="header_outputs_dl">{header} ➤</div>')
179
  content = [widgets.HTML(value=f'<div class="items_dl">{item}</div>') for item in items]
180
  container_widget = widgets.VBox([header_widget] + content).add_class("outputs_dl")
181
  return container_widget
182
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
  # Models
184
- models_list = [file for file in os.listdir(models_dir) if file.endswith('.safetensors')]
185
- models_widget = output_container_generator('Models', models_list).add_class("model")
186
  # Vaes
187
- vaes_list = [file for file in os.listdir(vaes_dir) if file.endswith('.safetensors')]
188
- vaes_widget = output_container_generator('VAEs', vaes_list).add_class("vae")
189
  # Embeddings
190
- embeddings_list = [file for file in os.listdir(embeddings_dir) if file.endswith(('.safetensors', '.pt')) and not os.path.isdir(os.path.join(embeddings_dir, file))]
191
- embeddings_widget = output_container_generator('Embeddings', embeddings_list).add_class("embedding")
192
  # LoRAs
193
- # loras_list = [file for file in os.listdir(loras_dir) if not file.endswith('.txt')]
194
- loras_list = [file for file in os.listdir(loras_dir) if file.endswith('.safetensors')]
195
- loras_widget = output_container_generator('LoRAs', loras_list).add_class("lora")
196
  # Extensions
197
- extensions_list = [folder for folder in os.listdir(extensions_dir) if os.path.isdir(os.path.join(extensions_dir, folder))]
198
- extensions_widget = output_container_generator('Extensions', extensions_list).add_class("extension")
199
  # ControlNet
200
- # controlnets_list = [file for file in os.listdir(control_dir) if not file.endswith(('.txt', '.yaml'))]
201
- filter_name = re.compile(r'^[^_]*_[^_]*_[^_]*_(.*)_fp16\.safetensors$')
202
- controlnets_list = [
203
- filter_name.match(file).group(1) if filter_name.match(file) else file
204
- for file in os.listdir(control_dir)
205
- if not file.endswith(('.txt', '.yaml'))
206
- ]
207
- controlnets_widget = output_container_generator('ControlNets', controlnets_list).add_class("controlnet")
208
 
209
 
210
  ## Sorting and Output
@@ -220,5 +224,4 @@ outputs_widgets_list = [widget for widget, widget_list in widgets_dict.items() i
220
  result_output_widget = widgets.HBox(outputs_widgets_list).add_class("result_output_dl")
221
 
222
  container_widget = widgets.VBox([header_widget, HR, result_output_widget, HR]).add_class("container_dl")
223
-
224
  display(container_widget)
 
117
  transition: all 0.15s ease-in-out;
118
  }
119
 
 
 
 
120
  /* good use of space */
121
  .extension {
122
  display: grid;
 
163
 
164
 
165
  # ==================== WIDGETS ====================
 
166
  HR = widgets.HTML('<hr>')
167
 
168
  header_widget = widgets.HTML(value='''
169
+ <div><span class="header_dl">DOWNLOAD RESULTS</span> <span style="color: grey; opacity: 0.25;">| v0.3</span></div>
170
  ''')
171
 
172
+ ## Functions
173
  def output_container_generator(header, items):
174
  header_widget = widgets.HTML(value=f'<div class="header_outputs_dl">{header} ➤</div>')
175
  content = [widgets.HTML(value=f'<div class="items_dl">{item}</div>') for item in items]
176
  container_widget = widgets.VBox([header_widget] + content).add_class("outputs_dl")
177
  return container_widget
178
 
179
+ def get_files_list(directory, extensions, exclude_dirs=()):
180
+ return [file for file in os.listdir(directory) if file.endswith(extensions)]
181
+
182
+ def get_folders_list(directory):
183
+ return [folder for folder in os.listdir(directory)]
184
+
185
+ def get_controlnets_list(directory, filter_pattern):
186
+ filter_name = re.compile(filter_pattern)
187
+ return [
188
+ filter_name.match(file).group(1) if filter_name.match(file) else file
189
+ for file in os.listdir(directory)
190
+ if not file.endswith(('.txt', '.yaml'))
191
+ ]
192
+
193
+
194
  # Models
195
+ models_list = get_files_list(models_dir, '.safetensors')
196
+ models_widget = output_container_generator('Models', models_list)
197
  # Vaes
198
+ vaes_list = get_files_list(vaes_dir, '.safetensors')
199
+ vaes_widget = output_container_generator('VAEs', vaes_list)
200
  # Embeddings
201
+ embeddings_list = get_files_list(embeddings_dir, ('.safetensors', '.pt'))
202
+ embeddings_widget = output_container_generator('Embeddings', embeddings_list)
203
  # LoRAs
204
+ loras_list = get_files_list(loras_dir, '.safetensors')
205
+ loras_widget = output_container_generator('LoRAs', loras_list)
 
206
  # Extensions
207
+ extensions_list = get_folders_list(extensions_dir)
208
+ extensions_widget = output_container_generator('Extensions', extensions_list).add_class("extension") # for fix height
209
  # ControlNet
210
+ controlnets_list = get_controlnets_list(control_dir, r'^[^_]*_[^_]*_[^_]*_(.*)_fp16\.safetensors')
211
+ controlnets_widget = output_container_generator('ControlNets', controlnets_list)
 
 
 
 
 
 
212
 
213
 
214
  ## Sorting and Output
 
224
  result_output_widget = widgets.HBox(outputs_widgets_list).add_class("result_output_dl")
225
 
226
  container_widget = widgets.VBox([header_widget, HR, result_output_widget, HR]).add_class("container_dl")
 
227
  display(container_widget)