# nitaid/ham10000-lesion-classification architecture

> Architecture diagram of the GitHub repository nitaid/ham10000-lesion-classification, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nitaid/ham10000-lesion-classification
- Repository: https://github.com/nitaid/ham10000-lesion-classification

## Overview

This repository is a HAM10000 skin-lesion classification research pipeline and single-image demo. Its main workflow prepares images and labels, creates lesion-safe (and deliberately leaky comparison) splits, trains and evaluates models, then summarizes results. Separate analyses measure lesion leakage and interpret predictions with confusion matrices and Grad-CAM. README commands document the overall workflow; source excerpts show the implementation and direct module dependencies. The dataset and run artifacts are not present in the supplied tree, so their paths are left null.

Main entry points: [`src/common.py`](https://github.com/nitaid/ham10000-lesion-classification/blob/main/src/common.py) (Loading, models, metrics), [`src/predict.py`](https://github.com/nitaid/ham10000-lesion-classification/blob/main/src/predict.py) (Classify image and Grad-CAM), [`src/train.py`](https://github.com/nitaid/ham10000-lesion-classification/blob/main/src/train.py) (Train and evaluate), [`src/interpret.py`](https://github.com/nitaid/ham10000-lesion-classification/blob/main/src/interpret.py) (Confusion matrix and Grad-CAM)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_prepare["Resize and label<br/>[prepare_data.py]"]
  node_processed[("Processed images and metadata")]
  node_splits["Split generation<br/>[splits.py]"]
  node_splitfiles[("Lesion and image splits")]
end

subgraph group_model["Model training"]
  node_common["Loading, models, metrics<br/>[common.py]"]
  node_training["Train and evaluate<br/>[train.py]"]
  node_runartifacts[("Run metrics, predictions, checkpoint")]
end

subgraph group_evaluation["Evaluation and analysis"]
  node_summarize["Aggregate experiment results<br/>[summarize.py]"]
  node_leakage["Seen versus unseen analysis"]
  node_interpret["Confusion matrix and Grad-CAM<br/>[interpret.py]"]
  node_results[("Analysis outputs")]
end

subgraph group_demo["Prediction demo"]
  node_predict["Classify image and Grad-CAM<br/>[predict.py]"]
end

node_dataset[("HAM10000 dataset")]
node_user(("Researcher"))
node_inputimage["Input dermatoscopic image"]

node_dataset -->|"provides images"| node_prepare
node_prepare -->|"writes resized data"| node_processed
node_processed -->|"provides metadata"| node_splits
node_splits -->|"writes splits"| node_splitfiles
node_processed -->|"loads images"| node_common
node_splitfiles -->|"loads split"| node_common
node_user -->|"starts runs"| node_training
node_training -->|"uses shared utilities"| node_common
node_training -->|"saves metrics and model"| node_runartifacts
node_runartifacts -->|"reads run metrics"| node_summarize
node_summarize -->|"writes summaries"| node_results
node_splitfiles -->|"reads image split"| node_leakage
node_runartifacts -->|"reads test predictions"| node_leakage
node_leakage -->|"writes leakage analysis"| node_results
node_runartifacts -->|"reads predictions and checkpoint"| node_interpret
node_interpret -->|"uses model and image helpers"| node_common
node_interpret -->|"writes figures and errors"| node_results
node_user -->|"requests prediction"| node_predict
node_inputimage -->|"provides image"| node_predict
node_predict -->|"builds model"| node_common
node_runartifacts -->|"loads checkpoint"| node_predict

click node_prepare "https://github.com/nitaid/ham10000-lesion-classification/blob/main/src/prepare_data.py"
click node_splits "https://github.com/nitaid/ham10000-lesion-classification/blob/main/src/splits.py"
click node_common "https://github.com/nitaid/ham10000-lesion-classification/blob/main/src/common.py"
click node_training "https://github.com/nitaid/ham10000-lesion-classification/blob/main/src/train.py"
click node_summarize "https://github.com/nitaid/ham10000-lesion-classification/blob/main/src/summarize.py"
click node_leakage "https://github.com/nitaid/ham10000-lesion-classification/blob/main/src/leakage_analysis.py"
click node_interpret "https://github.com/nitaid/ham10000-lesion-classification/blob/main/src/interpret.py"
click node_results "https://github.com/nitaid/ham10000-lesion-classification/tree/main/results"
click node_predict "https://github.com/nitaid/ham10000-lesion-classification/blob/main/src/predict.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_prepare,node_processed,node_splits,node_splitfiles toneBlue
class node_common,node_training,node_runartifacts,node_dataset toneAmber
class node_summarize,node_leakage,node_interpret,node_results toneMint
class node_predict toneRose
class node_user,node_inputimage toneIndigo
```

## Components

### Data preparation

- [Resize and label](https://github.com/nitaid/ham10000-lesion-classification/blob/main/src/prepare_data.py): `src/prepare_data.py`
- **Processed images and metadata**
- [Split generation](https://github.com/nitaid/ham10000-lesion-classification/blob/main/src/splits.py): `src/splits.py`
- **Lesion and image splits**

### Model training

- [Loading, models, metrics](https://github.com/nitaid/ham10000-lesion-classification/blob/main/src/common.py): `src/common.py`
- [Train and evaluate](https://github.com/nitaid/ham10000-lesion-classification/blob/main/src/train.py): `src/train.py`
- **Run metrics, predictions, checkpoint**

### Evaluation and analysis

- [Aggregate experiment results](https://github.com/nitaid/ham10000-lesion-classification/blob/main/src/summarize.py): `src/summarize.py`
- [Seen versus unseen analysis](https://github.com/nitaid/ham10000-lesion-classification/blob/main/src/leakage_analysis.py): `src/leakage_analysis.py`
- [Confusion matrix and Grad-CAM](https://github.com/nitaid/ham10000-lesion-classification/blob/main/src/interpret.py): `src/interpret.py`
- [Analysis outputs](https://github.com/nitaid/ham10000-lesion-classification/tree/main/results): `results`

### Prediction demo

- [Classify image and Grad-CAM](https://github.com/nitaid/ham10000-lesion-classification/blob/main/src/predict.py): `src/predict.py`

### Other components

- **HAM10000 dataset**
- **Researcher**
- **Input dermatoscopic image**

## Connections

- HAM10000 dataset → Resize and label: provides images (evidence: `README.md`)
- Resize and label → Processed images and metadata: writes resized data (evidence: `src/prepare_data.py`)
- Processed images and metadata → Split generation: provides metadata (evidence: `src/splits.py`)
- Split generation → Lesion and image splits: writes splits (evidence: `src/splits.py`)
- Processed images and metadata → Loading, models, metrics: loads images (evidence: `src/common.py`)
- Lesion and image splits → Loading, models, metrics: loads split (evidence: `src/common.py`)
- Researcher → Train and evaluate: starts runs (evidence: `README.md`)
- Train and evaluate → Loading, models, metrics: uses shared utilities (evidence: `src/train.py`)
- Train and evaluate → Run metrics, predictions, checkpoint: saves metrics and model (evidence: `src/train.py`)
- Run metrics, predictions, checkpoint → Aggregate experiment results: reads run metrics (evidence: `src/summarize.py`)
- Aggregate experiment results → Analysis outputs: writes summaries (evidence: `src/summarize.py`)
- Lesion and image splits → Seen versus unseen analysis: reads image split (evidence: `src/leakage_analysis.py`)
- Run metrics, predictions, checkpoint → Seen versus unseen analysis: reads test predictions (evidence: `src/leakage_analysis.py`)
- Seen versus unseen analysis → Analysis outputs: writes leakage analysis (evidence: `src/leakage_analysis.py`)
- Run metrics, predictions, checkpoint → Confusion matrix and Grad-CAM: reads predictions and checkpoint (evidence: `src/interpret.py`)
- Confusion matrix and Grad-CAM → Loading, models, metrics: uses model and image helpers (evidence: `src/interpret.py`)
- Confusion matrix and Grad-CAM → Analysis outputs: writes figures and errors (evidence: `src/interpret.py`)
- Researcher → Classify image and Grad-CAM: requests prediction (evidence: `README.md`)
- Input dermatoscopic image → Classify image and Grad-CAM: provides image (evidence: `src/predict.py`)
- Classify image and Grad-CAM → Loading, models, metrics: builds model (evidence: `src/predict.py`)
- Run metrics, predictions, checkpoint → Classify image and Grad-CAM: loads checkpoint (evidence: `src/predict.py`)
