Delete special
Browse files- special/dl_display_results.py +0 -230
special/dl_display_results.py
DELETED
|
@@ -1,230 +0,0 @@
|
|
| 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,
|
| 44 |
-
.header_outputs {
|
| 45 |
-
font-family: cursive;
|
| 46 |
-
font-size: 20px;
|
| 47 |
-
font-weight: bold;
|
| 48 |
-
text-align: center;
|
| 49 |
-
}
|
| 50 |
-
.header {
|
| 51 |
-
color: #8b9dc3;
|
| 52 |
-
margin-bottom: 15px;
|
| 53 |
-
}
|
| 54 |
-
.header_outputs {
|
| 55 |
-
color: #0083c0;
|
| 56 |
-
align-self: center;
|
| 57 |
-
}
|
| 58 |
-
|
| 59 |
-
hr {
|
| 60 |
-
border-color: grey;
|
| 61 |
-
background-color: grey;
|
| 62 |
-
opacity: 0.25;
|
| 63 |
-
width: 1000px;
|
| 64 |
-
}
|
| 65 |
-
|
| 66 |
-
/* Element text style */
|
| 67 |
-
.widget-html {
|
| 68 |
-
font-family: cursive;
|
| 69 |
-
font-size: 14px;
|
| 70 |
-
color: white !important;
|
| 71 |
-
user-select: none;
|
| 72 |
-
}
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
/* Container style */
|
| 76 |
-
.container {
|
| 77 |
-
position: relative;
|
| 78 |
-
flex-direction: column;
|
| 79 |
-
justify-content: flex-start;
|
| 80 |
-
align-items: center; /* Center horizontally */
|
| 81 |
-
position: relative;
|
| 82 |
-
background-color: #232323;
|
| 83 |
-
width: 1200px;
|
| 84 |
-
height: auto;
|
| 85 |
-
margin: 40px 10px 10px 10px;
|
| 86 |
-
padding: 10px 15px;
|
| 87 |
-
border-radius: 15px;
|
| 88 |
-
box-shadow: 0 0 50px rgba(0, 0, 0, 0.3), inset 0 0 10px rgba(0, 0, 0, 0.3);
|
| 89 |
-
overflow: visible;
|
| 90 |
-
transition: all 0.5s ease-in-out;
|
| 91 |
-
}
|
| 92 |
-
.container::after {
|
| 93 |
-
position: absolute;
|
| 94 |
-
top: 5px;
|
| 95 |
-
right: 10px;
|
| 96 |
-
content: "ANXETY";
|
| 97 |
-
font-weight: bold;
|
| 98 |
-
font-size: 24px;
|
| 99 |
-
color: rgba(0, 0, 0, 0.2);
|
| 100 |
-
}
|
| 101 |
-
|
| 102 |
-
.result_output {
|
| 103 |
-
flex-direction: row;
|
| 104 |
-
/* align-items: flex-start; */
|
| 105 |
-
flex-wrap: wrap;
|
| 106 |
-
overflow: visible;
|
| 107 |
-
box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.3);
|
| 108 |
-
border-radius: 8px;
|
| 109 |
-
background-color: #1f1f1f;
|
| 110 |
-
width: 95%;
|
| 111 |
-
padding: 10px 15px;
|
| 112 |
-
}
|
| 113 |
-
|
| 114 |
-
.outputs {
|
| 115 |
-
display: flex;
|
| 116 |
-
flex-wrap: wrap;
|
| 117 |
-
background-color: #181818;
|
| 118 |
-
padding: 10px 15px;
|
| 119 |
-
border-radius: 15px;
|
| 120 |
-
box-shadow: 0 0 8px rgba(0, 0, 0, 0.3), inset 0 0 10px rgba(0, 0, 0, 0.3);
|
| 121 |
-
color: #c1c1c1;
|
| 122 |
-
margin: 8px;
|
| 123 |
-
transition: all 0.15s ease;
|
| 124 |
-
flex-grow: 1;
|
| 125 |
-
}
|
| 126 |
-
.outputs:hover {
|
| 127 |
-
transform: scale(1.02);
|
| 128 |
-
background-color: #181718;
|
| 129 |
-
}
|
| 130 |
-
|
| 131 |
-
/* setting the height of "outputs" containers */
|
| 132 |
-
.outputs { max-height: 400px; }
|
| 133 |
-
.extension { height: 300px; }
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
/* Animation of elements */
|
| 137 |
-
|
| 138 |
-
.container,
|
| 139 |
-
.outputs {
|
| 140 |
-
animation-name: showedResult;
|
| 141 |
-
animation-duration: 1s;
|
| 142 |
-
}
|
| 143 |
-
.items {
|
| 144 |
-
animation-name: showedText;
|
| 145 |
-
animation-duration: 1s;
|
| 146 |
-
}
|
| 147 |
-
|
| 148 |
-
@keyframes showedResult {
|
| 149 |
-
0% {
|
| 150 |
-
transform: translate3d(0, 15%, 0) scale(0.98);
|
| 151 |
-
opacity: 0;
|
| 152 |
-
}
|
| 153 |
-
100% {
|
| 154 |
-
transform: translate3d(0, 0, 0) scale(1);
|
| 155 |
-
opacity: 1;
|
| 156 |
-
}
|
| 157 |
-
}
|
| 158 |
-
|
| 159 |
-
@keyframes showedText {
|
| 160 |
-
0% {
|
| 161 |
-
transform: translate3d(-30%, 0, 0);
|
| 162 |
-
opacity: 0;
|
| 163 |
-
}
|
| 164 |
-
100% {
|
| 165 |
-
transform: translate3d(0, 0, 0);
|
| 166 |
-
opacity: 1;
|
| 167 |
-
}
|
| 168 |
-
}
|
| 169 |
-
</style>
|
| 170 |
-
"""
|
| 171 |
-
|
| 172 |
-
display(HTML(CSS))
|
| 173 |
-
# ==================== CSS ====================
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
# ==================== WIDGETS ====================
|
| 177 |
-
# --- global widgets ---
|
| 178 |
-
HR = widgets.HTML('<hr>')
|
| 179 |
-
|
| 180 |
-
header_widget = widgets.HTML(value='<div class="header">DOWNLOAD RESULTS | v0.2<div>')
|
| 181 |
-
|
| 182 |
-
# Adding content to "outputs_widgets_list"
|
| 183 |
-
def output_container_generator(header, items):
|
| 184 |
-
header_widget = widgets.HTML(value=f'<div class="header_outputs">{header} ➤</div>')
|
| 185 |
-
content = [widgets.HTML(value=f'<div class="items">{item}</div>') for item in items]
|
| 186 |
-
container_widget = widgets.VBox([header_widget] + content).add_class("outputs")
|
| 187 |
-
return container_widget
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
# Models
|
| 191 |
-
models_list = [file for file in os.listdir(models_dir) if not file.endswith('.txt')]
|
| 192 |
-
models_widget = output_container_generator('Models', models_list).add_class("model")
|
| 193 |
-
# Vaes
|
| 194 |
-
vaes_list = [file for file in os.listdir(vaes_dir) if not file.endswith('.txt')]
|
| 195 |
-
vaes_widget = output_container_generator('VAEs', vaes_list).add_class("vae")
|
| 196 |
-
# Embeddings
|
| 197 |
-
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))]
|
| 198 |
-
embeddings_widget = output_container_generator('Embeddings', embeddings_list).add_class("embedding")
|
| 199 |
-
# LoRAs
|
| 200 |
-
loras_list = [file for file in os.listdir(loras_dir) if not file.endswith('.txt')]
|
| 201 |
-
loras_widget = output_container_generator('LoRAs', loras_list).add_class("lora")
|
| 202 |
-
# Extensions
|
| 203 |
-
extensions_list = [folder for folder in os.listdir(extensions_dir) if os.path.isdir(os.path.join(extensions_dir, folder))]
|
| 204 |
-
extensions_widget = output_container_generator('Extensions', extensions_list).add_class("extension")
|
| 205 |
-
# ControlNet
|
| 206 |
-
# controlnets_list = [file for file in os.listdir(control_dir) if not file.endswith(('.txt', '.yaml'))]
|
| 207 |
-
filter_name = re.compile(r'^[^_]*_[^_]*_[^_]*_(.*)_fp16\.safetensors$')
|
| 208 |
-
controlnets_list = [
|
| 209 |
-
filter_name.match(file).group(1) if filter_name.match(file) else file
|
| 210 |
-
for file in os.listdir(control_dir)
|
| 211 |
-
if not file.endswith(('.txt', '.yaml'))
|
| 212 |
-
]
|
| 213 |
-
controlnets_widget = output_container_generator('ControlNets', controlnets_list).add_class("controlnet")
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
## Sorting and Output
|
| 217 |
-
widgets_dict = {
|
| 218 |
-
models_widget: models_list,
|
| 219 |
-
vaes_widget: vaes_list,
|
| 220 |
-
embeddings_widget: embeddings_list,
|
| 221 |
-
loras_widget: loras_list,
|
| 222 |
-
extensions_widget: extensions_list,
|
| 223 |
-
controlnets_widget: controlnets_list
|
| 224 |
-
}
|
| 225 |
-
outputs_widgets_list = [widget for widget, widget_list in widgets_dict.items() if widget_list]
|
| 226 |
-
result_output_widget = widgets.HBox(outputs_widgets_list).add_class("result_output")
|
| 227 |
-
|
| 228 |
-
container_widget = widgets.VBox([header_widget, HR, result_output_widget, HR]).add_class("container")
|
| 229 |
-
|
| 230 |
-
display(container_widget)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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