Image_search / README.md
ThirdFourthFifth's picture
Update README.md
473254f verified

A newer version of the Gradio SDK is available: 6.11.0

Upgrade
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:

  1. Load image URLs from an Excel spreadsheet (image_database.xlsx)
  2. Encode all images in the database into embeddings
  3. Encode your text query into an embedding
  4. Find images with the highest similarity to your query
  5. 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 (or URL, image_url, urls, link, or image) 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:

  1. Edit image_database.xlsx with your own image URLs
  2. Save the file
  3. Restart the Gradio app

The app will automatically load all URLs from the Excel file at startup.

Usage

  1. Enter a search query (e.g., "sunset", "cat", "mountains", "technology")
  2. Adjust the number of results you want to see
  3. Click "Search" or press Enter
  4. 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

  1. Create a new Space on Hugging Face
  2. Select "Gradio" as the SDK
  3. Upload app.py, requirements.txt, and image_database.xlsx
  4. The Space will automatically build and deploy

Files Included

  • app.py - Main Gradio application
  • requirements.txt - Python dependencies
  • image_database.xlsx - Excel spreadsheet containing image URLs
  • README.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.