Update app.py
Browse files
app.py
CHANGED
@@ -1,52 +1,10 @@
|
|
1 |
-
from PIL import Image
|
2 |
import gradio as gr
|
3 |
-
from
|
|
|
|
|
|
|
|
|
4 |
|
5 |
-
import torch
|
6 |
-
import os
|
7 |
-
|
8 |
-
os.environ["CUDA_VISIBLE_DEVICES"] = "" # Отключаем CUDA
|
9 |
-
|
10 |
-
|
11 |
-
device = "cpu" # Используем CPU
|
12 |
-
model_repo_id = "stabilityai/sdxl-turbo"
|
13 |
-
|
14 |
-
torch_dtype = torch.float32 # Тип данных для CPU
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
# Список доступных моделей
|
19 |
-
models = [
|
20 |
-
'stabilityai/stable-diffusion-3.5-large-turbo',
|
21 |
-
'black-forest-labs/FLUX.1-dev',
|
22 |
-
'strangerzonehf/Flux-Isometric-3D-LoRA',
|
23 |
-
'ckpt/kivotos-xl-2.0',
|
24 |
-
'stabilityai/stable-diffusion-3.5-large',
|
25 |
-
'yodayo-ai/clandestine-xl-1.0',
|
26 |
-
'yodayo-ai/kivotos-xl-2.0',
|
27 |
-
'yodayo-ai/holodayo-xl-2.1',
|
28 |
-
'prithivMLmods/SD3.5-Large-Anime-LoRA',
|
29 |
-
'FluffyKaeloky/Midnight-Miqu-103B-v1.5',
|
30 |
-
'cagliostrolab/animagine-xl-3.1',
|
31 |
-
'votepurchase/ponyDiffusionV6XL',
|
32 |
-
'eienmojiki/Anything-XL',
|
33 |
-
'eienmojiki/Starry-XL-v5.2',
|
34 |
-
"digiplay/MilkyWonderland_v1",
|
35 |
-
'Sombressoul/Yi-34B-200K-AWQ',
|
36 |
-
'digiplay/majicMIX_realistic_v7',
|
37 |
-
'votepurchase/counterfeitV30_v30',
|
38 |
-
'Linaqruf/animagine-xl-2.0',
|
39 |
-
'KBlueLeaf/Kohaku-XL-Epsilon-rev3',
|
40 |
-
'KBlueLeaf/Kohaku-XL-Zeta',
|
41 |
-
'kayfahaarukku/UrangDiffusion-1.4',
|
42 |
-
'Eugeoter/artiwaifu-diffusion-2.0',
|
43 |
-
'Raelina/Rae-Diffusion-XL-V2',
|
44 |
-
'Raelina/Raemu-XL-V4',
|
45 |
-
'Jonjew/NSFWMaster',
|
46 |
-
]
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
max_images = 8
|
51 |
MAX_SEED = 2**32-1
|
52 |
load_models(models)
|
@@ -57,10 +15,9 @@ css = """
|
|
57 |
.gallery { min_width=512px; min_height=512px; max_height=1024px; !important; }
|
58 |
"""
|
59 |
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
with gr.Row():
|
64 |
with gr.Column(scale=10):
|
65 |
with gr.Group():
|
66 |
prompt = gr.Text(label="Prompt", lines=2, max_lines=8, placeholder="1girl, solo, ...", show_copy_button=True)
|
@@ -176,179 +133,10 @@ def make_me():
|
|
176 |
|
177 |
|
178 |
|
179 |
-
with gr.Row():
|
180 |
-
gr.HTML("")
|
181 |
-
|
182 |
-
custom_css = """
|
183 |
-
:root {
|
184 |
-
--body-background-fill: #2d3d4f;
|
185 |
-
}
|
186 |
-
|
187 |
-
body {
|
188 |
-
background-color: var(--body-background-fill) !important;
|
189 |
-
color: #2d3d4f;
|
190 |
-
margin: 0;
|
191 |
-
padding: 0;
|
192 |
-
font-family: Arial, sans-serif;
|
193 |
-
height: 100vh;
|
194 |
-
overflow-y: auto;
|
195 |
-
}
|
196 |
-
|
197 |
-
.gradio-container {
|
198 |
-
background-color: #2d3d4f;
|
199 |
-
color: #c5c6c7;
|
200 |
-
padding: 20px;
|
201 |
-
border-radius: 8px;
|
202 |
-
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
203 |
-
width: 100%;
|
204 |
-
max-width: 1200px;
|
205 |
-
margin: 20px auto;
|
206 |
-
display: block;
|
207 |
-
min-height: 100vh;
|
208 |
-
}
|
209 |
-
|
210 |
-
.app_title {
|
211 |
-
background-color: #2d3d4f;
|
212 |
-
color: #c5c6c7;
|
213 |
-
padding: 10px 20px;
|
214 |
-
border-bottom: 1px solid #3b4252;
|
215 |
-
text-align: center;
|
216 |
-
font-size: 24px;
|
217 |
-
font-weight: bold;
|
218 |
-
width: 100%;
|
219 |
-
box-sizing: border-box;
|
220 |
-
margin-bottom: 20px;
|
221 |
-
}
|
222 |
-
|
223 |
-
.custom_textbox {
|
224 |
-
background-color: #2d343f;
|
225 |
-
border: 1px solid #3b4252;
|
226 |
-
color: #7f8184;
|
227 |
-
padding: 10px;
|
228 |
-
border-radius: 4px;
|
229 |
-
margin-bottom: 10px;
|
230 |
-
width: 100%;
|
231 |
-
box-sizing: border-box;
|
232 |
-
}
|
233 |
-
|
234 |
-
.custom_gen_button {
|
235 |
-
background-color: #8b38ff;
|
236 |
-
border: 1px solid #ffffff;
|
237 |
-
color: blue;
|
238 |
-
padding: 15px 32px;
|
239 |
-
text-align: center;
|
240 |
-
text-decoration: none;
|
241 |
-
display: inline-block;
|
242 |
-
font-size: 16px;
|
243 |
-
margin: 4px 2px;
|
244 |
-
cursor: pointer;
|
245 |
-
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
246 |
-
transition: transform 0.2s, box-shadow 0.2s;
|
247 |
-
border-radius: 4px;
|
248 |
-
}
|
249 |
-
.custom_gen_button:hover {
|
250 |
-
transform: translateY(-2px);
|
251 |
-
box-shadow: 0 6px 10px rgba(0, 0, 0, 0.3);
|
252 |
-
}
|
253 |
-
.custom_stop_button {
|
254 |
-
background-color: #6200ea;
|
255 |
-
border: 1px solid #ffffff;
|
256 |
-
color: blue;
|
257 |
-
padding: 15px 32px;
|
258 |
-
text-align: center;
|
259 |
-
text-decoration: none;
|
260 |
-
display: inline-block;
|
261 |
-
font-size: 16px;
|
262 |
-
margin: 4px 2px;
|
263 |
-
cursor: pointer;
|
264 |
-
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
265 |
-
transition: transform 0.2s, box-shadow 0.2s;
|
266 |
-
border-radius: 4px;
|
267 |
-
}
|
268 |
-
.custom_stop_button:hover {
|
269 |
-
transform: translateY(-2px);
|
270 |
-
box-shadow: 0 6px 10px rgba(0, 0, 0, 0.3);
|
271 |
-
}
|
272 |
-
|
273 |
-
.custom_image {
|
274 |
-
border: 1px solid #3b4252;
|
275 |
-
background-color: #2d343f;
|
276 |
-
border-radius: 4px;
|
277 |
-
margin: 10px;
|
278 |
-
max-width: 100%;
|
279 |
-
box-sizing: border-box;
|
280 |
-
}
|
281 |
-
|
282 |
-
.custom_accordion {
|
283 |
-
background-color: #2d3d4f;
|
284 |
-
color: #7f8184;
|
285 |
-
border: 1px solid #3b4252;
|
286 |
-
border-radius: 4px;
|
287 |
-
margin-top: 20px;
|
288 |
-
width: 100%;
|
289 |
-
box-sizing: border-box;
|
290 |
-
transition: margin 0.2s ease;
|
291 |
-
}
|
292 |
-
|
293 |
-
.custom_accordion .gr-accordion-header {
|
294 |
-
background-color: #2d3d4f;
|
295 |
-
color: #7f8184;
|
296 |
-
padding: 10px 20px;
|
297 |
-
border-bottom: 1px solid #5b6270;
|
298 |
-
cursor: pointer;
|
299 |
-
font-size: 18px;
|
300 |
-
font-weight: bold;
|
301 |
-
height: 40px;
|
302 |
-
display: flex;
|
303 |
-
align-items: center;
|
304 |
-
}
|
305 |
-
|
306 |
-
.custom_accordion .gr-accordion-header:hover {
|
307 |
-
background-color: #2d3d4f;
|
308 |
-
}
|
309 |
-
|
310 |
-
.custom_accordion .gr-accordion-content {
|
311 |
-
padding: 10px 20px;
|
312 |
-
background-color: #2d3d4f;
|
313 |
-
border-top: 1px solid #5b6270;
|
314 |
-
max-height: 0;
|
315 |
-
overflow: hidden;
|
316 |
-
transition: max-height 0.2s ease;
|
317 |
-
}
|
318 |
-
|
319 |
-
.custom_accordion .gr-accordion-content.open {
|
320 |
-
max-height: 500px;
|
321 |
-
}
|
322 |
-
|
323 |
-
.custom_checkbox_group {
|
324 |
-
background-color: #2d343f;
|
325 |
-
border: 1px solid #3b4252;
|
326 |
-
color: #7f8184;
|
327 |
-
border-radius: 4px;
|
328 |
-
padding: 10px;
|
329 |
-
width: 100%;
|
330 |
-
box-sizing: border-box;
|
331 |
-
}
|
332 |
-
|
333 |
-
@media (max-width: 768px) {
|
334 |
-
.gradio-container {
|
335 |
-
width: 100%;
|
336 |
-
margin: 0;
|
337 |
-
padding: 10px;
|
338 |
-
}
|
339 |
-
.custom_textbox,.custom_image,.custom_checkbox_group {
|
340 |
-
width: 100%;
|
341 |
-
box-sizing: border-box;
|
342 |
-
}
|
343 |
-
}
|
344 |
-
"""
|
345 |
-
|
346 |
-
with gr.Blocks(css=custom_css) as demo:
|
347 |
-
make_me()
|
348 |
-
# Очередь и запуск интерфейса с параметрами
|
349 |
-
demo.queue(default_concurrency_limit=340, max_size=400)
|
350 |
-
demo.launch(max_threads=400, ssr_mode=False)
|
351 |
|
|
|
|
|
|
|
352 |
|
353 |
demo.queue(concurrency_count=50)
|
354 |
demo.launch()
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from model import models
|
3 |
+
from multit2i import (load_models, infer_fn, infer_rand_fn, save_gallery,
|
4 |
+
change_model, warm_model, get_model_info_md, loaded_models,
|
5 |
+
get_positive_prefix, get_positive_suffix, get_negative_prefix, get_negative_suffix,
|
6 |
+
get_recom_prompt_type, set_recom_prompt_preset, get_tag_type, randomize_seed, translate_to_en)
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
max_images = 8
|
9 |
MAX_SEED = 2**32-1
|
10 |
load_models(models)
|
|
|
15 |
.gallery { min_width=512px; min_height=512px; max_height=1024px; !important; }
|
16 |
"""
|
17 |
|
18 |
+
with gr.Blocks(theme="NoCrypt/miku@>=1.2.2", fill_width=True, css=css) as demo:
|
19 |
+
with gr.Tab("Image Generator"):
|
20 |
+
with gr.Row():
|
|
|
21 |
with gr.Column(scale=10):
|
22 |
with gr.Group():
|
23 |
prompt = gr.Text(label="Prompt", lines=2, max_lines=8, placeholder="1girl, solo, ...", show_copy_button=True)
|
|
|
133 |
|
134 |
|
135 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
|
137 |
+
demo.queue(default_concurrency_limit=240, max_size=240)
|
138 |
+
demo.launch(max_threads=400, ssr_mode=True)
|
139 |
+
# https://github.com/gradio-app/gradio/issues/6339
|
140 |
|
141 |
demo.queue(concurrency_count=50)
|
142 |
demo.launch()
|