# hoomesh0407/oral-cancer-prediction architecture

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

- Interactive diagram: https://gitdiagram.com/hoomesh0407/oral-cancer-prediction
- Repository: https://github.com/hoomesh0407/oral-cancer-prediction

## Overview

This repository is an oral-pathology image classification prototype: a web API accepts a slide image, predicts a differentiation grade, and returns a report; separate scripts train and compare four-class and three-class models and generate explanations. The main API path is visible in excerpts, while some model-loading and artifact wiring is not. Training and evaluation scripts are therefore shown as independently evidenced branches rather than an assumed end-to-end pipeline.

Main entry points: [`app_lora.py`](https://github.com/hoomesh0407/oral-cancer-prediction/blob/main/app_lora.py) (Prediction API), [`explain_lora.py`](https://github.com/hoomesh0407/oral-cancer-prediction/blob/main/explain_lora.py) (LoRA explanations), [`extract_embeddings.py`](https://github.com/hoomesh0407/oral-cancer-prediction/blob/main/extract_embeddings.py) (Embedding extraction), [`extract_embeddings_3class.py`](https://github.com/hoomesh0407/oral-cancer-prediction/blob/main/extract_embeddings_3class.py) (3-class embeddings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_product["Prediction product"]
  node_web_ui["Web interface<br/>[index.html]"]
  node_api["Prediction API<br/>[app_lora.py]"]
  node_image_prep["Image preparation<br/>[app_lora.py]"]
  node_classifier["Grade prediction<br/>[app_lora.py]"]
  node_report["Clinical report<br/>[app_lora.py]"]
  node_premium_ui["Premium interface<br/>[premium.html]"]
  node_doctor_ui["Doctor interface<br/>[doctor.html]"]
end

subgraph group_features["Model development"]
  node_embedding_extract["Embedding extraction"]
  node_embedding_3class["3-class embeddings"]
  node_classifier_training["Classifier training"]
  node_lora_training["LoRA training<br/>[train_lora.py]"]
  node_lora_3class_training["3-class LoRA"]
  node_densenet_training["DenseNet training"]
  node_frozen_training["Frozen classifier"]
  node_fusion_training["Fusion training"]
end

subgraph group_evaluation["Model evaluation"]
  node_baseline["Baseline comparison"]
  node_overfit["Overfit checks"]
  node_overfit_single["Overfit check"]
end

subgraph group_explanation["Interpretability"]
  node_explanation["LoRA explanations<br/>[explain_lora.py]"]
end

node_clinician(("Clinician"))
node_medsiglip["MedSigLIP model"]
node_image_files["Slide images"]
node_artifacts["Model artifacts"]

node_clinician -->|"opens"| node_web_ui
node_web_ui -.->|"submits images"| node_api
node_api -->|"cleans image"| node_image_prep
node_image_prep -->|"prepares pixels"| node_classifier
node_classifier -->|"produces grade"| node_report
node_report -.->|"returns result"| node_api
node_api -.->|"serves optionally"| node_premium_ui
node_api -.->|"serves doctor route"| node_doctor_ui
node_clinician -->|"uploads slide"| node_api
node_classifier -.->|"runs vision model"| node_medsiglip
node_image_files -->|"reads images"| node_embedding_extract
node_medsiglip -->|"extracts features"| node_embedding_extract
node_embedding_extract -.->|"saves embeddings"| node_artifacts
node_image_files -->|"reads images"| node_embedding_3class
node_medsiglip -->|"extracts features"| node_embedding_3class
node_embedding_3class -->|"saves tensors"| node_artifacts
node_artifacts -->|"loads embeddings"| node_classifier_training
node_artifacts -->|"loads embeddings"| node_frozen_training
node_image_files -->|"loads training images"| node_lora_training
node_medsiglip -->|"fine-tunes vision tower"| node_lora_training
node_image_files -->|"loads training images"| node_lora_3class_training
node_medsiglip -->|"fine-tunes vision tower"| node_lora_3class_training
node_image_files -->|"loads training images"| node_densenet_training
node_artifacts -->|"loads feature tensors"| node_fusion_training
node_image_files -->|"evaluates images"| node_baseline
node_image_files -->|"checks model splits"| node_overfit
node_image_files -.->|"checks overfitting"| node_overfit_single
node_image_files -->|"loads example slides"| node_explanation
node_medsiglip -->|"computes activations"| node_explanation
node_artifacts -->|"loads adapter and head"| node_explanation
node_explanation -->|"saves overlays"| node_artifacts

click node_web_ui "https://github.com/hoomesh0407/oral-cancer-prediction/blob/main/index.html"
click node_api "https://github.com/hoomesh0407/oral-cancer-prediction/blob/main/app_lora.py"
click node_image_prep "https://github.com/hoomesh0407/oral-cancer-prediction/blob/main/app_lora.py"
click node_classifier "https://github.com/hoomesh0407/oral-cancer-prediction/blob/main/app_lora.py"
click node_report "https://github.com/hoomesh0407/oral-cancer-prediction/blob/main/app_lora.py"
click node_premium_ui "https://github.com/hoomesh0407/oral-cancer-prediction/blob/main/premium.html"
click node_doctor_ui "https://github.com/hoomesh0407/oral-cancer-prediction/blob/main/doctor.html"
click node_embedding_extract "https://github.com/hoomesh0407/oral-cancer-prediction/blob/main/extract_embeddings.py"
click node_embedding_3class "https://github.com/hoomesh0407/oral-cancer-prediction/blob/main/extract_embeddings_3class.py"
click node_classifier_training "https://github.com/hoomesh0407/oral-cancer-prediction/blob/main/train_classifier.py"
click node_lora_training "https://github.com/hoomesh0407/oral-cancer-prediction/blob/main/train_lora.py"
click node_lora_3class_training "https://github.com/hoomesh0407/oral-cancer-prediction/blob/main/train_lora_3class.py"
click node_densenet_training "https://github.com/hoomesh0407/oral-cancer-prediction/blob/main/train_densenet_3class.py"
click node_frozen_training "https://github.com/hoomesh0407/oral-cancer-prediction/blob/main/train_frozen_3class.py"
click node_fusion_training "https://github.com/hoomesh0407/oral-cancer-prediction/blob/main/train_fusion_3class.py"
click node_baseline "https://github.com/hoomesh0407/oral-cancer-prediction/blob/main/baseline_comparison.py"
click node_overfit "https://github.com/hoomesh0407/oral-cancer-prediction/blob/main/overfit_check_all.py"
click node_overfit_single "https://github.com/hoomesh0407/oral-cancer-prediction/blob/main/check_overfitting.py"
click node_explanation "https://github.com/hoomesh0407/oral-cancer-prediction/blob/main/explain_lora.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_web_ui,node_api,node_image_prep,node_classifier,node_report,node_premium_ui,node_doctor_ui toneBlue
class node_embedding_extract,node_embedding_3class,node_classifier_training,node_lora_training,node_lora_3class_training,node_densenet_training,node_frozen_training,node_fusion_training toneAmber
class node_baseline,node_overfit,node_overfit_single toneMint
class node_explanation toneRose
class node_clinician,node_medsiglip,node_image_files,node_artifacts toneIndigo
```

## Components

### Prediction product

- [Web interface](https://github.com/hoomesh0407/oral-cancer-prediction/blob/main/index.html): `index.html`
- [Prediction API](https://github.com/hoomesh0407/oral-cancer-prediction/blob/main/app_lora.py): `app_lora.py`
- [Image preparation](https://github.com/hoomesh0407/oral-cancer-prediction/blob/main/app_lora.py): `app_lora.py`
- [Grade prediction](https://github.com/hoomesh0407/oral-cancer-prediction/blob/main/app_lora.py): `app_lora.py`
- [Clinical report](https://github.com/hoomesh0407/oral-cancer-prediction/blob/main/app_lora.py): `app_lora.py`
- [Premium interface](https://github.com/hoomesh0407/oral-cancer-prediction/blob/main/premium.html): `premium.html`
- [Doctor interface](https://github.com/hoomesh0407/oral-cancer-prediction/blob/main/doctor.html): `doctor.html`

### Model development

- [Embedding extraction](https://github.com/hoomesh0407/oral-cancer-prediction/blob/main/extract_embeddings.py): `extract_embeddings.py`
- [3-class embeddings](https://github.com/hoomesh0407/oral-cancer-prediction/blob/main/extract_embeddings_3class.py): `extract_embeddings_3class.py`
- [Classifier training](https://github.com/hoomesh0407/oral-cancer-prediction/blob/main/train_classifier.py): `train_classifier.py`
- [LoRA training](https://github.com/hoomesh0407/oral-cancer-prediction/blob/main/train_lora.py): `train_lora.py`
- [3-class LoRA](https://github.com/hoomesh0407/oral-cancer-prediction/blob/main/train_lora_3class.py): `train_lora_3class.py`
- [DenseNet training](https://github.com/hoomesh0407/oral-cancer-prediction/blob/main/train_densenet_3class.py): `train_densenet_3class.py`
- [Frozen classifier](https://github.com/hoomesh0407/oral-cancer-prediction/blob/main/train_frozen_3class.py): `train_frozen_3class.py`
- [Fusion training](https://github.com/hoomesh0407/oral-cancer-prediction/blob/main/train_fusion_3class.py): `train_fusion_3class.py`

### Model evaluation

- [Baseline comparison](https://github.com/hoomesh0407/oral-cancer-prediction/blob/main/baseline_comparison.py): `baseline_comparison.py`
- [Overfit checks](https://github.com/hoomesh0407/oral-cancer-prediction/blob/main/overfit_check_all.py): `overfit_check_all.py`
- [Overfit check](https://github.com/hoomesh0407/oral-cancer-prediction/blob/main/check_overfitting.py): `check_overfitting.py`

### Interpretability

- [LoRA explanations](https://github.com/hoomesh0407/oral-cancer-prediction/blob/main/explain_lora.py): `explain_lora.py`

### Other components

- **Clinician**
- **MedSigLIP model**
- **Slide images**
- **Model artifacts**

## Connections

- Clinician → Web interface: opens
- Web interface → Prediction API: submits images
- Prediction API → Image preparation: cleans image (evidence: `app_lora.py`)
- Image preparation → Grade prediction: prepares pixels (evidence: `app_lora.py`)
- Grade prediction → Clinical report: produces grade (evidence: `app_lora.py`)
- Clinical report → Prediction API: returns result (evidence: `app_lora.py`)
- Prediction API → Premium interface: serves optionally
- Prediction API → Doctor interface: serves doctor route
- Clinician → Prediction API: uploads slide (evidence: `app_lora.py`)
- Grade prediction → MedSigLIP model: runs vision model
- Slide images → Embedding extraction: reads images (evidence: `extract_embeddings.py`)
- MedSigLIP model → Embedding extraction: extracts features (evidence: `extract_embeddings.py`)
- Embedding extraction → Model artifacts: saves embeddings
- Slide images → 3-class embeddings: reads images (evidence: `extract_embeddings_3class.py`)
- MedSigLIP model → 3-class embeddings: extracts features (evidence: `extract_embeddings_3class.py`)
- 3-class embeddings → Model artifacts: saves tensors (evidence: `extract_embeddings_3class.py`)
- Model artifacts → Classifier training: loads embeddings (evidence: `train_classifier.py`)
- Model artifacts → Frozen classifier: loads embeddings (evidence: `train_frozen_3class.py`)
- Slide images → LoRA training: loads training images (evidence: `train_lora.py`)
- MedSigLIP model → LoRA training: fine-tunes vision tower (evidence: `train_lora.py`)
- Slide images → 3-class LoRA: loads training images (evidence: `train_lora_3class.py`)
- MedSigLIP model → 3-class LoRA: fine-tunes vision tower (evidence: `train_lora_3class.py`)
- Slide images → DenseNet training: loads training images (evidence: `train_densenet_3class.py`)
- Model artifacts → Fusion training: loads feature tensors (evidence: `train_fusion_3class.py`)
- Slide images → Baseline comparison: evaluates images (evidence: `baseline_comparison.py`)
- Slide images → Overfit checks: checks model splits (evidence: `overfit_check_all.py`)
- Slide images → Overfit check: checks overfitting
- Slide images → LoRA explanations: loads example slides (evidence: `explain_lora.py`)
- MedSigLIP model → LoRA explanations: computes activations (evidence: `explain_lora.py`)
- Model artifacts → LoRA explanations: loads adapter and head (evidence: `explain_lora.py`)
- LoRA explanations → Model artifacts: saves overlays (evidence: `explain_lora.py`)
