Spaces:
Sleeping
Sleeping
revert -1
Browse files
app.py
CHANGED
@@ -122,25 +122,36 @@ with gr.Blocks(css=custom_css) as interface:
|
|
122 |
outputs=sample_display,
|
123 |
)
|
124 |
|
125 |
-
#
|
126 |
-
def
|
127 |
-
|
128 |
-
|
129 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
netron_html = view_model(selected_models)
|
131 |
-
netron_display.update(netron_html) # Update Netron asynchronously
|
132 |
|
133 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
|
135 |
-
|
136 |
-
results = process_image(sample_choice, uploaded_image, selected_models)
|
137 |
-
return results
|
138 |
|
139 |
# Run button click
|
140 |
run_button.click(
|
141 |
-
fn=
|
142 |
inputs=[sample_selection, upload_image, selected_models],
|
143 |
-
outputs=[result_gallery],
|
144 |
)
|
145 |
|
146 |
# Launch Gradio interface
|
|
|
122 |
outputs=sample_display,
|
123 |
)
|
124 |
|
125 |
+
# Multi-threaded processing
|
126 |
+
def run_both(sample_choice, uploaded_image, selected_models):
|
127 |
+
results = []
|
128 |
+
netron_html = ""
|
129 |
+
|
130 |
+
# Thread to process the image
|
131 |
+
def process_thread():
|
132 |
+
nonlocal results
|
133 |
+
results = process_image(sample_choice, uploaded_image, selected_models)
|
134 |
+
|
135 |
+
# Thread to generate Netron visualization
|
136 |
+
def netron_thread():
|
137 |
+
nonlocal netron_html
|
138 |
netron_html = view_model(selected_models)
|
|
|
139 |
|
140 |
+
# Launch threads
|
141 |
+
t1 = threading.Thread(target=process_thread)
|
142 |
+
t2 = threading.Thread(target=netron_thread)
|
143 |
+
t1.start()
|
144 |
+
t2.start()
|
145 |
+
t1.join()
|
146 |
+
t2.join()
|
147 |
|
148 |
+
return results, netron_html
|
|
|
|
|
149 |
|
150 |
# Run button click
|
151 |
run_button.click(
|
152 |
+
fn=run_both,
|
153 |
inputs=[sample_selection, upload_image, selected_models],
|
154 |
+
outputs=[result_gallery, netron_display],
|
155 |
)
|
156 |
|
157 |
# Launch Gradio interface
|