Spaces:
Sleeping
Sleeping
Commit
·
f504910
1
Parent(s):
e2db038
Fix: interface update
Browse files
app.py
CHANGED
@@ -10,7 +10,6 @@ from yolov8 import xai_yolov8s
|
|
10 |
def process_image(image, yolo_versions=["yolov5"]):
|
11 |
image = np.array(image)
|
12 |
image = cv2.resize(image, (640, 640))
|
13 |
-
|
14 |
result_images = []
|
15 |
for yolo_version in yolo_versions:
|
16 |
if yolo_version == "yolov5":
|
@@ -32,10 +31,8 @@ def load_sample_image(sample_name):
|
|
32 |
return Image.open(image_path)
|
33 |
return None
|
34 |
|
35 |
-
# Default sample image
|
36 |
default_sample_image = load_sample_image("Sample 1")
|
37 |
-
|
38 |
-
# Gradio interface
|
39 |
with gr.Blocks() as interface:
|
40 |
gr.Markdown("# XAI: Upload an image to visualize object detection of your models..")
|
41 |
gr.Markdown("Upload an image or select a sample image to visualize object detection.")
|
@@ -52,16 +49,40 @@ with gr.Blocks() as interface:
|
|
52 |
|
53 |
selected_models = gr.CheckboxGroup(
|
54 |
choices=["yolov5", "yolov8s"],
|
55 |
-
value=["yolov5"],
|
56 |
label="Select Model(s)",
|
57 |
)
|
58 |
-
|
59 |
result_gallery = gr.Gallery(label="Results", elem_id="gallery", rows=2, height=500)
|
60 |
-
|
61 |
gr.Button("Run").click(
|
62 |
fn=process_image,
|
63 |
inputs=[uploaded_image, selected_models],
|
64 |
outputs=result_gallery,
|
65 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
|
67 |
interface.launch()
|
|
|
10 |
def process_image(image, yolo_versions=["yolov5"]):
|
11 |
image = np.array(image)
|
12 |
image = cv2.resize(image, (640, 640))
|
|
|
13 |
result_images = []
|
14 |
for yolo_version in yolo_versions:
|
15 |
if yolo_version == "yolov5":
|
|
|
31 |
return Image.open(image_path)
|
32 |
return None
|
33 |
|
|
|
34 |
default_sample_image = load_sample_image("Sample 1")
|
35 |
+
"""
|
|
|
36 |
with gr.Blocks() as interface:
|
37 |
gr.Markdown("# XAI: Upload an image to visualize object detection of your models..")
|
38 |
gr.Markdown("Upload an image or select a sample image to visualize object detection.")
|
|
|
49 |
|
50 |
selected_models = gr.CheckboxGroup(
|
51 |
choices=["yolov5", "yolov8s"],
|
52 |
+
value=["yolov5"],
|
53 |
label="Select Model(s)",
|
54 |
)
|
|
|
55 |
result_gallery = gr.Gallery(label="Results", elem_id="gallery", rows=2, height=500)
|
|
|
56 |
gr.Button("Run").click(
|
57 |
fn=process_image,
|
58 |
inputs=[uploaded_image, selected_models],
|
59 |
outputs=result_gallery,
|
60 |
)
|
61 |
+
"""
|
62 |
+
|
63 |
+
with gr.Blocks() as interface:
|
64 |
+
gr.Markdown("# XAI: Upload an image to visualize object detection of your models..")
|
65 |
+
gr.Markdown("Select a sample image to visualize object detection.")
|
66 |
+
|
67 |
+
with gr.Row():
|
68 |
+
sample_selection = gr.RadioButtons(
|
69 |
+
choices=list(sample_images.keys()),
|
70 |
+
label="Select a Sample Image",
|
71 |
+
type="value",
|
72 |
+
)
|
73 |
+
sample_display = gr.Image(label="Sample Image Preview", value=default_sample_image)
|
74 |
+
sample_selection.change(fn=load_sample_image, inputs=sample_selection, outputs=sample_display)
|
75 |
+
|
76 |
+
selected_models = gr.CheckboxGroup(
|
77 |
+
choices=["yolov5", "yolov8s"],
|
78 |
+
value=["yolov5"],
|
79 |
+
label="Select Model(s)",
|
80 |
+
)
|
81 |
+
result_gallery = gr.Gallery(label="Results", elem_id="gallery", rows=2, height=500)
|
82 |
+
gr.Button("Run").click(
|
83 |
+
fn=process_image,
|
84 |
+
inputs=[sample_selection, selected_models],
|
85 |
+
outputs=result_gallery,
|
86 |
+
)
|
87 |
|
88 |
interface.launch()
|