DEV Community

Cover image for πŸš€ What My First CNN Project Taught Me About Brain Tumor Detection
Tanmay P. Tawade
Tanmay P. Tawade

Posted on Edited on

πŸš€ What My First CNN Project Taught Me About Brain Tumor Detection

🧠 From Theory to Actually Building a CNN

My first real experience with a Convolutional Neural Network (CNN) came through a brain tumor detection and classification project using MRI images.

I had already studied the theory.

I knew what convolution, pooling, activation functions, epochs, loss, and accuracy meant.

At least, I thought I did.

Once I started implementing the model, I realized that understanding a concept theoretically and understanding how it behaves in a real project are two very different things.

This isn't a CNN tutorial.

Instead, I want to share some of the things that confused me, the mistakes I made, and what changed in my understanding after actually building the project.


πŸ€” Why I Chose This Project

I wanted a project that was:

  • Academically meaningful
  • Related to deep learning
  • Practical enough to connect theory with a real problem
  • Challenging enough to make me learn beyond the classroom

Medical image analysis stood out to me because it combines computer vision, deep learning, and a problem where model evaluation and interpretability matter.

That made it a good learning problem.


πŸ“Š The Dataset Was More Important Than I Expected

One of my first mistakes was focusing on the model before fully understanding the dataset.

I should have asked:

  • What exactly do the labels represent?
  • How many samples are available for each class?
  • Are the classes balanced?
  • How were the images collected?
  • Are the images already preprocessed?
  • Could there be differences between the training and evaluation data?

Instead, I was initially more interested in getting the CNN running.

That created problems later.

My biggest dataset lesson:

Before building the model, understand the data you're giving it.

A sophisticated model cannot compensate for poorly understood data.


πŸ–ΌοΈ Looking at the Images Changed My Perspective

Visualizing sample MRI images before training might seem obvious now.

But doing it made me realize how much information can be missed when you immediately jump into code.

Even a basic inspection helped me think about:

  • Image dimensions
  • Visual differences between classes
  • Background information
  • Image quality
  • Preprocessing requirements
  • Possible sources of variation

That made the dataset feel less like a folder of files and more like actual data that needed to be understood.


βš™οΈ CNNs Made More Sense Once I Implemented One

I had studied CNN architecture before.

But implementing one changed how I thought about it.

I started understanding that:

  • Convolution layers learn spatial features from images
  • Pooling layers reduce spatial dimensions and can help make representations more compact
  • Activation functions introduce non-linearity
  • The architecture affects what patterns the model can learn
  • Adding more layers does not automatically mean better performance

One of my biggest realizations was:

Small architectural changes can have a noticeable effect on model behavior.

Reading about CNNs gave me the terminology.

Building one gave those concepts context.


🧩 A Simple CNN Structure

CNN Architecture

Block diagram of CNN

The diagrams made something that initially felt abstract much easier to reason about.


⚠️ The Part That Actually Challenged Me

Getting the model to train wasn't the difficult part.

Understanding whether it was actually learning something useful was.

Some of the challenges I encountered included:

  • Overfitting
  • Interpreting validation results
  • Choosing hyperparameters
  • Understanding why performance changed between experiments
  • Figuring out whether a change actually improved the model

At one point, I genuinely thought:

"If the accuracy is high, the model must be good."

That turned out to be an incomplete way of looking at model performance.

Accuracy is useful, but it doesn't tell the whole story.

Depending on the dataset and problem, metrics such as precision, recall, F1-score, confusion matrices, and ROC-AUC can provide additional information about model behavior.

That was an important shift in how I evaluated my experiments.


πŸ” Why Explainability Became Important

As I worked more with the project, another question became interesting to me:

Why is the model making this prediction?

For an image classification model, getting a class prediction is only part of the story.

I started exploring Grad-CAM to visualize which regions of an image were contributing to a model's prediction.

This was particularly interesting in the context of medical imaging because it gave me a way to inspect the model's spatial focus instead of looking only at the final classification output.


🧠 Model Interpretation Example

Here are examples from my experiments:

Grad-CAM Output (No Tumor Image)

Grad-CAM Output (Tumor Image)

The heatmaps made the predictions more interesting to investigate because I could visually examine which regions were highlighted by the model.

But this also taught me an important lesson:

An explanation visualization is a tool for interpreting model behavior, not proof that the model is correct.

That distinction is important, especially for sensitive applications such as medical imaging.


πŸ“ˆ What This Project Actually Taught Me

The biggest lessons weren't specific to CNNs.

They were about the process of building machine learning systems.

1. Machine learning is iterative

My first approach wasn't my final approach.

Training, evaluating, changing, and testing again became part of the process.

2. Debugging is part of learning

When something doesn't work, reading logs, checking inputs, inspecting outputs, and questioning assumptions are often more valuable than immediately searching for a solution.

3. Data deserves as much attention as the model

A model is only learning from the data you provide.

Understanding that data should come before obsessing over architecture.

4. Metrics need context

A single number doesn't completely describe model performance.

5. Implementation exposes gaps in understanding

I could explain CNN concepts on paper.

But building one showed me exactly which parts I actually understood and which parts I had only memorized.

And probably the biggest lesson was:

Copying a solution is easy. Understanding why it works is the real learning.


πŸ”§ What I Want to Improve Next

This project also showed me where I need to improve.

My next areas of focus are:

  • Better evaluation and experiment tracking
  • Stronger understanding of model architecture
  • More rigorous dataset analysis
  • Improved project structure
  • Deeper exploration of explainable AI
  • Better understanding of how models behave outside controlled experiments

The goal isn't just to make the model produce a better number.

It's to understand why the system behaves the way it does.


πŸ”— Project Reference

You can explore the complete implementation and documentation here:

πŸ‘‰ GitHub Repository

You can also try the deployed Streamlit application:

πŸ‘‰ Live Demo - Streamlit

The repository includes:

  • CNN model implementation
  • MRI image preprocessing
  • Model evaluation
  • Grad-CAM explainability
  • Experimentation and results
  • Streamlit application

πŸ’¬ Final Thought

This was one of those projects where I started with:

"I know how CNNs work."

and ended with:

"I understand how much more there is to learn."

And honestly, I think that's a good outcome.

Building the project exposed the gap between knowing a concept and being able to reason about it when things don't go as expected.

That's probably one of the most valuable things I've learned from working on machine learning projects.

If you've built your first CNN or machine learning project, what was the first thing that made more sense only after you actually implemented it?


πŸ‘‹ Let's Connect

I'm continuing to explore machine learning by building practical projects and sharing what I learn along the way.

If you're also learning CNNs, computer vision, or deep learning, feel free to connect or share what you're working on.

🌐 Portfolio

πŸ’» GitHub

πŸ’Ό LinkedIn

Thanks for reading!

Top comments (0)