Update README.md
Browse files
README.md
CHANGED
@@ -4,6 +4,47 @@ tags:
|
|
4 |
- pytorch_model_hub_mixin
|
5 |
---
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
- pytorch_model_hub_mixin
|
5 |
---
|
6 |
|
7 |
+
# Model Card: MRI Brain Tumor Classification (EfficientNet-B1)
|
8 |
+
|
9 |
+
## Model Details
|
10 |
+
- **Model Name**: `MRIModel`
|
11 |
+
- **Architecture**: EfficientNet-B1-based model for MRI brain tumor classification
|
12 |
+
- **Dataset**: [Brain Tumor MRI Dataset](https://www.kaggle.com/datasets/masoudnickparvar/brain-tumor-mri-dataset)
|
13 |
+
- **Batch Size**: 32
|
14 |
+
- **Loss Function**: CrossEntropy Loss
|
15 |
+
- **Optimizer**: Adam (learning rate = 1e-3)
|
16 |
+
- **Transfer Learning**: No (trained from scratch)
|
17 |
+
|
18 |
+
## Model Architecture
|
19 |
+
This model is based on **EfficientNet-B1**, a lightweight yet powerful convolutional neural network, and has been adapted for **MRI-based brain tumor classification**.
|
20 |
+
|
21 |
+
### **Modifications**
|
22 |
+
- **Input Channel Adaptation**: The first convolutional layer is modified to accept single-channel (grayscale) MRI scans.
|
23 |
+
- **Classifier Head**: The fully connected (FC) layer is modified to output 756 features.
|
24 |
+
|
25 |
+
## Implementation
|
26 |
+
### **Model Definition**
|
27 |
+
```python
|
28 |
+
import torch
|
29 |
+
import torch.nn as nn
|
30 |
+
from torchvision.models import efficientnet_b1
|
31 |
+
|
32 |
+
class MRIModel(nn.Module, PyTorchModelHubMixin):
|
33 |
+
def __init__(self):
|
34 |
+
super(MRIModel, self).__init__()
|
35 |
+
self.base_model = efficientnet_b1(weights=False) # No pretrained weights
|
36 |
+
self.base_model.features[0] = nn.Sequential(
|
37 |
+
nn.Conv2d(1, 32, kernel_size=(3, 3), stride=(2, 2), bias=False),
|
38 |
+
nn.BatchNorm2d(
|
39 |
+
32, eps=0.001, momentum=0.1, affine=True, track_running_stats=True
|
40 |
+
),
|
41 |
+
nn.ReLU6(inplace=True),
|
42 |
+
)
|
43 |
+
self.base_model.classifier = nn.Linear(1280, 756)
|
44 |
+
|
45 |
+
def forward(self, x):
|
46 |
+
x = self.base_model(x)
|
47 |
+
return x
|
48 |
+
```
|
49 |
+
|
50 |
+
This model has been pushed to the Hub using the [PytorchModelHubMixin](https://huggingface.co/docs/huggingface_hub/package_reference/mixins#huggingface_hub.PyTorchModelHubMixin) integration:
|