Back to Cocoindex

Image Search with CocoIndex (v1)

examples/image_search/README.md

1.0.61.8 KB
Original Source

Image Search with CocoIndex (v1)

This example builds an image search index with CLIP embeddings and Qdrant, then queries it with natural language via a small FastAPI server and React frontend.

We appreciate a star ⭐ at CocoIndex Github if this is helpful.

Technologies

  • CocoIndex v1 app pipeline
  • CLIP ViT-L/14 for embeddings
  • Qdrant for vector storage

Setup

  • A running Postgres. If you don't have one, start a local instance with the compose file in this repo:

    sh
    docker compose -f ../../dev/postgres.yaml up -d
    
  • Make sure Qdrant is running

    sh
    docker run -d -p 6334:6334 -p 6333:6333 qdrant/qdrant
    

Run

Install dependencies:

sh
pip install -e .

Start the FastAPI server:

sh
python -m uvicorn api:app --reload --host 0.0.0.0 --port 8000

The server runs the index in live mode in the background — startup blocks until the initial sweep over img/ finishes (so the collection is queryable), then file changes keep flowing into Qdrant while requests are served. There is no separate "build the index" step.

Then in another terminal, start the frontend:

sh
cd frontend
npm install
npm run dev

Then open http://localhost:5173.

Code layout

  • pipeline.py — defines the CocoIndex app, the CLIP embedder helpers, and a small _qdrant_search shim. Library only — not an entry point.
  • api.py — FastAPI server. Imports pipeline, runs pipeline.app.update(live=True) in the background, and exposes /search.