Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -46,8 +46,14 @@ def gen_fn(model_str, prompt):
|
|
| 46 |
def make_me():
|
| 47 |
with gr.Row():
|
| 48 |
with gr.Column(scale=1):
|
| 49 |
-
txt_input = gr.Textbox(
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
gen_button = gr.Button('Generate images', elem_id="custom_gen_button")
|
| 52 |
stop_button = gr.Button('Stop', variant='secondary', interactive=False, elem_id="custom_stop_button")
|
| 53 |
|
|
@@ -60,18 +66,53 @@ def make_me():
|
|
| 60 |
gen_button.click(on_generate_click, inputs=None, outputs=[gen_button, stop_button])
|
| 61 |
stop_button.click(on_stop_click, inputs=None, outputs=[gen_button, stop_button])
|
| 62 |
|
|
|
|
| 63 |
with gr.Row():
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
gen_event = gen_button.click(gen_fn, [m, txt_input], o)
|
| 68 |
stop_button.click(on_stop_click, inputs=None, outputs=[gen_button, stop_button], cancels=[gen_event])
|
| 69 |
|
|
|
|
| 70 |
with gr.Accordion('Model selection', elem_id="custom_accordion"):
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
with gr.Row():
|
| 76 |
gr.HTML("")
|
| 77 |
|
|
|
|
| 46 |
def make_me():
|
| 47 |
with gr.Row():
|
| 48 |
with gr.Column(scale=1):
|
| 49 |
+
txt_input = gr.Textbox(
|
| 50 |
+
label='Your prompt:',
|
| 51 |
+
lines=3,
|
| 52 |
+
container=False,
|
| 53 |
+
elem_id="custom_textbox",
|
| 54 |
+
placeholder="Prompt"
|
| 55 |
+
)
|
| 56 |
+
with gr.Row():
|
| 57 |
gen_button = gr.Button('Generate images', elem_id="custom_gen_button")
|
| 58 |
stop_button = gr.Button('Stop', variant='secondary', interactive=False, elem_id="custom_stop_button")
|
| 59 |
|
|
|
|
| 66 |
gen_button.click(on_generate_click, inputs=None, outputs=[gen_button, stop_button])
|
| 67 |
stop_button.click(on_stop_click, inputs=None, outputs=[gen_button, stop_button])
|
| 68 |
|
| 69 |
+
# Делим вывод изображений на два ряда
|
| 70 |
with gr.Row():
|
| 71 |
+
half = len(default_models) // 2
|
| 72 |
+
output_row1 = [gr.Image(label=m, min_width=250, height=250, elem_id="custom_image") for m in default_models[:half]]
|
| 73 |
+
output_row2 = [gr.Image(label=m, min_width=250, height=250, elem_id="custom_image") for m in default_models[half:]]
|
| 74 |
+
current_models_row1 = [gr.Textbox(m, visible=False) for m in default_models[:half]]
|
| 75 |
+
current_models_row2 = [gr.Textbox(m, visible=False) for m in default_models[half:]]
|
| 76 |
+
|
| 77 |
+
# Первый ряд изображений
|
| 78 |
+
for m, o in zip(current_models_row1, output_row1):
|
| 79 |
+
gen_event = gen_button.click(gen_fn, [m, txt_input], o)
|
| 80 |
+
stop_button.click(on_stop_click, inputs=None, outputs=[gen_button, stop_button], cancels=[gen_event])
|
| 81 |
+
|
| 82 |
+
# Второй ряд изображений
|
| 83 |
+
for m, o in zip(current_models_row2, output_row2):
|
| 84 |
gen_event = gen_button.click(gen_fn, [m, txt_input], o)
|
| 85 |
stop_button.click(on_stop_click, inputs=None, outputs=[gen_button, stop_button], cancels=[gen_event])
|
| 86 |
|
| 87 |
+
# Разделяем чекбоксы на два ряда
|
| 88 |
with gr.Accordion('Model selection', elem_id="custom_accordion"):
|
| 89 |
+
half = len(models) // 2
|
| 90 |
+
model_choice_row1 = models[:half]
|
| 91 |
+
model_choice_row2 = models[half:]
|
| 92 |
+
|
| 93 |
+
model_choice1 = gr.CheckboxGroup(
|
| 94 |
+
model_choice_row1,
|
| 95 |
+
label=f'{len(model_choice_row1)} models selected',
|
| 96 |
+
value=default_models[:half],
|
| 97 |
+
interactive=True,
|
| 98 |
+
elem_id="custom_checkbox_group"
|
| 99 |
+
)
|
| 100 |
+
model_choice2 = gr.CheckboxGroup(
|
| 101 |
+
model_choice_row2,
|
| 102 |
+
label=f'{len(model_choice_row2)} models selected',
|
| 103 |
+
value=default_models[half:],
|
| 104 |
+
interactive=True,
|
| 105 |
+
elem_id="custom_checkbox_group"
|
| 106 |
+
)
|
| 107 |
+
|
| 108 |
+
# Обновляем первый ряд
|
| 109 |
+
model_choice1.change(update_imgbox, model_choice1, output_row1)
|
| 110 |
+
model_choice1.change(extend_choices, model_choice1, current_models_row1)
|
| 111 |
+
|
| 112 |
+
# Обновляем второй ряд
|
| 113 |
+
model_choice2.change(update_imgbox, model_choice2, output_row2)
|
| 114 |
+
model_choice2.change(extend_choices, model_choice2, current_models_row2)
|
| 115 |
+
|
| 116 |
with gr.Row():
|
| 117 |
gr.HTML("")
|
| 118 |
|