Update app.py
Browse files
app.py
CHANGED
@@ -19,14 +19,6 @@ repos = [
|
|
19 |
"hsuwill000/Fluently-v4-LCM-openvino_3",
|
20 |
"hsuwill000/Fluently-v4-LCM-openvino_4",
|
21 |
]
|
22 |
-
"""
|
23 |
-
"hsuwill000/Fluently-v4-LCM-openvino_5",
|
24 |
-
"hsuwill000/Fluently-v4-LCM-openvino_6",
|
25 |
-
"hsuwill000/Fluently-v4-LCM-openvino_7",
|
26 |
-
"hsuwill000/Fluently-v4-LCM-openvino_8",
|
27 |
-
"hsuwill000/Fluently-v4-LCM-openvino_9",
|
28 |
-
"hsuwill000/Fluently-v4-LCM-openvino_10",
|
29 |
-
"""
|
30 |
|
31 |
class CustomClient(Client):
|
32 |
def __init__(self, *args, timeout=30, **kwargs):
|
@@ -75,7 +67,13 @@ async def infer_single_gradio(client, prompt):
|
|
75 |
traceback.print_exc() # Print stack trace for debugging
|
76 |
return None # Return nothing if an error occurs
|
77 |
|
78 |
-
async def infer_gradio(prompt: str):
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
# Create a list of tasks (one for each repo)
|
80 |
tasks = []
|
81 |
for repo in repos:
|
@@ -93,6 +91,13 @@ async def infer_gradio(prompt: str):
|
|
93 |
|
94 |
# Run all tasks concurrently (i.e., generate images from all repos)
|
95 |
results = await asyncio.gather(*tasks)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
return results # Return all the images as a list
|
97 |
|
98 |
# Define Gradio Interface
|
@@ -113,7 +118,7 @@ with gr.Blocks() as demo:
|
|
113 |
output_images = gr.Gallery(label="Generated Images", elem_id="gallery", show_label=False)
|
114 |
|
115 |
# Connecting the button click to the image generation function
|
116 |
-
run_button.click(infer_gradio, inputs=prompt_input, outputs=output_images)
|
117 |
|
118 |
# Launch Gradio app
|
119 |
demo.launch()
|
|
|
19 |
"hsuwill000/Fluently-v4-LCM-openvino_3",
|
20 |
"hsuwill000/Fluently-v4-LCM-openvino_4",
|
21 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
class CustomClient(Client):
|
24 |
def __init__(self, *args, timeout=30, **kwargs):
|
|
|
67 |
traceback.print_exc() # Print stack trace for debugging
|
68 |
return None # Return nothing if an error occurs
|
69 |
|
70 |
+
async def infer_gradio(prompt: str, output_images: gr.Gallery):
|
71 |
+
# Clear previous images from the gallery
|
72 |
+
output_images.update([])
|
73 |
+
|
74 |
+
# Record the start time
|
75 |
+
start_time = time.time()
|
76 |
+
|
77 |
# Create a list of tasks (one for each repo)
|
78 |
tasks = []
|
79 |
for repo in repos:
|
|
|
91 |
|
92 |
# Run all tasks concurrently (i.e., generate images from all repos)
|
93 |
results = await asyncio.gather(*tasks)
|
94 |
+
|
95 |
+
# Calculate the time taken for image generation
|
96 |
+
end_time = time.time()
|
97 |
+
time_taken = end_time - start_time
|
98 |
+
print(f"Time taken to generate the image(s): {time_taken:.2f} seconds")
|
99 |
+
|
100 |
+
# Return the results (images)
|
101 |
return results # Return all the images as a list
|
102 |
|
103 |
# Define Gradio Interface
|
|
|
118 |
output_images = gr.Gallery(label="Generated Images", elem_id="gallery", show_label=False)
|
119 |
|
120 |
# Connecting the button click to the image generation function
|
121 |
+
run_button.click(infer_gradio, inputs=[prompt_input, output_images], outputs=output_images)
|
122 |
|
123 |
# Launch Gradio app
|
124 |
demo.launch()
|