Spaces:
Sleeping
Sleeping
revert -3
Browse files
app.py
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
-
import netron
|
2 |
import threading
|
3 |
import gradio as gr
|
4 |
import os
|
@@ -7,8 +6,6 @@ import cv2
|
|
7 |
import numpy as np
|
8 |
from yolov5 import xai_yolov5
|
9 |
from yolov8 import xai_yolov8s
|
10 |
-
import time
|
11 |
-
import tempfile
|
12 |
|
13 |
# Sample images directory
|
14 |
sample_images = {
|
@@ -70,6 +67,31 @@ custom_css = """
|
|
70 |
}
|
71 |
"""
|
72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
with gr.Blocks(css=custom_css) as interface:
|
74 |
gr.Markdown("# NeuralVista: Visualize Object Detection of Your Models")
|
75 |
|
@@ -122,18 +144,13 @@ with gr.Blocks(css=custom_css) as interface:
|
|
122 |
outputs=sample_display,
|
123 |
)
|
124 |
|
125 |
-
#
|
126 |
run_button.click(
|
127 |
-
fn=
|
128 |
-
view_model(yolo_versions), # Display model visualization
|
129 |
-
process_image(sample_choice, uploaded_image, yolo_versions),
|
130 |
-
|
131 |
-
],
|
132 |
inputs=[sample_selection, upload_image, selected_models],
|
133 |
outputs=[result_gallery, netron_display],
|
134 |
)
|
135 |
|
136 |
# Launching Gradio app
|
137 |
if __name__ == "__main__":
|
138 |
-
interface.launch(share=True)
|
139 |
-
|
|
|
|
|
1 |
import threading
|
2 |
import gradio as gr
|
3 |
import os
|
|
|
6 |
import numpy as np
|
7 |
from yolov5 import xai_yolov5
|
8 |
from yolov8 import xai_yolov8s
|
|
|
|
|
9 |
|
10 |
# Sample images directory
|
11 |
sample_images = {
|
|
|
67 |
}
|
68 |
"""
|
69 |
|
70 |
+
def run_both(sample_choice, uploaded_image, yolo_versions):
|
71 |
+
"""Run both image processing and model visualization simultaneously."""
|
72 |
+
results = []
|
73 |
+
|
74 |
+
def process_thread():
|
75 |
+
result_images = process_image(sample_choice, uploaded_image, yolo_versions)
|
76 |
+
results.append(result_images)
|
77 |
+
|
78 |
+
def model_thread():
|
79 |
+
model_html = view_model(yolo_versions)
|
80 |
+
results.append(model_html)
|
81 |
+
|
82 |
+
# Create threads to run both functions simultaneously
|
83 |
+
process_thread_obj = threading.Thread(target=process_thread)
|
84 |
+
model_thread_obj = threading.Thread(target=model_thread)
|
85 |
+
|
86 |
+
process_thread_obj.start()
|
87 |
+
model_thread_obj.start()
|
88 |
+
|
89 |
+
# Wait for both threads to finish
|
90 |
+
process_thread_obj.join()
|
91 |
+
model_thread_obj.join()
|
92 |
+
|
93 |
+
return results[0], results[1] # Return processed image results and model visualization
|
94 |
+
|
95 |
with gr.Blocks(css=custom_css) as interface:
|
96 |
gr.Markdown("# NeuralVista: Visualize Object Detection of Your Models")
|
97 |
|
|
|
144 |
outputs=sample_display,
|
145 |
)
|
146 |
|
147 |
+
# Run both functions concurrently on button click
|
148 |
run_button.click(
|
149 |
+
fn=run_both,
|
|
|
|
|
|
|
|
|
150 |
inputs=[sample_selection, upload_image, selected_models],
|
151 |
outputs=[result_gallery, netron_display],
|
152 |
)
|
153 |
|
154 |
# Launching Gradio app
|
155 |
if __name__ == "__main__":
|
156 |
+
interface.launch(share=True)
|
|