0

Image Extraction to Vector DB

End-to-end pipeline: extract structured descriptions from images with an agent, then embed and store them in a vector database for similarity search. The classic "build a searchable media library" labeling workflow.

Example · مثال

Content

Image Extraction to Vector DB

End-to-end pipeline: extract structured descriptions from images with an agent, then embed and store them in a vector database for similarity search. The classic "build a searchable media library" labeling workflow.

Files

  • basic.py — extract → embed → store → search. All in one file.

No variants. The value here is the full pipeline.

How it works

  1. For each image URL, an agent extracts a structured ImageDescription (subject, setting, mood, key objects).
  2. The structured fields are flattened to a single searchable string.
  3. The string is embedded with GeminiEmbedder and stored in LanceDb.
  4. A text query searches the index and returns the most similar images.

When to use

  • Searching a stock photo library by natural-language query.
  • Deduplicating a product catalog by description similarity. Note the search operates on the extracted text descriptions, not on image embeddings - two images match when their descriptions match.
  • Building "find more like this" features on user-uploaded media.

Run

Install the extra dependency for LanceDb first:

pip install lancedb
python cookbook/data_labeling/_09_image_extraction_to_vectordb/basic.py

Requires GOOGLE_API_KEY. Writes to tmp/lancedb/ under the repo root.

Source and license

Source
Agno
Original
agno-agi/agno/cookbook/data_labeling/_09_image_extraction_to_vectordb
License
Apache-2.0