Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -95,13 +95,16 @@ async def infer(model_str, prompt, nprompt="", height=0, width=0, steps=0, cfg=0
|
|
95 |
def gen_fn(model_str, prompt, nprompt="", height=0, width=0, steps=0, cfg=0, seed=-1):
|
96 |
try:
|
97 |
loop = asyncio.new_event_loop()
|
98 |
-
result
|
|
|
99 |
except (Exception, asyncio.CancelledError) as e:
|
|
|
100 |
print(f"gen_fn: Task aborted: {model_str}")
|
|
|
101 |
raise gr.Error(f"Task aborted: {model_str}, Error: {e}")
|
102 |
finally:
|
103 |
loop.close()
|
104 |
-
return result
|
105 |
|
106 |
|
107 |
def add_gallery(image, model_str, gallery):
|
@@ -137,7 +140,7 @@ with gr.Blocks(fill_width=True, head=js) as demo:
|
|
137 |
with gr.Column(scale=1):
|
138 |
with gr.Group():
|
139 |
with gr.Row():
|
140 |
-
output = [gr.Image(label=m, show_download_button=True, elem_classes="
|
141 |
interactive=False, width=112, height=112, show_share_button=False, format="png",
|
142 |
visible=True) for m in default_models]
|
143 |
current_models = [gr.Textbox(m, visible=False) for m in default_models]
|
|
|
95 |
def gen_fn(model_str, prompt, nprompt="", height=0, width=0, steps=0, cfg=0, seed=-1):
|
96 |
try:
|
97 |
loop = asyncio.new_event_loop()
|
98 |
+
result = loop.run_until_complete(infer(model_str, prompt, nprompt,
|
99 |
+
height, width, steps, cfg, seed, inference_timeout))
|
100 |
except (Exception, asyncio.CancelledError) as e:
|
101 |
+
print(e)
|
102 |
print(f"gen_fn: Task aborted: {model_str}")
|
103 |
+
result = None
|
104 |
raise gr.Error(f"Task aborted: {model_str}, Error: {e}")
|
105 |
finally:
|
106 |
loop.close()
|
107 |
+
return result
|
108 |
|
109 |
|
110 |
def add_gallery(image, model_str, gallery):
|
|
|
140 |
with gr.Column(scale=1):
|
141 |
with gr.Group():
|
142 |
with gr.Row():
|
143 |
+
output = [gr.Image(label=m, show_download_button=True, elem_classes=["renderedImg"],
|
144 |
interactive=False, width=112, height=112, show_share_button=False, format="png",
|
145 |
visible=True) for m in default_models]
|
146 |
current_models = [gr.Textbox(m, visible=False) for m in default_models]
|