Spaces:
Running
Running
Upload app.py
Browse files
app.py
CHANGED
@@ -91,7 +91,7 @@ def gen_fn_single_gallery(model_str, prompt):
|
|
91 |
def add_gallery(image, model_str, gallery):
|
92 |
if gallery is None: gallery = []
|
93 |
with lock:
|
94 |
-
gallery.
|
95 |
return gallery
|
96 |
|
97 |
|
@@ -103,7 +103,7 @@ def gen_fn_gallery(model_str, prompt, gallery):
|
|
103 |
loop = asyncio.new_event_loop()
|
104 |
result = loop.run_until_complete(infer(model_str, prompt, timeout))
|
105 |
with lock:
|
106 |
-
if result: gallery.
|
107 |
except (Exception, asyncio.CancelledError) as e:
|
108 |
print(e)
|
109 |
print(f"Task aborted: {model_str}")
|
@@ -113,7 +113,8 @@ def gen_fn_gallery(model_str, prompt, gallery):
|
|
113 |
|
114 |
|
115 |
CSS="""
|
116 |
-
.output { width=120px; height=120px !important; }
|
|
|
117 |
"""
|
118 |
|
119 |
with gr.Blocks(css=CSS) as demo:
|
@@ -135,12 +136,15 @@ with gr.Blocks(css=CSS) as demo:
|
|
135 |
</div>
|
136 |
"""
|
137 |
)
|
138 |
-
with gr.
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
|
|
|
|
|
|
144 |
|
145 |
for m, o in zip(current_models, output):
|
146 |
#gen_event = gen_button.click(gen_fn, [m, txt_input], o)
|
@@ -151,7 +155,7 @@ with gr.Blocks(css=CSS) as demo:
|
|
151 |
|
152 |
with gr.Accordion('Model selection'):
|
153 |
model_choice = gr.CheckboxGroup(models, label = f'Choose up to {num_models} different models from the 866 available!', value = default_models, interactive = True)
|
154 |
-
|
155 |
#model_choice.change(update_imgbox_gallery, model_choice, output)
|
156 |
model_choice.change(extend_choices, model_choice, current_models)
|
157 |
with gr.Row():
|
|
|
91 |
def add_gallery(image, model_str, gallery):
|
92 |
if gallery is None: gallery = []
|
93 |
with lock:
|
94 |
+
if image is not None: gallery.insert(0, (image, model_str))
|
95 |
return gallery
|
96 |
|
97 |
|
|
|
103 |
loop = asyncio.new_event_loop()
|
104 |
result = loop.run_until_complete(infer(model_str, prompt, timeout))
|
105 |
with lock:
|
106 |
+
if result: gallery.insert(0, result)
|
107 |
except (Exception, asyncio.CancelledError) as e:
|
108 |
print(e)
|
109 |
print(f"Task aborted: {model_str}")
|
|
|
113 |
|
114 |
|
115 |
CSS="""
|
116 |
+
.output { width=120px; height=120px; !important; }
|
117 |
+
.gallery { width=100%; height=512px; max_height=512px !important; }
|
118 |
"""
|
119 |
|
120 |
with gr.Blocks(css=CSS) as demo:
|
|
|
136 |
</div>
|
137 |
"""
|
138 |
)
|
139 |
+
with gr.Group():
|
140 |
+
with gr.Row():
|
141 |
+
output = [gr.Image(label = m, show_download_button=True, elem_classes="output", interactive=False, show_share_button=True, min_width=80, visible=True) for m in default_models]
|
142 |
+
#output = [gr.Image(label = m, show_download_button=True, elem_classes="output", interactive=False, show_share_button=True) for m in default_models]
|
143 |
+
#output = [gr.Gallery(label = m, show_download_button=True, elem_classes="output", interactive=False, show_share_button=True, container=True, format="png", object_fit="cover") for m in default_models]
|
144 |
+
current_models = [gr.Textbox(m, visible = False) for m in default_models]
|
145 |
+
gallery = gr.Gallery(label="Output", show_download_button=True, elem_classes="gallery",
|
146 |
+
interactive=False, show_share_button=True, container=True, format="png",
|
147 |
+
object_fit="cover", columns=2) # , height=768
|
148 |
|
149 |
for m, o in zip(current_models, output):
|
150 |
#gen_event = gen_button.click(gen_fn, [m, txt_input], o)
|
|
|
155 |
|
156 |
with gr.Accordion('Model selection'):
|
157 |
model_choice = gr.CheckboxGroup(models, label = f'Choose up to {num_models} different models from the 866 available!', value = default_models, interactive = True)
|
158 |
+
model_choice.change(update_imgbox, model_choice, output)
|
159 |
#model_choice.change(update_imgbox_gallery, model_choice, output)
|
160 |
model_choice.change(extend_choices, model_choice, current_models)
|
161 |
with gr.Row():
|