mirror of
https://github.com/supabase/supabase.git
synced 2026-10-14 21:59:16 +03:00
improve image search README with setup and usage examples Enhanced the AI image search example README with comprehensive documentation improvements. ## What - Added Prerequisites section with system requirements - Enhanced Setup section with step-by-step Supabase configuration - Added "What to expect" sections for better user guidance - Included example search queries for testing - Added troubleshooting section for common issues - Explained how the CLIP model works in simple terms ## Why The previous README was missing crucial setup steps, prerequisites, and expected outputs, making it difficult for developers to use this AI example effectively. ## How - Maintained original formatting style and structure - Added missing prerequisite information - Provided clear step-by-step instructions - Included practical examples and troubleshooting tips
3.1 KiB
3.1 KiB
Image Search with Supabase Vector
In this example we're implementing image search using the OpenAI CLIP Model, which was trained on a variety of (image, text)-pairs.
We're implementing two methods in the /image_search/main.py file:
- The
seedmethod generates embeddings for the images in theimagesfolder and upserts them into a collection in Supabase Vector. - The
searchmethod generates an embedding from the search query and performs a vector similarity search query.
Prerequisites
Before running this example, ensure you have:
- Python 3.8 or higher installed
- A Supabase account (sign up at https://supabase.com)
- Poetry package manager
- Basic familiarity with vector databases (helpful but not required)
Setup
- Create a new project in your Supabase dashboard
- Go to Settings > Database and copy your connection string
- Ensure the Vector extension is enabled in your project
- Install poetry:
pip install poetry - Activate the virtual environment:
poetry shell- (to leave the venv just run
exit)
- (to leave the venv just run
- Install app dependencies:
poetry install
Run locally
Generate the embeddings and seed the collection
supabase startpoetry run seed- Check the embeddings stored in the local Supabase Dashboard: http://localhost:54323/project/default/editor > schema: vecs
What to expect: The seed command will process all images in the images folder and generate vector embeddings for each one.
Perform a search
poetry run search "bike in front of red brick wall"
What to expect: The search will return a list of images ranked by similarity to your search query, along with similarity scores.
Run on hosted Supabase project
- Set
DB_CONNECTIONwith the connection string from your hosted Supabase Dashboard: https://supabase.com/dashboard/project/_/settings/database > Connection string > URI
Example Search Queries
Try these search queries to test the image search functionality:
"bike in front of red brick wall""person walking in park""blue sky with clouds""city street at night"
Troubleshooting
Common Issues:
- Poetry not found: Make sure Poetry is installed with
pip install poetry - Connection errors: Verify your Supabase connection string is correct
- No search results: Ensure you've run the seed command first to populate the database
- Python version errors: This example requires Python 3.8 or higher
How It Works
This example uses the CLIP (Contrastive Language-Image Pre-training) model to:
- Convert images into high-dimensional vector representations (embeddings)
- Convert text search queries into similar vector representations
- Find images with embeddings most similar to the search query embedding
- Return ranked results based on vector similarity scores
Attributions
Models
clip-ViT-B-32 via Hugging Face
Images
Images from https://unsplash.com/license via https://picsum.photos/