A Python toolkit for converting images, generating rich natural-language descriptions, producing embeddings, and performing semantic/hybrid image search. The repository contains two versions (v1 for historical reference and v2 for the current implementation). v2 is the actively developed code path and uses ChromaDB for persistent vector storage.
This README covers: a feature guide, quick setup, usage examples (CLI and web), developer notes, and troubleshooting tips.
Image conversion
convert_image.py (present in both v1 and v2).Image description / captioning
v2/describe_image.py) or Hugging Face pipelines (when installed).caption_image pipeline orchestrates description generation and embedding extraction for bulk ingestion.Embeddings and vector storage
v2 uses ChromaDB (persistent client) and exposes PersistenceAPI for upsert/query/cleanup.v1 provides an alternate persistence implementation using SQLite + FAISS (images.db and faiss.index).siglip or clip (configurable).Hybrid semantic search
Interfaces
v2/image_cli.py: Click-based CLI exposing ingestion, search, inspection, cleanup, stats, and web server startup.v2/gui.py: Flask app used by the web CLI command to display search results in a grid.Model & resource management
v2/model_manager.py centralizes model loading and device detection (CUDA / MPS / CPU). Use environment variables such as HF_TOKEN for private HF models.Metrics & observability
v2/metrics.py to track ingestion and embedding costs.Tests & examples
v1/tests and v2/tests for core components (embeddings, search). Use pytest to run them.Prerequisites
requirements*.txt for environment-specific packages.v2/describe_image.py calls http://localhost:11434/api/generate by default.HF_TOKEN) if using private or rate-limited HF models.Basic setup
git clone <repo-url>
cd image_converter
python3 -m venv .venv
source .venv/bin/activate
v2 codebase (recommended):cd v2
pip install --upgrade pip
pip install -r requirements.txt
Notes on dependency files
requirements.txt, requirements_mac.txt, requirements310.txt, and requirements312.txt exist to support different targets. Prefer v2/requirements.txt for the primary v2 development path.Configure model credentials (optional)
# Set Hugging Face token for private models
export HF_TOKEN="<your-hf-token>"
# Ensure Ollama (if used) is running locally on port 11434
# ollama serve # (or follow Ollama docs)
Common workflows
Index (describe) a folder of images (ingest + index):
# from repo root
python v2/image_cli.py describe --ip /path/to/images --embed-model siglip --cap-model ollama --chroma-path ./chroma_db
Search (text or image query):
# text query
python v2/image_cli.py search --query "a dog running on the beach" --embed-model siglip
# image query
python v2/image_cli.py search --image /path/to/query.jpg --embed-model siglip
Inspect a stored image's metadata and embeddings:
python v2/image_cli.py inspect --image-path /path/to/image.jpg --embed-model siglip
Run the web UI (Flask):
python v2/image_cli.py web --host 0.0.0.0 --port 5000
# Then open http://localhost:5000
Cleanup empty text embeddings (captions/description chunks):
python v2/image_cli.py cleanup-embeddings --embed-model siglip
Purge a collection (destructive):
python v2/image_cli.py purge --model siglip
Developer & maintenance commands
pytest -q
pip install black ruff mypy
black .
ruff check .
mypy v2 --ignore-missing-imports
v2/image_cli.py — CLI front-end (Click) for v2 workflows.v2/caption_image.py — Orchestrates description generation and embedding for ingestion.v2/persistence.py — ChromaDB-backed PersistenceAPI (insert/update/query/upsert/cleanup).v2/model_manager.py — Loads and caches models (embedding and captioning).v2/find_similar.py — Hybrid search logic combining embeddings and text signals.v2/gui.py — Flask templates and handlers used by the web UI.v1/ — Historical v1 implementation using SQLite + FAISS; useful reference for alternative persistence patterns.Design considerations
v2 favors ChromaDB for persistent vector store and richer metadata handling.http://localhost:11434 or switch to --cap-model florence2 (requires HF models installed and HF_TOKEN if private)../chroma_db) contains data and that you used the same --embed-model when indexing and searching.Contributions are welcome. Suggested steps:
If you'd like, I can also:
pyproject.toml and a requirements-dev.txt for development tools.black) and replace ad-hoc print() logging with structured logging in key modules.A Python toolkit for converting images, generating rich natural-language descriptions, producing embeddings, and performing semantic/hybrid image search. The repository contains two versions (v1 for historical reference and v2 for the current implementation). v2 is the actively developed code path and uses ChromaDB for persistent vector storage.
This README covers: a feature guide, quick setup, usage examples (CLI and web), developer notes, and troubleshooting tips.
Image conversion
convert_image.py (present in both v1 and v2).Image description / captioning
v2/describe_image.py) or Hugging Face pipelines (when installed).caption_image pipeline orchestrates description generation and embedding extraction for bulk ingestion.Embeddings and vector storage
v2 uses ChromaDB (persistent client) and exposes PersistenceAPI for upsert/query/cleanup.v1 provides an alternate persistence implementation using SQLite + FAISS (images.db and faiss.index).siglip or clip (configurable).Hybrid semantic search
Interfaces
v2/image_cli.py: Click-based CLI exposing ingestion, search, inspection, cleanup, stats, and web server startup.v2/gui.py: Flask app used by the web CLI command to display search results in a grid.Model & resource management
v2/model_manager.py centralizes model loading and device detection (CUDA / MPS / CPU). Use environment variables such as HF_TOKEN for private HF models.Metrics & observability
v2/metrics.py to track ingestion and embedding costs.Tests & examples
v1/tests and v2/tests for core components (embeddings, search). Use pytest to run them.Prerequisites
requirements*.txt for environment-specific packages.v2/describe_image.py calls http://localhost:11434/api/generate by default.HF_TOKEN) if using private or rate-limited HF models.Basic setup
git clone <repo-url>
cd image_converter
python3 -m venv .venv
source .venv/bin/activate
v2 codebase (recommended):cd v2
pip install --upgrade pip
pip install -r requirements.txt
Notes on dependency files
requirements.txt, requirements_mac.txt, requirements310.txt, and requirements312.txt exist to support different targets. Prefer v2/requirements.txt for the primary v2 development path.Configure model credentials (optional)
# Set Hugging Face token for private models
export HF_TOKEN="<your-hf-token>"
# Ensure Ollama (if used) is running locally on port 11434
# ollama serve # (or follow Ollama docs)
Common workflows
Index (describe) a folder of images (ingest + index):
# from repo root
python v2/image_cli.py describe --ip /path/to/images --embed-model siglip --cap-model ollama --chroma-path ./chroma_db
Search (text or image query):
# text query
python v2/image_cli.py search --query "a dog running on the beach" --embed-model siglip
# image query
python v2/image_cli.py search --image /path/to/query.jpg --embed-model siglip
Inspect a stored image's metadata and embeddings:
python v2/image_cli.py inspect --image-path /path/to/image.jpg --embed-model siglip
Run the web UI (Flask):
python v2/image_cli.py web --host 0.0.0.0 --port 5000
# Then open http://localhost:5000
Cleanup empty text embeddings (captions/description chunks):
python v2/image_cli.py cleanup-embeddings --embed-model siglip
Purge a collection (destructive):
python v2/image_cli.py purge --model siglip
Developer & maintenance commands
pytest -q
pip install black ruff mypy
black .
ruff check .
mypy v2 --ignore-missing-imports
v2/image_cli.py — CLI front-end (Click) for v2 workflows.v2/caption_image.py — Orchestrates description generation and embedding for ingestion.v2/persistence.py — ChromaDB-backed PersistenceAPI (insert/update/query/upsert/cleanup).v2/model_manager.py — Loads and caches models (embedding and captioning).v2/find_similar.py — Hybrid search logic combining embeddings and text signals.v2/gui.py — Flask templates and handlers used by the web UI.v1/ — Historical v1 implementation using SQLite + FAISS; useful reference for alternative persistence patterns.Design considerations
v2 favors ChromaDB for persistent vector store and richer metadata handling.http://localhost:11434 or switch to --cap-model florence2 (requires HF models installed and HF_TOKEN if private)../chroma_db) contains data and that you used the same --embed-model when indexing and searching.Contributions are welcome. Suggested steps:
If you'd like, I can also:
pyproject.toml and a requirements-dev.txt for development tools.black) and replace ad-hoc print() logging with structured logging in key modules.