| --- |
| tags: |
| - image-classification |
| - tensorflow |
| - medical |
| - mri |
| - brain-tumor |
| datasets: |
| - the-shoaib2/Brain_Tumor_MRI |
| library_name: tensorflow |
| pipeline_tag: image-classification |
| license: mit |
| --- |
| |
| # MRI Brain Tumor Classification Model V3 |
|
|
| This model is a fine-tuned Xception network for classifying brain MRI scans into 4 categories: |
| `glioma`, `meningioma`, `notumor`, `pituitary`. |
|
|
| ## Model Details |
| - **Architecture**: Xception (Pre-trained on ImageNet) |
| - **Input Size**: (299, 299) |
| - **Framework**: TensorFlow / Keras |
| - **Classes**: 4 (glioma, meningioma, notumor, pituitary) |
|
|
| ## Training Configuration |
| - **Epochs**: 10 |
| - **Batch Size**: 32 |
| - **Learning Rate**: 0.001 |
| - **Optimizer**: Adamax |
| - **Loss**: Categorical Crossentropy |
| - **Metrics**: Accuracy, Precision, Recall |
|
|
| ## Performance Metrics |
|
|
| ```text |
| |
| Final Training Metrics (Epoch 10): |
| - Training Accuracy: 0.9979 |
| - Training Loss: 0.0076 |
| - Validation Accuracy: 0.9786 |
| - Validation Loss: 0.1827 |
| - Precision: 0.9979 |
| - Recall: 0.9977 |
| |
| ``` |
|
|
| ## Training History |
|
|
| ### Metrics Plot |
|  |
|
|
| ### Final Metrics |
|  |
|
|
| ## Confusion Matrix |
|  |
|
|
| ## Data Distribution |
|  |
|  |
|
|
| ## Sample Predictions |
|  |
|
|
| ## Usage |
|
|
| ```python |
| import tensorflow as tf |
| from huggingface_hub import from_pretrained_keras |
| import numpy as np |
| from PIL import Image |
| |
| # Load model |
| model = from_pretrained_keras("the-shoaib2/Brain_Tumor_MRI_Classification") |
| |
| # Load and preprocess image |
| img = Image.open("path/to/mri_scan.jpg") |
| img = img.resize((299, 299)) |
| img_array = np.array(img) |
| img_array = np.expand_dims(img_array, axis=0) |
| img_array = img_array / 255.0 |
| |
| # Predict |
| predictions = model.predict(img_array) |
| class_names = ['glioma', 'meningioma', 'notumor', 'pituitary'] |
| predicted_class = class_names[np.argmax(predictions[0])] |
| confidence = np.max(predictions[0]) |
| |
| print(f"Predicted: {predicted_class} ({confidence:.2%} confidence)") |
| ``` |
|
|
| ## Model Architecture |
|
|
| The model uses transfer learning with Xception as the base: |
| - Xception base (pre-trained on ImageNet) |
| - Global Max Pooling |
| - Flatten layer |
| - Dropout (0.3) |
| - Dense layer (128 units, ReLU activation) |
| - Dropout (0.25) |
| - Output layer (4 units, Softmax activation) |
|
|
| ## Dataset |
|
|
| This model was trained on the [Brain Tumor MRI Dataset](https://huggingface.co/datasets/the-shoaib2/Brain_Tumor_MRI). |
|
|
| ## Citation |
|
|
| If you use this model, please cite: |
|
|
| ```bibtex |
| @misc{brain_tumor_mri_v3, |
| author = {Shoaib}, |
| title = {MRI Brain Tumor Classification Model V3}, |
| year = {2026}, |
| publisher = {Hugging Face}, |
| howpublished = {\url{https://huggingface.co/the-shoaib2/Brain_Tumor_MRI_Classification}} |
| } |
| ``` |
|
|