Spaces:
Sleeping
Sleeping
Commit
·
7991981
1
Parent(s):
d4cd198
Fix: interface layout
Browse files
app.py
CHANGED
@@ -84,49 +84,48 @@ def process_image(choice, yolo_versions=["yolov5"]):
|
|
84 |
with gr.Blocks() as interface:
|
85 |
gr.Markdown("# XAI: Visualize Object Detection of Your Models")
|
86 |
gr.Markdown("Select a sample image or upload your own image to visualize object detection.")
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
)
|
128 |
-
|
129 |
-
result_gallery = gr.Gallery(label="Results", elem_id="gallery", rows=2, height=500)
|
130 |
|
131 |
# Use the uploaded image if available, otherwise the selected sample
|
132 |
gr.Button("Run").click(
|
|
|
84 |
with gr.Blocks() as interface:
|
85 |
gr.Markdown("# XAI: Visualize Object Detection of Your Models")
|
86 |
gr.Markdown("Select a sample image or upload your own image to visualize object detection.")
|
87 |
+
with gr.Row(): # Row layout to divide the screen into two sections
|
88 |
+
with gr.Column(): # Left section for image selection and upload
|
89 |
+
# Radio button with default value set
|
90 |
+
sample_selection = gr.Radio(
|
91 |
+
choices=list(sample_images.keys()),
|
92 |
+
label="Select a Sample Image",
|
93 |
+
type="value",
|
94 |
+
value="Sample 1", # Set default selection
|
95 |
+
)
|
96 |
+
# Display the selected or uploaded image
|
97 |
+
image_display = gr.Image(
|
98 |
+
value=load_sample_image("Sample 1"), # Load default sample image
|
99 |
+
label="Selected/Uploaded Image",
|
100 |
+
)
|
101 |
+
|
102 |
+
# File upload for custom images (placed below the sample selection)
|
103 |
+
uploaded_image = gr.Image(type="numpy", label="Upload an Image")
|
104 |
+
|
105 |
+
# Update display when sample selection changes
|
106 |
+
sample_selection.change(
|
107 |
+
fn=load_sample_image,
|
108 |
+
inputs=sample_selection,
|
109 |
+
outputs=image_display,
|
110 |
+
)
|
111 |
+
|
112 |
+
# Update display when an image is uploaded
|
113 |
+
uploaded_image.change(
|
114 |
+
fn=lambda img: img,
|
115 |
+
inputs=uploaded_image,
|
116 |
+
outputs=image_display,
|
117 |
+
)
|
118 |
+
|
119 |
+
# Model selection below the image options
|
120 |
+
selected_models = gr.CheckboxGroup(
|
121 |
+
choices=["yolov5", "yolov8s"],
|
122 |
+
value=["yolov5"],
|
123 |
+
label="Select Model(s)",
|
124 |
+
)
|
125 |
+
|
126 |
+
# Right section for image display
|
127 |
+
with gr.Column():
|
128 |
+
result_gallery = gr.Gallery(label="Results", elem_id="gallery", rows=2, height=500)
|
|
|
129 |
|
130 |
# Use the uploaded image if available, otherwise the selected sample
|
131 |
gr.Button("Run").click(
|