Skip to content

A deep learning system for brain tumor classification using MobileNetV2, Flask

License

Notifications You must be signed in to change notification settings

yashnaiduu/NeuroScan

Repository files navigation


NeuroScan subtitle



   



     



NeuroScan Preview




  What is NeuroScan?

NeuroScan is a full-stack medical imaging application that classifies brain MRI scans into four categories using a fine-tuned MobileNetV2 model. Upload an MRI, and the app instantly tells you the tumor type, shows a Grad-CAM heatmap highlighting the affected region, and validates the image is actually an MRI using OpenAI CLIP — all in under 2 seconds.


  Features

  4-Class Classification

Identifies Glioma, Meningioma, Pituitary tumors, or a healthy scan with 96.8% accuracy.

  Grad-CAM Heatmaps

Generates visual saliency maps that highlight exactly which brain regions influenced the model's prediction.

  CLIP MRI Validation

Uses OpenAI CLIP to reject non-MRI images before they reach the classifier — no garbage in, no garbage out.

  Confidence Scores

Returns a full probability breakdown across all four classes for every prediction.

  Random Sample Testing

One-click testing using real MRI samples bundled with the application — no upload required.

  Dark Mode UI

Sleek, responsive interface with smooth animations — designed for clarity and ease of use.


  Model Architecture

Model Architecture
Base Model MobileNetV2 — ImageNet pre-trained
Input 224 × 224 RGB
Backbone Depthwise separable convolutions
Head GAP → Dropout(0.5) → Dense(4) → Softmax
Accuracy 96.8% on held-out test set
Inference < 2s on CPU

  API Reference

Endpoint Method Description
/ GET API info & version
/health GET Health check
/stats GET Model & system stats
/predict POST Classify an uploaded MRI
/heatmap POST Generate Grad-CAM heatmap
/random GET Test with a random sample MRI

  Tech Stack

Technologies
Backend Python · Flask · TensorFlow/Keras · OpenCV · CLIP
Frontend HTML · CSS · Vanilla JavaScript
Hosting Hugging Face Spaces (backend) · Vercel (frontend)

  Dataset

The Brain Tumor Classification MRI dataset from Kaggle — 3,264 labeled MRI scans across four classes.


Class Count Description
Glioma ~826 Primary tumors from glial cells
Meningioma ~822 Tumors from the meninges
Pituitary ~827 Tumors of the pituitary gland
No Tumor ~395 Healthy brain scans

  Run Locally

# 1. Clone
git clone https://github.com/yashnaiduu/NeuroScan-Brain-Tumor-Classification.git
cd NeuroScan-Brain-Tumor-Classification

# 2. Environment
python -m venv venv && source venv/bin/activate
pip install -r requirements.txt

# 3. Start backend
python server1.py # → http://localhost:5050

# 4. Start frontend (new terminal)
cd client && python3 -m http.server 8000 # → http://localhost:8000

Tip: Set PORT=7860 when deploying to Hugging Face Spaces.


  Deployment

Platform Role Key Files
Hugging Face Spaces Backend API Dockerfile, entrypoint.sh
Vercel Frontend vercel.json

Detailed steps in DEPLOYMENT.md.


  License

MIT — see LICENSE.



Yash Naidu



Built with TensorFlow  ·  Deployed on Hugging Face & Vercel


About

A deep learning system for brain tumor classification using MobileNetV2, Flask

Resources

License

Stars

Watchers

Forks

Contributors