File size: 2,811 Bytes
7845d6e ebf0a45 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
---
license: mit
datasets:
- brain-mri-dataset
metrics:
- accuracy
- auc
model-index:
- name: CNN Brain Tumor Classifier
results:
- task:
type: image-classification
dataset:
name: Brain MRI Dataset
type: brain-mri-dataset
metrics:
- name: Accuracy
type: accuracy
value: 0.90
- name: AUC
type: auc
value: 0.90
---
# 🧠 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
```bash
pip install tensorflow huggingface_hub
```
```python
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}}
}
|