# mazenshalaby/ai-models architecture

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

- Interactive diagram: https://gitdiagram.com/mazenshalaby/ai-models
- Repository: https://github.com/mazenshalaby/ai-models

## Overview

This is a Flask image-classification service for colon, lung, leukemia, and skin cancer. A client uploads an image and cancer type; the API validates the request, selects a preloaded model, and calls the prediction utility. That utility applies the relevant image preprocessing, runs inference, and maps the highest-scoring class to a label and confidence. The excerpts show the request and inference flow; there is no README or evidence for additional product capabilities.

Main entry points: [`app.py`](https://github.com/mazenshalaby/ai-models/blob/main/app.py) (Prediction endpoint), [`utils/preprocess.py`](https://github.com/mazenshalaby/ai-models/blob/main/utils/preprocess.py) (Image preprocessing), [`models/colon_model.h5`](https://github.com/mazenshalaby/ai-models/blob/main/models/colon_model.h5) (Colon model), [`models/lung_model.h5`](https://github.com/mazenshalaby/ai-models/blob/main/models/lung_model.h5) (Lung model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_predict_route["Prediction endpoint<br/>[app.py]"]
end

subgraph group_inference["Inference"]
  node_preprocessing["Image preprocessing<br/>[preprocess.py]"]
  node_classification["Class and confidence<br/>[preprocess.py]"]
  node_colon_model["Colon model<br/>[colon_model.h5]"]
  node_lung_model["Lung model<br/>[lung_model.h5]"]
  node_leukemia_model["Leukemia model<br/>[leukemia_model.h5]"]
  node_skin_model["Skin model<br/>[skin_model.h5]"]
end

node_client(("Client"))

node_client -->|"uploads image"| node_predict_route
node_predict_route -->|"loads at startup"| node_colon_model
node_predict_route -->|"loads at startup"| node_lung_model
node_predict_route -->|"loads at startup"| node_leukemia_model
node_predict_route -->|"loads at startup"| node_skin_model
node_predict_route -->|"calls prediction"| node_preprocessing
node_preprocessing -->|"maps scores"| node_classification
node_preprocessing -.->|"runs inference"| node_colon_model
node_preprocessing -.->|"runs inference"| node_lung_model
node_preprocessing -.->|"runs inference"| node_leukemia_model
node_preprocessing -.->|"runs inference"| node_skin_model

click node_predict_route "https://github.com/mazenshalaby/ai-models/blob/main/app.py"
click node_preprocessing "https://github.com/mazenshalaby/ai-models/blob/main/utils/preprocess.py"
click node_classification "https://github.com/mazenshalaby/ai-models/blob/main/utils/preprocess.py"
click node_colon_model "https://github.com/mazenshalaby/ai-models/blob/main/models/colon_model.h5"
click node_lung_model "https://github.com/mazenshalaby/ai-models/blob/main/models/lung_model.h5"
click node_leukemia_model "https://github.com/mazenshalaby/ai-models/blob/main/models/leukemia_model.h5"
click node_skin_model "https://github.com/mazenshalaby/ai-models/blob/main/models/skin_model.h5"

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_predict_route,node_client toneBlue
class node_preprocessing,node_classification,node_colon_model,node_lung_model,node_leukemia_model,node_skin_model toneAmber
```

## Components

### HTTP API

- [Prediction endpoint](https://github.com/mazenshalaby/ai-models/blob/main/app.py): `app.py`

### Inference

- [Image preprocessing](https://github.com/mazenshalaby/ai-models/blob/main/utils/preprocess.py): `utils/preprocess.py`
- [Class and confidence](https://github.com/mazenshalaby/ai-models/blob/main/utils/preprocess.py): `utils/preprocess.py`
- [Colon model](https://github.com/mazenshalaby/ai-models/blob/main/models/colon_model.h5): `models/colon_model.h5`
- [Lung model](https://github.com/mazenshalaby/ai-models/blob/main/models/lung_model.h5): `models/lung_model.h5`
- [Leukemia model](https://github.com/mazenshalaby/ai-models/blob/main/models/leukemia_model.h5): `models/leukemia_model.h5`
- [Skin model](https://github.com/mazenshalaby/ai-models/blob/main/models/skin_model.h5): `models/skin_model.h5`

### Other components

- **Client**

## Connections

- Client → Prediction endpoint: uploads image (evidence: `app.py`)
- Prediction endpoint → Colon model: loads at startup (evidence: `app.py`)
- Prediction endpoint → Lung model: loads at startup (evidence: `app.py`)
- Prediction endpoint → Leukemia model: loads at startup (evidence: `app.py`)
- Prediction endpoint → Skin model: loads at startup (evidence: `app.py`)
- Prediction endpoint → Image preprocessing: calls prediction (evidence: `app.py`)
- Image preprocessing → Class and confidence: maps scores (evidence: `utils/preprocess.py`)
- Image preprocessing → Colon model: runs inference
- Image preprocessing → Lung model: runs inference
- Image preprocessing → Leukemia model: runs inference
- Image preprocessing → Skin model: runs inference
