Spaces:
Runtime error
Runtime error
remove manual resizing, add example
Browse files- app.py +11 -5
- assets/.DS_Store +0 -0
- assets/butterflies.jpeg +0 -0
app.py
CHANGED
@@ -21,9 +21,7 @@ def query_image(img, text_queries, score_threshold):
|
|
21 |
text_queries = text_queries.split(",")
|
22 |
|
23 |
target_sizes = torch.Tensor([img.shape[:2]])
|
24 |
-
|
25 |
-
|
26 |
-
inputs = processor(text=text_queries, images=img_input, return_tensors="pt").to(device)
|
27 |
|
28 |
with torch.no_grad():
|
29 |
outputs = model(**inputs)
|
@@ -57,7 +55,11 @@ introduced in <a href="https://arxiv.org/abs/2205.06230">Simple Open-Vocabulary
|
|
57 |
with Vision Transformers</a>.
|
58 |
\n\nYou can use OWL-ViT to query images with text descriptions of any object.
|
59 |
To use it, simply upload an image and enter comma separated text descriptions of objects you want to query the image for. You
|
60 |
-
can also use the score threshold slider to set a threshold to filter out low probability predictions.
|
|
|
|
|
|
|
|
|
61 |
\n\n<a href="https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/zeroshot_object_detection_with_owlvit.ipynb">Colab demo</a>
|
62 |
"""
|
63 |
demo = gr.Interface(
|
@@ -66,6 +68,10 @@ demo = gr.Interface(
|
|
66 |
outputs="image",
|
67 |
title="Zero-Shot Object Detection with OWL-ViT",
|
68 |
description=description,
|
69 |
-
examples=[
|
|
|
|
|
|
|
|
|
70 |
)
|
71 |
demo.launch()
|
|
|
21 |
text_queries = text_queries.split(",")
|
22 |
|
23 |
target_sizes = torch.Tensor([img.shape[:2]])
|
24 |
+
inputs = processor(text=text_queries, images=img, return_tensors="pt").to(device)
|
|
|
|
|
25 |
|
26 |
with torch.no_grad():
|
27 |
outputs = model(**inputs)
|
|
|
55 |
with Vision Transformers</a>.
|
56 |
\n\nYou can use OWL-ViT to query images with text descriptions of any object.
|
57 |
To use it, simply upload an image and enter comma separated text descriptions of objects you want to query the image for. You
|
58 |
+
can also use the score threshold slider to set a threshold to filter out low probability predictions.
|
59 |
+
|
60 |
+
\n\nOWL-ViT is trained on text templates,
|
61 |
+
hence you can get better predictions by querying the image with text templates used in training the original model: *"photo of a star-spangled banner"*,
|
62 |
+
*"image of a shoe"*. Refer to the <a href="https://arxiv.org/abs/2103.00020">CLIP</a> paper to see the full list of text templates used to augment the training data.
|
63 |
\n\n<a href="https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/zeroshot_object_detection_with_owlvit.ipynb">Colab demo</a>
|
64 |
"""
|
65 |
demo = gr.Interface(
|
|
|
68 |
outputs="image",
|
69 |
title="Zero-Shot Object Detection with OWL-ViT",
|
70 |
description=description,
|
71 |
+
examples=[
|
72 |
+
["assets/astronaut.png", "human face, rocket, star-spangled banner, nasa badge", 0.11],
|
73 |
+
["assets/coffee.png", "coffee mug, spoon, plate", 0.1],
|
74 |
+
["assets/butterflies.jpeg", "orange butterfly", 0.3],
|
75 |
+
],
|
76 |
)
|
77 |
demo.launch()
|
assets/.DS_Store
CHANGED
Binary files a/assets/.DS_Store and b/assets/.DS_Store differ
|
|
assets/butterflies.jpeg
ADDED