Update app.py
Browse files
app.py
CHANGED
|
@@ -5,6 +5,7 @@ from datetime import datetime
|
|
| 5 |
|
| 6 |
now2 = 0
|
| 7 |
|
|
|
|
| 8 |
def get_current_time():
|
| 9 |
now = datetime.now()
|
| 10 |
now2 = now
|
|
@@ -25,41 +26,41 @@ def gen_fn(model_str, prompt):
|
|
| 25 |
noise = str(randint(0, 9999))
|
| 26 |
return models_load[model_str](f'{prompt} {noise}')
|
| 27 |
|
| 28 |
-
def extend_choices(choices):
|
| 29 |
-
return choices
|
| 30 |
-
|
| 31 |
def make_me():
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
with gr.Row():
|
| 36 |
-
txt_input = gr.Textbox(label='Your prompt:', lines=3)
|
| 37 |
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
-
with gr.Row():
|
| 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), [stop_button], stop_button, cancels=[gen_event])
|
| 49 |
|
| 50 |
-
with gr.Accordion('Model selection'):
|
| 51 |
-
model_choice = gr.CheckboxGroup(models, label=f'{num_models} different models selected', value=default_models, interactive=True)
|
| 52 |
-
model_choice.change(update_imgbox, model_choice, output)
|
| 53 |
-
model_choice.change(extend_choices, model_choice, current_models)
|
| 54 |
-
|
| 55 |
-
with gr.Row():
|
| 56 |
-
gr.HTML()
|
| 57 |
|
| 58 |
js_code = """
|
| 59 |
-
|
|
|
|
|
|
|
| 60 |
"""
|
| 61 |
|
| 62 |
-
with gr.Blocks(css="div.float.svelte-1mwvhlq {
|
| 63 |
gr.Markdown("<script>" + js_code + "</script>")
|
| 64 |
make_me()
|
| 65 |
|
|
|
|
| 5 |
|
| 6 |
now2 = 0
|
| 7 |
|
| 8 |
+
|
| 9 |
def get_current_time():
|
| 10 |
now = datetime.now()
|
| 11 |
now2 = now
|
|
|
|
| 26 |
noise = str(randint(0, 9999))
|
| 27 |
return models_load[model_str](f'{prompt} {noise}')
|
| 28 |
|
|
|
|
|
|
|
|
|
|
| 29 |
def make_me():
|
| 30 |
+
with gr.Row():
|
| 31 |
+
txt_input = gr.Textbox(label='Your prompt:', lines=3, width=800, max_height=100)
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
+
gen_button = gr.Button('Generate images', width=30, height=30)
|
| 34 |
+
stop_button = gr.Button('Stop', variant='secondary', interactive=False, width=30, height=30)
|
| 35 |
+
gen_button.click(lambda s: gr.update(interactive=True), None, stop_button)
|
| 36 |
+
gr.HTML("""
|
| 37 |
+
<div style="text-align: center; max-width: 100%; margin: 0 auto;">
|
| 38 |
+
<body>
|
| 39 |
+
</body>
|
| 40 |
+
</div>
|
| 41 |
+
""")
|
| 42 |
+
with gr.Row():
|
| 43 |
+
output = [gr.Image(label=m, min_width=250, height=250) for m in default_models]
|
| 44 |
+
current_models = [gr.Textbox(m, visible=False) for m in default_models]
|
| 45 |
+
for m, o in zip(current_models, output):
|
| 46 |
+
gen_event = gen_button.click(gen_fn, [m, txt_input], o)
|
| 47 |
+
stop_button.click(lambda s: gr.update(interactive=False), None, stop_button, cancels=[gen_event])
|
| 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 |
+
with gr.Row():
|
| 53 |
+
gr.HTML()
|
| 54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
js_code = """
|
| 58 |
+
|
| 59 |
+
console.log('ghgh');
|
| 60 |
+
|
| 61 |
"""
|
| 62 |
|
| 63 |
+
with gr.Blocks(css="div.float.svelte-1mwvhlq { position: absolute; top: var(--block-label-margin); left: var(--block-label-margin); background: none; border: none;}") as demo:
|
| 64 |
gr.Markdown("<script>" + js_code + "</script>")
|
| 65 |
make_me()
|
| 66 |
|