Article
visual-searchimage-embeddingssimilarity-searchclipmultimodal-searchqdrantfastapigradio
Build a Visual Search Engine with CLIP and Qdrant
Deploy a reverse image search engine using the Visual Search Engine script. This pack shows you how to index your own images with CLIP, store them in Qdrant, and query them using text or other images via a Gradio web interface.
intermediate30 min5 steps
The play
- Set Up Environment and QdrantClone the example repository and install dependencies. This project uses Qdrant as the vector database, so you'll need to start a Qdrant instance using Docker.
- Prepare Your Image DatasetPlace your image files (.jpg, .png) into the `data/` directory. If you don't have images, you can run the provided script to download the Unsplash Lite dataset.
- Index Your Image CollectionRun the `index.py` script. It will process each image in the `data/` folder, generate embeddings using the CLIP model, and upload them to your running Qdrant instance for searching.
- Launch the Search Service and UIThe project includes a Gradio interface for easy interaction. Run `app.py` to launch a web server that provides both the backend API and the frontend user interface.
- Perform Visual SearchesOpen your browser to the URL provided by Gradio (usually http://127.0.0.1:7860). You can now search your image collection by typing a text description or uploading another image.
Starter code
#!/bin/bash # This script sets up and runs the Visual Search Engine. # Make sure you have Docker, Python 3.8+, and pip installed. # 1. Clone the repository and navigate into the project directory echo "Cloning repository..." git clone https://github.com/qdrant/examples.git cd examples/visual-search-engine # 2. Start Qdrant in a separate terminal # You must run this command in another terminal window before proceeding. echo "*********************************************************************" echo "IMPORTANT: In a SEPARATE terminal, run the following command:" echo "docker run -p 6333:6333 -p 6334:6334 qdrant/qdrant" echo "*********************************************************************" read -p "Press [Enter] after you have started Qdrant..." # 3. Install Python dependencies echo "Installing dependencies..." pip install -r requirements.txt # 4. Download a sample dataset (optional, can be skipped if you have your own) echo "Downloading sample dataset..." python download_data.py # 5. Index the images echo "Indexing images... This may take a few minutes." python index.py # 6. Launch the Gradio application echo "Launching the search UI..." echo "Open your browser to the URL provided below (e.g., http://127.0.0.1:7860)" python app.py