Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -384,6 +384,14 @@ def random_seed() -> int:
|
|
| 384 |
"""Генерация случайного seed"""
|
| 385 |
return random.randint(0, 2**32 - 1)
|
| 386 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 387 |
def create_interface():
|
| 388 |
"""Create Gradio interface with current language"""
|
| 389 |
with gr.Blocks(title=get_text("title"), theme=gr.themes.Soft()) as demo:
|
|
@@ -496,17 +504,11 @@ def create_interface():
|
|
| 496 |
)
|
| 497 |
|
| 498 |
# Кликабельные примеры промтов
|
| 499 |
-
gr.Markdown(f"### {get_text('examples_title')}")
|
| 500 |
-
single_examples = gr.
|
| 501 |
-
|
| 502 |
-
|
| 503 |
-
|
| 504 |
-
[get_text("example_3")],
|
| 505 |
-
[get_text("example_4")]
|
| 506 |
-
],
|
| 507 |
-
inputs=[single_prompt],
|
| 508 |
-
label="",
|
| 509 |
-
examples_per_page=4
|
| 510 |
)
|
| 511 |
|
| 512 |
# Вкладка пакетной обработки
|
|
@@ -560,14 +562,8 @@ def create_interface():
|
|
| 560 |
gr.update(label=get_text("prompt"), placeholder=get_text("prompt_placeholder")), # single_prompt
|
| 561 |
gr.update(value=get_text("generate_btn")), # single_submit_btn
|
| 562 |
gr.update(label=get_text("result")), # single_output
|
| 563 |
-
|
| 564 |
-
|
| 565 |
-
[get_text("example_1")],
|
| 566 |
-
[get_text("example_2")],
|
| 567 |
-
[get_text("example_3")],
|
| 568 |
-
[get_text("example_4")]
|
| 569 |
-
]
|
| 570 |
-
), # single_examples
|
| 571 |
gr.update(label=get_text("batch_processing")), # batch_tab
|
| 572 |
gr.update(label=get_text("upload_images")), # batch_images
|
| 573 |
gr.update(label=get_text("prompts_multiline"), placeholder=get_text("prompts_placeholder"), info=get_text("prompts_info")), # batch_prompts
|
|
@@ -594,6 +590,7 @@ def create_interface():
|
|
| 594 |
single_prompt,
|
| 595 |
single_submit_btn,
|
| 596 |
single_output,
|
|
|
|
| 597 |
single_examples,
|
| 598 |
batch_tab,
|
| 599 |
batch_images,
|
|
@@ -603,6 +600,12 @@ def create_interface():
|
|
| 603 |
]
|
| 604 |
)
|
| 605 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 606 |
random_seed_btn.click(
|
| 607 |
fn=random_seed,
|
| 608 |
outputs=seed_number
|
|
|
|
| 384 |
"""Генерация случайного seed"""
|
| 385 |
return random.randint(0, 2**32 - 1)
|
| 386 |
|
| 387 |
+
def update_examples():
|
| 388 |
+
return [
|
| 389 |
+
[get_text("example_1")],
|
| 390 |
+
[get_text("example_2")],
|
| 391 |
+
[get_text("example_3")],
|
| 392 |
+
[get_text("example_4")]
|
| 393 |
+
]
|
| 394 |
+
|
| 395 |
def create_interface():
|
| 396 |
"""Create Gradio interface with current language"""
|
| 397 |
with gr.Blocks(title=get_text("title"), theme=gr.themes.Soft()) as demo:
|
|
|
|
| 504 |
)
|
| 505 |
|
| 506 |
# Кликабельные примеры промтов
|
| 507 |
+
examples_title = gr.Markdown(f"### {get_text('examples_title')}")
|
| 508 |
+
single_examples = gr.Dataset(
|
| 509 |
+
components=[single_prompt],
|
| 510 |
+
samples=update_examples(),
|
| 511 |
+
type="values"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 512 |
)
|
| 513 |
|
| 514 |
# Вкладка пакетной обработки
|
|
|
|
| 562 |
gr.update(label=get_text("prompt"), placeholder=get_text("prompt_placeholder")), # single_prompt
|
| 563 |
gr.update(value=get_text("generate_btn")), # single_submit_btn
|
| 564 |
gr.update(label=get_text("result")), # single_output
|
| 565 |
+
f"### {get_text('examples_title')}", # examples_title
|
| 566 |
+
gr.update(samples=update_examples()), # single_examples
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 567 |
gr.update(label=get_text("batch_processing")), # batch_tab
|
| 568 |
gr.update(label=get_text("upload_images")), # batch_images
|
| 569 |
gr.update(label=get_text("prompts_multiline"), placeholder=get_text("prompts_placeholder"), info=get_text("prompts_info")), # batch_prompts
|
|
|
|
| 590 |
single_prompt,
|
| 591 |
single_submit_btn,
|
| 592 |
single_output,
|
| 593 |
+
examples_title,
|
| 594 |
single_examples,
|
| 595 |
batch_tab,
|
| 596 |
batch_images,
|
|
|
|
| 600 |
]
|
| 601 |
)
|
| 602 |
|
| 603 |
+
single_examples.click(
|
| 604 |
+
fn=lambda x: x[0] if x else "",
|
| 605 |
+
inputs=[single_examples],
|
| 606 |
+
outputs=[single_prompt]
|
| 607 |
+
)
|
| 608 |
+
|
| 609 |
random_seed_btn.click(
|
| 610 |
fn=random_seed,
|
| 611 |
outputs=seed_number
|