Spaces:
Sleeping
Sleeping
A newer version of the Gradio SDK is available: 6.11.0
metadata
title: Image Search
sdk: gradio
emoji: π
colorFrom: pink
colorTo: red
Image Search with SigLIP2
An image search application powered by Google's SigLIP2 model (google/siglip2-so400m-patch16-naflex).
Features
- π Natural language image search
- πΌοΈ Search through a curated database of images
- π Similarity scores for each result
- π― Adjustable number of results (top-k)
- π Easy image management via Excel spreadsheet
How It Works
The app uses the SigLIP2 vision-language model to:
- Load image URLs from an Excel spreadsheet (
image_database.xlsx) - Encode all images in the database into embeddings
- Encode your text query into an embedding
- Find images with the highest similarity to your query
- Display the top matching results with similarity scores
Image Database Format
The app reads image URLs from an Excel file named image_database.xlsx. The Excel file should have:
- Required: A column named
url(orURL,image_url,urls,link, orimage) containing the image URLs - Optional: Additional columns like
description,category, etc. for your own reference
Example Excel Format:
| url | description |
|---|---|
| https://example.com/image1.jpg | Mountain landscape |
| https://example.com/image2.jpg | Cat photo |
| https://example.com/image3.jpg | Beach sunset |
To Update Your Image Database:
- Edit
image_database.xlsxwith your own image URLs - Save the file
- Restart the Gradio app
The app will automatically load all URLs from the Excel file at startup.
Usage
- Enter a search query (e.g., "sunset", "cat", "mountains", "technology")
- Adjust the number of results you want to see
- Click "Search" or press Enter
- View the matching images with their similarity scores
Example Queries
- "a cat"
- "mountain landscape"
- "beach sunset"
- "city skyline at night"
- "person running"
- "food on a plate"
- "car on the road"
- "flowers in bloom"
Model
This space uses the google/siglip2-so400m-patch16-naflex model, a state-of-the-art vision-language model from Google.
Local Setup
To run this locally:
pip install -r requirements.txt
python app.py
Make sure you have image_database.xlsx in the same directory.
Deployment on Hugging Face Spaces
- Create a new Space on Hugging Face
- Select "Gradio" as the SDK
- Upload
app.py,requirements.txt, andimage_database.xlsx - The Space will automatically build and deploy
Files Included
app.py- Main Gradio applicationrequirements.txt- Python dependenciesimage_database.xlsx- Excel spreadsheet containing image URLsREADME.md- This file
License
This application is provided as-is for demonstration purposes. The SigLIP2 model is provided by Google and subject to its own license terms.