Skip to content

LionelRoxas/brain_tumor_classification

Repository files navigation

🧠 Brain Tumor Classification: AI-Powered Analysis 🔬

Harnessing the power of deep learning for medical diagnosis

🎯 Project Overview

A cutting-edge Streamlit application that uses AI to analyze brain MRI scans! Our system can detect and classify four types of conditions:

  • 🔴 Glioma
  • 🔵 Meningioma
  • 🟢 Pituitary Tumor
  • ⚪ No Tumor

🤖 Our Smart Models

1. 🌟 Transfer Learning with Xception (The Powerhouse)

📐 Architecture Details
Base: Xception (pretrained on ImageNet) 🏗️
Input Shape: (299, 299, 3)
Magic Ingredients:
- Flatten Layer (for 2D1D conversion)
- Dropout (0.3) 🎲
- Dense (128, ReLU) ⚡
- Dropout (0.25) 🎲
- Dense (4, Softmax) 🎯

💫 Why Xception is Awesome?

  • 🚀 Uses depth-wise separable convolutions (super efficient!)
  • 🎓 Pre-trained on millions of images (it's already smart!)
  • 📊 Perfect for capturing complex medical image patterns

🛠️ Our Special Sauce

  • 🔄 Global Max Pooling: Keeps the important stuff
  • 🎲 Strategic Dropout: Prevents memorization
  • 🧮 Smart Dense Layer: Compresses information beautifully
  • ⚡ Adamax Optimizer: Stable and reliable for medical images

2. 🔧 Custom CNN Model (The Specialist)

  • 📏 Works with (224, 224, 3) images
  • 🎯 Specifically trained for brain scans
  • 🧠 Understands brain MRI characteristics

🔍 How We Explain Our AI's Decisions

🎨 Saliency Map Generation

Making AI transparent through beautiful visualizations:

Key Steps 📝:
1. Calculate importance of each pixel
2. Focus on brain area with smart masking
3. Highlight the most significant regions
4. Make it visually appealing

🤝 AI Expert Analysis

Powered by Google's Gemini 1.5 Flash:

  • 📊 Interprets complex saliency maps
  • 👨‍⚕️ Provides clinical context
  • 📝 Generates detailed reports

📊 How We Measure Success

Our models track:

  • ✅ Accuracy: Overall correctness
  • 🎯 Precision: True positive reliability
  • 🔍 Recall: Finding all positive cases
  • 📈 Confidence: How sure we are

🔬 Technical Magic

🖼️ Image Processing Pipeline

  1. Preprocessing Magic:

    • 📐 Perfect sizing for each model
    • 🔢 Smart normalization
    • 📄 Handles any image format like a pro
  2. Model Selection:

    • 🔄 Smooth switching between models
    • 📏 Automatic image adjustment
    • ⚡ Lightning-fast processing

📊 Beautiful Visualizations

  • 📈 Interactive charts with Plotly
  • 🖼️ Side-by-side comparisons
  • 💅 Stylish result displays

💡 Pro Tips for Model Selection

  • 🌟 Xception Model: Your go-to for most cases
  • 🔧 Custom CNN: Perfect for specific scenarios

🚀 Future Dreams

  • 🤝 Model collaboration approaches
  • 🏗️ New architecture experiments
  • 🔍 Even better explanations
  • 🧠 3D MRI capabilities

🙏 Thanks for Exploring Our Project! 🚀

Made with ❤️ by Headstarter and implemented by Lionel Derrick Roxas for medical professionals