Spaces:
Running
Running
Commit
·
7e2bb82
1
Parent(s):
8f09828
adding text box
Browse files
app.py
CHANGED
@@ -52,20 +52,23 @@ def display_images(image,detections,prompt='traffic light'):
|
|
52 |
|
53 |
|
54 |
def shot(image, labels_text):
|
55 |
-
print(labels_text)
|
56 |
prompts = labels_text.split(',')
|
57 |
global classes
|
58 |
classes = prompts
|
59 |
|
|
|
|
|
|
|
60 |
detections = detect_using_clip(image,prompts=prompts)
|
61 |
-
|
62 |
return detections
|
63 |
|
64 |
def add_text(text):
|
65 |
labels = text.split(',')
|
66 |
return labels
|
67 |
|
68 |
-
inputt = gr.Image(type="numpy", label="Input Image for Classification")
|
69 |
|
70 |
# with gr.Blocks(title="Zero Shot Object ddetection using Text Prompts") as demo :
|
71 |
# gr.Markdown(
|
@@ -94,9 +97,11 @@ inputt = gr.Image(type="numpy", label="Input Image for Classification")
|
|
94 |
|
95 |
# demo.launch()
|
96 |
iface = gr.Interface(fn=shot,
|
97 |
-
inputs = ["image","text"],
|
98 |
outputs="label",
|
99 |
-
|
|
|
|
|
100 |
# allow_flagging=False,
|
101 |
# analytics_enabled=False,
|
102 |
)
|
|
|
52 |
|
53 |
|
54 |
def shot(image, labels_text):
|
55 |
+
print("Labels Text ",labels_text)
|
56 |
prompts = labels_text.split(',')
|
57 |
global classes
|
58 |
classes = prompts
|
59 |
|
60 |
+
print("prompts :",prompts,classes)
|
61 |
+
print("Image shape ",image.shape )
|
62 |
+
|
63 |
detections = detect_using_clip(image,prompts=prompts)
|
64 |
+
print("detections :",detections)
|
65 |
return detections
|
66 |
|
67 |
def add_text(text):
|
68 |
labels = text.split(',')
|
69 |
return labels
|
70 |
|
71 |
+
# inputt = gr.Image(type="numpy", label="Input Image for Classification")
|
72 |
|
73 |
# with gr.Blocks(title="Zero Shot Object ddetection using Text Prompts") as demo :
|
74 |
# gr.Markdown(
|
|
|
97 |
|
98 |
# demo.launch()
|
99 |
iface = gr.Interface(fn=shot,
|
100 |
+
inputs = ["image","text",gr.Dropdown(classes, label="Category Label",info='Select Categories')],
|
101 |
outputs="label",
|
102 |
+
description="Add a picture and a list of labels separated by commas",
|
103 |
+
title="Zero-shot Image Classification with Prompt ",
|
104 |
+
examples=[["images/room.jpg","bed,table,plant"]],
|
105 |
# allow_flagging=False,
|
106 |
# analytics_enabled=False,
|
107 |
)
|