When I started working on Brain Tumor Detection, I honestly just wanted a project that felt real. Not another CRUD app, not another fake dataset demo. I wanted something that could actually matter, even if it’s only a student version.
So I built this Student Portfolio Project: an end-to-end web app where you upload an MRI scan and a deep learning model tells you whether it looks like a tumor or not. It runs with Flask + PyTorch, and yes, I struggled a lot before it finally worked.
The “Why”: Why You Should Build This Project
What made Brain Tumor Detection special for me:
- It feels like a real-world medical use case
- It connects deep learning + web development
- It’s impressive for interviews and portfolios
- And, honestly, it forced me to understand CNNs properly (not just copy code)
Tech Stack (and Why I Chose It)
Here’s what powers this project (from the repo ):
- Python – main language
- PyTorch – for building and running the CNN
- Flask – lightweight backend web framework
- HTML/CSS – frontend interface
- OpenCV / PIL – image preprocessing
- Pretrained .pth model – saved neural network weights
Why not TensorFlow?
I wanted to really understand tensors and backprop, and PyTorch felt more flexible. Also, many research labs use it, so learning PyTorch helps long-term.
Why Flask?
Because it’s simple. I didn’t want Django complexity for a small ML web app.
The Logic: How the Project Actually Works
At a high level, the flow is:
- User uploads MRI image
- Flask receives the image
- Image is preprocessed
- CNN model runs prediction
- Result is shown on the page
But the real learning happened inside the src folder ():
1. Dataset Loader (dataset.py)
This script reads MRI images from two folders:
tumornon-tumor
It resizes every image to 64×64, converts it to grayscale, and normalizes pixel values between 0 and 1. That part confused me at first, but now I see why consistency matters.
2. CNN Model (model.py)
It’s a Convolutional Neural Network with:
- Conv layers to extract features
- Max pooling to reduce size
- Fully connected layers to classify
3. Training Script (train.py)
- Loads the dataset
- Feeds it to the CNN
- Calculates loss
- Updates weights
Flask Web App: From Terminal to Browser
Inside the app/ folder (), the magic happens.
The file app.py:
- Loads the pretrained model
- Accepts image uploads
- Runs the prediction
- Sends the result back to HTML
The UI is simple but functional:
- Upload MRI image
- Click submit
- See “Tumor” or “Non-Tumor”
This is where I felt like a real developer, not just a student running notebooks.
Project tutorials, coding guides & placement tips for students.
How to Run It (Beginner Step-by-Step Guide)
Step 1: Download the Project
cd Brain-Tumor-Detection
Step 2: Create Virtual Environment
python -m venv venv
venv\Scripts\activate # Windows
source venv/bin/activate # Mac/Linux
Step 3: Install Requirements
pip install -r requirements.txt
Step 4: Download the Model
Download the .pth model and place it in:
model/brain_tumor_model.pth
Step 5: Run the App
cd app
python app.py
Now open:
http://127.0.0.1:5000/
Upload an MRI image and test it.
What I’d Do Differently
- Use Transfer Learning instead of a basic CNN
- Add probability scores instead of only labels
- Improve frontend UI
- Add model confidence warning
Screenshots




Why This Is a Great Student Portfolio Project
This project shows that you can:
- Work with medical image data
- Build deep learning models
- Integrate ML into a real web app
- Deploy predictions end-to-end
Download
brain tumor detection project with source code
brain tumor detection python code
brain tumor detection using machine learning github
brain tumor detection using image processing python code github
brain tumor detection using machine learning project report
brain tumor detection github
brain tumor detection using machine learning project report pdf