Data Science Project

Brain Tumor Detection Using Python + ML

brain tumor detection project
brain tumor detection project

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 its 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
  • Its 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)

Heres 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 its simple. I didnt want Django complexity for a small ML web app.

The Logic: How the Project Actually Works

At a high level, the flow is:

  1. User uploads MRI image
  2. Flask receives the image
  3. Image is preprocessed
  4. CNN model runs prediction
  5. 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:

  • tumor
  • non-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)

Its 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.

Subscribe on YouTube: DecodeIT2

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 Id 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

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

Source Code Available

Interested in This Project?

Get the complete source code for this project at a very affordable price — perfect for your portfolio, college submission, or learning. Message us on WhatsApp and we'll get back to you instantly!

Full source code included Step-by-step setup guide Instant delivery on WhatsApp Instant reply on WhatsApp
Chat on WhatsApp

We usually reply within a few minutes

Leave a Reply

Your email address will not be published. Required fields are marked *

Chat with us