# rieyanshi/automated-brain-tumor architecture

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

- Interactive diagram: https://gitdiagram.com/rieyanshi/automated-brain-tumor
- Repository: https://github.com/rieyanshi/automated-brain-tumor

## Overview

This repository trains a two-class brain MRI classifier and exposes image upload and prediction through Flask. Although the README describes segmentation, the sampled code predicts tumor/no-tumor classes. Training, web inference, and TFLite conversion are distinct workflows; the available files do not establish that training produces the H5 model used by the app.

Main entry points: [`app.py`](https://github.com/rieyanshi/automated-brain-tumor/blob/main/app.py) (Flask routes), [`modelConverter.py`](https://github.com/rieyanshi/automated-brain-tumor/blob/main/modelConverter.py) (TFLite converter), [`mainTrain.py`](https://github.com/rieyanshi/automated-brain-tumor/blob/main/mainTrain.py) (Image preparation), [`BrainTumor10Epochs.h5`](https://github.com/rieyanshi/automated-brain-tumor/blob/main/BrainTumor10Epochs.h5) (H5 inference model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_training["Model training"]
  node_train_data["Training images<br/>[mainTrain.py]"]
  node_train_prep["Image preparation<br/>[mainTrain.py]"]
  node_cnn_train["CNN training<br/>[mainTrain.py]"]
  node_categorical_model["Categorical H5 model"]
end

subgraph group_web["Web inference"]
  node_flask_app["Flask routes<br/>[app.py]"]
  node_image_prep["Image preprocessing<br/>[app.py]"]
  node_prediction["Class prediction<br/>[app.py]"]
  node_class_label["Tumor label<br/>[app.py]"]
  node_app_model["H5 inference model"]
end

subgraph group_conversion["Model conversion"]
  node_converter["TFLite converter<br/>[modelConverter.py]"]
  node_converted_model["TFLite model<br/>[model.tflite]"]
end

node_user(("Image uploader"))

node_train_data -->|"loads and resizes"| node_train_prep
node_train_prep -->|"supplies image data"| node_cnn_train
node_cnn_train -->|"saves weights"| node_categorical_model
node_user -->|"uploads image"| node_flask_app
node_flask_app -->|"calls getResult"| node_image_prep
node_image_prep -->|"prepares input"| node_prediction
node_prediction -->|"predicts with"| node_app_model
node_flask_app -->|"maps prediction"| node_class_label
node_class_label -->|"returns label"| node_user
node_converter -->|"loads model"| node_app_model
node_converter -->|"writes model"| node_converted_model

click node_train_data "https://github.com/rieyanshi/automated-brain-tumor/blob/main/mainTrain.py"
click node_train_prep "https://github.com/rieyanshi/automated-brain-tumor/blob/main/mainTrain.py"
click node_cnn_train "https://github.com/rieyanshi/automated-brain-tumor/blob/main/mainTrain.py"
click node_categorical_model "https://github.com/rieyanshi/automated-brain-tumor/blob/main/BrainTumor10EpochsCategorical.h5"
click node_flask_app "https://github.com/rieyanshi/automated-brain-tumor/blob/main/app.py"
click node_image_prep "https://github.com/rieyanshi/automated-brain-tumor/blob/main/app.py"
click node_prediction "https://github.com/rieyanshi/automated-brain-tumor/blob/main/app.py"
click node_class_label "https://github.com/rieyanshi/automated-brain-tumor/blob/main/app.py"
click node_app_model "https://github.com/rieyanshi/automated-brain-tumor/blob/main/BrainTumor10Epochs.h5"
click node_converter "https://github.com/rieyanshi/automated-brain-tumor/blob/main/modelConverter.py"
click node_converted_model "https://github.com/rieyanshi/automated-brain-tumor/blob/main/model.tflite"

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_train_data,node_train_prep,node_cnn_train,node_categorical_model toneBlue
class node_flask_app,node_image_prep,node_prediction,node_class_label,node_app_model toneAmber
class node_converter,node_converted_model toneMint
class node_user toneIndigo
```

## Components

### Model training

- [Training images](https://github.com/rieyanshi/automated-brain-tumor/blob/main/mainTrain.py): `mainTrain.py`
- [Image preparation](https://github.com/rieyanshi/automated-brain-tumor/blob/main/mainTrain.py): `mainTrain.py`
- [CNN training](https://github.com/rieyanshi/automated-brain-tumor/blob/main/mainTrain.py): `mainTrain.py`
- [Categorical H5 model](https://github.com/rieyanshi/automated-brain-tumor/blob/main/BrainTumor10EpochsCategorical.h5): `BrainTumor10EpochsCategorical.h5`

### Web inference

- [Flask routes](https://github.com/rieyanshi/automated-brain-tumor/blob/main/app.py): `app.py`
- [Image preprocessing](https://github.com/rieyanshi/automated-brain-tumor/blob/main/app.py): `app.py`
- [Class prediction](https://github.com/rieyanshi/automated-brain-tumor/blob/main/app.py): `app.py`
- [Tumor label](https://github.com/rieyanshi/automated-brain-tumor/blob/main/app.py): `app.py`
- [H5 inference model](https://github.com/rieyanshi/automated-brain-tumor/blob/main/BrainTumor10Epochs.h5): `BrainTumor10Epochs.h5`

### Model conversion

- [TFLite converter](https://github.com/rieyanshi/automated-brain-tumor/blob/main/modelConverter.py): `modelConverter.py`
- [TFLite model](https://github.com/rieyanshi/automated-brain-tumor/blob/main/model.tflite): `model.tflite`

### Other components

- **Image uploader**

## Connections

- Training images → Image preparation: loads and resizes
- Image preparation → CNN training: supplies image data
- CNN training → Categorical H5 model: saves weights
- Image uploader → Flask routes: uploads image
- Flask routes → Image preprocessing: calls getResult
- Image preprocessing → Class prediction: prepares input
- Class prediction → H5 inference model: predicts with
- Flask routes → Tumor label: maps prediction
- Tumor label → Image uploader: returns label
- TFLite converter → H5 inference model: loads model
- TFLite converter → TFLite model: writes model
