Spaces:
Runtime error
Runtime error
Vivien
commited on
Commit
β’
81c0cb7
1
Parent(s):
563e3ef
Switch to the large models
Browse files
README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
---
|
2 |
-
title: Search and Detect (CLIP/
|
3 |
emoji: π¦
|
4 |
colorFrom: indigo
|
5 |
colorTo: red
|
|
|
1 |
---
|
2 |
+
title: Search and Detect (CLIP/OWL-ViT)
|
3 |
emoji: π¦
|
4 |
colorFrom: indigo
|
5 |
colorTo: red
|
app.py
CHANGED
@@ -12,7 +12,7 @@ from transformers import OwlViTProcessor, OwlViTForObjectDetection
|
|
12 |
from transformers.image_utils import ImageFeatureExtractionMixin
|
13 |
import tokenizers
|
14 |
|
15 |
-
DEBUG =
|
16 |
if DEBUG:
|
17 |
MODEL = "vit-base-patch32"
|
18 |
OWL_MODEL = f"google/owlvit-base-patch32"
|
@@ -31,7 +31,7 @@ N_RESULTS = 6
|
|
31 |
|
32 |
color = st.get_option("theme.primaryColor")
|
33 |
if color is None:
|
34 |
-
color = (255,
|
35 |
else:
|
36 |
color = tuple(int(color.lstrip("#")[i : i + 2], 16) for i in (0, 2, 4))
|
37 |
|
@@ -215,7 +215,7 @@ This demo illustrates how you can both retrieve images containing certain object
|
|
215 |
|
216 |
**Tip 2**: change the score threshold below to adjust the sensitivity of the object detection.
|
217 |
|
218 |
-
*Built with OpenAI's [CLIP](https://openai.com/blog/clip/) model and Google's [
|
219 |
|
220 |
"""
|
221 |
|
@@ -266,13 +266,15 @@ def main():
|
|
266 |
)
|
267 |
|
268 |
_, c, _ = st.columns((1, 3, 1))
|
269 |
-
query = c.text_input("", value="
|
270 |
corpus = st.radio("", ["Unsplash", "Movies"])
|
271 |
|
272 |
if len(query) > 0:
|
273 |
if "/" in query:
|
274 |
queries = query.split("/")
|
275 |
-
clip_query, owl_query = ("/").join(queries[:-1]), queries[
|
|
|
|
|
276 |
else:
|
277 |
clip_query, owl_query = query, query
|
278 |
retrieved = image_search(clip_query, corpus)
|
|
|
12 |
from transformers.image_utils import ImageFeatureExtractionMixin
|
13 |
import tokenizers
|
14 |
|
15 |
+
DEBUG = False
|
16 |
if DEBUG:
|
17 |
MODEL = "vit-base-patch32"
|
18 |
OWL_MODEL = f"google/owlvit-base-patch32"
|
|
|
31 |
|
32 |
color = st.get_option("theme.primaryColor")
|
33 |
if color is None:
|
34 |
+
color = (255, 196, 35)
|
35 |
else:
|
36 |
color = tuple(int(color.lstrip("#")[i : i + 2], 16) for i in (0, 2, 4))
|
37 |
|
|
|
215 |
|
216 |
**Tip 2**: change the score threshold below to adjust the sensitivity of the object detection.
|
217 |
|
218 |
+
*Built with OpenAI's [CLIP](https://openai.com/blog/clip/) model and Google's [OWL-ViT](https://arxiv.org/abs/2205.06230) model, π€ Hugging Face's [transformers library](https://huggingface.co/transformers/), [Streamlit](https://streamlit.io/), 25k images from [Unsplash](https://unsplash.com/) and 8k images from [The Movie Database (TMDB)](https://www.themoviedb.org/)*
|
219 |
|
220 |
"""
|
221 |
|
|
|
266 |
)
|
267 |
|
268 |
_, c, _ = st.columns((1, 3, 1))
|
269 |
+
query = c.text_input("", value="koala")
|
270 |
corpus = st.radio("", ["Unsplash", "Movies"])
|
271 |
|
272 |
if len(query) > 0:
|
273 |
if "/" in query:
|
274 |
queries = query.split("/")
|
275 |
+
clip_query, owl_query = ("/").join(queries[:-1]).strip(), queries[
|
276 |
+
-1
|
277 |
+
].strip()
|
278 |
else:
|
279 |
clip_query, owl_query = query, query
|
280 |
retrieved = image_search(clip_query, corpus)
|