A high-performance, multimodal search engine powered by OpenAI CLIP and Qdrant Vector Database.
This project implements a semantic search engine that allows users to find images using natural language descriptions (e.g., "a peaceful mountain lake at sunset") or by uploading a reference image.
Unlike traditional keyword search, this system understands the content and context of images using high-dimensional vector embeddings generated by the CLIP (Contrastive Language-Image Pre-training) model.
The application follows a modern microservices pattern:
- Frontend (Streamlit): Lightweight UI for user interaction and result visualization.
- Backend (FastAPI): Handles model inference (CPU/GPU) and coordinates with the database.
- Database (Qdrant): Stores 512-dimensional vector embeddings and metadata.
Before running the project, ensure you have the following installed:
- Docker Desktop (Required to run Qdrant and the Microservices).
- Python 3.13+ (For running local setup scripts).
- Unsplash Lite Dataset:
- Download the Unsplash Lite Dataset (25k images) freely available online.
- Extract it to a folder on your machine (e.g.,
Downloads/unsplash-lite).
You must update the file paths to point to your downloaded dataset.
-
Update
docker-compose.yml: Change the volume path underservices: -> backend:andservices: -> frontend:to match your local image folder.volumes: - C:/Path/To/Your/unsplash-lite:/data/images:ro
-
Update
qdrant_setup.py: Update theIMAGE_FOLDERvariable at the top of the file:IMAGE_FOLDER = r"C:\Path\To\Your\unsplash-lite"
-
Clone the repository:
git clone https://github.com/yourusername/semantic-image-search.git cd semantic-image-search -
Start the Services: Run the following command to build and start the Docker containers:
docker-compose up --build
Wait until you see the logs
Uvicorn running on http://0.0.0.0:8000andStreamlit ... http://0.0.0.0:8501.
Once the Docker containers are running (specifically the Qdrant database on port 6333), you need to populate the database with your images.
Open a new terminal window and run:
# Make sure you have the dependencies installed locally first
pip install -r requirements.txt
# Run the ingestion script
python qdrant_setup.py- Frontend (UI): http://localhost:8501 - Open this in your browser to use the search engine.
- Backend (API Docs): http://localhost:8000/docs - Swagger UI for testing API endpoints.
- Qdrant Dashboard: http://localhost:6333/dashboard - View your vector collection status.
This project uses Docker Bind Mounts (./qdrant_data:/qdrant/storage) for simplicity and portability. This ensures:
- Zero-Config: You can clone the repo and run it without setting up external database clouds.
- Easy Backup: All your vector data is visible in the
qdrant_datafolder on your host machine.
Note for Production: In a large-scale enterprise environment, this would typically be replaced by Docker Named Volumes (for better I/O performance) or a Managed Vector Database (like Qdrant Cloud or AWS RDS) to handle backups and high availability.
| Component | Technology | Description |
|---|---|---|
| Model | OpenAI CLIP | Multimodal (Text-to-Image) Embeddings |
| Backend | FastAPI | High-performance Async API |
| Frontend | Streamlit | Data Science & ML Web Interface |
| Database | Qdrant | Vector Search Engine (Running in Docker) |
| DevOps | Docker Compose | Container Orchestration |
- Dimension: 512
- Search Latency: < 50ms (Approx, depends on hardware)
- Model: ViT-B/16 (Running on Python 3.13)
