Update app.py
Browse files
app.py
CHANGED
|
@@ -26,30 +26,30 @@ def gen_fn(model_str, prompt):
|
|
| 26 |
return models_load[model_str](f'{prompt} {noise}')
|
| 27 |
|
| 28 |
def make_me():
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
with gr.Row():
|
| 30 |
txt_input = gr.Textbox(label='Your prompt:', lines=3)
|
| 31 |
|
| 32 |
gen_button = gr.Button('Generate images')
|
| 33 |
stop_button = gr.Button('Stop', variant='secondary', interactive=False)
|
| 34 |
-
gen_button.click(lambda s: gr.update(interactive=True),
|
| 35 |
-
gr.
|
| 36 |
-
|
| 37 |
-
<body>
|
| 38 |
-
</body>
|
| 39 |
-
</div>
|
| 40 |
-
""")
|
| 41 |
with gr.Row():
|
| 42 |
-
# Define default_models before using it
|
| 43 |
-
default_models = ['model1', 'model2'] # Example values
|
| 44 |
output = [gr.Image(label=m, min_width=250, height=250) for m in default_models]
|
| 45 |
current_models = [gr.Textbox(m, visible=False) for m in default_models]
|
| 46 |
for m, o in zip(current_models, output):
|
| 47 |
gen_event = gen_button.click(gen_fn, [m, txt_input], o)
|
| 48 |
-
stop_button.click(lambda s: gr.update(interactive=False),
|
|
|
|
| 49 |
with gr.Accordion('Model selection'):
|
| 50 |
-
model_choice = gr.CheckboxGroup(models, label=f'
|
| 51 |
model_choice.change(update_imgbox, model_choice, output)
|
| 52 |
model_choice.change(extend_choices, model_choice, current_models)
|
|
|
|
| 53 |
with gr.Row():
|
| 54 |
gr.HTML()
|
| 55 |
|
|
|
|
| 26 |
return models_load[model_str](f'{prompt} {noise}')
|
| 27 |
|
| 28 |
def make_me():
|
| 29 |
+
# Define default_models and num_models before using them
|
| 30 |
+
default_models = ['model1', 'model2'] # Example values
|
| 31 |
+
num_models = len(models) # Assuming models is a list of available models
|
| 32 |
+
|
| 33 |
with gr.Row():
|
| 34 |
txt_input = gr.Textbox(label='Your prompt:', lines=3)
|
| 35 |
|
| 36 |
gen_button = gr.Button('Generate images')
|
| 37 |
stop_button = gr.Button('Stop', variant='secondary', interactive=False)
|
| 38 |
+
gen_button.click(lambda s: gr.update(interactive=True), [stop_button], stop_button)
|
| 39 |
+
stop_button.click(lambda s: gr.update(interactive=False), [stop_button], stop_button)
|
| 40 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
with gr.Row():
|
|
|
|
|
|
|
| 42 |
output = [gr.Image(label=m, min_width=250, height=250) for m in default_models]
|
| 43 |
current_models = [gr.Textbox(m, visible=False) for m in default_models]
|
| 44 |
for m, o in zip(current_models, output):
|
| 45 |
gen_event = gen_button.click(gen_fn, [m, txt_input], o)
|
| 46 |
+
stop_button.click(lambda s: gr.update(interactive=False), [stop_button], stop_button, cancels=[gen_event])
|
| 47 |
+
|
| 48 |
with gr.Accordion('Model selection'):
|
| 49 |
+
model_choice = gr.CheckboxGroup(models, label=f'{num_models} different models selected', value=default_models, multiselect=True, max_choices=num_models, interactive=True, filterable=False)
|
| 50 |
model_choice.change(update_imgbox, model_choice, output)
|
| 51 |
model_choice.change(extend_choices, model_choice, current_models)
|
| 52 |
+
|
| 53 |
with gr.Row():
|
| 54 |
gr.HTML()
|
| 55 |
|