# rathodakashnayak/multimodal-fashion-context-retrieval-glance-ml-assignment architecture

> Architecture diagram of the GitHub repository rathodakashnayak/multimodal-fashion-context-retrieval-glance-ml-assignment, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rathodakashnayak/multimodal-fashion-context-retrieval-glance-ml-assignment
- Repository: https://github.com/rathodakashnayak/multimodal-fashion-context-retrieval-glance-ml-assignment

## Overview

#### 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: [`retriever/retrieve.py`](https://github.com/rathodakashnayak/multimodal-fashion-context-retrieval-glance-ml-assignment/blob/master/retriever/retrieve.py) (Retrieval coordinator), [`indexer/index_images.py`](https://github.com/rathodakashnayak/multimodal-fashion-context-retrieval-glance-ml-assignment/blob/master/indexer/index_images.py) (Index builder), [`indexer/vector_store.py`](https://github.com/rathodakashnayak/multimodal-fashion-context-retrieval-glance-ml-assignment/blob/master/indexer/vector_store.py) (Chroma store adapter), [`indexer/feature_extractor.py`](https://github.com/rathodakashnayak/multimodal-fashion-context-retrieval-glance-ml-assignment/blob/master/indexer/feature_extractor.py) (CLIP feature extractor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Dataset &amp; artifacts"]
  node_images["Fashion images<br/>image corpus"]
  node_metadata["Image metadata<br/>CSV metadata<br/>[metadata.csv]"]
  node_chroma_db[("Persistent Chroma index<br/>vector database<br/>[chroma.sqlite3]")]
end

subgraph group_indexing["Offline indexing"]
  node_index_images["Index builder<br/>Python batch job<br/>[index_images.py]"]
  node_feature_extractor{{"CLIP feature extractor<br/>embedding adapter"}}
  node_clip{{"CLIP inference<br/>model dependency"}}
  node_vector_store["Chroma store adapter<br/>persistence adapter<br/>[vector_store.py]"]
end

subgraph group_retrieval["Online retrieval"]
  node_retrieve["Retrieval coordinator<br/>Python retrieval service<br/>[retrieve.py]"]
  node_query_parser["Query parser<br/>attribute extraction<br/>[query_parser.py]"]
  node_scorer["Attribute reranker<br/>ranking logic<br/>[scorer.py]"]
end

subgraph group_interfaces["Entry points"]
  node_dataset_download["Dataset preparation<br/>Python script"]
  node_cli["CLI query<br/>command-line entry point<br/>[retrieve.py]"]
  node_gradio_demo["Gradio demo<br/>local web UI<br/>[demo.py]"]
  node_gradio{{"Gradio<br/>UI dependency"}}
end

node_requirements["Runtime dependencies<br/>Python requirements<br/>[requirements.txt]"]

node_dataset_download -->|"creates"| node_images
node_dataset_download -->|"creates"| node_metadata
node_images -->|"batch input"| node_index_images
node_metadata -->|"record attributes"| node_index_images
node_index_images -->|"image batches"| node_feature_extractor
node_feature_extractor -->|"uses"| node_clip
node_index_images -->|"embeddings and metadata"| node_vector_store
node_vector_store -->|"persists records"| node_chroma_db
node_cli -->|"invokes"| node_retrieve
node_gradio_demo -->|"invokes shared flow"| node_retrieve
node_gradio_demo -->|"renders with"| node_gradio
node_retrieve -->|"encodes query text"| node_feature_extractor
node_retrieve -->|"requests top candidates"| node_vector_store
node_vector_store -->|"queries"| node_chroma_db
node_retrieve -->|"parses query"| node_query_parser
node_retrieve -->|"candidates and attributes"| node_scorer
node_requirements -.->|"declares"| node_clip
node_requirements -.->|"declares"| node_gradio

