This project is a professional research and prototype full-stack web application designed for automatic brain tumor classification and diagnostic support using magnetic resonance imaging (MRI) scans. It classifies images into four categories: Glioma, Meningioma, Pituitary, or No Tumor.
| Dashboard | Upload Scan |
|---|---|
![]() |
![]() |
| Classification Results | Analysis Report |
![]() |
![]() |
- Fine-tuned MedGamma model: A pre-trained medical AI model adapted specifically for brain MRI data.
- Brain tumor classification: The system identifies whether an MRI scan contains a tumor and classifies the tumor type.
- Diagnosis assistance: The model provides support for medical professionals by highlighting findings and enabling faster, more consistent image interpretation.
- MRI image input: The pipeline processes MRI scans, extracts relevant imaging features, and delivers predictions based on the fine-tuned model.
- Data preprocessing: MRI scans are standardized in size and intensity, then augmented with rotations, flips, and noise to improve model generalization across different patients and scanners.
- Model fine-tuning: MedGamma is adapted with labeled brain MRI scans, enabling it to learn tumor-specific imaging patterns while preserving its medical imaging expertise. (A fallback Keras CNN model is also included).
- Prediction pipeline: Incoming MRI scans are processed by the fine-tuned model, which outputs tumor classification, tumor type probabilities, and region-of-interest localization guidance.
- Diagnostic support: The system highlights suspicious areas and provides concise findings to assist radiologists in faster and more consistent interpretation.
project/frontend/: React.js + TypeScript + Vite + TailwindCSS dashboard.project/backend/: FastAPI + Python REST API with ML Inference orchestration.project/backend/training/: Training and evaluation scripts for the dataset.
- Node.js (v18+)
- Python (3.10+)
- Docker (optional, for containerized deployment)
Copy .env.example to .env in the project root folder:
cp project/.env.example project/.envAdd your HuggingFace token if you intend to use the MedGemma model.
cd project/backend
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
# Start the API server
uvicorn app.main:app --reloadThe API will be available at http://localhost:8000.
API Documentation: http://localhost:8000/docs
cd project/frontend
npm install
npm run devThe frontend will be available at http://localhost:5173.
By default, USE_FALLBACK_MODEL=True is set, which looks for a local Keras CNN model (brain_tumor_cnn_best_patched.keras). If this is not found, a mock randomizer is used.
To use MedGemma 4B, set USE_FALLBACK_MODEL=False in your environment and provide a valid HF_TOKEN.
The training scripts dynamically scan the dataset directory (default: ../Dataset) and generate artifacts.
cd project/backend/training
python train.py
python evaluate.pyThis is a research/decision-support prototype, not a medical diagnosis system. Predictions provided by this system require independent clinical review by a qualified radiologist.



