Spaces:
Sleeping
Sleeping
Commit
·
29a24a4
1
Parent(s):
aca98af
Fix: gradio interface
Browse files
app.py
CHANGED
@@ -62,12 +62,18 @@ def main_logic(uploaded_image, selected_models, sample_selection):
|
|
62 |
|
63 |
interface.launch()
|
64 |
"""
|
65 |
-
|
66 |
def load_sample_image(sample_name):
|
67 |
if sample_name in sample_images:
|
68 |
-
|
|
|
|
|
|
|
|
|
69 |
return None
|
70 |
|
|
|
|
|
|
|
71 |
with gr.Blocks() as interface:
|
72 |
gr.Markdown("# Visualizing Key Features with Explainable AI")
|
73 |
gr.Markdown("Upload an image or select a sample image to visualize object detection.")
|
@@ -79,7 +85,7 @@ with gr.Blocks() as interface:
|
|
79 |
label="Select a Sample Image",
|
80 |
type="value",
|
81 |
)
|
82 |
-
sample_display = gr.Image(label="Sample Image Preview")
|
83 |
sample_selection.change(fn=load_sample_image, inputs=sample_selection, outputs=sample_display)
|
84 |
|
85 |
selected_models = gr.CheckboxGroup(
|
|
|
62 |
|
63 |
interface.launch()
|
64 |
"""
|
|
|
65 |
def load_sample_image(sample_name):
|
66 |
if sample_name in sample_images:
|
67 |
+
try:
|
68 |
+
return Image.open(sample_images[sample_name]) # Load and return the image
|
69 |
+
except Exception as e:
|
70 |
+
print(f"Error loading image: {e}")
|
71 |
+
return None
|
72 |
return None
|
73 |
|
74 |
+
|
75 |
+
|
76 |
+
# Gradio interface
|
77 |
with gr.Blocks() as interface:
|
78 |
gr.Markdown("# Visualizing Key Features with Explainable AI")
|
79 |
gr.Markdown("Upload an image or select a sample image to visualize object detection.")
|
|
|
85 |
label="Select a Sample Image",
|
86 |
type="value",
|
87 |
)
|
88 |
+
sample_display = gr.Image(label="Sample Image Preview", value=None)
|
89 |
sample_selection.change(fn=load_sample_image, inputs=sample_selection, outputs=sample_display)
|
90 |
|
91 |
selected_models = gr.CheckboxGroup(
|