Spaces:
Sleeping
Sleeping
specified tokens
Browse files
app.py
CHANGED
@@ -63,8 +63,12 @@ glip_demo = GLIPDemo(
|
|
63 |
)
|
64 |
|
65 |
|
66 |
-
def predict(image, text):
|
67 |
-
|
|
|
|
|
|
|
|
|
68 |
return result[:, :, [2, 1, 0]]
|
69 |
|
70 |
|
@@ -73,7 +77,7 @@ image = gr.inputs.Image()
|
|
73 |
gr.Interface(
|
74 |
description="Object Recognition with DesCo",
|
75 |
fn=predict,
|
76 |
-
inputs=["image", "text"],
|
77 |
outputs=[
|
78 |
gr.outputs.Image(
|
79 |
type="pil",
|
@@ -83,9 +87,10 @@ gr.Interface(
|
|
83 |
examples=[
|
84 |
#["./flickr_9472793441.jpg", "bobble heads on top of the shelf ."],
|
85 |
#["./flickr_9472793441.jpg", "sofa . remote . dog . person . car . sky . plane ."],
|
86 |
-
["./coco_000000281759.jpg", "A green umbrella. A pink striped umbrella. A plain white umbrella."],
|
87 |
-
["./coco_000000281759.jpg", "a flowery top. A blue dress. An orange shirt ."],
|
88 |
-
["./coco_000000281759.jpg", "a car . An electricity box ."],
|
|
|
89 |
#["./flickr_7520721.jpg", "A woman figure skater in a blue costume holds her leg by the blade of her skate ."]
|
90 |
],
|
91 |
article=Path("docs/intro.md").read_text()
|
|
|
63 |
)
|
64 |
|
65 |
|
66 |
+
def predict(image, text, specified_tokens=""):
|
67 |
+
if specified_tokens.strip() == "":
|
68 |
+
specified_tokens = None
|
69 |
+
else:
|
70 |
+
specified_tokens = specified_tokens..split(";")
|
71 |
+
result, _ = glip_demo.run_on_web_image(image[:, :, [2, 1, 0]], text, 0.5, specified_tokens)
|
72 |
return result[:, :, [2, 1, 0]]
|
73 |
|
74 |
|
|
|
77 |
gr.Interface(
|
78 |
description="Object Recognition with DesCo",
|
79 |
fn=predict,
|
80 |
+
inputs=["image", "text", "ground tokens (optional)"],
|
81 |
outputs=[
|
82 |
gr.outputs.Image(
|
83 |
type="pil",
|
|
|
87 |
examples=[
|
88 |
#["./flickr_9472793441.jpg", "bobble heads on top of the shelf ."],
|
89 |
#["./flickr_9472793441.jpg", "sofa . remote . dog . person . car . sky . plane ."],
|
90 |
+
["./coco_000000281759.jpg", "A green umbrella. A pink striped umbrella. A plain white umbrella.", ""],
|
91 |
+
["./coco_000000281759.jpg", "a flowery top. A blue dress. An orange shirt .", ""],
|
92 |
+
["./coco_000000281759.jpg", "a car . An electricity box .", ""],
|
93 |
+
["./1.jpg", "a train besides sidewalk", "train;sidewalk"],
|
94 |
#["./flickr_7520721.jpg", "A woman figure skater in a blue costume holds her leg by the blade of her skate ."]
|
95 |
],
|
96 |
article=Path("docs/intro.md").read_text()
|