click node_dataset_download "https://github.com/rathodakashnayak/multimodal-fashion-context-retrieval-glance-ml-assignment/blob/master/data/download_dataset.py"
click node_images "https://github.com/rathodakashnayak/multimodal-fashion-context-retrieval-glance-ml-assignment/tree/master/data/images"
click node_metadata "https://github.com/rathodakashnayak/multimodal-fashion-context-retrieval-glance-ml-assignment/blob/master/data/metadata.csv"
click node_index_images "https://github.com/rathodakashnayak/multimodal-fashion-context-retrieval-glance-ml-assignment/blob/master/indexer/index_images.py"
click node_feature_extractor "https://github.com/rathodakashnayak/multimodal-fashion-context-retrieval-glance-ml-assignment/blob/master/indexer/feature_extractor.py"
click node_vector_store "https://github.com/rathodakashnayak/multimodal-fashion-context-retrieval-glance-ml-assignment/blob/master/indexer/vector_store.py"
click node_chroma_db "https://github.com/rathodakashnayak/multimodal-fashion-context-retrieval-glance-ml-assignment/blob/master/data/chroma_db/chroma.sqlite3"
click node_retrieve "https://github.com/rathodakashnayak/multimodal-fashion-context-retrieval-glance-ml-assignment/blob/master/retriever/retrieve.py"
click node_query_parser "https://github.com/rathodakashnayak/multimodal-fashion-context-retrieval-glance-ml-assignment/blob/master/retriever/query_parser.py"
click node_scorer "https://github.com/rathodakashnayak/multimodal-fashion-context-retrieval-glance-ml-assignment/blob/master/retriever/scorer.py"
click node_cli "https://github.com/rathodakashnayak/multimodal-fashion-context-retrieval-glance-ml-assignment/blob/master/retriever/retrieve.py"
click node_gradio_demo "https://github.com/rathodakashnayak/multimodal-fashion-context-retrieval-glance-ml-assignment/blob/master/app/demo.py"
click node_requirements "https://github.com/rathodakashnayak/multimodal-fashion-context-retrieval-glance-ml-assignment/blob/master/requirements.txt"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_images,node_metadata,node_chroma_db toneBlue
class node_index_images,node_feature_extractor,node_clip,node_vector_store toneAmber
class node_retrieve,node_query_parser,node_scorer toneMint
class node_dataset_download,node_cli,node_gradio_demo,node_gradio toneRose
class node_requirements toneNeutral
```

## Components

### Dataset & artifacts

- [Fashion images](https://github.com/rathodakashnayak/multimodal-fashion-context-retrieval-glance-ml-assignment/tree/master/data/images): image corpus · `data/images`
- [Image metadata](https://github.com/rathodakashnayak/multimodal-fashion-context-retrieval-glance-ml-assignment/blob/master/data/metadata.csv): CSV metadata · `data/metadata.csv`
- [Persistent Chroma index](https://github.com/rathodakashnayak/multimodal-fashion-context-retrieval-glance-ml-assignment/blob/master/data/chroma_db/chroma.sqlite3): vector database · Precomputed image vectors and associated records. · `data/chroma_db/chroma.sqlite3`

### Offline indexing

- [Index builder](https://github.com/rathodakashnayak/multimodal-fashion-context-retrieval-glance-ml-assignment/blob/master/indexer/index_images.py): Python batch job · Traverses the corpus and creates vector records. · `indexer/index_images.py`
- [CLIP feature extractor](https://github.com/rathodakashnayak/multimodal-fashion-context-retrieval-glance-ml-assignment/blob/master/indexer/feature_extractor.py): embedding adapter · Produces normalized image and text embeddings in one space. · `indexer/feature_extractor.py`
- **CLIP inference**: model dependency
- [Chroma store adapter](https://github.com/rathodakashnayak/multimodal-fashion-context-retrieval-glance-ml-assignment/blob/master/indexer/vector_store.py): persistence adapter · Encapsulates Chroma collection access. · `indexer/vector_store.py`

### Online retrieval

- [Retrieval coordinator](https://github.com/rathodakashnayak/multimodal-fashion-context-retrieval-glance-ml-assignment/blob/master/retriever/retrieve.py): Python retrieval service · Embeds queries, retrieves candidates, and returns reranked results. · `retriever/retrieve.py`
- [Query parser](https://github.com/rathodakashnayak/multimodal-fashion-context-retrieval-glance-ml-assignment/blob/master/retriever/query_parser.py): attribute extraction · Extracts category, color, location, and style cues. · `retriever/query_parser.py`
- [Attribute reranker](https://github.com/rathodakashnayak/multimodal-fashion-context-retrieval-glance-ml-assignment/blob/master/retriever/scorer.py): ranking logic · Adjusts ordering within the bounded vector-search candidate set. · `retriever/scorer.py`

### Entry points

- [Dataset preparation](https://github.com/rathodakashnayak/multimodal-fashion-context-retrieval-glance-ml-assignment/blob/master/data/download_dataset.py): Python script · Acquires or generates the local dataset. · `data/download_dataset.py`
- [CLI query](https://github.com/rathodakashnayak/multimodal-fashion-context-retrieval-glance-ml-assignment/blob/master/retriever/retrieve.py): command-line entry point · `retriever/retrieve.py`
- [Gradio demo](https://github.com/rathodakashnayak/multimodal-fashion-context-retrieval-glance-ml-assignment/blob/master/app/demo.py): local web UI · Uses the shared retrieval flow interactively. · `app/demo.py`
- **Gradio**: UI dependency

### Other components

- [Runtime dependencies](https://github.com/rathodakashnayak/multimodal-fashion-context-retrieval-glance-ml-assignment/blob/master/requirements.txt): Python requirements · `requirements.txt`

## Connections

- 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
