# wrathemperor/skincancerdetection_ham100000 architecture

> Architecture diagram of the GitHub repository wrathemperor/skincancerdetection_ham100000, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/wrathemperor/skincancerdetection_ham100000
- Repository: https://github.com/wrathemperor/skincancerdetection_ham100000

## Overview

#### Purpose and Entrypoints
This repository trains and serves a seven-class dermatoscopic lesion classifier based on HAM10000. It has three operational entrypoints:
- Dataset organization and imbalance handling: `prepare_data.py`
- Transfer-learning training, fine-tuning, and evaluation: `main.py`
- Flask image-upload inference UI: `app.py`

#### Data Preparation and Split Boundary
`prepare_data.py` ingests the externally downloaded HAM10000 metadata and image partitions, performs stratified 70/15/15 train-validation-test splitting, and strategically oversamples underrepresented training classes. Its output is an expected on-disk dataset layout under `data/HAM10000/` (not present in this tree), separating immutable validation/test samples from augmented/duplicated training inputs.
- `prepare_data.py`
- `config.py`

#### Training Input Pipeline
`data_preprocessing.py` constructs image-loading and augmentation pipelines for the prepared splits. Training receives real-time geometric and brightness augmentation; validation and test data are intended as evaluation-only flows. This component bridges directory-organized image data to TensorFlow/Keras model fitting.
- `data_preprocessing.py`
- `config.py`

#### Model Construction
`model_architecture.py` defines the CNN around ImageNet-pretrained MobileNetV3Small. The architecture adds pooling, normalization, dropout, and dense classification layers for the seven HAM10000 categories. The pretrained backbone creates the principal external-model dependency and supports staged transfer learning/fine-tuning.
- `model_architecture.py`
- `config.py`

#### Training, Checkpointing, and Evaluation
`main.py` orchestrates model creation, initial transfer-learning training, fine-tuning, cosine-decay scheduling, AdamW optimization, early stopping, and Keras checkpoint persistence. It consumes generators from the preprocessing stage and emits deployable `.keras` models plus evaluation artifacts. Visualization functions are separated into a source module for training-history, class-distribution, and confusion-matrix outputs.
- `main.py`
- `model_architecture.py`
- `data_preprocessing.py`
- `src/visualization.py`
- `results`

#### Serving and Inference Boundary
`app.py` is a Flask development-server entrypoint. It loads a trained Keras model, accepts user-uploaded lesion images, preprocesses them into model input, executes inference, and returns predicted class/confidence through the HTML interface. Uploaded files cross a trust boundary and are stored under the static upload directory.
- `app.py`
- `templates/index.html`
- `static/uploads`

#### Runtime and External Dependencies
The stack is Python 3.9+, TensorFlow/Keras for MobileNetV3 training and inference, Flask for local HTTP/UI serving, and Matplotlib/Seaborn for result plots. External inputs are the Kaggle-hosted HAM10000 dataset and ImageNet pretrained weights; trained model files and dataset directories are runtime artifacts described by the project but absent from the checked-in tree.
- `requirements.txt`
- `config.py`
- `src/run.sh`
- `src/run.bat`

