Spaces:
Runtime error
Runtime error
fix bug
Browse files- .DS_Store +0 -0
- .gitattributes +1 -0
- app.py +6 -5
- assets/.DS_Store +0 -0
- assets/Helvatica.ttc +3 -0
- astronaut.png β assets/astronaut.png +0 -0
- coffee.png β assets/coffee.png +0 -0
.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
.gitattributes
CHANGED
@@ -29,3 +29,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
29 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
30 |
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
31 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
29 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
30 |
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
31 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
32 |
+
assets/Helvatica.ttc filter=lfs diff=lfs merge=lfs -text
|
app.py
CHANGED
@@ -13,14 +13,14 @@ def query_image(img, text_queries):
|
|
13 |
inputs = processor(text=text_queries, images=img, return_tensors="pt")
|
14 |
|
15 |
with torch.no_grad():
|
16 |
-
|
17 |
|
18 |
target_sizes = torch.Tensor([[768, 768]])
|
19 |
results = processor.post_process(outputs=outputs, target_sizes=target_sizes)
|
20 |
boxes, scores, labels = results[0]["boxes"], results[0]["scores"], results[0]["labels"]
|
21 |
|
22 |
draw = ImageDraw.Draw(img)
|
23 |
-
font = ImageFont.truetype("/
|
24 |
|
25 |
score_threshold = 0.1
|
26 |
for box, score, label in zip(boxes, scores, labels):
|
@@ -35,19 +35,20 @@ def query_image(img, text_queries):
|
|
35 |
return img
|
36 |
|
37 |
|
38 |
-
description =
|
39 |
Gradio demo for <a href="https://huggingface.co/docs/transformers/main/en/model_doc/owlvit">OWL-ViT</a>,
|
40 |
introduced in <a href="https://arxiv.org/abs/2205.06230">Simple Open-Vocabulary Object Detection
|
41 |
with Vision Transformers</a>.
|
42 |
\n\nYou can use OWL-ViT to query images with text descriptions of any object.
|
43 |
To use it, simply upload an image and enter comma separated text descriptions of objects you want to query the image for.
|
|
|
44 |
"""
|
45 |
demo = gr.Interface(
|
46 |
query_image,
|
47 |
inputs=[gr.Image(shape=(768, 768), type="pil"), "text"],
|
48 |
outputs="image",
|
49 |
title="Zero-Shot Object Detection with OWL-ViT",
|
50 |
-
description=
|
51 |
-
examples=[["astronaut.png", "human face, rocket, flag, nasa badge"], ["coffee.png", "coffee mug, spoon, plate"]]
|
52 |
)
|
53 |
demo.launch(debug=True)
|
|
|
13 |
inputs = processor(text=text_queries, images=img, return_tensors="pt")
|
14 |
|
15 |
with torch.no_grad():
|
16 |
+
outputs = model(**inputs)
|
17 |
|
18 |
target_sizes = torch.Tensor([[768, 768]])
|
19 |
results = processor.post_process(outputs=outputs, target_sizes=target_sizes)
|
20 |
boxes, scores, labels = results[0]["boxes"], results[0]["scores"], results[0]["labels"]
|
21 |
|
22 |
draw = ImageDraw.Draw(img)
|
23 |
+
font = ImageFont.truetype("assets/Helvetica.ttc", size=22)
|
24 |
|
25 |
score_threshold = 0.1
|
26 |
for box, score, label in zip(boxes, scores, labels):
|
|
|
35 |
return img
|
36 |
|
37 |
|
38 |
+
description = """
|
39 |
Gradio demo for <a href="https://huggingface.co/docs/transformers/main/en/model_doc/owlvit">OWL-ViT</a>,
|
40 |
introduced in <a href="https://arxiv.org/abs/2205.06230">Simple Open-Vocabulary Object Detection
|
41 |
with Vision Transformers</a>.
|
42 |
\n\nYou can use OWL-ViT to query images with text descriptions of any object.
|
43 |
To use it, simply upload an image and enter comma separated text descriptions of objects you want to query the image for.
|
44 |
+
\n\n<a href="https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/zeroshot_object_detection_with_owlvit.ipynb">Colab demo</a>
|
45 |
"""
|
46 |
demo = gr.Interface(
|
47 |
query_image,
|
48 |
inputs=[gr.Image(shape=(768, 768), type="pil"), "text"],
|
49 |
outputs="image",
|
50 |
title="Zero-Shot Object Detection with OWL-ViT",
|
51 |
+
description=description,
|
52 |
+
examples=[["assets/astronaut.png", "human face, rocket, flag, nasa badge"], ["assets/coffee.png", "coffee mug, spoon, plate"]]
|
53 |
)
|
54 |
demo.launch(debug=True)
|
assets/.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
assets/Helvatica.ttc
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c4cb0b7e8b3e53b29d356bfae0663075fdd20e45ad94b56e1b77cca117e415e0
|
3 |
+
size 2356684
|
astronaut.png β assets/astronaut.png
RENAMED
File without changes
|
coffee.png β assets/coffee.png
RENAMED
File without changes
|