๐Ÿง  CNN Brain Tumor Classifier

Model Description

This repository contains a Convolutional Neural Network (CNN) built with TensorFlow/Keras for classifying brain MRI scans.
The model can distinguish between three types of brain tumors and healthy scans.

โš ๏ธ Disclaimer: This model is provided for educational and research purposes only.
It is not a medical diagnostic tool and should not be used in clinical practice.


Classes

The model predicts one of the following four categories:

  • Glioma
  • Meningioma
  • Pituitary tumor
  • No tumor (healthy)

Training Details

  • Framework: TensorFlow / Keras
  • Architecture: Custom CNN
  • Input size: 224 ร— 224 RGB MRI images
  • Loss function: categorical_crossentropy
  • Optimizer: Adam
  • Epochs: 10
  • Metrics: Accuracy, AUC

Dataset

  • Source: Public brain MRI dataset (glioma, meningioma, pituitary, no tumor)
  • Preprocessing:
    • Images resized to 224 ร— 224
    • Normalized to [0, 1] range
    • Augmentation (rotation, flipping, zoom) applied during training

Evaluation Results

Metric Value
Training Accuracy ~96%
Validation Accuracy ~85โ€“90%
AUC (training) ~0.90

(values may vary depending on train/validation split)


Usage

Installation

pip install tensorflow huggingface_hub
from tensorflow.keras.models import load_model
from huggingface_hub import hf_hub_download
import numpy as np
from tensorflow.keras.preprocessing import image

# Download model file from Hugging Face Hub
model_path = hf_hub_download(
    repo_id="larrikin-coder/brain-tumor-cnn",  # replace with your repo
    filename="cnn_model.h5"
)

# Load model
model = load_model(model_path)

# Preprocess an image
img = image.load_img("test_mri.jpg", target_size=(224, 224))
img_array = image.img_to_array(img) / 255.0
img_array = np.expand_dims(img_array, axis=0)

# Predict
pred = model.predict(img_array)
class_names = ["glioma", "meningioma", "pituitary", "no_tumor"]
print("Prediction:", class_names[np.argmax(pred)])

@misc{larrikin-coder2025, title={CNN Brain Tumor Classifier}, author={Larrikin Coder}, year={2025}, howpublished={\url{https://huggingface.co/larrikin-coder/brain-tumor-cnn}} }

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ 1 Ask for provider support

Evaluation results