Main entry points: [`main.py`](https://github.com/wrathemperor/skincancerdetection_ham100000/blob/main/main.py) (Training and evaluation), [`app.py`](https://github.com/wrathemperor/skincancerdetection_ham100000/blob/main/app.py) (Flask inference app), [`config.py`](https://github.com/wrathemperor/skincancerdetection_ham100000/blob/main/config.py) (Shared configuration), [`prepare_data.py`](https://github.com/wrathemperor/skincancerdetection_ham100000/blob/main/prepare_data.py) (Dataset preparation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data pipeline"]
  node_ham10000[("HAM10000 dataset<br/>external dataset")]
  node_prepare["Dataset preparation<br/>Python entrypoint<br/>[prepare_data.py]"]
  node_dataset_layout[("Prepared dataset splits<br/>runtime artifact")]
  node_preprocessing["Image pipelines<br/>data preprocessing"]
end

subgraph group_training["Training"]
  node_imagenet[("ImageNet weights<br/>external model")]
  node_architecture["MobileNetV3 classifier<br/>model builder"]
  node_training_entrypoint["Training and evaluation<br/>Python entrypoint<br/>[main.py]"]
  node_trained_models[("Trained Keras models<br/>runtime artifact")]
  node_visualization["Training visualizations<br/>Python module<br/>[visualization.py]"]
  node_results["Evaluation results<br/>runtime artifact"]
end

subgraph group_serving["Serving"]
  node_flask_app["Flask inference app<br/>Python entrypoint<br/>[app.py]"]
  node_upload_store[("Uploaded images<br/>runtime storage")]
  node_ui["Inference interface<br/>HTML template<br/>[index.html]"]
end

node_config["Shared configuration<br/>Python module<br/>[config.py]"]
node_runtime_scripts["Run scripts<br/>shell launchers<br/>[run.sh]"]
node_dependencies["Python dependencies<br/>dependency manifest<br/>[requirements.txt]"]

node_ham10000 -->|"metadata and images"| node_prepare
node_config -->|"split settings"| node_prepare
node_prepare -->|"stratified 70/15/15 splits"| node_dataset_layout
node_dataset_layout -->|"organized images"| node_preprocessing
node_config -->|"image settings"| node_preprocessing
node_preprocessing -->|"augmented train and eval generators"| node_training_entrypoint
node_imagenet -->|"pretrained backbone"| node_architecture
node_config -->|"model settings"| node_architecture
node_architecture -->|"model construction"| node_training_entrypoint
node_training_entrypoint -->|"checkpoints and final model"| node_trained_models
node_training_entrypoint -->|"training metrics"| node_visualization
node_visualization -->|"plots"| node_results
node_training_entrypoint -->|"evaluation artifacts"| node_results
node_trained_models -->|"loads model"| node_flask_app
node_ui -->|"image upload request"| node_flask_app
node_flask_app -->|"stores uploaded file"| node_upload_store
node_flask_app -->|"prediction and confidence"| node_ui
node_runtime_scripts -.->|"launches"| node_flask_app
node_dependencies -.->|"runtime libraries"| node_training_entrypoint
node_dependencies -.->|"runtime libraries"| node_flask_app

click node_prepare "https://github.com/wrathemperor/skincancerdetection_ham100000/blob/main/prepare_data.py"
click node_preprocessing "https://github.com/wrathemperor/skincancerdetection_ham100000/blob/main/data_preprocessing.py"
click node_config "https://github.com/wrathemperor/skincancerdetection_ham100000/blob/main/config.py"
click node_architecture "https://github.com/wrathemperor/skincancerdetection_ham100000/blob/main/model_architecture.py"
click node_training_entrypoint "https://github.com/wrathemperor/skincancerdetection_ham100000/blob/main/main.py"
click node_visualization "https://github.com/wrathemperor/skincancerdetection_ham100000/blob/main/src/visualization.py"
click node_results "https://github.com/wrathemperor/skincancerdetection_ham100000/tree/main/results"
click node_flask_app "https://github.com/wrathemperor/skincancerdetection_ham100000/blob/main/app.py"
click node_upload_store "https://github.com/wrathemperor/skincancerdetection_ham100000/tree/main/static/uploads"
click node_ui "https://github.com/wrathemperor/skincancerdetection_ham100000/blob/main/templates/index.html"
click node_runtime_scripts "https://github.com/wrathemperor/skincancerdetection_ham100000/blob/main/src/run.sh"
click node_dependencies "https://github.com/wrathemperor/skincancerdetection_ham100000/blob/main/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_ham10000,node_prepare,node_dataset_layout,node_preprocessing toneBlue
class node_imagenet,node_architecture,node_training_entrypoint,node_trained_models,node_visualization,node_results toneAmber
class node_flask_app,node_upload_store,node_ui toneMint
class node_config,node_runtime_scripts,node_dependencies toneNeutral
```

## Components

### Data pipeline

- **HAM10000 dataset**: external dataset · Kaggle images and metadata.
- [Dataset preparation](https://github.com/wrathemperor/skincancerdetection_ham100000/blob/main/prepare_data.py): Python entrypoint · Stratifies splits and oversamples training classes. · `prepare_data.py`
- **Prepared dataset splits**: runtime artifact · Train, validation, and test directory layout.
- [Image pipelines](https://github.com/wrathemperor/skincancerdetection_ham100000/blob/main/data_preprocessing.py): data preprocessing · Loads splits and applies train-only augmentation. · `data_preprocessing.py`

### Training

- **ImageNet weights**: external model · Pretrained MobileNetV3Small weights.
- [MobileNetV3 classifier](https://github.com/wrathemperor/skincancerdetection_ham100000/blob/main/model_architecture.py): model builder · Transfer-learning model with seven-class classification head. · `model_architecture.py`
- [Training and evaluation](https://github.com/wrathemperor/skincancerdetection_ham100000/blob/main/main.py): Python entrypoint · Runs transfer learning, fine-tuning, checkpointing, and evaluation. · `main.py`
- **Trained Keras models**: runtime artifact · Deployable .keras checkpoints.
- [Training visualizations](https://github.com/wrathemperor/skincancerdetection_ham100000/blob/main/src/visualization.py): Python module · Produces history, distribution, and confusion-matrix plots. · `src/visualization.py`
- [Evaluation results](https://github.com/wrathemperor/skincancerdetection_ham100000/tree/main/results): runtime artifact · `results`

### Serving

- [Flask inference app](https://github.com/wrathemperor/skincancerdetection_ham100000/blob/main/app.py): Python entrypoint · Loads a model and serves image-upload inference. · `app.py`
- [Uploaded images](https://github.com/wrathemperor/skincancerdetection_ham100000/tree/main/static/uploads): runtime storage · Untrusted uploads stored before inference. · `static/uploads`
- [Inference interface](https://github.com/wrathemperor/skincancerdetection_ham100000/blob/main/templates/index.html): HTML template · `templates/index.html`

### Other components

- [Shared configuration](https://github.com/wrathemperor/skincancerdetection_ham100000/blob/main/config.py): Python module · `config.py`
- [Run scripts](https://github.com/wrathemperor/skincancerdetection_ham100000/blob/main/src/run.sh): shell launchers · Platform-specific local launch helpers. · `src/run.sh`
- [Python dependencies](https://github.com/wrathemperor/skincancerdetection_ham100000/blob/main/requirements.txt): dependency manifest · TensorFlow/Keras, Flask, Matplotlib, and Seaborn. · `requirements.txt`

## Connections

- HAM10000 dataset → Dataset preparation: metadata and images
- Shared configuration → Dataset preparation: split settings
- Dataset preparation → Prepared dataset splits: stratified 70/15/15 splits
- Prepared dataset splits → Image pipelines: organized images
- Shared configuration → Image pipelines: image settings
- Image pipelines → Training and evaluation: augmented train and eval generators
- ImageNet weights → MobileNetV3 classifier: pretrained backbone
- Shared configuration → MobileNetV3 classifier: model settings
- MobileNetV3 classifier → Training and evaluation: model construction
- Training and evaluation → Trained Keras models: checkpoints and final model
- Training and evaluation → Training visualizations: training metrics
- Training visualizations → Evaluation results: plots
- Training and evaluation → Evaluation results: evaluation artifacts
- Trained Keras models → Flask inference app: loads model
- Inference interface → Flask inference app: image upload request
- Flask inference app → Uploaded images: stores uploaded file
- Flask inference app → Inference interface: prediction and confidence
- Run scripts → Flask inference app: launches
- Python dependencies → Training and evaluation: runtime libraries
- Python dependencies → Flask inference app: runtime libraries
