Spaces:
Sleeping
Sleeping
Commit
·
872c6af
1
Parent(s):
6ddb87c
Fix: sample option selection
Browse files
app.py
CHANGED
|
@@ -28,15 +28,19 @@ sample_images = [
|
|
| 28 |
os.path.join(os.getcwd(), "data/xai/sample2.jpg")
|
| 29 |
]
|
| 30 |
|
| 31 |
-
# Interface definition
|
| 32 |
interface = gr.Interface(
|
| 33 |
fn=process_image,
|
| 34 |
inputs=[
|
| 35 |
gr.Radio(
|
| 36 |
-
label="Select Sample Image",
|
| 37 |
-
choices=sample_images, #
|
| 38 |
-
value=
|
| 39 |
-
type="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
),
|
| 41 |
gr.CheckboxGroup(
|
| 42 |
choices=["yolov5", "yolov8s"],
|
|
@@ -47,7 +51,7 @@ interface = gr.Interface(
|
|
| 47 |
],
|
| 48 |
outputs=gr.Gallery(label="Results", elem_id="gallery", rows=2, height=500),
|
| 49 |
title="Explainable AI for YOLO Models",
|
| 50 |
-
description="Select a sample image and choose a model to visualize YOLO object detection with Grad-CAM.",
|
| 51 |
examples=sample_images, # Example images to display
|
| 52 |
live=True,
|
| 53 |
)
|
|
|
|
| 28 |
os.path.join(os.getcwd(), "data/xai/sample2.jpg")
|
| 29 |
]
|
| 30 |
|
|
|
|
| 31 |
interface = gr.Interface(
|
| 32 |
fn=process_image,
|
| 33 |
inputs=[
|
| 34 |
gr.Radio(
|
| 35 |
+
label="Select Sample Image or Upload Image",
|
| 36 |
+
choices=["None"] + sample_images, # Add 'None' option for uploading image
|
| 37 |
+
value="None", # Default option is 'None'
|
| 38 |
+
type="value", # We pass the file path or 'None' here
|
| 39 |
+
),
|
| 40 |
+
gr.Image(
|
| 41 |
+
label="Upload Image",
|
| 42 |
+
type="pil", # Type 'pil' to work with PIL images
|
| 43 |
+
visible=False # Initially hidden, will only be visible if 'None' is selected
|
| 44 |
),
|
| 45 |
gr.CheckboxGroup(
|
| 46 |
choices=["yolov5", "yolov8s"],
|
|
|
|
| 51 |
],
|
| 52 |
outputs=gr.Gallery(label="Results", elem_id="gallery", rows=2, height=500),
|
| 53 |
title="Explainable AI for YOLO Models",
|
| 54 |
+
description="Select a sample image or upload your own image and choose a model to visualize YOLO object detection with Grad-CAM.",
|
| 55 |
examples=sample_images, # Example images to display
|
| 56 |
live=True,
|
| 57 |
)
|