- CSS/auto_cleaner.css +187 -0
- CSS/main_widgets.css +333 -0
- files_cells/notebooks/en/auto_cleaner_en.ipynb +165 -0
- files_cells/notebooks/en/downloading_en.ipynb +94 -112
- files_cells/notebooks/en/widgets_en.ipynb +144 -426
- files_cells/notebooks/ru/auto_cleaner_ru.ipynb +165 -0
- files_cells/notebooks/ru/downloading_ru.ipynb +94 -112
- files_cells/notebooks/ru/widgets_ru.ipynb +144 -426
- files_cells/python/en/auto_cleaner_en.py +138 -0
- files_cells/python/en/downloading_en.py +94 -112
- files_cells/python/en/widgets_en.py +138 -420
- files_cells/python/ru/auto_cleaner_ru.py +138 -0
- files_cells/python/ru/downloading_ru.py +94 -112
- files_cells/python/ru/widgets_ru.py +138 -420
- special/dl_display_results.py +11 -10
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 |
-
"#
|
| 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 |
-
"
|
| 110 |
-
" '
|
| 111 |
-
" '
|
| 112 |
-
" '
|
| 113 |
-
" '
|
| 114 |
" 'ngrok_token', 'zrok_token', 'commandline_arguments',\n",
|
| 115 |
-
" 'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url'
|
|
|
|
| 116 |
"]\n",
|
| 117 |
"\n",
|
| 118 |
-
"locals().update({key: settings.get(key) for key in
|
| 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",
|
|
@@ -339,26 +322,47 @@
|
|
| 339 |
"}\n",
|
| 340 |
"\n",
|
| 341 |
"extension_repo = []\n",
|
| 342 |
-
"directories =
|
| 343 |
"!mkdir -p {\" \".join(directories)}\n",
|
| 344 |
"\n",
|
| 345 |
-
"hf_token =
|
| 346 |
"user_header = f\"\\\"Authorization: Bearer {hf_token}\\\"\"\n",
|
| 347 |
"\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 348 |
"''' Get Image Preview | CivitAi '''\n",
|
| 349 |
"\n",
|
| 350 |
-
"def get_data_from_api(model_id)
|
|
|
|
| 351 |
" endpoint_url = f\"https://civitai.com/api/v1/model-versions/{model_id}\"\n",
|
| 352 |
" headers = {\"Content-Type\": \"application/json\"}\n",
|
| 353 |
" try:\n",
|
| 354 |
" response = requests.get(endpoint_url, headers=headers)\n",
|
| 355 |
-
"
|
| 356 |
-
"
|
| 357 |
" except requests.exceptions.RequestException as e:\n",
|
| 358 |
" print(f\"An error occurred: {e}\")\n",
|
| 359 |
" return None\n",
|
| 360 |
"\n",
|
| 361 |
"def extract_model_info(data, url):\n",
|
|
|
|
| 362 |
" if 'type=' in url:\n",
|
| 363 |
" model_type = parse_qs(urlparse(url).query).get('type', [''])[0]\n",
|
| 364 |
" model_name = data['files'][1]['name']\n",
|
|
@@ -375,59 +379,69 @@
|
|
| 375 |
" return model_type, model_name, image_url\n",
|
| 376 |
"\n",
|
| 377 |
"def gen_preview_filename(model_name, image_url):\n",
|
|
|
|
| 378 |
" name = model_name.split('.')\n",
|
| 379 |
" img_exts = image_url.split('.')\n",
|
| 380 |
-
" return f\"{name[0]}.preview.{img_exts[-1]}\"
|
| 381 |
"\n",
|
| 382 |
"''' main download code '''\n",
|
| 383 |
"\n",
|
| 384 |
"def handle_manual(url):\n",
|
| 385 |
-
"
|
| 386 |
-
"
|
| 387 |
-
"
|
| 388 |
-
" file_name = file_name.group(1) if file_name else None\n",
|
| 389 |
-
" if file_name:\n",
|
| 390 |
-
" url = re.sub(r'\\[.*?\\]', '', url)\n",
|
| 391 |
"\n",
|
| 392 |
-
"
|
| 393 |
-
"
|
| 394 |
-
"
|
| 395 |
-
"
|
| 396 |
-
"
|
| 397 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 398 |
"\n",
|
| 399 |
"def manual_download(url, dst_dir, file_name):\n",
|
| 400 |
" aria2_args = '--optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -j5 -x16 -s16 -k1M -c'\n",
|
| 401 |
" basename = url.split(\"/\")[-1] if file_name is None else file_name\n",
|
| 402 |
" header_option = f\"--header={user_header}\"\n",
|
| 403 |
"\n",
|
| 404 |
-
" #
|
| 405 |
" support_types = ('Checkpoint', 'Model', 'TextualInversion', 'LORA') # for dl preview image\n",
|
| 406 |
" civitai_token = \"62c0c5956b2f9defbd844d754000180b\"\n",
|
| 407 |
"\n",
|
| 408 |
" if 'civitai' in url:\n",
|
| 409 |
-
" url = f\"{url}{'&' if '?' in url else '?'}token={civitai_token}\"
|
| 410 |
-
" model_id = url.split('/')[-1]\n",
|
| 411 |
-
" clean_url =
|
| 412 |
"\n",
|
| 413 |
" data = get_data_from_api(model_id)\n",
|
| 414 |
" if data:\n",
|
| 415 |
" model_type, model_name, image_url = extract_model_info(data, url)\n",
|
| 416 |
-
"
|
| 417 |
-
"
|
| 418 |
-
" if
|
| 419 |
-
"
|
| 420 |
-
"
|
|
|
|
| 421 |
" del cap\n",
|
| 422 |
-
" file_name = file_name or model_name
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 423 |
"\n",
|
| 424 |
-
" \"\"\" information output \"\"\"\n",
|
| 425 |
-
" # -- wrold's best print info --\n",
|
| 426 |
-
" print(f\"\\n\\033[32m{'---'*45}\\n\\033[33mURL: \\033[34m{clean_url if 'civitai' in url else url}\\n\\033[33mSAVE DIR: \\033[34m{dst_dir}\\n\\033[33mFILE NAME: \\033[34m{file_name if not 'huggingface' in url else basename}\\033[0m\")\n",
|
| 427 |
" print(\"\\033[31m[Data Info]:\\033[0m Failed to retrieve data from the API.\\n\") if 'civitai' in url and not data else None\n",
|
| 428 |
-
" if 'civitai' in url and data and any(
|
| 429 |
" print(f\"\\033[32m[Preview DL]:\\033[0m {image_file_name} - {image_url}\\n\")\n",
|
| 430 |
-
" #
|
| 431 |
"\n",
|
| 432 |
" # -- GDrive --\n",
|
| 433 |
" if 'drive.google' in url:\n",
|
|
@@ -471,9 +485,8 @@
|
|
| 471 |
"\n",
|
| 472 |
" unpucking_zip_files()\n",
|
| 473 |
"\n",
|
| 474 |
-
"
|
| 475 |
"def unpucking_zip_files():\n",
|
| 476 |
-
" # directories - above\n",
|
| 477 |
" for directory in directories:\n",
|
| 478 |
" for root, dirs, files in os.walk(directory):\n",
|
| 479 |
" for file in files:\n",
|
|
@@ -486,8 +499,6 @@
|
|
| 486 |
"\n",
|
| 487 |
"''' submodels - added urls '''\n",
|
| 488 |
"\n",
|
| 489 |
-
"submodels = []\n",
|
| 490 |
-
"\n",
|
| 491 |
"def add_submodels(selection, num_selection, model_dict, dst_dir):\n",
|
| 492 |
" if selection == \"none\":\n",
|
| 493 |
" return []\n",
|
|
@@ -499,33 +510,32 @@
|
|
| 499 |
" else:\n",
|
| 500 |
" selected_models = model_dict[selection]\n",
|
| 501 |
" selected_nums = map(int, num_selection.replace(',', '').split())\n",
|
| 502 |
-
"\n",
|
| 503 |
" for num in selected_nums:\n",
|
| 504 |
" if 1 <= num <= len(model_dict):\n",
|
| 505 |
" name = list(model_dict)[num - 1]\n",
|
| 506 |
" selected_models.extend(model_dict[name])\n",
|
| 507 |
"\n",
|
| 508 |
" unique_models = list({model['name']: model for model in selected_models}.values())\n",
|
| 509 |
-
"\n",
|
| 510 |
" for model in unique_models:\n",
|
| 511 |
" model['dst_dir'] = dst_dir\n",
|
| 512 |
"\n",
|
| 513 |
" return unique_models\n",
|
| 514 |
"\n",
|
| 515 |
-
"
|
| 516 |
-
"submodels
|
| 517 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 518 |
"\n",
|
| 519 |
-
"
|
| 520 |
-
"
|
| 521 |
-
"
|
| 522 |
-
" url += f\"{submodel['url']} {submodel['dst_dir']} {submodel['name']}, \"\n",
|
| 523 |
"\n",
|
| 524 |
"''' file.txt - added urls '''\n",
|
| 525 |
"\n",
|
| 526 |
-
"
|
| 527 |
-
"\n",
|
| 528 |
-
"def process_file_download(file_url):\n",
|
| 529 |
" files_urls = \"\"\n",
|
| 530 |
"\n",
|
| 531 |
" if file_url.startswith(\"http\"):\n",
|
|
@@ -539,19 +549,23 @@
|
|
| 539 |
"\n",
|
| 540 |
" current_tag = None\n",
|
| 541 |
" for line in lines:\n",
|
|
|
|
| 542 |
" if any(f'# {tag}' in line.lower() for tag in prefixes):\n",
|
| 543 |
" current_tag = next((tag for tag in prefixes if tag in line.lower()))\n",
|
| 544 |
"\n",
|
| 545 |
" urls = [url.split('#')[0].strip() for url in line.split(',')] # filter urls\n",
|
| 546 |
" for url in urls:\n",
|
| 547 |
-
"
|
|
|
|
|
|
|
| 548 |
" files_urls += f\"{current_tag}:{url}, \"\n",
|
| 549 |
-
" unique_urls.
|
| 550 |
"\n",
|
| 551 |
" return files_urls\n",
|
| 552 |
"\n",
|
| 553 |
-
"# fix all possible errors/options and function call\n",
|
| 554 |
"file_urls = \"\"\n",
|
|
|
|
|
|
|
| 555 |
"if custom_file_urls:\n",
|
| 556 |
" for custom_file_url in custom_file_urls.replace(',', '').split():\n",
|
| 557 |
" if not custom_file_url.endswith('.txt'):\n",
|
|
@@ -561,7 +575,7 @@
|
|
| 561 |
" custom_file_url = f'{root_path}/{custom_file_url}'\n",
|
| 562 |
"\n",
|
| 563 |
" try:\n",
|
| 564 |
-
" file_urls += process_file_download(custom_file_url)\n",
|
| 565 |
" except FileNotFoundError:\n",
|
| 566 |
" pass\n",
|
| 567 |
"\n",
|
|
@@ -604,40 +618,8 @@
|
|
| 604 |
"## List Models and stuff V2\n",
|
| 605 |
"if detailed_download == \"off\":\n",
|
| 606 |
" print(\"\\n\\n\\033[33mIf you don't see any downloaded files, enable the 'Detailed Downloads' feature in the widget.\")\n",
|
| 607 |
-
" get_ipython().run_line_magic('run', '{root_path}/file_cell/special/dl_display_results.py') # display widgets result\n",
|
| 608 |
"\n",
|
| 609 |
-
"
|
| 610 |
-
" if any(not file.endswith('.txt') for file in os.listdir(models_dir)):\n",
|
| 611 |
-
" print(\"\\n\\033[33m➤ Models\\033[0m\")\n",
|
| 612 |
-
" !find {models_dir}/ -mindepth 1 -name '*.safetensors' -printf '%f\\n'\n",
|
| 613 |
-
" if any(not file.endswith('.txt') for file in os.listdir(vaes_dir)):\n",
|
| 614 |
-
" print(\"\\n\\033[33m➤ VAEs\\033[0m\")\n",
|
| 615 |
-
" !find {vaes_dir}/ -mindepth 1 -name '*.safetensors' -printf '%f\\n'\n",
|
| 616 |
-
" 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",
|
| 617 |
-
" print(\"\\n\\033[33m➤ Embeddings\\033[0m\")\n",
|
| 618 |
-
" !find {embeddings_dir}/ -mindepth 1 -maxdepth 1 \\( -name '*.pt' -or -name '*.safetensors' \\) -printf '%f\\n'\n",
|
| 619 |
-
" if any(not file.endswith('.txt') for file in os.listdir(loras_dir)):\n",
|
| 620 |
-
" print(\"\\n\\033[33m➤ LoRAs\\033[0m\")\n",
|
| 621 |
-
" !find {loras_dir}/ -mindepth 1 -name '*.safetensors' -printf '%f\\n'\n",
|
| 622 |
-
" print(f\"\\n\\033[33m➤ Extensions\\033[0m\")\n",
|
| 623 |
-
" !find {extensions_dir}/ -mindepth 1 -maxdepth 1 ! -name '*.txt' -printf '%f\\n'\n",
|
| 624 |
-
" if any(not file.endswith(('.txt', '.yaml')) for file in os.listdir(control_dir)):\n",
|
| 625 |
-
" print(\"\\n\\033[33m➤ ControlNet\\033[0m\")\n",
|
| 626 |
-
" !find {control_dir}/ -mindepth 1 ! -name '*.yaml' -printf '%f\\n' | sed 's/^[^_]*_[^_]*_[^_]*_\\([^_]*\\)_fp16\\.safetensors$/\\1/'\n",
|
| 627 |
-
"\n",
|
| 628 |
-
"\n",
|
| 629 |
-
"# === OTHER ===\n",
|
| 630 |
-
"# Downlaod discord tags UmiWildcards\n",
|
| 631 |
-
"files_umi = [\n",
|
| 632 |
-
" \"https://huggingface.co/NagisaNao/fast_repo/resolve/main/extensions/UmiWildacrd/discord/200_pan_gen.txt\",\n",
|
| 633 |
-
" \"https://huggingface.co/NagisaNao/fast_repo/resolve/main/extensions/UmiWildacrd/discord/150_bra_gen.txt\"\n",
|
| 634 |
-
"]\n",
|
| 635 |
-
"save_dir_path = f\"{webui_path}/extensions/Umi-AI-Wildcards/wildcards/discord\"\n",
|
| 636 |
-
"\n",
|
| 637 |
-
"with capture.capture_output() as cap:\n",
|
| 638 |
-
" for file in files_umi:\n",
|
| 639 |
-
" !aria2c --optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -j5 -x16 -s16 -k1M -c -d {save_dir_path} {file}\n",
|
| 640 |
-
"del cap"
|
| 641 |
]
|
| 642 |
}
|
| 643 |
],
|
|
|
|
| 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",
|
|
|
|
| 322 |
"}\n",
|
| 323 |
"\n",
|
| 324 |
"extension_repo = []\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",
|
| 332 |
+
"\n",
|
| 333 |
+
"from math import floor\n",
|
| 334 |
+
"\n",
|
| 335 |
+
"def center_text(text, terminal_width=45):\n",
|
| 336 |
+
" text_length = len(text)\n",
|
| 337 |
+
" left_padding = floor((terminal_width - text_length) / 2)\n",
|
| 338 |
+
" right_padding = terminal_width - text_length - left_padding\n",
|
| 339 |
+
" return f\"\\033[1m\\033[36m{' ' * left_padding}{text}{' ' * right_padding}\\033[0m\\033[32m\"\n",
|
| 340 |
+
"\n",
|
| 341 |
+
"def format_output(url, dst_dir, file_name):\n",
|
| 342 |
+
" info = f\"[{file_name.split('.')[0]}]\"\n",
|
| 343 |
+
" info = center_text(info)\n",
|
| 344 |
+
"\n",
|
| 345 |
+
" print(f\"\\n\\033[32m{'---'*20}]{info}[{'---'*20}\")\n",
|
| 346 |
+
" print(f\"\\033[33mURL: \\033[34m{url}\")\n",
|
| 347 |
+
" print(f\"\\033[33mSAVE DIR: \\033[34m{dst_dir}\")\n",
|
| 348 |
+
" print(f\"\\033[33mFILE NAME: \\033[34m{file_name}\\033[0m\")\n",
|
| 349 |
+
"\n",
|
| 350 |
"''' Get Image Preview | CivitAi '''\n",
|
| 351 |
"\n",
|
| 352 |
+
"def get_data_from_api(model_id):\n",
|
| 353 |
+
" \"\"\"Fetch model data from the API\"\"\"\n",
|
| 354 |
" endpoint_url = f\"https://civitai.com/api/v1/model-versions/{model_id}\"\n",
|
| 355 |
" headers = {\"Content-Type\": \"application/json\"}\n",
|
| 356 |
" try:\n",
|
| 357 |
" response = requests.get(endpoint_url, headers=headers)\n",
|
| 358 |
+
" response.raise_for_status()\n",
|
| 359 |
+
" return response.json()\n",
|
| 360 |
" except requests.exceptions.RequestException as e:\n",
|
| 361 |
" print(f\"An error occurred: {e}\")\n",
|
| 362 |
" return None\n",
|
| 363 |
"\n",
|
| 364 |
"def extract_model_info(data, url):\n",
|
| 365 |
+
" \"\"\"Extract model information based on URL\"\"\"\n",
|
| 366 |
" if 'type=' in url:\n",
|
| 367 |
" model_type = parse_qs(urlparse(url).query).get('type', [''])[0]\n",
|
| 368 |
" model_name = data['files'][1]['name']\n",
|
|
|
|
| 379 |
" return model_type, model_name, image_url\n",
|
| 380 |
"\n",
|
| 381 |
"def gen_preview_filename(model_name, image_url):\n",
|
| 382 |
+
" \"\"\"Generate a preview filename\"\"\"\n",
|
| 383 |
" name = model_name.split('.')\n",
|
| 384 |
" img_exts = image_url.split('.')\n",
|
| 385 |
+
" return f\"{name[0]}.preview.{img_exts[-1]}\"\n",
|
| 386 |
"\n",
|
| 387 |
"''' main download code '''\n",
|
| 388 |
"\n",
|
| 389 |
"def handle_manual(url):\n",
|
| 390 |
+
" url_parts = url.split(':', 1)\n",
|
| 391 |
+
" prefix = url_parts[0]\n",
|
| 392 |
+
" path = url_parts[1]\n",
|
|
|
|
|
|
|
|
|
|
| 393 |
"\n",
|
| 394 |
+
" file_name_match = re.search(r'\\[(.*?)\\]', path)\n",
|
| 395 |
+
" file_name = file_name_match.group(1) if file_name_match else None\n",
|
| 396 |
+
" if file_name:\n",
|
| 397 |
+
" path = re.sub(r'\\[.*?\\]', '', path)\n",
|
| 398 |
+
"\n",
|
| 399 |
+
" if prefix in prefixes:\n",
|
| 400 |
+
" dir = prefixes[prefix]\n",
|
| 401 |
+
" if prefix != \"extension\":\n",
|
| 402 |
+
" try:\n",
|
| 403 |
+
" manual_download(path, dir, file_name=file_name)\n",
|
| 404 |
+
" except Exception as e:\n",
|
| 405 |
+
" print(f\"Error downloading file: {e}\")\n",
|
| 406 |
+
" else:\n",
|
| 407 |
+
" extension_repo.append((path, file_name))\n",
|
| 408 |
"\n",
|
| 409 |
"def manual_download(url, dst_dir, file_name):\n",
|
| 410 |
" aria2_args = '--optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -j5 -x16 -s16 -k1M -c'\n",
|
| 411 |
" basename = url.split(\"/\")[-1] if file_name is None else file_name\n",
|
| 412 |
" header_option = f\"--header={user_header}\"\n",
|
| 413 |
"\n",
|
| 414 |
+
" # ==== CivitAi API+ ====\n",
|
| 415 |
" support_types = ('Checkpoint', 'Model', 'TextualInversion', 'LORA') # for dl preview image\n",
|
| 416 |
" civitai_token = \"62c0c5956b2f9defbd844d754000180b\"\n",
|
| 417 |
"\n",
|
| 418 |
" if 'civitai' in url:\n",
|
| 419 |
+
" url = f\"{url}{'&' if '?' in url else '?'}token={civitai_token}\"\n",
|
| 420 |
+
" model_id = url.split('/')[-1].split('?')[0]\n",
|
| 421 |
+
" clean_url = re.sub(r'[?&]token=[^&]*', '', url) # hide token\n",
|
| 422 |
"\n",
|
| 423 |
" data = get_data_from_api(model_id)\n",
|
| 424 |
" if data:\n",
|
| 425 |
" model_type, model_name, image_url = extract_model_info(data, url)\n",
|
| 426 |
+
"\n",
|
| 427 |
+
" if any(t in model_type for t in support_types):\n",
|
| 428 |
+
" if model_name and image_url:\n",
|
| 429 |
+
" image_file_name = gen_preview_filename(model_name if not file_name else file_name, image_url)\n",
|
| 430 |
+
" with capture.capture_output() as cap:\n",
|
| 431 |
+
" !aria2c {aria2_args} -d {dst_dir} -o {image_file_name} '{image_url}'\n",
|
| 432 |
" del cap\n",
|
| 433 |
+
" file_name = file_name or model_name\n",
|
| 434 |
+
" else:\n",
|
| 435 |
+
" clean_url = url\n",
|
| 436 |
+
"\n",
|
| 437 |
+
" \"\"\" Formatted info output \"\"\"\n",
|
| 438 |
+
" model_name_or_basename = file_name if not 'huggingface' in url else basename\n",
|
| 439 |
+
" format_output(clean_url or url, dst_dir, model_name_or_basename)\n",
|
| 440 |
"\n",
|
|
|
|
|
|
|
|
|
|
| 441 |
" print(\"\\033[31m[Data Info]:\\033[0m Failed to retrieve data from the API.\\n\") if 'civitai' in url and not data else None\n",
|
| 442 |
+
" if 'civitai' in url and data and any(t in model_type for t in support_types) and (locals().get('image_file_name') or ''):\n",
|
| 443 |
" print(f\"\\033[32m[Preview DL]:\\033[0m {image_file_name} - {image_url}\\n\")\n",
|
| 444 |
+
" # =====================\n",
|
| 445 |
"\n",
|
| 446 |
" # -- GDrive --\n",
|
| 447 |
" if 'drive.google' in url:\n",
|
|
|
|
| 485 |
"\n",
|
| 486 |
" unpucking_zip_files()\n",
|
| 487 |
"\n",
|
| 488 |
+
"# unpucking zip files\n",
|
| 489 |
"def unpucking_zip_files():\n",
|
|
|
|
| 490 |
" for directory in directories:\n",
|
| 491 |
" for root, dirs, files in os.walk(directory):\n",
|
| 492 |
" for file in files:\n",
|
|
|
|
| 499 |
"\n",
|
| 500 |
"''' submodels - added urls '''\n",
|
| 501 |
"\n",
|
|
|
|
|
|
|
| 502 |
"def add_submodels(selection, num_selection, model_dict, dst_dir):\n",
|
| 503 |
" if selection == \"none\":\n",
|
| 504 |
" return []\n",
|
|
|
|
| 510 |
" else:\n",
|
| 511 |
" selected_models = model_dict[selection]\n",
|
| 512 |
" selected_nums = map(int, num_selection.replace(',', '').split())\n",
|
|
|
|
| 513 |
" for num in selected_nums:\n",
|
| 514 |
" if 1 <= num <= len(model_dict):\n",
|
| 515 |
" name = list(model_dict)[num - 1]\n",
|
| 516 |
" selected_models.extend(model_dict[name])\n",
|
| 517 |
"\n",
|
| 518 |
" unique_models = list({model['name']: model for model in selected_models}.values())\n",
|
|
|
|
| 519 |
" for model in unique_models:\n",
|
| 520 |
" model['dst_dir'] = dst_dir\n",
|
| 521 |
"\n",
|
| 522 |
" return unique_models\n",
|
| 523 |
"\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",
|
| 538 |
+
"def process_file_download(file_url, prefixes, unique_urls):\n",
|
|
|
|
|
|
|
| 539 |
" files_urls = \"\"\n",
|
| 540 |
"\n",
|
| 541 |
" if file_url.startswith(\"http\"):\n",
|
|
|
|
| 549 |
"\n",
|
| 550 |
" current_tag = None\n",
|
| 551 |
" for line in lines:\n",
|
| 552 |
+
" line = line.strip()\n",
|
| 553 |
" if any(f'# {tag}' in line.lower() for tag in prefixes):\n",
|
| 554 |
" current_tag = next((tag for tag in prefixes if tag in line.lower()))\n",
|
| 555 |
"\n",
|
| 556 |
" urls = [url.split('#')[0].strip() for url in line.split(',')] # filter urls\n",
|
| 557 |
" for url in urls:\n",
|
| 558 |
+
" filter_url = url.split('[')[0] # same url filter\n",
|
| 559 |
+
"\n",
|
| 560 |
+
" if url.startswith(\"http\") and filter_url not in unique_urls:\n",
|
| 561 |
" files_urls += f\"{current_tag}:{url}, \"\n",
|
| 562 |
+
" unique_urls.add(filter_url)\n",
|
| 563 |
"\n",
|
| 564 |
" return files_urls\n",
|
| 565 |
"\n",
|
|
|
|
| 566 |
"file_urls = \"\"\n",
|
| 567 |
+
"unique_urls = set()\n",
|
| 568 |
+
"\n",
|
| 569 |
"if custom_file_urls:\n",
|
| 570 |
" for custom_file_url in custom_file_urls.replace(',', '').split():\n",
|
| 571 |
" if not custom_file_url.endswith('.txt'):\n",
|
|
|
|
| 575 |
" custom_file_url = f'{root_path}/{custom_file_url}'\n",
|
| 576 |
"\n",
|
| 577 |
" try:\n",
|
| 578 |
+
" file_urls += process_file_download(custom_file_url, prefixes, unique_urls)\n",
|
| 579 |
" except FileNotFoundError:\n",
|
| 580 |
" pass\n",
|
| 581 |
"\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 |
-
"#
|
| 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 |
-
"
|
| 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 |
-
"\
|
| 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 |
-
"
|
| 306 |
-
"
|
| 307 |
-
"
|
| 308 |
-
"
|
| 309 |
-
"
|
| 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 |
-
"
|
| 456 |
-
"
|
| 457 |
"\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 458 |
"\n",
|
| 459 |
-
"
|
| 460 |
-
"
|
| 461 |
-
"
|
| 462 |
-
"
|
|
|
|
| 463 |
"\n",
|
| 464 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 465 |
"\n",
|
| 466 |
"# --- MODEL ---\n",
|
| 467 |
-
"model_header =
|
| 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 |
-
"
|
| 479 |
-
"
|
| 480 |
-
"
|
| 481 |
-
"Inpainting_Model_widget = widgets.Checkbox(value=False, description='Inpainting Models', style=style)\n",
|
| 482 |
"\n",
|
| 483 |
-
"
|
| 484 |
-
"all_model_box =
|
| 485 |
-
"display(all_model_box)\n",
|
| 486 |
"\n",
|
| 487 |
"# --- VAE ---\n",
|
| 488 |
-
"vae_header =
|
| 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 |
-
"
|
| 496 |
-
"
|
| 497 |
"\n",
|
| 498 |
-
"
|
| 499 |
-
"all_vae_box =
|
| 500 |
-
"display(all_vae_box)\n",
|
| 501 |
"\n",
|
| 502 |
"# --- ADDITIONAL ---\n",
|
| 503 |
-
"additional_header =
|
| 504 |
-
"latest_webui_widget =
|
| 505 |
-
"latest_exstensions_widget =
|
| 506 |
-
"change_webui_widget =
|
| 507 |
-
"detailed_download_widget =
|
| 508 |
-
"
|
|
|
|
| 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 |
-
"
|
| 517 |
-
"
|
| 518 |
-
"
|
| 519 |
-
"
|
| 520 |
-
"
|
| 521 |
-
"ngrok_token_widget =
|
| 522 |
-
"ngrock_button =
|
| 523 |
-
"ngrok_widget =
|
| 524 |
-
"
|
| 525 |
-
"
|
| 526 |
-
"
|
| 527 |
-
"
|
|
|
|
| 528 |
"commandline_arguments_options = \"--listen --enable-insecure-extension-access --theme dark --no-half-vae --disable-console-progressbars --xformers\"\n",
|
| 529 |
-
"commandline_arguments_widget =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
"
|
| 537 |
-
"
|
| 538 |
-
"all_additional_box =
|
| 539 |
-
"display(all_additional_box)\n",
|
| 540 |
"\n",
|
| 541 |
"# --- CUSTOM DOWNLOAD ---\n",
|
| 542 |
-
"custom_download_header_popup =
|
| 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 |
-
"
|
| 568 |
-
"Model_url_widget =
|
| 569 |
-
"Vae_url_widget =
|
| 570 |
-
"LoRA_url_widget =
|
| 571 |
-
"Embedding_url_widget =
|
| 572 |
-
"Extensions_url_widget =
|
| 573 |
-
"custom_file_urls_widget =
|
| 574 |
-
"\n",
|
| 575 |
-
"
|
| 576 |
-
"all_custom_box =
|
| 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 |
-
"
|
| 579 |
-
"display(all_custom_box)\n",
|
| 580 |
"\n",
|
| 581 |
"# --- Save Button ---\n",
|
| 582 |
-
"save_button =
|
| 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 |
-
"
|
| 590 |
-
" '
|
| 591 |
-
" '
|
| 592 |
-
" '
|
| 593 |
-
" '
|
| 594 |
" 'ngrok_token', 'zrok_token', 'commandline_arguments',\n",
|
| 595 |
-
" 'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url'
|
|
|
|
| 596 |
"]\n",
|
| 597 |
"\n",
|
| 598 |
"def save_settings():\n",
|
| 599 |
-
" settings = {key: globals()[f\"{key}_widget\"].value for key in
|
| 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
|
| 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 |
-
"
|
| 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 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
"#
|
| 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 |
-
"
|
| 110 |
-
" '
|
| 111 |
-
" '
|
| 112 |
-
" '
|
| 113 |
-
" '
|
| 114 |
" 'ngrok_token', 'zrok_token', 'commandline_arguments',\n",
|
| 115 |
-
" 'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url'
|
|
|
|
| 116 |
"]\n",
|
| 117 |
"\n",
|
| 118 |
-
"locals().update({key: settings.get(key) for key in
|
| 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",
|
|
@@ -339,26 +322,47 @@
|
|
| 339 |
"}\n",
|
| 340 |
"\n",
|
| 341 |
"extension_repo = []\n",
|
| 342 |
-
"directories =
|
| 343 |
"!mkdir -p {\" \".join(directories)}\n",
|
| 344 |
"\n",
|
| 345 |
-
"hf_token =
|
| 346 |
"user_header = f\"\\\"Authorization: Bearer {hf_token}\\\"\"\n",
|
| 347 |
"\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 348 |
"''' Get Image Preview | CivitAi '''\n",
|
| 349 |
"\n",
|
| 350 |
-
"def get_data_from_api(model_id)
|
|
|
|
| 351 |
" endpoint_url = f\"https://civitai.com/api/v1/model-versions/{model_id}\"\n",
|
| 352 |
" headers = {\"Content-Type\": \"application/json\"}\n",
|
| 353 |
" try:\n",
|
| 354 |
" response = requests.get(endpoint_url, headers=headers)\n",
|
| 355 |
-
"
|
| 356 |
-
"
|
| 357 |
" except requests.exceptions.RequestException as e:\n",
|
| 358 |
" print(f\"An error occurred: {e}\")\n",
|
| 359 |
" return None\n",
|
| 360 |
"\n",
|
| 361 |
"def extract_model_info(data, url):\n",
|
|
|
|
| 362 |
" if 'type=' in url:\n",
|
| 363 |
" model_type = parse_qs(urlparse(url).query).get('type', [''])[0]\n",
|
| 364 |
" model_name = data['files'][1]['name']\n",
|
|
@@ -375,59 +379,69 @@
|
|
| 375 |
" return model_type, model_name, image_url\n",
|
| 376 |
"\n",
|
| 377 |
"def gen_preview_filename(model_name, image_url):\n",
|
|
|
|
| 378 |
" name = model_name.split('.')\n",
|
| 379 |
" img_exts = image_url.split('.')\n",
|
| 380 |
-
" return f\"{name[0]}.preview.{img_exts[-1]}\"
|
| 381 |
"\n",
|
| 382 |
"''' main download code '''\n",
|
| 383 |
"\n",
|
| 384 |
"def handle_manual(url):\n",
|
| 385 |
-
"
|
| 386 |
-
"
|
| 387 |
-
"
|
| 388 |
-
" file_name = file_name.group(1) if file_name else None\n",
|
| 389 |
-
" if file_name:\n",
|
| 390 |
-
" url = re.sub(r'\\[.*?\\]', '', url)\n",
|
| 391 |
"\n",
|
| 392 |
-
"
|
| 393 |
-
"
|
| 394 |
-
"
|
| 395 |
-
"
|
| 396 |
-
"
|
| 397 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 398 |
"\n",
|
| 399 |
"def manual_download(url, dst_dir, file_name):\n",
|
| 400 |
" aria2_args = '--optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -j5 -x16 -s16 -k1M -c'\n",
|
| 401 |
" basename = url.split(\"/\")[-1] if file_name is None else file_name\n",
|
| 402 |
" header_option = f\"--header={user_header}\"\n",
|
| 403 |
"\n",
|
| 404 |
-
" #
|
| 405 |
" support_types = ('Checkpoint', 'Model', 'TextualInversion', 'LORA') # for dl preview image\n",
|
| 406 |
" civitai_token = \"62c0c5956b2f9defbd844d754000180b\"\n",
|
| 407 |
"\n",
|
| 408 |
" if 'civitai' in url:\n",
|
| 409 |
-
" url = f\"{url}{'&' if '?' in url else '?'}token={civitai_token}\"
|
| 410 |
-
" model_id = url.split('/')[-1]\n",
|
| 411 |
-
" clean_url =
|
| 412 |
"\n",
|
| 413 |
" data = get_data_from_api(model_id)\n",
|
| 414 |
" if data:\n",
|
| 415 |
" model_type, model_name, image_url = extract_model_info(data, url)\n",
|
| 416 |
-
"
|
| 417 |
-
"
|
| 418 |
-
" if
|
| 419 |
-
"
|
| 420 |
-
"
|
|
|
|
| 421 |
" del cap\n",
|
| 422 |
-
" file_name = file_name or model_name
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 423 |
"\n",
|
| 424 |
-
" \"\"\" information output \"\"\"\n",
|
| 425 |
-
" # -- wrold's best print info --\n",
|
| 426 |
-
" print(f\"\\n\\033[32m{'---'*45}\\n\\033[33mURL: \\033[34m{clean_url if 'civitai' in url else url}\\n\\033[33mSAVE DIR: \\033[34m{dst_dir}\\n\\033[33mFILE NAME: \\033[34m{file_name if not 'huggingface' in url else basename}\\033[0m\")\n",
|
| 427 |
" print(\"\\033[31m[Data Info]:\\033[0m Failed to retrieve data from the API.\\n\") if 'civitai' in url and not data else None\n",
|
| 428 |
-
" if 'civitai' in url and data and any(
|
| 429 |
" print(f\"\\033[32m[Preview DL]:\\033[0m {image_file_name} - {image_url}\\n\")\n",
|
| 430 |
-
" #
|
| 431 |
"\n",
|
| 432 |
" # -- GDrive --\n",
|
| 433 |
" if 'drive.google' in url:\n",
|
|
@@ -471,9 +485,8 @@
|
|
| 471 |
"\n",
|
| 472 |
" unpucking_zip_files()\n",
|
| 473 |
"\n",
|
| 474 |
-
"
|
| 475 |
"def unpucking_zip_files():\n",
|
| 476 |
-
" # directories - above\n",
|
| 477 |
" for directory in directories:\n",
|
| 478 |
" for root, dirs, files in os.walk(directory):\n",
|
| 479 |
" for file in files:\n",
|
|
@@ -486,8 +499,6 @@
|
|
| 486 |
"\n",
|
| 487 |
"''' submodels - added urls '''\n",
|
| 488 |
"\n",
|
| 489 |
-
"submodels = []\n",
|
| 490 |
-
"\n",
|
| 491 |
"def add_submodels(selection, num_selection, model_dict, dst_dir):\n",
|
| 492 |
" if selection == \"none\":\n",
|
| 493 |
" return []\n",
|
|
@@ -499,33 +510,32 @@
|
|
| 499 |
" else:\n",
|
| 500 |
" selected_models = model_dict[selection]\n",
|
| 501 |
" selected_nums = map(int, num_selection.replace(',', '').split())\n",
|
| 502 |
-
"\n",
|
| 503 |
" for num in selected_nums:\n",
|
| 504 |
" if 1 <= num <= len(model_dict):\n",
|
| 505 |
" name = list(model_dict)[num - 1]\n",
|
| 506 |
" selected_models.extend(model_dict[name])\n",
|
| 507 |
"\n",
|
| 508 |
" unique_models = list({model['name']: model for model in selected_models}.values())\n",
|
| 509 |
-
"\n",
|
| 510 |
" for model in unique_models:\n",
|
| 511 |
" model['dst_dir'] = dst_dir\n",
|
| 512 |
"\n",
|
| 513 |
" return unique_models\n",
|
| 514 |
"\n",
|
| 515 |
-
"
|
| 516 |
-
"submodels
|
| 517 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 518 |
"\n",
|
| 519 |
-
"
|
| 520 |
-
"
|
| 521 |
-
"
|
| 522 |
-
" url += f\"{submodel['url']} {submodel['dst_dir']} {submodel['name']}, \"\n",
|
| 523 |
"\n",
|
| 524 |
"''' file.txt - added urls '''\n",
|
| 525 |
"\n",
|
| 526 |
-
"
|
| 527 |
-
"\n",
|
| 528 |
-
"def process_file_download(file_url):\n",
|
| 529 |
" files_urls = \"\"\n",
|
| 530 |
"\n",
|
| 531 |
" if file_url.startswith(\"http\"):\n",
|
|
@@ -539,19 +549,23 @@
|
|
| 539 |
"\n",
|
| 540 |
" current_tag = None\n",
|
| 541 |
" for line in lines:\n",
|
|
|
|
| 542 |
" if any(f'# {tag}' in line.lower() for tag in prefixes):\n",
|
| 543 |
" current_tag = next((tag for tag in prefixes if tag in line.lower()))\n",
|
| 544 |
"\n",
|
| 545 |
" urls = [url.split('#')[0].strip() for url in line.split(',')] # filter urls\n",
|
| 546 |
" for url in urls:\n",
|
| 547 |
-
"
|
|
|
|
|
|
|
| 548 |
" files_urls += f\"{current_tag}:{url}, \"\n",
|
| 549 |
-
" unique_urls.
|
| 550 |
"\n",
|
| 551 |
" return files_urls\n",
|
| 552 |
"\n",
|
| 553 |
-
"# fix all possible errors/options and function call\n",
|
| 554 |
"file_urls = \"\"\n",
|
|
|
|
|
|
|
| 555 |
"if custom_file_urls:\n",
|
| 556 |
" for custom_file_url in custom_file_urls.replace(',', '').split():\n",
|
| 557 |
" if not custom_file_url.endswith('.txt'):\n",
|
|
@@ -561,7 +575,7 @@
|
|
| 561 |
" custom_file_url = f'{root_path}/{custom_file_url}'\n",
|
| 562 |
"\n",
|
| 563 |
" try:\n",
|
| 564 |
-
" file_urls += process_file_download(custom_file_url)\n",
|
| 565 |
" except FileNotFoundError:\n",
|
| 566 |
" pass\n",
|
| 567 |
"\n",
|
|
@@ -604,40 +618,8 @@
|
|
| 604 |
"## List Models and stuff V2\n",
|
| 605 |
"if detailed_download == \"off\":\n",
|
| 606 |
" print(\"\\n\\n\\033[33mЕсли вы не видете каких-то скаченных файлов, включите в виджетах функцию 'Подробная Загрузка'.\")\n",
|
| 607 |
-
" get_ipython().run_line_magic('run', '{root_path}/file_cell/special/dl_display_results.py') # display widgets result\n",
|
| 608 |
"\n",
|
| 609 |
-
"
|
| 610 |
-
" if any(not file.endswith('.txt') for file in os.listdir(models_dir)):\n",
|
| 611 |
-
" print(\"\\n\\033[33m➤ Models\\033[0m\")\n",
|
| 612 |
-
" !find {models_dir}/ -mindepth 1 -name '*.safetensors' -printf '%f\\n'\n",
|
| 613 |
-
" if any(not file.endswith('.txt') for file in os.listdir(vaes_dir)):\n",
|
| 614 |
-
" print(\"\\n\\033[33m➤ VAEs\\033[0m\")\n",
|
| 615 |
-
" !find {vaes_dir}/ -mindepth 1 -name '*.safetensors' -printf '%f\\n'\n",
|
| 616 |
-
" 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",
|
| 617 |
-
" print(\"\\n\\033[33m➤ Embeddings\\033[0m\")\n",
|
| 618 |
-
" !find {embeddings_dir}/ -mindepth 1 -maxdepth 1 \\( -name '*.pt' -or -name '*.safetensors' \\) -printf '%f\\n'\n",
|
| 619 |
-
" if any(not file.endswith('.txt') for file in os.listdir(loras_dir)):\n",
|
| 620 |
-
" print(\"\\n\\033[33m➤ LoRAs\\033[0m\")\n",
|
| 621 |
-
" !find {loras_dir}/ -mindepth 1 -name '*.safetensors' -printf '%f\\n'\n",
|
| 622 |
-
" print(f\"\\n\\033[33m➤ Extensions\\033[0m\")\n",
|
| 623 |
-
" !find {extensions_dir}/ -mindepth 1 -maxdepth 1 ! -name '*.txt' -printf '%f\\n'\n",
|
| 624 |
-
" if any(not file.endswith(('.txt', '.yaml')) for file in os.listdir(control_dir)):\n",
|
| 625 |
-
" print(\"\\n\\033[33m➤ ControlNet\\033[0m\")\n",
|
| 626 |
-
" !find {control_dir}/ -mindepth 1 ! -name '*.yaml' -printf '%f\\n' | sed 's/^[^_]*_[^_]*_[^_]*_\\([^_]*\\)_fp16\\.safetensors$/\\1/'\n",
|
| 627 |
-
"\n",
|
| 628 |
-
"\n",
|
| 629 |
-
"# === OTHER ===\n",
|
| 630 |
-
"# Downlaod discord tags UmiWildcards\n",
|
| 631 |
-
"files_umi = [\n",
|
| 632 |
-
" \"https://huggingface.co/NagisaNao/fast_repo/resolve/main/extensions/UmiWildacrd/discord/200_pan_gen.txt\",\n",
|
| 633 |
-
" \"https://huggingface.co/NagisaNao/fast_repo/resolve/main/extensions/UmiWildacrd/discord/150_bra_gen.txt\"\n",
|
| 634 |
-
"]\n",
|
| 635 |
-
"save_dir_path = f\"{webui_path}/extensions/Umi-AI-Wildcards/wildcards/discord\"\n",
|
| 636 |
-
"\n",
|
| 637 |
-
"with capture.capture_output() as cap:\n",
|
| 638 |
-
" for file in files_umi:\n",
|
| 639 |
-
" !aria2c --optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -j5 -x16 -s16 -k1M -c -d {save_dir_path} {file}\n",
|
| 640 |
-
"del cap"
|
| 641 |
]
|
| 642 |
}
|
| 643 |
],
|
|
|
|
| 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",
|
|
|
|
| 322 |
"}\n",
|
| 323 |
"\n",
|
| 324 |
"extension_repo = []\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",
|
| 332 |
+
"\n",
|
| 333 |
+
"from math import floor\n",
|
| 334 |
+
"\n",
|
| 335 |
+
"def center_text(text, terminal_width=45):\n",
|
| 336 |
+
" text_length = len(text)\n",
|
| 337 |
+
" left_padding = floor((terminal_width - text_length) / 2)\n",
|
| 338 |
+
" right_padding = terminal_width - text_length - left_padding\n",
|
| 339 |
+
" return f\"\\033[1m\\033[36m{' ' * left_padding}{text}{' ' * right_padding}\\033[0m\\033[32m\"\n",
|
| 340 |
+
"\n",
|
| 341 |
+
"def format_output(url, dst_dir, file_name):\n",
|
| 342 |
+
" info = f\"[{file_name.split('.')[0]}]\"\n",
|
| 343 |
+
" info = center_text(info)\n",
|
| 344 |
+
"\n",
|
| 345 |
+
" print(f\"\\n\\033[32m{'---'*20}]{info}[{'---'*20}\")\n",
|
| 346 |
+
" print(f\"\\033[33mURL: \\033[34m{url}\")\n",
|
| 347 |
+
" print(f\"\\033[33mSAVE DIR: \\033[34m{dst_dir}\")\n",
|
| 348 |
+
" print(f\"\\033[33mFILE NAME: \\033[34m{file_name}\\033[0m\")\n",
|
| 349 |
+
"\n",
|
| 350 |
"''' Get Image Preview | CivitAi '''\n",
|
| 351 |
"\n",
|
| 352 |
+
"def get_data_from_api(model_id):\n",
|
| 353 |
+
" \"\"\"Fetch model data from the API\"\"\"\n",
|
| 354 |
" endpoint_url = f\"https://civitai.com/api/v1/model-versions/{model_id}\"\n",
|
| 355 |
" headers = {\"Content-Type\": \"application/json\"}\n",
|
| 356 |
" try:\n",
|
| 357 |
" response = requests.get(endpoint_url, headers=headers)\n",
|
| 358 |
+
" response.raise_for_status()\n",
|
| 359 |
+
" return response.json()\n",
|
| 360 |
" except requests.exceptions.RequestException as e:\n",
|
| 361 |
" print(f\"An error occurred: {e}\")\n",
|
| 362 |
" return None\n",
|
| 363 |
"\n",
|
| 364 |
"def extract_model_info(data, url):\n",
|
| 365 |
+
" \"\"\"Extract model information based on URL\"\"\"\n",
|
| 366 |
" if 'type=' in url:\n",
|
| 367 |
" model_type = parse_qs(urlparse(url).query).get('type', [''])[0]\n",
|
| 368 |
" model_name = data['files'][1]['name']\n",
|
|
|
|
| 379 |
" return model_type, model_name, image_url\n",
|
| 380 |
"\n",
|
| 381 |
"def gen_preview_filename(model_name, image_url):\n",
|
| 382 |
+
" \"\"\"Generate a preview filename\"\"\"\n",
|
| 383 |
" name = model_name.split('.')\n",
|
| 384 |
" img_exts = image_url.split('.')\n",
|
| 385 |
+
" return f\"{name[0]}.preview.{img_exts[-1]}\"\n",
|
| 386 |
"\n",
|
| 387 |
"''' main download code '''\n",
|
| 388 |
"\n",
|
| 389 |
"def handle_manual(url):\n",
|
| 390 |
+
" url_parts = url.split(':', 1)\n",
|
| 391 |
+
" prefix = url_parts[0]\n",
|
| 392 |
+
" path = url_parts[1]\n",
|
|
|
|
|
|
|
|
|
|
| 393 |
"\n",
|
| 394 |
+
" file_name_match = re.search(r'\\[(.*?)\\]', path)\n",
|
| 395 |
+
" file_name = file_name_match.group(1) if file_name_match else None\n",
|
| 396 |
+
" if file_name:\n",
|
| 397 |
+
" path = re.sub(r'\\[.*?\\]', '', path)\n",
|
| 398 |
+
"\n",
|
| 399 |
+
" if prefix in prefixes:\n",
|
| 400 |
+
" dir = prefixes[prefix]\n",
|
| 401 |
+
" if prefix != \"extension\":\n",
|
| 402 |
+
" try:\n",
|
| 403 |
+
" manual_download(path, dir, file_name=file_name)\n",
|
| 404 |
+
" except Exception as e:\n",
|
| 405 |
+
" print(f\"Error downloading file: {e}\")\n",
|
| 406 |
+
" else:\n",
|
| 407 |
+
" extension_repo.append((path, file_name))\n",
|
| 408 |
"\n",
|
| 409 |
"def manual_download(url, dst_dir, file_name):\n",
|
| 410 |
" aria2_args = '--optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -j5 -x16 -s16 -k1M -c'\n",
|
| 411 |
" basename = url.split(\"/\")[-1] if file_name is None else file_name\n",
|
| 412 |
" header_option = f\"--header={user_header}\"\n",
|
| 413 |
"\n",
|
| 414 |
+
" # ==== CivitAi API+ ====\n",
|
| 415 |
" support_types = ('Checkpoint', 'Model', 'TextualInversion', 'LORA') # for dl preview image\n",
|
| 416 |
" civitai_token = \"62c0c5956b2f9defbd844d754000180b\"\n",
|
| 417 |
"\n",
|
| 418 |
" if 'civitai' in url:\n",
|
| 419 |
+
" url = f\"{url}{'&' if '?' in url else '?'}token={civitai_token}\"\n",
|
| 420 |
+
" model_id = url.split('/')[-1].split('?')[0]\n",
|
| 421 |
+
" clean_url = re.sub(r'[?&]token=[^&]*', '', url) # hide token\n",
|
| 422 |
"\n",
|
| 423 |
" data = get_data_from_api(model_id)\n",
|
| 424 |
" if data:\n",
|
| 425 |
" model_type, model_name, image_url = extract_model_info(data, url)\n",
|
| 426 |
+
"\n",
|
| 427 |
+
" if any(t in model_type for t in support_types):\n",
|
| 428 |
+
" if model_name and image_url:\n",
|
| 429 |
+
" image_file_name = gen_preview_filename(model_name if not file_name else file_name, image_url)\n",
|
| 430 |
+
" with capture.capture_output() as cap:\n",
|
| 431 |
+
" !aria2c {aria2_args} -d {dst_dir} -o {image_file_name} '{image_url}'\n",
|
| 432 |
" del cap\n",
|
| 433 |
+
" file_name = file_name or model_name\n",
|
| 434 |
+
" else:\n",
|
| 435 |
+
" clean_url = url\n",
|
| 436 |
+
"\n",
|
| 437 |
+
" \"\"\" Formatted info output \"\"\"\n",
|
| 438 |
+
" model_name_or_basename = file_name if not 'huggingface' in url else basename\n",
|
| 439 |
+
" format_output(clean_url or url, dst_dir, model_name_or_basename)\n",
|
| 440 |
"\n",
|
|
|
|
|
|
|
|
|
|
| 441 |
" print(\"\\033[31m[Data Info]:\\033[0m Failed to retrieve data from the API.\\n\") if 'civitai' in url and not data else None\n",
|
| 442 |
+
" if 'civitai' in url and data and any(t in model_type for t in support_types) and (locals().get('image_file_name') or ''):\n",
|
| 443 |
" print(f\"\\033[32m[Preview DL]:\\033[0m {image_file_name} - {image_url}\\n\")\n",
|
| 444 |
+
" # =====================\n",
|
| 445 |
"\n",
|
| 446 |
" # -- GDrive --\n",
|
| 447 |
" if 'drive.google' in url:\n",
|
|
|
|
| 485 |
"\n",
|
| 486 |
" unpucking_zip_files()\n",
|
| 487 |
"\n",
|
| 488 |
+
"# unpucking zip files\n",
|
| 489 |
"def unpucking_zip_files():\n",
|
|
|
|
| 490 |
" for directory in directories:\n",
|
| 491 |
" for root, dirs, files in os.walk(directory):\n",
|
| 492 |
" for file in files:\n",
|
|
|
|
| 499 |
"\n",
|
| 500 |
"''' submodels - added urls '''\n",
|
| 501 |
"\n",
|
|
|
|
|
|
|
| 502 |
"def add_submodels(selection, num_selection, model_dict, dst_dir):\n",
|
| 503 |
" if selection == \"none\":\n",
|
| 504 |
" return []\n",
|
|
|
|
| 510 |
" else:\n",
|
| 511 |
" selected_models = model_dict[selection]\n",
|
| 512 |
" selected_nums = map(int, num_selection.replace(',', '').split())\n",
|
|
|
|
| 513 |
" for num in selected_nums:\n",
|
| 514 |
" if 1 <= num <= len(model_dict):\n",
|
| 515 |
" name = list(model_dict)[num - 1]\n",
|
| 516 |
" selected_models.extend(model_dict[name])\n",
|
| 517 |
"\n",
|
| 518 |
" unique_models = list({model['name']: model for model in selected_models}.values())\n",
|
|
|
|
| 519 |
" for model in unique_models:\n",
|
| 520 |
" model['dst_dir'] = dst_dir\n",
|
| 521 |
"\n",
|
| 522 |
" return unique_models\n",
|
| 523 |
"\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",
|
| 538 |
+
"def process_file_download(file_url, prefixes, unique_urls):\n",
|
|
|
|
|
|
|
| 539 |
" files_urls = \"\"\n",
|
| 540 |
"\n",
|
| 541 |
" if file_url.startswith(\"http\"):\n",
|
|
|
|
| 549 |
"\n",
|
| 550 |
" current_tag = None\n",
|
| 551 |
" for line in lines:\n",
|
| 552 |
+
" line = line.strip()\n",
|
| 553 |
" if any(f'# {tag}' in line.lower() for tag in prefixes):\n",
|
| 554 |
" current_tag = next((tag for tag in prefixes if tag in line.lower()))\n",
|
| 555 |
"\n",
|
| 556 |
" urls = [url.split('#')[0].strip() for url in line.split(',')] # filter urls\n",
|
| 557 |
" for url in urls:\n",
|
| 558 |
+
" filter_url = url.split('[')[0] # same url filter\n",
|
| 559 |
+
"\n",
|
| 560 |
+
" if url.startswith(\"http\") and filter_url not in unique_urls:\n",
|
| 561 |
" files_urls += f\"{current_tag}:{url}, \"\n",
|
| 562 |
+
" unique_urls.add(filter_url)\n",
|
| 563 |
"\n",
|
| 564 |
" return files_urls\n",
|
| 565 |
"\n",
|
|
|
|
| 566 |
"file_urls = \"\"\n",
|
| 567 |
+
"unique_urls = set()\n",
|
| 568 |
+
"\n",
|
| 569 |
"if custom_file_urls:\n",
|
| 570 |
" for custom_file_url in custom_file_urls.replace(',', '').split():\n",
|
| 571 |
" if not custom_file_url.endswith('.txt'):\n",
|
|
|
|
| 575 |
" custom_file_url = f'{root_path}/{custom_file_url}'\n",
|
| 576 |
"\n",
|
| 577 |
" try:\n",
|
| 578 |
+
" file_urls += process_file_download(custom_file_url, prefixes, unique_urls)\n",
|
| 579 |
" except FileNotFoundError:\n",
|
| 580 |
" pass\n",
|
| 581 |
"\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 |
-
"#
|
| 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 |
-
"
|
| 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 |
-
"\
|
| 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 |
-
"
|
| 306 |
-
"
|
| 307 |
-
"
|
| 308 |
-
"
|
| 309 |
-
"
|
| 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 |
-
"
|
| 456 |
-
"
|
| 457 |
"\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 458 |
"\n",
|
| 459 |
-
"
|
| 460 |
-
"
|
| 461 |
-
"
|
| 462 |
-
"
|
|
|
|
| 463 |
"\n",
|
| 464 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 465 |
"\n",
|
| 466 |
"# --- MODEL ---\n",
|
| 467 |
-
"model_header =
|
| 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 |
-
"
|
| 479 |
-
"
|
| 480 |
-
"
|
| 481 |
-
"Inpainting_Model_widget = widgets.Checkbox(value=False, description='Inpainting Модели', style=style)\n",
|
| 482 |
"\n",
|
| 483 |
-
"
|
| 484 |
-
"all_model_box =
|
| 485 |
-
"display(all_model_box)\n",
|
| 486 |
"\n",
|
| 487 |
"# --- VAE ---\n",
|
| 488 |
-
"vae_header =
|
| 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 |
-
"
|
| 496 |
-
"
|
| 497 |
"\n",
|
| 498 |
-
"
|
| 499 |
-
"all_vae_box =
|
| 500 |
-
"display(all_vae_box)\n",
|
| 501 |
"\n",
|
| 502 |
"# --- ADDITIONAL ---\n",
|
| 503 |
-
"additional_header =
|
| 504 |
-
"latest_webui_widget =
|
| 505 |
-
"latest_exstensions_widget =
|
| 506 |
-
"change_webui_widget =
|
| 507 |
-
"detailed_download_widget =
|
| 508 |
-
"
|
|
|
|
| 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 |
-
"
|
| 517 |
-
"
|
| 518 |
-
"
|
| 519 |
-
"
|
| 520 |
-
"
|
| 521 |
-
"ngrok_token_widget =
|
| 522 |
-
"ngrock_button =
|
| 523 |
-
"ngrok_widget =
|
| 524 |
-
"
|
| 525 |
-
"
|
| 526 |
-
"
|
| 527 |
-
"
|
|
|
|
| 528 |
"commandline_arguments_options = \"--listen --enable-insecure-extension-access --theme dark --no-half-vae --disable-console-progressbars --xformers\"\n",
|
| 529 |
-
"commandline_arguments_widget =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
"
|
| 537 |
-
"
|
| 538 |
-
"all_additional_box =
|
| 539 |
-
"display(all_additional_box)\n",
|
| 540 |
"\n",
|
| 541 |
"# --- CUSTOM DOWNLOAD ---\n",
|
| 542 |
-
"custom_download_header_popup =
|
| 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 |
-
"
|
| 568 |
-
"Model_url_widget =
|
| 569 |
-
"Vae_url_widget =
|
| 570 |
-
"LoRA_url_widget =
|
| 571 |
-
"Embedding_url_widget =
|
| 572 |
-
"Extensions_url_widget =
|
| 573 |
-
"custom_file_urls_widget =
|
| 574 |
-
"\n",
|
| 575 |
-
"
|
| 576 |
-
"all_custom_box =
|
| 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 |
-
"
|
| 579 |
-
"display(all_custom_box)\n",
|
| 580 |
"\n",
|
| 581 |
"# --- Save Button ---\n",
|
| 582 |
-
"save_button =
|
| 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 |
-
"
|
| 590 |
-
" '
|
| 591 |
-
" '
|
| 592 |
-
" '
|
| 593 |
-
" '
|
| 594 |
" 'ngrok_token', 'zrok_token', 'commandline_arguments',\n",
|
| 595 |
-
" 'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url'
|
|
|
|
| 596 |
"]\n",
|
| 597 |
"\n",
|
| 598 |
"def save_settings():\n",
|
| 599 |
-
" settings = {key: globals()[f\"{key}_widget\"].value for key in
|
| 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
|
| 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 |
-
"
|
| 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 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
#
|
| 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 |
-
|
| 100 |
-
'
|
| 101 |
-
'
|
| 102 |
-
'
|
| 103 |
-
'
|
| 104 |
'ngrok_token', 'zrok_token', 'commandline_arguments',
|
| 105 |
-
'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url',
|
|
|
|
| 106 |
]
|
| 107 |
|
| 108 |
-
locals().update({key: settings.get(key) for key in
|
| 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"}],
|
|
@@ -329,26 +312,47 @@ prefixes = {
|
|
| 329 |
}
|
| 330 |
|
| 331 |
extension_repo = []
|
| 332 |
-
directories =
|
| 333 |
get_ipython().system('mkdir -p {" ".join(directories)}')
|
| 334 |
|
| 335 |
-
hf_token =
|
| 336 |
user_header = f"\"Authorization: Bearer {hf_token}\""
|
| 337 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 338 |
''' Get Image Preview | CivitAi '''
|
| 339 |
|
| 340 |
-
def get_data_from_api(model_id):
|
|
|
|
| 341 |
endpoint_url = f"https://civitai.com/api/v1/model-versions/{model_id}"
|
| 342 |
headers = {"Content-Type": "application/json"}
|
| 343 |
try:
|
| 344 |
response = requests.get(endpoint_url, headers=headers)
|
| 345 |
-
|
| 346 |
-
|
| 347 |
except requests.exceptions.RequestException as e:
|
| 348 |
print(f"An error occurred: {e}")
|
| 349 |
return None
|
| 350 |
|
| 351 |
def extract_model_info(data, url):
|
|
|
|
| 352 |
if 'type=' in url:
|
| 353 |
model_type = parse_qs(urlparse(url).query).get('type', [''])[0]
|
| 354 |
model_name = data['files'][1]['name']
|
|
@@ -365,59 +369,69 @@ def extract_model_info(data, url):
|
|
| 365 |
return model_type, model_name, image_url
|
| 366 |
|
| 367 |
def gen_preview_filename(model_name, image_url):
|
|
|
|
| 368 |
name = model_name.split('.')
|
| 369 |
img_exts = image_url.split('.')
|
| 370 |
-
return f"{name[0]}.preview.{img_exts[-1]}"
|
| 371 |
|
| 372 |
''' main download code '''
|
| 373 |
|
| 374 |
def handle_manual(url):
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
file_name = file_name.group(1) if file_name else None
|
| 379 |
-
if file_name:
|
| 380 |
-
url = re.sub(r'\[.*?\]', '', url)
|
| 381 |
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 388 |
|
| 389 |
def manual_download(url, dst_dir, file_name):
|
| 390 |
aria2_args = '--optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -j5 -x16 -s16 -k1M -c'
|
| 391 |
basename = url.split("/")[-1] if file_name is None else file_name
|
| 392 |
header_option = f"--header={user_header}"
|
| 393 |
|
| 394 |
-
#
|
| 395 |
support_types = ('Checkpoint', 'Model', 'TextualInversion', 'LORA') # for dl preview image
|
| 396 |
civitai_token = "62c0c5956b2f9defbd844d754000180b"
|
| 397 |
|
| 398 |
if 'civitai' in url:
|
| 399 |
-
url = f"{url}{'&' if '?' in url else '?'}token={civitai_token}"
|
| 400 |
-
model_id = url.split('/')[-1]
|
| 401 |
-
clean_url =
|
| 402 |
|
| 403 |
data = get_data_from_api(model_id)
|
| 404 |
if data:
|
| 405 |
model_type, model_name, image_url = extract_model_info(data, url)
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
if
|
| 409 |
-
|
| 410 |
-
|
|
|
|
| 411 |
del cap
|
| 412 |
-
file_name = file_name or model_name
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 413 |
|
| 414 |
-
""" information output """
|
| 415 |
-
# -- wrold's best print info --
|
| 416 |
-
print(f"\n\033[32m{'---'*45}\n\033[33mURL: \033[34m{clean_url if 'civitai' in url else url}\n\033[33mSAVE DIR: \033[34m{dst_dir}\n\033[33mFILE NAME: \033[34m{file_name if not 'huggingface' in url else basename}\033[0m")
|
| 417 |
print("\033[31m[Data Info]:\033[0m Failed to retrieve data from the API.\n") if 'civitai' in url and not data else None
|
| 418 |
-
if 'civitai' in url and data and any(
|
| 419 |
print(f"\033[32m[Preview DL]:\033[0m {image_file_name} - {image_url}\n")
|
| 420 |
-
#
|
| 421 |
|
| 422 |
# -- GDrive --
|
| 423 |
if 'drive.google' in url:
|
|
@@ -461,9 +475,8 @@ def download(url):
|
|
| 461 |
|
| 462 |
unpucking_zip_files()
|
| 463 |
|
| 464 |
-
|
| 465 |
def unpucking_zip_files():
|
| 466 |
-
# directories - above
|
| 467 |
for directory in directories:
|
| 468 |
for root, dirs, files in os.walk(directory):
|
| 469 |
for file in files:
|
|
@@ -476,8 +489,6 @@ def unpucking_zip_files():
|
|
| 476 |
|
| 477 |
''' submodels - added urls '''
|
| 478 |
|
| 479 |
-
submodels = []
|
| 480 |
-
|
| 481 |
def add_submodels(selection, num_selection, model_dict, dst_dir):
|
| 482 |
if selection == "none":
|
| 483 |
return []
|
|
@@ -489,33 +500,32 @@ def add_submodels(selection, num_selection, model_dict, dst_dir):
|
|
| 489 |
else:
|
| 490 |
selected_models = model_dict[selection]
|
| 491 |
selected_nums = map(int, num_selection.replace(',', '').split())
|
| 492 |
-
|
| 493 |
for num in selected_nums:
|
| 494 |
if 1 <= num <= len(model_dict):
|
| 495 |
name = list(model_dict)[num - 1]
|
| 496 |
selected_models.extend(model_dict[name])
|
| 497 |
|
| 498 |
unique_models = list({model['name']: model for model in selected_models}.values())
|
| 499 |
-
|
| 500 |
for model in unique_models:
|
| 501 |
model['dst_dir'] = dst_dir
|
| 502 |
|
| 503 |
return unique_models
|
| 504 |
|
| 505 |
-
|
| 506 |
-
submodels
|
| 507 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 508 |
|
| 509 |
-
|
| 510 |
-
|
| 511 |
-
|
| 512 |
-
url += f"{submodel['url']} {submodel['dst_dir']} {submodel['name']}, "
|
| 513 |
|
| 514 |
''' file.txt - added urls '''
|
| 515 |
|
| 516 |
-
|
| 517 |
-
|
| 518 |
-
def process_file_download(file_url):
|
| 519 |
files_urls = ""
|
| 520 |
|
| 521 |
if file_url.startswith("http"):
|
|
@@ -529,19 +539,23 @@ def process_file_download(file_url):
|
|
| 529 |
|
| 530 |
current_tag = None
|
| 531 |
for line in lines:
|
|
|
|
| 532 |
if any(f'# {tag}' in line.lower() for tag in prefixes):
|
| 533 |
current_tag = next((tag for tag in prefixes if tag in line.lower()))
|
| 534 |
|
| 535 |
urls = [url.split('#')[0].strip() for url in line.split(',')] # filter urls
|
| 536 |
for url in urls:
|
| 537 |
-
|
|
|
|
|
|
|
| 538 |
files_urls += f"{current_tag}:{url}, "
|
| 539 |
-
unique_urls.
|
| 540 |
|
| 541 |
return files_urls
|
| 542 |
|
| 543 |
-
# fix all possible errors/options and function call
|
| 544 |
file_urls = ""
|
|
|
|
|
|
|
| 545 |
if custom_file_urls:
|
| 546 |
for custom_file_url in custom_file_urls.replace(',', '').split():
|
| 547 |
if not custom_file_url.endswith('.txt'):
|
|
@@ -551,7 +565,7 @@ if custom_file_urls:
|
|
| 551 |
custom_file_url = f'{root_path}/{custom_file_url}'
|
| 552 |
|
| 553 |
try:
|
| 554 |
-
file_urls += process_file_download(custom_file_url)
|
| 555 |
except FileNotFoundError:
|
| 556 |
pass
|
| 557 |
|
|
@@ -591,38 +605,6 @@ if len(extension_repo) > 0:
|
|
| 591 |
## List Models and stuff V2
|
| 592 |
if detailed_download == "off":
|
| 593 |
print("\n\n\033[33mIf you don't see any downloaded files, enable the 'Detailed Downloads' feature in the widget.")
|
| 594 |
-
get_ipython().run_line_magic('run', '{root_path}/file_cell/special/dl_display_results.py') # display widgets result
|
| 595 |
|
| 596 |
-
|
| 597 |
-
if any(not file.endswith('.txt') for file in os.listdir(models_dir)):
|
| 598 |
-
print("\n\033[33m➤ Models\033[0m")
|
| 599 |
-
get_ipython().system("find {models_dir}/ -mindepth 1 -name '*.safetensors' -printf '%f\\n'")
|
| 600 |
-
if any(not file.endswith('.txt') for file in os.listdir(vaes_dir)):
|
| 601 |
-
print("\n\033[33m➤ VAEs\033[0m")
|
| 602 |
-
get_ipython().system("find {vaes_dir}/ -mindepth 1 -name '*.safetensors' -printf '%f\\n'")
|
| 603 |
-
if any(not file.endswith('.txt') and not os.path.isdir(os.path.join(embeddings_dir, file)) for file in os.listdir(embeddings_dir)):
|
| 604 |
-
print("\n\033[33m➤ Embeddings\033[0m")
|
| 605 |
-
get_ipython().system("find {embeddings_dir}/ -mindepth 1 -maxdepth 1 \\( -name '*.pt' -or -name '*.safetensors' \\) -printf '%f\\n'")
|
| 606 |
-
if any(not file.endswith('.txt') for file in os.listdir(loras_dir)):
|
| 607 |
-
print("\n\033[33m➤ LoRAs\033[0m")
|
| 608 |
-
get_ipython().system("find {loras_dir}/ -mindepth 1 -name '*.safetensors' -printf '%f\\n'")
|
| 609 |
-
print(f"\n\033[33m➤ Extensions\033[0m")
|
| 610 |
-
get_ipython().system("find {extensions_dir}/ -mindepth 1 -maxdepth 1 ! -name '*.txt' -printf '%f\\n'")
|
| 611 |
-
if any(not file.endswith(('.txt', '.yaml')) for file in os.listdir(control_dir)):
|
| 612 |
-
print("\n\033[33m➤ ControlNet\033[0m")
|
| 613 |
-
get_ipython().system("find {control_dir}/ -mindepth 1 ! -name '*.yaml' -printf '%f\\n' | sed 's/^[^_]*_[^_]*_[^_]*_\\([^_]*\\)_fp16\\.safetensors$/\\1/'")
|
| 614 |
-
|
| 615 |
-
|
| 616 |
-
# === OTHER ===
|
| 617 |
-
# Downlaod discord tags UmiWildcards
|
| 618 |
-
files_umi = [
|
| 619 |
-
"https://huggingface.co/NagisaNao/fast_repo/resolve/main/extensions/UmiWildacrd/discord/200_pan_gen.txt",
|
| 620 |
-
"https://huggingface.co/NagisaNao/fast_repo/resolve/main/extensions/UmiWildacrd/discord/150_bra_gen.txt"
|
| 621 |
-
]
|
| 622 |
-
save_dir_path = f"{webui_path}/extensions/Umi-AI-Wildcards/wildcards/discord"
|
| 623 |
-
|
| 624 |
-
with capture.capture_output() as cap:
|
| 625 |
-
for file in files_umi:
|
| 626 |
-
get_ipython().system('aria2c --optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -j5 -x16 -s16 -k1M -c -d {save_dir_path} {file}')
|
| 627 |
-
del cap
|
| 628 |
|
|
|
|
| 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"}],
|
|
|
|
| 312 |
}
|
| 313 |
|
| 314 |
extension_repo = []
|
| 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 '''
|
| 322 |
+
|
| 323 |
+
from math import floor
|
| 324 |
+
|
| 325 |
+
def center_text(text, terminal_width=45):
|
| 326 |
+
text_length = len(text)
|
| 327 |
+
left_padding = floor((terminal_width - text_length) / 2)
|
| 328 |
+
right_padding = terminal_width - text_length - left_padding
|
| 329 |
+
return f"\033[1m\033[36m{' ' * left_padding}{text}{' ' * right_padding}\033[0m\033[32m"
|
| 330 |
+
|
| 331 |
+
def format_output(url, dst_dir, file_name):
|
| 332 |
+
info = f"[{file_name.split('.')[0]}]"
|
| 333 |
+
info = center_text(info)
|
| 334 |
+
|
| 335 |
+
print(f"\n\033[32m{'---'*20}]{info}[{'---'*20}")
|
| 336 |
+
print(f"\033[33mURL: \033[34m{url}")
|
| 337 |
+
print(f"\033[33mSAVE DIR: \033[34m{dst_dir}")
|
| 338 |
+
print(f"\033[33mFILE NAME: \033[34m{file_name}\033[0m")
|
| 339 |
+
|
| 340 |
''' Get Image Preview | CivitAi '''
|
| 341 |
|
| 342 |
+
def get_data_from_api(model_id):
|
| 343 |
+
"""Fetch model data from the API"""
|
| 344 |
endpoint_url = f"https://civitai.com/api/v1/model-versions/{model_id}"
|
| 345 |
headers = {"Content-Type": "application/json"}
|
| 346 |
try:
|
| 347 |
response = requests.get(endpoint_url, headers=headers)
|
| 348 |
+
response.raise_for_status()
|
| 349 |
+
return response.json()
|
| 350 |
except requests.exceptions.RequestException as e:
|
| 351 |
print(f"An error occurred: {e}")
|
| 352 |
return None
|
| 353 |
|
| 354 |
def extract_model_info(data, url):
|
| 355 |
+
"""Extract model information based on URL"""
|
| 356 |
if 'type=' in url:
|
| 357 |
model_type = parse_qs(urlparse(url).query).get('type', [''])[0]
|
| 358 |
model_name = data['files'][1]['name']
|
|
|
|
| 369 |
return model_type, model_name, image_url
|
| 370 |
|
| 371 |
def gen_preview_filename(model_name, image_url):
|
| 372 |
+
"""Generate a preview filename"""
|
| 373 |
name = model_name.split('.')
|
| 374 |
img_exts = image_url.split('.')
|
| 375 |
+
return f"{name[0]}.preview.{img_exts[-1]}"
|
| 376 |
|
| 377 |
''' main download code '''
|
| 378 |
|
| 379 |
def handle_manual(url):
|
| 380 |
+
url_parts = url.split(':', 1)
|
| 381 |
+
prefix = url_parts[0]
|
| 382 |
+
path = url_parts[1]
|
|
|
|
|
|
|
|
|
|
| 383 |
|
| 384 |
+
file_name_match = re.search(r'\[(.*?)\]', path)
|
| 385 |
+
file_name = file_name_match.group(1) if file_name_match else None
|
| 386 |
+
if file_name:
|
| 387 |
+
path = re.sub(r'\[.*?\]', '', path)
|
| 388 |
+
|
| 389 |
+
if prefix in prefixes:
|
| 390 |
+
dir = prefixes[prefix]
|
| 391 |
+
if prefix != "extension":
|
| 392 |
+
try:
|
| 393 |
+
manual_download(path, dir, file_name=file_name)
|
| 394 |
+
except Exception as e:
|
| 395 |
+
print(f"Error downloading file: {e}")
|
| 396 |
+
else:
|
| 397 |
+
extension_repo.append((path, file_name))
|
| 398 |
|
| 399 |
def manual_download(url, dst_dir, file_name):
|
| 400 |
aria2_args = '--optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -j5 -x16 -s16 -k1M -c'
|
| 401 |
basename = url.split("/")[-1] if file_name is None else file_name
|
| 402 |
header_option = f"--header={user_header}"
|
| 403 |
|
| 404 |
+
# ==== CivitAi API+ ====
|
| 405 |
support_types = ('Checkpoint', 'Model', 'TextualInversion', 'LORA') # for dl preview image
|
| 406 |
civitai_token = "62c0c5956b2f9defbd844d754000180b"
|
| 407 |
|
| 408 |
if 'civitai' in url:
|
| 409 |
+
url = f"{url}{'&' if '?' in url else '?'}token={civitai_token}"
|
| 410 |
+
model_id = url.split('/')[-1].split('?')[0]
|
| 411 |
+
clean_url = re.sub(r'[?&]token=[^&]*', '', url) # hide token
|
| 412 |
|
| 413 |
data = get_data_from_api(model_id)
|
| 414 |
if data:
|
| 415 |
model_type, model_name, image_url = extract_model_info(data, url)
|
| 416 |
+
|
| 417 |
+
if any(t in model_type for t in support_types):
|
| 418 |
+
if model_name and image_url:
|
| 419 |
+
image_file_name = gen_preview_filename(model_name if not file_name else file_name, image_url)
|
| 420 |
+
with capture.capture_output() as cap:
|
| 421 |
+
get_ipython().system("aria2c {aria2_args} -d {dst_dir} -o {image_file_name} '{image_url}'")
|
| 422 |
del cap
|
| 423 |
+
file_name = file_name or model_name
|
| 424 |
+
else:
|
| 425 |
+
clean_url = url
|
| 426 |
+
|
| 427 |
+
""" Formatted info output """
|
| 428 |
+
model_name_or_basename = file_name if not 'huggingface' in url else basename
|
| 429 |
+
format_output(clean_url or url, dst_dir, model_name_or_basename)
|
| 430 |
|
|
|
|
|
|
|
|
|
|
| 431 |
print("\033[31m[Data Info]:\033[0m Failed to retrieve data from the API.\n") if 'civitai' in url and not data else None
|
| 432 |
+
if 'civitai' in url and data and any(t in model_type for t in support_types) and (locals().get('image_file_name') or ''):
|
| 433 |
print(f"\033[32m[Preview DL]:\033[0m {image_file_name} - {image_url}\n")
|
| 434 |
+
# =====================
|
| 435 |
|
| 436 |
# -- GDrive --
|
| 437 |
if 'drive.google' in url:
|
|
|
|
| 475 |
|
| 476 |
unpucking_zip_files()
|
| 477 |
|
| 478 |
+
# unpucking zip files
|
| 479 |
def unpucking_zip_files():
|
|
|
|
| 480 |
for directory in directories:
|
| 481 |
for root, dirs, files in os.walk(directory):
|
| 482 |
for file in files:
|
|
|
|
| 489 |
|
| 490 |
''' submodels - added urls '''
|
| 491 |
|
|
|
|
|
|
|
| 492 |
def add_submodels(selection, num_selection, model_dict, dst_dir):
|
| 493 |
if selection == "none":
|
| 494 |
return []
|
|
|
|
| 500 |
else:
|
| 501 |
selected_models = model_dict[selection]
|
| 502 |
selected_nums = map(int, num_selection.replace(',', '').split())
|
|
|
|
| 503 |
for num in selected_nums:
|
| 504 |
if 1 <= num <= len(model_dict):
|
| 505 |
name = list(model_dict)[num - 1]
|
| 506 |
selected_models.extend(model_dict[name])
|
| 507 |
|
| 508 |
unique_models = list({model['name']: model for model in selected_models}.values())
|
|
|
|
| 509 |
for model in unique_models:
|
| 510 |
model['dst_dir'] = dst_dir
|
| 511 |
|
| 512 |
return unique_models
|
| 513 |
|
| 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 |
|
| 528 |
+
def process_file_download(file_url, prefixes, unique_urls):
|
|
|
|
|
|
|
| 529 |
files_urls = ""
|
| 530 |
|
| 531 |
if file_url.startswith("http"):
|
|
|
|
| 539 |
|
| 540 |
current_tag = None
|
| 541 |
for line in lines:
|
| 542 |
+
line = line.strip()
|
| 543 |
if any(f'# {tag}' in line.lower() for tag in prefixes):
|
| 544 |
current_tag = next((tag for tag in prefixes if tag in line.lower()))
|
| 545 |
|
| 546 |
urls = [url.split('#')[0].strip() for url in line.split(',')] # filter urls
|
| 547 |
for url in urls:
|
| 548 |
+
filter_url = url.split('[')[0] # same url filter
|
| 549 |
+
|
| 550 |
+
if url.startswith("http") and filter_url not in unique_urls:
|
| 551 |
files_urls += f"{current_tag}:{url}, "
|
| 552 |
+
unique_urls.add(filter_url)
|
| 553 |
|
| 554 |
return files_urls
|
| 555 |
|
|
|
|
| 556 |
file_urls = ""
|
| 557 |
+
unique_urls = set()
|
| 558 |
+
|
| 559 |
if custom_file_urls:
|
| 560 |
for custom_file_url in custom_file_urls.replace(',', '').split():
|
| 561 |
if not custom_file_url.endswith('.txt'):
|
|
|
|
| 565 |
custom_file_url = f'{root_path}/{custom_file_url}'
|
| 566 |
|
| 567 |
try:
|
| 568 |
+
file_urls += process_file_download(custom_file_url, prefixes, unique_urls)
|
| 569 |
except FileNotFoundError:
|
| 570 |
pass
|
| 571 |
|
|
|
|
| 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 |
-
#
|
| 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 |
-
|
| 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 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 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 |
-
|
| 437 |
-
|
| 438 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 439 |
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
|
|
|
| 444 |
|
| 445 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 446 |
|
| 447 |
# --- MODEL ---
|
| 448 |
-
model_header =
|
| 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 |
-
|
| 461 |
-
|
| 462 |
-
Inpainting_Model_widget = widgets.Checkbox(value=False, description='Inpainting Models', style=style)
|
| 463 |
|
| 464 |
-
|
| 465 |
-
all_model_box =
|
| 466 |
-
display(all_model_box)
|
| 467 |
|
| 468 |
# --- VAE ---
|
| 469 |
-
vae_header =
|
| 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 |
-
|
| 477 |
-
|
| 478 |
|
| 479 |
-
|
| 480 |
-
all_vae_box =
|
| 481 |
-
display(all_vae_box)
|
| 482 |
|
| 483 |
# --- ADDITIONAL ---
|
| 484 |
-
additional_header =
|
| 485 |
-
latest_webui_widget =
|
| 486 |
-
latest_exstensions_widget =
|
| 487 |
-
change_webui_widget =
|
| 488 |
-
detailed_download_widget =
|
| 489 |
-
|
|
|
|
| 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 |
-
|
| 499 |
-
|
| 500 |
-
|
| 501 |
-
|
| 502 |
-
ngrok_token_widget =
|
| 503 |
-
ngrock_button =
|
| 504 |
-
ngrok_widget =
|
| 505 |
-
|
| 506 |
-
|
| 507 |
-
|
| 508 |
-
|
|
|
|
| 509 |
commandline_arguments_options = "--listen --enable-insecure-extension-access --theme dark --no-half-vae --disable-console-progressbars --xformers"
|
| 510 |
-
commandline_arguments_widget =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
| 518 |
-
|
| 519 |
-
all_additional_box =
|
| 520 |
-
display(all_additional_box)
|
| 521 |
|
| 522 |
# --- CUSTOM DOWNLOAD ---
|
| 523 |
-
custom_download_header_popup =
|
| 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 =
|
| 550 |
-
Vae_url_widget =
|
| 551 |
-
LoRA_url_widget =
|
| 552 |
-
Embedding_url_widget =
|
| 553 |
-
Extensions_url_widget =
|
| 554 |
-
custom_file_urls_widget =
|
| 555 |
-
|
| 556 |
-
|
| 557 |
-
all_custom_box =
|
| 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 |
-
|
| 560 |
-
display(all_custom_box)
|
| 561 |
|
| 562 |
# --- Save Button ---
|
| 563 |
-
save_button =
|
| 564 |
-
display(save_button)
|
| 565 |
|
| 566 |
|
| 567 |
# ============ Load / Save - Settings V2 ============
|
| 568 |
SETTINGS_FILE = f'{root_path}/settings.json'
|
| 569 |
|
| 570 |
-
|
| 571 |
-
'
|
| 572 |
-
'
|
| 573 |
-
'
|
| 574 |
-
'
|
| 575 |
'ngrok_token', 'zrok_token', 'commandline_arguments',
|
| 576 |
-
'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url',
|
|
|
|
| 577 |
]
|
| 578 |
|
| 579 |
def save_settings():
|
| 580 |
-
settings = {key: globals()[f"{key}_widget"].value for key in
|
| 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
|
| 589 |
-
globals()[f"{key}_widget"].value = settings.get(key)
|
| 590 |
|
| 591 |
-
def
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
#
|
| 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 |
-
|
| 100 |
-
'
|
| 101 |
-
'
|
| 102 |
-
'
|
| 103 |
-
'
|
| 104 |
'ngrok_token', 'zrok_token', 'commandline_arguments',
|
| 105 |
-
'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url',
|
|
|
|
| 106 |
]
|
| 107 |
|
| 108 |
-
locals().update({key: settings.get(key) for key in
|
| 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"}],
|
|
@@ -329,26 +312,47 @@ prefixes = {
|
|
| 329 |
}
|
| 330 |
|
| 331 |
extension_repo = []
|
| 332 |
-
directories =
|
| 333 |
get_ipython().system('mkdir -p {" ".join(directories)}')
|
| 334 |
|
| 335 |
-
hf_token =
|
| 336 |
user_header = f"\"Authorization: Bearer {hf_token}\""
|
| 337 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 338 |
''' Get Image Preview | CivitAi '''
|
| 339 |
|
| 340 |
-
def get_data_from_api(model_id):
|
|
|
|
| 341 |
endpoint_url = f"https://civitai.com/api/v1/model-versions/{model_id}"
|
| 342 |
headers = {"Content-Type": "application/json"}
|
| 343 |
try:
|
| 344 |
response = requests.get(endpoint_url, headers=headers)
|
| 345 |
-
|
| 346 |
-
|
| 347 |
except requests.exceptions.RequestException as e:
|
| 348 |
print(f"An error occurred: {e}")
|
| 349 |
return None
|
| 350 |
|
| 351 |
def extract_model_info(data, url):
|
|
|
|
| 352 |
if 'type=' in url:
|
| 353 |
model_type = parse_qs(urlparse(url).query).get('type', [''])[0]
|
| 354 |
model_name = data['files'][1]['name']
|
|
@@ -365,59 +369,69 @@ def extract_model_info(data, url):
|
|
| 365 |
return model_type, model_name, image_url
|
| 366 |
|
| 367 |
def gen_preview_filename(model_name, image_url):
|
|
|
|
| 368 |
name = model_name.split('.')
|
| 369 |
img_exts = image_url.split('.')
|
| 370 |
-
return f"{name[0]}.preview.{img_exts[-1]}"
|
| 371 |
|
| 372 |
''' main download code '''
|
| 373 |
|
| 374 |
def handle_manual(url):
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
file_name = file_name.group(1) if file_name else None
|
| 379 |
-
if file_name:
|
| 380 |
-
url = re.sub(r'\[.*?\]', '', url)
|
| 381 |
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 388 |
|
| 389 |
def manual_download(url, dst_dir, file_name):
|
| 390 |
aria2_args = '--optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -j5 -x16 -s16 -k1M -c'
|
| 391 |
basename = url.split("/")[-1] if file_name is None else file_name
|
| 392 |
header_option = f"--header={user_header}"
|
| 393 |
|
| 394 |
-
#
|
| 395 |
support_types = ('Checkpoint', 'Model', 'TextualInversion', 'LORA') # for dl preview image
|
| 396 |
civitai_token = "62c0c5956b2f9defbd844d754000180b"
|
| 397 |
|
| 398 |
if 'civitai' in url:
|
| 399 |
-
url = f"{url}{'&' if '?' in url else '?'}token={civitai_token}"
|
| 400 |
-
model_id = url.split('/')[-1]
|
| 401 |
-
clean_url =
|
| 402 |
|
| 403 |
data = get_data_from_api(model_id)
|
| 404 |
if data:
|
| 405 |
model_type, model_name, image_url = extract_model_info(data, url)
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
if
|
| 409 |
-
|
| 410 |
-
|
|
|
|
| 411 |
del cap
|
| 412 |
-
file_name = file_name or model_name
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 413 |
|
| 414 |
-
""" information output """
|
| 415 |
-
# -- wrold's best print info --
|
| 416 |
-
print(f"\n\033[32m{'---'*45}\n\033[33mURL: \033[34m{clean_url if 'civitai' in url else url}\n\033[33mSAVE DIR: \033[34m{dst_dir}\n\033[33mFILE NAME: \033[34m{file_name if not 'huggingface' in url else basename}\033[0m")
|
| 417 |
print("\033[31m[Data Info]:\033[0m Failed to retrieve data from the API.\n") if 'civitai' in url and not data else None
|
| 418 |
-
if 'civitai' in url and data and any(
|
| 419 |
print(f"\033[32m[Preview DL]:\033[0m {image_file_name} - {image_url}\n")
|
| 420 |
-
#
|
| 421 |
|
| 422 |
# -- GDrive --
|
| 423 |
if 'drive.google' in url:
|
|
@@ -461,9 +475,8 @@ def download(url):
|
|
| 461 |
|
| 462 |
unpucking_zip_files()
|
| 463 |
|
| 464 |
-
|
| 465 |
def unpucking_zip_files():
|
| 466 |
-
# directories - above
|
| 467 |
for directory in directories:
|
| 468 |
for root, dirs, files in os.walk(directory):
|
| 469 |
for file in files:
|
|
@@ -476,8 +489,6 @@ def unpucking_zip_files():
|
|
| 476 |
|
| 477 |
''' submodels - added urls '''
|
| 478 |
|
| 479 |
-
submodels = []
|
| 480 |
-
|
| 481 |
def add_submodels(selection, num_selection, model_dict, dst_dir):
|
| 482 |
if selection == "none":
|
| 483 |
return []
|
|
@@ -489,33 +500,32 @@ def add_submodels(selection, num_selection, model_dict, dst_dir):
|
|
| 489 |
else:
|
| 490 |
selected_models = model_dict[selection]
|
| 491 |
selected_nums = map(int, num_selection.replace(',', '').split())
|
| 492 |
-
|
| 493 |
for num in selected_nums:
|
| 494 |
if 1 <= num <= len(model_dict):
|
| 495 |
name = list(model_dict)[num - 1]
|
| 496 |
selected_models.extend(model_dict[name])
|
| 497 |
|
| 498 |
unique_models = list({model['name']: model for model in selected_models}.values())
|
| 499 |
-
|
| 500 |
for model in unique_models:
|
| 501 |
model['dst_dir'] = dst_dir
|
| 502 |
|
| 503 |
return unique_models
|
| 504 |
|
| 505 |
-
|
| 506 |
-
submodels
|
| 507 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 508 |
|
| 509 |
-
|
| 510 |
-
|
| 511 |
-
|
| 512 |
-
url += f"{submodel['url']} {submodel['dst_dir']} {submodel['name']}, "
|
| 513 |
|
| 514 |
''' file.txt - added urls '''
|
| 515 |
|
| 516 |
-
|
| 517 |
-
|
| 518 |
-
def process_file_download(file_url):
|
| 519 |
files_urls = ""
|
| 520 |
|
| 521 |
if file_url.startswith("http"):
|
|
@@ -529,19 +539,23 @@ def process_file_download(file_url):
|
|
| 529 |
|
| 530 |
current_tag = None
|
| 531 |
for line in lines:
|
|
|
|
| 532 |
if any(f'# {tag}' in line.lower() for tag in prefixes):
|
| 533 |
current_tag = next((tag for tag in prefixes if tag in line.lower()))
|
| 534 |
|
| 535 |
urls = [url.split('#')[0].strip() for url in line.split(',')] # filter urls
|
| 536 |
for url in urls:
|
| 537 |
-
|
|
|
|
|
|
|
| 538 |
files_urls += f"{current_tag}:{url}, "
|
| 539 |
-
unique_urls.
|
| 540 |
|
| 541 |
return files_urls
|
| 542 |
|
| 543 |
-
# fix all possible errors/options and function call
|
| 544 |
file_urls = ""
|
|
|
|
|
|
|
| 545 |
if custom_file_urls:
|
| 546 |
for custom_file_url in custom_file_urls.replace(',', '').split():
|
| 547 |
if not custom_file_url.endswith('.txt'):
|
|
@@ -551,7 +565,7 @@ if custom_file_urls:
|
|
| 551 |
custom_file_url = f'{root_path}/{custom_file_url}'
|
| 552 |
|
| 553 |
try:
|
| 554 |
-
file_urls += process_file_download(custom_file_url)
|
| 555 |
except FileNotFoundError:
|
| 556 |
pass
|
| 557 |
|
|
@@ -591,38 +605,6 @@ if len(extension_repo) > 0:
|
|
| 591 |
## List Models and stuff V2
|
| 592 |
if detailed_download == "off":
|
| 593 |
print("\n\n\033[33mЕсли вы не видете каких-то скаченных файлов, включите в виджетах функцию 'Подробная Загрузка'.")
|
| 594 |
-
get_ipython().run_line_magic('run', '{root_path}/file_cell/special/dl_display_results.py') # display widgets result
|
| 595 |
|
| 596 |
-
|
| 597 |
-
if any(not file.endswith('.txt') for file in os.listdir(models_dir)):
|
| 598 |
-
print("\n\033[33m➤ Models\033[0m")
|
| 599 |
-
get_ipython().system("find {models_dir}/ -mindepth 1 -name '*.safetensors' -printf '%f\\n'")
|
| 600 |
-
if any(not file.endswith('.txt') for file in os.listdir(vaes_dir)):
|
| 601 |
-
print("\n\033[33m➤ VAEs\033[0m")
|
| 602 |
-
get_ipython().system("find {vaes_dir}/ -mindepth 1 -name '*.safetensors' -printf '%f\\n'")
|
| 603 |
-
if any(not file.endswith('.txt') and not os.path.isdir(os.path.join(embeddings_dir, file)) for file in os.listdir(embeddings_dir)):
|
| 604 |
-
print("\n\033[33m➤ Embeddings\033[0m")
|
| 605 |
-
get_ipython().system("find {embeddings_dir}/ -mindepth 1 -maxdepth 1 \\( -name '*.pt' -or -name '*.safetensors' \\) -printf '%f\\n'")
|
| 606 |
-
if any(not file.endswith('.txt') for file in os.listdir(loras_dir)):
|
| 607 |
-
print("\n\033[33m➤ LoRAs\033[0m")
|
| 608 |
-
get_ipython().system("find {loras_dir}/ -mindepth 1 -name '*.safetensors' -printf '%f\\n'")
|
| 609 |
-
print(f"\n\033[33m➤ Extensions\033[0m")
|
| 610 |
-
get_ipython().system("find {extensions_dir}/ -mindepth 1 -maxdepth 1 ! -name '*.txt' -printf '%f\\n'")
|
| 611 |
-
if any(not file.endswith(('.txt', '.yaml')) for file in os.listdir(control_dir)):
|
| 612 |
-
print("\n\033[33m➤ ControlNet\033[0m")
|
| 613 |
-
get_ipython().system("find {control_dir}/ -mindepth 1 ! -name '*.yaml' -printf '%f\\n' | sed 's/^[^_]*_[^_]*_[^_]*_\\([^_]*\\)_fp16\\.safetensors$/\\1/'")
|
| 614 |
-
|
| 615 |
-
|
| 616 |
-
# === OTHER ===
|
| 617 |
-
# Downlaod discord tags UmiWildcards
|
| 618 |
-
files_umi = [
|
| 619 |
-
"https://huggingface.co/NagisaNao/fast_repo/resolve/main/extensions/UmiWildacrd/discord/200_pan_gen.txt",
|
| 620 |
-
"https://huggingface.co/NagisaNao/fast_repo/resolve/main/extensions/UmiWildacrd/discord/150_bra_gen.txt"
|
| 621 |
-
]
|
| 622 |
-
save_dir_path = f"{webui_path}/extensions/Umi-AI-Wildcards/wildcards/discord"
|
| 623 |
-
|
| 624 |
-
with capture.capture_output() as cap:
|
| 625 |
-
for file in files_umi:
|
| 626 |
-
get_ipython().system('aria2c --optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -j5 -x16 -s16 -k1M -c -d {save_dir_path} {file}')
|
| 627 |
-
del cap
|
| 628 |
|
|
|
|
| 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"}],
|
|
|
|
| 312 |
}
|
| 313 |
|
| 314 |
extension_repo = []
|
| 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 '''
|
| 322 |
+
|
| 323 |
+
from math import floor
|
| 324 |
+
|
| 325 |
+
def center_text(text, terminal_width=45):
|
| 326 |
+
text_length = len(text)
|
| 327 |
+
left_padding = floor((terminal_width - text_length) / 2)
|
| 328 |
+
right_padding = terminal_width - text_length - left_padding
|
| 329 |
+
return f"\033[1m\033[36m{' ' * left_padding}{text}{' ' * right_padding}\033[0m\033[32m"
|
| 330 |
+
|
| 331 |
+
def format_output(url, dst_dir, file_name):
|
| 332 |
+
info = f"[{file_name.split('.')[0]}]"
|
| 333 |
+
info = center_text(info)
|
| 334 |
+
|
| 335 |
+
print(f"\n\033[32m{'---'*20}]{info}[{'---'*20}")
|
| 336 |
+
print(f"\033[33mURL: \033[34m{url}")
|
| 337 |
+
print(f"\033[33mSAVE DIR: \033[34m{dst_dir}")
|
| 338 |
+
print(f"\033[33mFILE NAME: \033[34m{file_name}\033[0m")
|
| 339 |
+
|
| 340 |
''' Get Image Preview | CivitAi '''
|
| 341 |
|
| 342 |
+
def get_data_from_api(model_id):
|
| 343 |
+
"""Fetch model data from the API"""
|
| 344 |
endpoint_url = f"https://civitai.com/api/v1/model-versions/{model_id}"
|
| 345 |
headers = {"Content-Type": "application/json"}
|
| 346 |
try:
|
| 347 |
response = requests.get(endpoint_url, headers=headers)
|
| 348 |
+
response.raise_for_status()
|
| 349 |
+
return response.json()
|
| 350 |
except requests.exceptions.RequestException as e:
|
| 351 |
print(f"An error occurred: {e}")
|
| 352 |
return None
|
| 353 |
|
| 354 |
def extract_model_info(data, url):
|
| 355 |
+
"""Extract model information based on URL"""
|
| 356 |
if 'type=' in url:
|
| 357 |
model_type = parse_qs(urlparse(url).query).get('type', [''])[0]
|
| 358 |
model_name = data['files'][1]['name']
|
|
|
|
| 369 |
return model_type, model_name, image_url
|
| 370 |
|
| 371 |
def gen_preview_filename(model_name, image_url):
|
| 372 |
+
"""Generate a preview filename"""
|
| 373 |
name = model_name.split('.')
|
| 374 |
img_exts = image_url.split('.')
|
| 375 |
+
return f"{name[0]}.preview.{img_exts[-1]}"
|
| 376 |
|
| 377 |
''' main download code '''
|
| 378 |
|
| 379 |
def handle_manual(url):
|
| 380 |
+
url_parts = url.split(':', 1)
|
| 381 |
+
prefix = url_parts[0]
|
| 382 |
+
path = url_parts[1]
|
|
|
|
|
|
|
|
|
|
| 383 |
|
| 384 |
+
file_name_match = re.search(r'\[(.*?)\]', path)
|
| 385 |
+
file_name = file_name_match.group(1) if file_name_match else None
|
| 386 |
+
if file_name:
|
| 387 |
+
path = re.sub(r'\[.*?\]', '', path)
|
| 388 |
+
|
| 389 |
+
if prefix in prefixes:
|
| 390 |
+
dir = prefixes[prefix]
|
| 391 |
+
if prefix != "extension":
|
| 392 |
+
try:
|
| 393 |
+
manual_download(path, dir, file_name=file_name)
|
| 394 |
+
except Exception as e:
|
| 395 |
+
print(f"Error downloading file: {e}")
|
| 396 |
+
else:
|
| 397 |
+
extension_repo.append((path, file_name))
|
| 398 |
|
| 399 |
def manual_download(url, dst_dir, file_name):
|
| 400 |
aria2_args = '--optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -j5 -x16 -s16 -k1M -c'
|
| 401 |
basename = url.split("/")[-1] if file_name is None else file_name
|
| 402 |
header_option = f"--header={user_header}"
|
| 403 |
|
| 404 |
+
# ==== CivitAi API+ ====
|
| 405 |
support_types = ('Checkpoint', 'Model', 'TextualInversion', 'LORA') # for dl preview image
|
| 406 |
civitai_token = "62c0c5956b2f9defbd844d754000180b"
|
| 407 |
|
| 408 |
if 'civitai' in url:
|
| 409 |
+
url = f"{url}{'&' if '?' in url else '?'}token={civitai_token}"
|
| 410 |
+
model_id = url.split('/')[-1].split('?')[0]
|
| 411 |
+
clean_url = re.sub(r'[?&]token=[^&]*', '', url) # hide token
|
| 412 |
|
| 413 |
data = get_data_from_api(model_id)
|
| 414 |
if data:
|
| 415 |
model_type, model_name, image_url = extract_model_info(data, url)
|
| 416 |
+
|
| 417 |
+
if any(t in model_type for t in support_types):
|
| 418 |
+
if model_name and image_url:
|
| 419 |
+
image_file_name = gen_preview_filename(model_name if not file_name else file_name, image_url)
|
| 420 |
+
with capture.capture_output() as cap:
|
| 421 |
+
get_ipython().system("aria2c {aria2_args} -d {dst_dir} -o {image_file_name} '{image_url}'")
|
| 422 |
del cap
|
| 423 |
+
file_name = file_name or model_name
|
| 424 |
+
else:
|
| 425 |
+
clean_url = url
|
| 426 |
+
|
| 427 |
+
""" Formatted info output """
|
| 428 |
+
model_name_or_basename = file_name if not 'huggingface' in url else basename
|
| 429 |
+
format_output(clean_url or url, dst_dir, model_name_or_basename)
|
| 430 |
|
|
|
|
|
|
|
|
|
|
| 431 |
print("\033[31m[Data Info]:\033[0m Failed to retrieve data from the API.\n") if 'civitai' in url and not data else None
|
| 432 |
+
if 'civitai' in url and data and any(t in model_type for t in support_types) and (locals().get('image_file_name') or ''):
|
| 433 |
print(f"\033[32m[Preview DL]:\033[0m {image_file_name} - {image_url}\n")
|
| 434 |
+
# =====================
|
| 435 |
|
| 436 |
# -- GDrive --
|
| 437 |
if 'drive.google' in url:
|
|
|
|
| 475 |
|
| 476 |
unpucking_zip_files()
|
| 477 |
|
| 478 |
+
# unpucking zip files
|
| 479 |
def unpucking_zip_files():
|
|
|
|
| 480 |
for directory in directories:
|
| 481 |
for root, dirs, files in os.walk(directory):
|
| 482 |
for file in files:
|
|
|
|
| 489 |
|
| 490 |
''' submodels - added urls '''
|
| 491 |
|
|
|
|
|
|
|
| 492 |
def add_submodels(selection, num_selection, model_dict, dst_dir):
|
| 493 |
if selection == "none":
|
| 494 |
return []
|
|
|
|
| 500 |
else:
|
| 501 |
selected_models = model_dict[selection]
|
| 502 |
selected_nums = map(int, num_selection.replace(',', '').split())
|
|
|
|
| 503 |
for num in selected_nums:
|
| 504 |
if 1 <= num <= len(model_dict):
|
| 505 |
name = list(model_dict)[num - 1]
|
| 506 |
selected_models.extend(model_dict[name])
|
| 507 |
|
| 508 |
unique_models = list({model['name']: model for model in selected_models}.values())
|
|
|
|
| 509 |
for model in unique_models:
|
| 510 |
model['dst_dir'] = dst_dir
|
| 511 |
|
| 512 |
return unique_models
|
| 513 |
|
| 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 |
|
| 528 |
+
def process_file_download(file_url, prefixes, unique_urls):
|
|
|
|
|
|
|
| 529 |
files_urls = ""
|
| 530 |
|
| 531 |
if file_url.startswith("http"):
|
|
|
|
| 539 |
|
| 540 |
current_tag = None
|
| 541 |
for line in lines:
|
| 542 |
+
line = line.strip()
|
| 543 |
if any(f'# {tag}' in line.lower() for tag in prefixes):
|
| 544 |
current_tag = next((tag for tag in prefixes if tag in line.lower()))
|
| 545 |
|
| 546 |
urls = [url.split('#')[0].strip() for url in line.split(',')] # filter urls
|
| 547 |
for url in urls:
|
| 548 |
+
filter_url = url.split('[')[0] # same url filter
|
| 549 |
+
|
| 550 |
+
if url.startswith("http") and filter_url not in unique_urls:
|
| 551 |
files_urls += f"{current_tag}:{url}, "
|
| 552 |
+
unique_urls.add(filter_url)
|
| 553 |
|
| 554 |
return files_urls
|
| 555 |
|
|
|
|
| 556 |
file_urls = ""
|
| 557 |
+
unique_urls = set()
|
| 558 |
+
|
| 559 |
if custom_file_urls:
|
| 560 |
for custom_file_url in custom_file_urls.replace(',', '').split():
|
| 561 |
if not custom_file_url.endswith('.txt'):
|
|
|
|
| 565 |
custom_file_url = f'{root_path}/{custom_file_url}'
|
| 566 |
|
| 567 |
try:
|
| 568 |
+
file_urls += process_file_download(custom_file_url, prefixes, unique_urls)
|
| 569 |
except FileNotFoundError:
|
| 570 |
pass
|
| 571 |
|
|
|
|
| 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 |
-
#
|
| 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 |
-
|
| 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 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 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 |
-
|
| 437 |
-
|
| 438 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 439 |
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
|
|
|
| 444 |
|
| 445 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 446 |
|
| 447 |
# --- MODEL ---
|
| 448 |
-
model_header =
|
| 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 |
-
|
| 461 |
-
|
| 462 |
-
Inpainting_Model_widget = widgets.Checkbox(value=False, description='Inpainting Модели', style=style)
|
| 463 |
|
| 464 |
-
|
| 465 |
-
all_model_box =
|
| 466 |
-
display(all_model_box)
|
| 467 |
|
| 468 |
# --- VAE ---
|
| 469 |
-
vae_header =
|
| 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 |
-
|
| 477 |
-
|
| 478 |
|
| 479 |
-
|
| 480 |
-
all_vae_box =
|
| 481 |
-
display(all_vae_box)
|
| 482 |
|
| 483 |
# --- ADDITIONAL ---
|
| 484 |
-
additional_header =
|
| 485 |
-
latest_webui_widget =
|
| 486 |
-
latest_exstensions_widget =
|
| 487 |
-
change_webui_widget =
|
| 488 |
-
detailed_download_widget =
|
| 489 |
-
|
|
|
|
| 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 |
-
|
| 499 |
-
|
| 500 |
-
|
| 501 |
-
|
| 502 |
-
ngrok_token_widget =
|
| 503 |
-
ngrock_button =
|
| 504 |
-
ngrok_widget =
|
| 505 |
-
|
| 506 |
-
|
| 507 |
-
|
| 508 |
-
|
|
|
|
| 509 |
commandline_arguments_options = "--listen --enable-insecure-extension-access --theme dark --no-half-vae --disable-console-progressbars --xformers"
|
| 510 |
-
commandline_arguments_widget =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
| 518 |
-
|
| 519 |
-
all_additional_box =
|
| 520 |
-
display(all_additional_box)
|
| 521 |
|
| 522 |
# --- CUSTOM DOWNLOAD ---
|
| 523 |
-
custom_download_header_popup =
|
| 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 =
|
| 550 |
-
Vae_url_widget =
|
| 551 |
-
LoRA_url_widget =
|
| 552 |
-
Embedding_url_widget =
|
| 553 |
-
Extensions_url_widget =
|
| 554 |
-
custom_file_urls_widget =
|
| 555 |
-
|
| 556 |
-
|
| 557 |
-
all_custom_box =
|
| 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 |
-
|
| 560 |
-
display(all_custom_box)
|
| 561 |
|
| 562 |
# --- Save Button ---
|
| 563 |
-
save_button =
|
| 564 |
-
display(save_button)
|
| 565 |
|
| 566 |
|
| 567 |
# ============ Load / Save - Settings V2 ============
|
| 568 |
SETTINGS_FILE = f'{root_path}/settings.json'
|
| 569 |
|
| 570 |
-
|
| 571 |
-
'
|
| 572 |
-
'
|
| 573 |
-
'
|
| 574 |
-
'
|
| 575 |
'ngrok_token', 'zrok_token', 'commandline_arguments',
|
| 576 |
-
'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url',
|
|
|
|
| 577 |
]
|
| 578 |
|
| 579 |
def save_settings():
|
| 580 |
-
settings = {key: globals()[f"{key}_widget"].value for key in
|
| 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
|
| 589 |
-
globals()[f"{key}_widget"].value = settings.get(key)
|
| 590 |
|
| 591 |
-
def
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
CHANGED
|
@@ -33,7 +33,6 @@ 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 ====================
|
|
@@ -163,24 +162,23 @@ display(HTML(CSS))
|
|
| 163 |
|
| 164 |
|
| 165 |
# ==================== WIDGETS ====================
|
|
|
|
| 166 |
HR = widgets.HTML('<hr>')
|
| 167 |
-
|
| 168 |
-
|
| 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 |
-
|
| 176 |
-
container_widget = widgets.VBox([header_widget]
|
| 177 |
return container_widget
|
| 178 |
|
| 179 |
-
def get_files_list(directory, extensions
|
| 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(
|
| 184 |
|
| 185 |
def get_controlnets_list(directory, filter_pattern):
|
| 186 |
filter_name = re.compile(filter_pattern)
|
|
@@ -190,6 +188,10 @@ def get_controlnets_list(directory, filter_pattern):
|
|
| 190 |
if not file.endswith(('.txt', '.yaml'))
|
| 191 |
]
|
| 192 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 193 |
|
| 194 |
# Models
|
| 195 |
models_list = get_files_list(models_dir, '.safetensors')
|
|
@@ -210,7 +212,6 @@ extensions_widget = output_container_generator('Extensions', extensions_list).ad
|
|
| 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
|
| 215 |
widgets_dict = {
|
| 216 |
models_widget: models_list,
|
|
|
|
| 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 ====================
|
|
|
|
| 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)
|
|
|
|
| 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')
|
|
|
|
| 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,
|