# sarandharshansp/amazon-ml-challenge-2024 architecture

> Architecture diagram of the GitHub repository sarandharshansp/amazon-ml-challenge-2024, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sarandharshansp/amazon-ml-challenge-2024
- Repository: https://github.com/sarandharshansp/amazon-ml-challenge-2024

## Overview

This repository implements an image-based product-attribute extraction workflow for the Amazon ML Challenge. A test record’s image link and entity name guide image preparation, prompting, Qwen-VL inference, and post-processing into a prediction CSV. The README documents those stages, but the relevant notebooks were not sampled, so their internal wiring is shown only where documented. The graph also includes image-download and output-format validation utilities; it does not infer how the saved output chunks are merged.

Main entry points: [`src/code.ipynb`](https://github.com/sarandharshansp/amazon-ml-challenge-2024/blob/main/src/code.ipynb) (Prepare image and prompt), [`src/utils.py`](https://github.com/sarandharshansp/amazon-ml-challenge-2024/blob/main/src/utils.py) (Image downloader), [`dataset/test.csv`](https://github.com/sarandharshansp/amazon-ml-challenge-2024/blob/main/dataset/test.csv) (Test records), [`src/constants.py`](https://github.com/sarandharshansp/amazon-ml-challenge-2024/blob/main/src/constants.py) (Entity units)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Extraction workflow"]
  node_image_download["Image downloader<br/>[utils.py]"]
  node_prep_prompt["Prepare image and prompt<br/>[code.ipynb]"]
  node_inference["Batch inference<br/>[code.ipynb]"]
  node_generated_text["Generated text<br/>[code.ipynb]"]
  node_postprocess["Extract and normalize values"]
  node_predictions["Prediction CSV"]
end

subgraph group_resources["Inputs and model"]
  node_test_data["Test records<br/>[test.csv]"]
  node_image_links["Product images"]
  node_image_service["Image URL host"]
  node_qwen["Qwen2-VL-2B"]
end

subgraph group_formatting["Output formatting"]
  node_entity_map["Entity units<br/>[constants.py]"]
  node_sanity["Format checker<br/>[sanity.py]"]
  node_parse["Prediction parser<br/>[utils.py]"]
end

node_user(("Challenge user"))

node_user -->|"provides records"| node_test_data
node_test_data -->|"supplies test data"| node_prep_prompt
node_test_data -->|"provides image links"| node_image_download
node_image_download -->|"fetches images"| node_image_service
node_image_download -->|"provides downloaded images"| node_prep_prompt
node_entity_map -->|"defines entity units"| node_prep_prompt
node_prep_prompt -->|"prepares inputs"| node_inference
node_inference -->|"requests generation"| node_qwen
node_qwen -->|"generates text"| node_generated_text
node_generated_text -->|"provides text"| node_postprocess
node_entity_map -->|"guides unit normalization"| node_postprocess
node_postprocess -->|"writes predictions"| node_predictions
node_user -->|"requests validation"| node_sanity
node_predictions -->|"checks output"| node_sanity
node_sanity -->|"parses predictions"| node_parse
node_parse -->|"checks allowed units"| node_entity_map

click node_test_data "https://github.com/sarandharshansp/amazon-ml-challenge-2024/blob/main/dataset/test.csv"
click node_image_download "https://github.com/sarandharshansp/amazon-ml-challenge-2024/blob/main/src/utils.py"
click node_prep_prompt "https://github.com/sarandharshansp/amazon-ml-challenge-2024/blob/main/src/code.ipynb"
click node_entity_map "https://github.com/sarandharshansp/amazon-ml-challenge-2024/blob/main/src/constants.py"
click node_inference "https://github.com/sarandharshansp/amazon-ml-challenge-2024/blob/main/src/code.ipynb"
click node_generated_text "https://github.com/sarandharshansp/amazon-ml-challenge-2024/blob/main/src/code.ipynb"
click node_postprocess "https://github.com/sarandharshansp/amazon-ml-challenge-2024/blob/main/src/post_processing.ipynb"
click node_predictions "https://github.com/sarandharshansp/amazon-ml-challenge-2024/tree/main/outputs"
click node_sanity "https://github.com/sarandharshansp/amazon-ml-challenge-2024/blob/main/src/sanity.py"
click node_parse "https://github.com/sarandharshansp/amazon-ml-challenge-2024/blob/main/src/utils.py"

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_image_download,node_prep_prompt,node_inference,node_generated_text,node_postprocess,node_predictions,node_user toneBlue
class node_test_data,node_image_links,node_image_service,node_qwen toneAmber
class node_entity_map,node_sanity,node_parse toneMint
```

## Components

### Extraction workflow

- [Image downloader](https://github.com/sarandharshansp/amazon-ml-challenge-2024/blob/main/src/utils.py): `src/utils.py`
- [Prepare image and prompt](https://github.com/sarandharshansp/amazon-ml-challenge-2024/blob/main/src/code.ipynb): `src/code.ipynb`
- [Batch inference](https://github.com/sarandharshansp/amazon-ml-challenge-2024/blob/main/src/code.ipynb): `src/code.ipynb`
- [Generated text](https://github.com/sarandharshansp/amazon-ml-challenge-2024/blob/main/src/code.ipynb): `src/code.ipynb`
- [Extract and normalize values](https://github.com/sarandharshansp/amazon-ml-challenge-2024/blob/main/src/post_processing.ipynb): `src/post_processing.ipynb`
- [Prediction CSV](https://github.com/sarandharshansp/amazon-ml-challenge-2024/tree/main/outputs): `outputs`

### Inputs and model

- [Test records](https://github.com/sarandharshansp/amazon-ml-challenge-2024/blob/main/dataset/test.csv): `dataset/test.csv`
- **Product images**
- **Image URL host**
- **Qwen2-VL-2B**

### Output formatting

- [Entity units](https://github.com/sarandharshansp/amazon-ml-challenge-2024/blob/main/src/constants.py): `src/constants.py`
- [Format checker](https://github.com/sarandharshansp/amazon-ml-challenge-2024/blob/main/src/sanity.py): `src/sanity.py`
- [Prediction parser](https://github.com/sarandharshansp/amazon-ml-challenge-2024/blob/main/src/utils.py): `src/utils.py`

### Other components

- **Challenge user**

## Connections

- Challenge user → Test records: provides records
- Test records → Prepare image and prompt: supplies test data
- Test records → Image downloader: provides image links
- Image downloader → Image URL host: fetches images
- Image downloader → Prepare image and prompt: provides downloaded images
- Entity units → Prepare image and prompt: defines entity units
- Prepare image and prompt → Batch inference: prepares inputs
- Batch inference → Qwen2-VL-2B: requests generation
- Qwen2-VL-2B → Generated text: generates text
- Generated text → Extract and normalize values: provides text
- Entity units → Extract and normalize values: guides unit normalization
- Extract and normalize values → Prediction CSV: writes predictions
- Challenge user → Format checker: requests validation
- Prediction CSV → Format checker: checks output
- Format checker → Prediction parser: parses predictions
- Prediction parser → Entity units: checks allowed units
