# dharunkumar-v/ai-skin-cancer-detection architecture

> Architecture diagram of the GitHub repository dharunkumar-v/ai-skin-cancer-detection, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dharunkumar-v/ai-skin-cancer-detection
- Repository: https://github.com/dharunkumar-v/ai-skin-cancer-detection

## Overview

This repository is a skin-lesion classification application plus its model-training and evaluation workflow. The user uploads an image through the web app; the route saves it, calls inference, and renders a label, confidence, and heatmap. Note that the web inference currently generates a colorized-image placeholder, while `src/gradcam.py` contains a separate Grad-CAM workflow and is not called by the route. Training, evaluation, and preprocessing links reflect the sampled source; the dataset itself is not present in the tree.

Main entry points: [`src/evaluate.py`](https://github.com/dharunkumar-v/ai-skin-cancer-detection/blob/main/src/evaluate.py) (Test evaluation), [`src/model_utils.py`](https://github.com/dharunkumar-v/ai-skin-cancer-detection/blob/main/src/model_utils.py) (Prediction helper), [`src/train.py`](https://github.com/dharunkumar-v/ai-skin-cancer-detection/blob/main/src/train.py) (Model training), [`src/gradcam.py`](https://github.com/dharunkumar-v/ai-skin-cancer-detection/blob/main/src/gradcam.py) (Grad-CAM workflow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web inference"]
  node_page["Upload and results<br/>[index.html]"]
  node_style["Page styling<br/>[style.css]"]
  node_route["FastAPI routes<br/>[main.py]"]
  node_predict["Prediction helper<br/>[model_utils.py]"]
end

subgraph group_ml["Model workflow"]
  node_transform["Image transforms<br/>[transforms.py]"]
  node_preprocess["Data preparation<br/>[preprocess.py]"]
  node_dataset["Dataset loader<br/>[dataset.py]"]
  node_train["Model training<br/>[train.py]"]
  node_evaluate["Test evaluation<br/>[evaluate.py]"]
end

subgraph group_explain["Explainability"]
  node_gradcam["Grad-CAM workflow<br/>[gradcam.py]"]
end

subgraph group_state["Files and data"]
  node_model["Saved weights<br/>[best_model.pth]"]
  node_uploads[("Uploaded images")]
  node_outputs[("Generated outputs")]
  node_inputdata[("HAM10000 input data")]
end

node_user(("Image uploader"))

node_user -->|"uploads image"| node_page
node_page -->|"submits request"| node_route
node_route -->|"renders results"| node_page
node_route -->|"saves image"| node_uploads
node_route -->|"calls inference"| node_predict
node_predict -->|"reads image"| node_uploads
node_predict -->|"loads weights"| node_model
node_predict -->|"gets transforms"| node_transform
node_predict -->|"writes heatmap"| node_uploads
node_preprocess -->|"reads metadata and images"| node_inputdata
node_train -->|"loads and splits data"| node_preprocess
node_train -->|"gets transforms"| node_transform
node_train -->|"creates datasets"| node_dataset
node_dataset -->|"reads image files"| node_inputdata
node_train -->|"saves best weights"| node_model
node_evaluate -->|"loads test split"| node_preprocess
node_evaluate -->|"gets transforms"| node_transform
node_evaluate -->|"creates test dataset"| node_dataset
node_evaluate -->|"loads weights"| node_model
node_evaluate -->|"saves confusion matrix"| node_outputs
node_gradcam -->|"loads weights"| node_model
node_gradcam -->|"gets transforms"| node_transform
node_gradcam -->|"reads image"| node_inputdata
node_gradcam -->|"saves visualization"| node_outputs

click node_page "https://github.com/dharunkumar-v/ai-skin-cancer-detection/blob/main/webapp/templates/index.html"
click node_style "https://github.com/dharunkumar-v/ai-skin-cancer-detection/blob/main/webapp/static/style.css"
click node_route "https://github.com/dharunkumar-v/ai-skin-cancer-detection/blob/main/webapp/main.py"
click node_predict "https://github.com/dharunkumar-v/ai-skin-cancer-detection/blob/main/src/model_utils.py"
click node_transform "https://github.com/dharunkumar-v/ai-skin-cancer-detection/blob/main/src/transforms.py"
click node_preprocess "https://github.com/dharunkumar-v/ai-skin-cancer-detection/blob/main/src/preprocess.py"
click node_dataset "https://github.com/dharunkumar-v/ai-skin-cancer-detection/blob/main/src/dataset.py"
click node_train "https://github.com/dharunkumar-v/ai-skin-cancer-detection/blob/main/src/train.py"
click node_evaluate "https://github.com/dharunkumar-v/ai-skin-cancer-detection/blob/main/src/evaluate.py"
click node_model "https://github.com/dharunkumar-v/ai-skin-cancer-detection/blob/main/models/best_model.pth"
click node_gradcam "https://github.com/dharunkumar-v/ai-skin-cancer-detection/blob/main/src/gradcam.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_page,node_style,node_route,node_predict toneBlue
class node_transform,node_preprocess,node_dataset,node_train,node_evaluate toneAmber
class node_gradcam toneMint
class node_model,node_uploads,node_outputs,node_inputdata toneRose
class node_user toneIndigo
```

## Components

### Web inference

- [Upload and results](https://github.com/dharunkumar-v/ai-skin-cancer-detection/blob/main/webapp/templates/index.html): `webapp/templates/index.html`
- [Page styling](https://github.com/dharunkumar-v/ai-skin-cancer-detection/blob/main/webapp/static/style.css): `webapp/static/style.css`
- [FastAPI routes](https://github.com/dharunkumar-v/ai-skin-cancer-detection/blob/main/webapp/main.py): `webapp/main.py`
- [Prediction helper](https://github.com/dharunkumar-v/ai-skin-cancer-detection/blob/main/src/model_utils.py): `src/model_utils.py`

### Model workflow

- [Image transforms](https://github.com/dharunkumar-v/ai-skin-cancer-detection/blob/main/src/transforms.py): `src/transforms.py`
- [Data preparation](https://github.com/dharunkumar-v/ai-skin-cancer-detection/blob/main/src/preprocess.py): `src/preprocess.py`
- [Dataset loader](https://github.com/dharunkumar-v/ai-skin-cancer-detection/blob/main/src/dataset.py): `src/dataset.py`
- [Model training](https://github.com/dharunkumar-v/ai-skin-cancer-detection/blob/main/src/train.py): `src/train.py`
- [Test evaluation](https://github.com/dharunkumar-v/ai-skin-cancer-detection/blob/main/src/evaluate.py): `src/evaluate.py`

### Explainability

- [Grad-CAM workflow](https://github.com/dharunkumar-v/ai-skin-cancer-detection/blob/main/src/gradcam.py): `src/gradcam.py`

### Files and data

- [Saved weights](https://github.com/dharunkumar-v/ai-skin-cancer-detection/blob/main/models/best_model.pth): `models/best_model.pth`
- **Uploaded images**
- **Generated outputs**
- **HAM10000 input data**

### Other components

- **Image uploader**

## Connections

- Image uploader → Upload and results: uploads image
- Upload and results → FastAPI routes: submits request
- FastAPI routes → Upload and results: renders results
- FastAPI routes → Uploaded images: saves image
- FastAPI routes → Prediction helper: calls inference
- Prediction helper → Uploaded images: reads image
- Prediction helper → Saved weights: loads weights
- Prediction helper → Image transforms: gets transforms
- Prediction helper → Uploaded images: writes heatmap
- Data preparation → HAM10000 input data: reads metadata and images
- Model training → Data preparation: loads and splits data
- Model training → Image transforms: gets transforms
- Model training → Dataset loader: creates datasets
- Dataset loader → HAM10000 input data: reads image files
- Model training → Saved weights: saves best weights
- Test evaluation → Data preparation: loads test split
- Test evaluation → Image transforms: gets transforms
- Test evaluation → Dataset loader: creates test dataset
- Test evaluation → Saved weights: loads weights
- Test evaluation → Generated outputs: saves confusion matrix
- Grad-CAM workflow → Saved weights: loads weights
- Grad-CAM workflow → Image transforms: gets transforms
- Grad-CAM workflow → HAM10000 input data: reads image
- Grad-CAM workflow → Generated outputs: saves visualization
