Spaces:
Sleeping
Sleeping
Saanvi12011
commited on
Commit
•
134125f
1
Parent(s):
3712cce
Update app.py
Browse files
app.py
CHANGED
@@ -9,20 +9,21 @@ def detect_objects(image, labels):
|
|
9 |
# Split the labels into a list
|
10 |
candidate_labels = [label.strip() for label in labels.split(",")]
|
11 |
result = pipe(image, candidate_labels=candidate_labels)
|
12 |
-
#
|
13 |
return result
|
14 |
|
15 |
# Create the Gradio interface
|
16 |
iface = gr.Interface(
|
17 |
fn=detect_objects, # function to process input
|
18 |
inputs=[
|
19 |
-
gr.
|
20 |
-
gr.
|
21 |
],
|
22 |
-
outputs=
|
23 |
title="Zero-Shot Object Detection", # Title of the interface
|
24 |
description="Upload an image and provide a list of labels (comma separated) for object detection.", # Description
|
25 |
)
|
26 |
|
27 |
# Launch the interface
|
28 |
iface.launch()
|
|
|
|
9 |
# Split the labels into a list
|
10 |
candidate_labels = [label.strip() for label in labels.split(",")]
|
11 |
result = pipe(image, candidate_labels=candidate_labels)
|
12 |
+
# Return the detected objects and their confidence scores
|
13 |
return result
|
14 |
|
15 |
# Create the Gradio interface
|
16 |
iface = gr.Interface(
|
17 |
fn=detect_objects, # function to process input
|
18 |
inputs=[
|
19 |
+
gr.Image(type="filepath", label="Upload Image"), # input for image using updated gr.Image
|
20 |
+
gr.Textbox(lines=2, label="Candidate Labels (comma separated)"), # input for candidate labels
|
21 |
],
|
22 |
+
outputs=gr.JSON(), # output as JSON for multiple object detection results
|
23 |
title="Zero-Shot Object Detection", # Title of the interface
|
24 |
description="Upload an image and provide a list of labels (comma separated) for object detection.", # Description
|
25 |
)
|
26 |
|
27 |
# Launch the interface
|
28 |
iface.launch()
|
29 |
+
|