MRI VisionGuard — AI Brain Tumor Detection

Inspiration

I wanted to learn more about artificial intelligence and how it could be used in healthcare. I decided to build a brain tumor detection model using MRI images because I was interested in computer vision and machine learning.

At first, my goal was just to train a CNN that could recognize tumors. As I worked on it, I realized that getting high accuracy wasn't enough. I wanted to understand why the model made certain predictions and how reliable those predictions actually were.

What It Does

MRI VisionGuard is a web application that uses AI to analyze brain MRI images. Users can upload an MRI scan and get:

  • A prediction of whether a tumor may be present.
  • A Grad-CAM heatmap showing which parts of the image influenced the prediction.
  • Nine image-quality checks using OpenCV.
  • A reliability check that flags predictions that may need further review.

The website also lets users compare the original MRI with the heatmap using an interactive slider.

How I Built It

I started by building and training a CNN from scratch using TensorFlow, then moved the project to PyTorch.

The final model has five convolutional blocks and around 394,000 parameters. I used OpenCV to crop, resize, and process MRI images before passing them into the model.

I also used Grad-CAM to visualize what the model was focusing on. For the website, I used FastAPI, HTML, CSS, and JavaScript.

To make the system more useful, I added image-quality checks and a reliability system that can perform an additional analysis when it detects a possible problem.

Challenges I Faced

One of my biggest challenges was discovering that some images in my training and testing datasets were nearly identical. This made my original accuracy results look better than they really were.

I also found that the model sometimes focused on image backgrounds instead of important brain features. I worked on fixing this by improving preprocessing and balancing the training data.

After making these changes, my model achieved 93.8% balanced accuracy on a test set with near-duplicates filtered out. However, on a different dataset, the balanced accuracy dropped to 84.7%, and it only detected 73.5% of tumors.

This showed me that a model can perform well on one dataset but struggle with unfamiliar images.

What I Learned

I learned a lot about PyTorch, CNNs, OpenCV, model training, and building web applications.

The biggest thing I learned was that high accuracy doesn't always mean a model is reliable. I also learned how important it is to check datasets for duplicates, test models on different data, and understand why predictions go wrong.

What's Next

I want to continue improving the model by testing pretrained networks like ResNet18, improving its ability to recognize tumors from different datasets, and making the reliability checks more accurate.

I also want to explore deploying the application online so others can try it.

Overall, this project helped me understand what goes into building an AI application beyond just training a neural network.

Note: MRI VisionGuard is an educational project and is not intended for medical diagnosis.

Built With

Share this project:

Updates

Submission history