Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -76,7 +76,36 @@ def gradio_text_search(text):
|
|
| 76 |
# 5. Build Gradio App
|
| 77 |
# -----------------------------
|
| 78 |
with gr.Blocks() as demo:
|
| 79 |
-
gr.Markdown("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
with gr.Tab("Image Search"):
|
| 82 |
img_in = gr.Image(type="pil")
|
|
|
|
| 76 |
# 5. Build Gradio App
|
| 77 |
# -----------------------------
|
| 78 |
with gr.Blocks() as demo:
|
| 79 |
+
gr.Markdown("""
|
| 80 |
+
# 🐾 Animal Similarity Finder
|
| 81 |
+
|
| 82 |
+
Welcome! This app allows you to find animals that look visually similar using image and text embeddings.
|
| 83 |
+
|
| 84 |
+
How it works
|
| 85 |
+
- The model uses **CLIP embeddings** to compare your input with a database of animal images.
|
| 86 |
+
- It returns the **Top 3 most similar images** from the Animals-10 dataset.
|
| 87 |
+
|
| 88 |
+
Image Search
|
| 89 |
+
Upload a picture of an animal (dog, cat, spider, butterfly, horse, etc.).
|
| 90 |
+
The app will analyze the image and show you the 3 closest matches based on **visual similarity**.
|
| 91 |
+
|
| 92 |
+
Text Search
|
| 93 |
+
Type a description like:
|
| 94 |
+
- **"pet"** → finds dogs & cats
|
| 95 |
+
- **"bug"** → finds spiders
|
| 96 |
+
- **"farm animal"** → finds sheep, cows, horses
|
| 97 |
+
- **"bird"** → finds chickens
|
| 98 |
+
|
| 99 |
+
The model converts your text into an embedding and returns the 3 images most related to your description.
|
| 100 |
+
|
| 101 |
+
Behind the scenes
|
| 102 |
+
- Embeddings generated with **CLIP (ViT-B/32)**
|
| 103 |
+
- Similarity is computed using **cosine similarity**
|
| 104 |
+
- All embeddings are precomputed for speed
|
| 105 |
+
|
| 106 |
+
Enjoy exploring the animal dataset! 🐶🐱🐴🦋🕷️
|
| 107 |
+
""")
|
| 108 |
+
|
| 109 |
|
| 110 |
with gr.Tab("Image Search"):
|
| 111 |
img_in = gr.Image(type="pil")
|