How rathodakashnayak/multimodal-fashion-context-retrieval-glance-ml-assignment works
Purpose and Entry Points
A local Python multimodal fashion-image retrieval system. It embeds fashion images with CLIP, stores vectors in a persistent Chroma database, retrieves candidates from natural-language queries, then applies attribute-aware re-ranking. Main executable paths are:
• Dataset preparation: data/download_dataset.py
• Index construction: indexer/index_images.py
• CLI retrieval: retriever/retrieve.py
• Local Gradio UI: app/demo.py
Dataset and Persistent Artifacts
The pipeline operates over categorized local fashion images and associated metadata:
• Images: data/images/
• Metadata: data/metadata.csv
• Persistent Chroma vector-store files: data/chroma_db/chroma.sqlite3, data/chroma_db/7387742d-b8c5-477e-9e42-61ac1635cf16/data_level0.bin
data/download_dataset.py is the acquisition/generation boundary. Indexing should be rerun after changing images or relevant metadata so vector records remain aligned with the dataset.
Embedding Extraction
indexer/feature_extractor.py owns image-feature generation, using CLIP-compatible multimodal embeddings. This is the representation boundary: image pixels become normalized vector embeddings suitable for similarity search. Query text must be encoded in the corresponding embedding space during retrieval.
Indexing and Vector Persistence
indexer/index_images.py orchestrates batch traversal of data/images/, feature extraction, and record creation. indexer/vector_store.py encapsulates interaction with the persisted Chroma store at data/chroma_db/.
Control flow: local image files → image embeddings and metadata → Chroma collection/storage. The index is a precomputed offline artifact; serving queries should consume it rather than re-embed the full image corpus.
Query Understanding
retriever/query_parser.py converts a free-form user query into structured fashion/context signals, including cues such as clothing category, color, location, and style. Its output is the bridge between broad CLIP semantic matching and explicit attribute preference logic.
Candidate Retrieval and Re-ranking
retriever/retrieve.py is the online retrieval coordinator and CLI entry point. It embeds the text query, requests top candidates from the vector store, parses query attributes, and produces final results.
retriever/scorer.py applies attribute-aware fusion/re-ranking to vector-search candidates. This is the precision boundary: semantic similarity supplies recall, while parsed fashion/context attributes adjust ordering. It should operate on a bounded candidate set returned by Chroma, not replace vector retrieval with exhaustive scoring.
Runtime and External Dependencies
The runtime is local Python with dependencies declared in requirements.txt. Material external libraries/services are CLIP/model inference, ChromaDB for local vector persistence, and Gradio for the local web interface. app/demo.py exposes the retrieval flow interactively at the configured local Gradio endpoint; it should call the same retrieval logic as retriever/retrieve.py to keep CLI and UI behavior consistent.
Main entry points: retrieve.py Retrieval coordinator · index_images.py Index builder · vector_store.py Chroma store adapter · feature_extractor.py CLIP feature extractor
Components 15
Dataset & artifacts
- Fashion images
data/images - Image metadata
data/metadata.csv - Persistent Chroma index · Precomputed image vectors and associated records.
data/chroma_db/chroma.sqlite3
Offline indexing
- Index builder · Traverses the corpus and creates vector records.
indexer/index_images.py - CLIP feature extractor · Produces normalized image and text embeddings in one space.
indexer/feature_extractor.py - CLIP inference
- Chroma store adapter · Encapsulates Chroma collection access.
indexer/vector_store.py
Online retrieval
- Retrieval coordinator · Embeds queries, retrieves candidates, and returns reranked results.
retriever/retrieve.py - Query parser · Extracts category, color, location, and style cues.
retriever/query_parser.py - Attribute reranker · Adjusts ordering within the bounded vector-search candidate set.
retriever/scorer.py
Entry points
- Dataset preparation · Acquires or generates the local dataset.
data/download_dataset.py - CLI query
retriever/retrieve.py - Gradio demo · Uses the shared retrieval flow interactively.
app/demo.py - Gradio
Other components
- Runtime dependencies
requirements.txt
Connections 18
- Dataset preparation → Fashion images: creates
- Dataset preparation → Image metadata: creates
- Fashion images → Index builder: batch input
- Image metadata → Index builder: record attributes
- Index builder → CLIP feature extractor: image batches
- CLIP feature extractor → CLIP inference: uses
- Index builder → Chroma store adapter: embeddings and metadata
- Chroma store adapter → Persistent Chroma index: persists records
- CLI query → Retrieval coordinator: invokes
- Gradio demo → Retrieval coordinator: invokes shared flow
- Gradio demo → Gradio: renders with
- Retrieval coordinator → CLIP feature extractor: encodes query text
- Retrieval coordinator → Chroma store adapter: requests top candidates
- Chroma store adapter → Persistent Chroma index: queries
- Retrieval coordinator → Query parser: parses query
- Retrieval coordinator → Attribute reranker: candidates and attributes
- Runtime dependencies → CLIP inference: declares
- Runtime dependencies → Gradio: declares