This project implements an image search API using FastAPI and Qdrant for vector similarity search. It allows users to upload an image and find similar images from a pre-indexed collection.
- Image similarity search using vector embeddings
- FastAPI backend for handling image upload and search requests
- Integration with Qdrant for efficient vector similarity search
- CORS middleware for cross-origin requests
- Static file serving for frontend assets
- Python 3.11+
- Docker (optional, for containerization)
- Clone the repository:
git clone <repository-url>
cd <project-directory>
- Install the required dependencies:
pip install -r requirements.txt
The project uses environment variables for configuration. You can set these in a .env
file or directly in your environment:
QDRANT_URL=http://localhost:6333/
QDRANT_API_KEY=your_api_key
COLLECTION_NAME=nocnoc
EMBEDDINGS_MODEL=Qdrant/clip-ViT-B-32-vision
- Start the FastAPI server:
python main.py
-
The API will be available at
http://localhost:8000
. -
To search for similar images, send a POST request to
/image/search
with the image file in the request body.
POST /image/search
: Upload an image to search for similar images in the collection.
A Dockerfile is provided for containerization. To build and run the Docker image:
docker build -t image-search-api .
docker run -p 8000:8000 image-search-api
main.py
: FastAPI application and main entry pointconfig.py
: Configuration settings and environment variablesimage_searcher.py
: Image search functionality using Qdrantrequirements.txt
: Python dependenciesDockerfile
: Docker configuration for containerizationstatic/
: Directory for static frontend assets (if applicable)
The project includes a Jupyter notebook (image_search_processing.ipynb
) for data preprocessing and indexing. This notebook demonstrates how to:
- Load and preprocess image data
- Generate image embeddings using a pre-trained model
- Index the embeddings in Qdrant for efficient similarity search
Contributions are welcome! Please feel free to submit a Pull Request.
[Specify your license here]