How subhamroushan2018/brain-tumor-detection works
Purpose and Entry Points
This repository trains and deploys a deep-learning classifier for brain-tumor MRI images. The offline training/evaluation entry point is Model/brain_tumor_model.ipynb; the runtime inference entry point is the Python web application at Web App/app.py.
Dataset Boundary
MRI training and testing data are intentionally external to version control. The expected dataset structure is documented in Dataset/README.md and must be supplied locally, typically as training/testing image directories. Dataset paths are environment-specific, creating a boundary between reproducible code and large medical-image assets.
Training and Model Selection
The notebook implements the ML lifecycle: loading labeled image paths, balancing/splitting data, preprocessing through Keras image generators, training multiple CNN variants, and comparing validation/test metrics. It covers simple and deeper custom CNNs plus VGG16 transfer learning.
• Model/brain_tumor_model.ipynb
• Model/README.md
The selected model is serialized as best_model.keras; it is a generated deployment artifact rather than a tracked repository file.
Inference Artifact Handoff
Training and serving are decoupled through the saved Keras model. The notebook produces best_model.keras, and deployment expects that artifact to be placed alongside the web application in Web App/. This file contract is the primary handoff: changes to preprocessing, class order, or model architecture must remain compatible with inference in Web App/app.py.
• Model/brain_tumor_model.ipynb
• Web App/app.py
• Web App/README.md
Web Request Flow
The web application accepts an uploaded MRI image, loads/applies the trained model for prediction, and renders an HTML result or failure response. Its server-side routes and inference orchestration reside in Web App/app.py; presentation is separated into templates:
• Web App/Templates/index.html
• Web App/Templates/result.html
• Web App/Templates/error.html
Styles are static frontend assets under Web App/Style/styles.css and Web App/Style/styles1.css.
Runtime and Dependencies
The system runs on Python. TensorFlow/Keras provides CNN/VGG16 modeling, training, serialization, and inference; NumPy and Pandas support data processing; Matplotlib supports training/evaluation visualization. Deployment-specific dependencies are declared in Web App/requirements.txt, while project/training dependencies are represented by root requirements.txt.
External Services and Infrastructure
No hosted infrastructure, database, API, or cloud integration is represented in the tree. The main external dependency is the Kaggle Brain Tumor MRI dataset referenced by the root documentation. The application is designed for local or separately hosted Python web serving, with the trained .keras artifact and image dataset provisioned outside Git.
Main entry points: app.py Inference application · brain_tumor_model.ipynb Training notebook · index.html Result templates · README.md Dataset contract
Components 17
Offline training
Model development and selection workflow.
- Dataset contract · Documents the required local training and testing image layout.
Dataset/README.md - External MRI dataset · Locally supplied labeled brain-tumor MRI images.
- Training notebook · Loads data, trains CNN variants, and selects a model.
Model/brain_tumor_model.ipynb - Model workflow docs
Model/README.md - Balanced data splits · Balances labeled paths and creates training, validation, and test partitions.
- Keras image pipeline · Applies image loading and generator-based preprocessing.
- CNN candidates · Trains custom CNNs and VGG16 transfer learning variants.
- Model evaluation · Compares validation and test metrics to select the deployable model.
- Training dependencies · TensorFlow/Keras, NumPy, Pandas, and Matplotlib environment.
requirements.txt
Web serving
Runtime image prediction application.
- Inference application · Receives uploads, runs model prediction, and handles failures.
Web App/app.py - Uploaded MRI image
- Result templates · Separate index, prediction-result, and error views.
Web App/Templates/index.html - Error template
Web App/Templates/error.html - Frontend styles
Web App/Style/styles.css - Web app contract · Documents runtime model placement and application use.
Web App/README.md - Serving dependencies
Web App/requirements.txt
Other components
- best_model.keras · Generated Keras model handoff; provisioned beside the web app.
Connections 16
- Dataset contract → External MRI dataset: defines layout
- External MRI dataset → Training notebook: labeled images
- Training dependencies → Training notebook: supports
- Model workflow docs → Training notebook: documents
- Training notebook → Balanced data splits: loads and balances
- Balanced data splits → Keras image pipeline: partitions
- Keras image pipeline → CNN candidates: preprocessed batches
- CNN candidates → Model evaluation: metrics
- Model evaluation → best_model.keras: serializes selected model
- best_model.keras → Inference application: deployment handoff · Preprocessing and class order must remain compatible.
- Serving dependencies → Inference application: supports
- Uploaded MRI image → Inference application: HTTP upload
- Inference application → Result templates: renders index or prediction
- Inference application → Error template: renders failures
- Frontend styles → Result templates: styles views
- Web app contract → Inference application: documents