ThisenEkanayake commited on
Commit
005d14b
·
verified ·
1 Parent(s): 28a099b

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +342 -3
README.md CHANGED
@@ -1,3 +1,342 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ metrics:
4
+ - accuracy
5
+ - precision
6
+ - recall
7
+ - f1
8
+ base_model:
9
+ - microsoft/resnet-18
10
+ pipeline_tag: image-classification
11
+ tags:
12
+ - deep-learning
13
+ - computer-vision
14
+ - medical-imaging
15
+ ---
16
+ # Model Card: Brain Tumor Multi-Class Classification
17
+
18
+ ## Model Details
19
+
20
+ ### Model Description
21
+ A fine-tuned ResNet18 convolutional neural network for classifying brain MRI scans into four categories of brain tumors. The model uses transfer learning with ImageNet pre-trained weights and has been adapted for medical image classification.
22
+
23
+ - **Developed by:** Thisen Ekanayake
24
+ - **Model type:** Convolutional Neural Network (ResNet18)
25
+ - **Language(s):** Python (PyTorch)
26
+ - **License:** MIT License
27
+ - **Demo:** https://brainet.thisenekanayake.me
28
+ - **Parent Model:** ResNet18 (pretrained on ImageNet)
29
+ - **Model Variants:** This model card focuses on the **multi-class classification model** (4 classes: glioma, meningioma, no tumor, pituitary). A **binary classification model** (tumor vs. no tumor) is also available in the GitHub repository with complete training and evaluation scripts.
30
+
31
+ ### Model Architecture
32
+ - **Base Architecture:** ResNet18
33
+ - **Input:** RGB images resized to 224x224 pixels
34
+ - **Output:** 4-class classification (glioma, meningioma, notumor, pituitary)
35
+ - **Modifications:**
36
+ - Final fully connected layer replaced with 4-class output
37
+ - Early layers frozen during training
38
+ - Only layer4 and final FC layer fine-tuned
39
+ - **Parameters:** ~11M total parameters
40
+
41
+ ## Intended Uses
42
+
43
+ ### Primary Use Case
44
+ This model is designed for **research and educational purposes only** to demonstrate deep learning applications in medical image analysis. It can be used to:
45
+ - Study transfer learning techniques in medical imaging
46
+ - Explore brain tumor classification methodologies
47
+ - Educational demonstrations of CNN architectures
48
+ - Research prototyping and benchmarking
49
+
50
+ ### Out-of-Scope Uses
51
+ - **NOT for clinical diagnosis or treatment decisions**
52
+ - **NOT for patient care or medical decision-making**
53
+ - **NOT a replacement for professional medical evaluation**
54
+ - **NOT validated for deployment in healthcare settings**
55
+ - Should not be used without expert medical supervision
56
+
57
+ ## Training Data
58
+
59
+ ### Dataset Information
60
+ - **Source:** Brain Tumor Segmentation(BraTS2020)
61
+ - **Dataset Link:** https://www.kaggle.com/datasets/awsaf49/brats2020-training-data
62
+ - **Classes:**
63
+ 1. Glioma
64
+ 2. Meningioma
65
+ 3. No Tumor
66
+ 4. Pituitary Tumor
67
+
68
+ ### Dataset Statistics
69
+ - **Training samples:** 5712
70
+ - **Testing samples:** 1311
71
+ - **Class Distribution (Training):**
72
+ - Imbalanced dataset with varying samples per class
73
+ - Weighted sampling used to address class imbalance
74
+ - Class weights applied during training
75
+
76
+ ### Data Preprocessing
77
+ - **Image Resizing:** 224x224 pixels
78
+ - **Normalization:** ImageNet statistics (mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
79
+ - **Training Augmentations:**
80
+ - Random horizontal flip (p=0.5)
81
+ - Random rotation (±10 degrees)
82
+ - Color jitter (brightness=0.2, contrast=0.2)
83
+ - **Test Preprocessing:** Resize and normalize only (no augmentation)
84
+
85
+ ### Known Dataset Limitations
86
+ - Limited diversity in imaging protocols and scanner types
87
+ - Potential demographic biases in patient populations
88
+ - Images may not represent all tumor subtypes or presentations
89
+ - Dataset size may limit generalization to rare cases
90
+ - Quality and annotation consistency may vary
91
+
92
+ ## Model Performance
93
+
94
+ ### Overall Metrics (Test Set)
95
+ Evaluated on **1,311 test samples** with **1,298 correct predictions** (13 errors):
96
+
97
+ | Metric | Weighted Avg | Macro Avg |
98
+ |--------|--------------|-----------|
99
+ | **Accuracy** | **99.01%** | - |
100
+ | **Precision** | **99.03%** | 98.96% |
101
+ | **Recall** | **99.01%** | 98.92% |
102
+ | **F1 Score** | **99.01%** | 98.92% |
103
+
104
+ ### Per-Class Performance
105
+
106
+ | Class | Precision | Recall | F1 Score | Support |
107
+ |-------|-----------|--------|----------|---------|
108
+ | **Glioma** | 99.66% | 96.33% | 97.97% | 300 |
109
+ | **Meningioma** | 96.53% | 100.00% | 98.23% | 306 |
110
+ | **No Tumor** | 100.00% | 100.00% | 100.00% | 405 |
111
+ | **Pituitary** | 99.67% | 99.33% | 99.50% | 300 |
112
+
113
+ #### Detailed Analysis by Class
114
+
115
+ **Glioma:**
116
+ - Correctly classified: 289/300 (96.33%)
117
+ - Misclassified as Meningioma: 10 cases
118
+ - Misclassified as Pituitary: 1 case
119
+ - High precision (99.66%) indicates few false positives
120
+
121
+ **Meningioma:**
122
+ - Correctly classified: 306/306 (100% recall)
123
+ - Perfect recall with no false negatives
124
+ - Precision of 96.53% due to 11 false positives from other classes
125
+
126
+ **No Tumor:**
127
+ - Perfect classification (100% precision, recall, and F1)
128
+ - 405/405 correctly identified
129
+ - No confusion with tumor classes
130
+
131
+ **Pituitary:**
132
+ - Correctly classified: 298/300 (99.33%)
133
+ - Misclassified as Glioma: 1 case
134
+ - Misclassified as Meningioma: 1 case
135
+ - Near-perfect performance across all metrics
136
+
137
+ ### Confusion Analysis
138
+ - **Total Errors:** 13 out of 1,311 samples (0.99% error rate)
139
+ - **Most Common Error:** Glioma misclassified as Meningioma (10 cases)
140
+ - **Best Performance:** No Tumor class (perfect classification)
141
+ - **Clinical Significance:** The model never confuses tumor cases with "No Tumor", which is critical for medical screening applications
142
+
143
+ ## Training Procedure
144
+
145
+ ### Training Configuration
146
+ - **Framework:** PyTorch
147
+ - **Optimizer:** Adam
148
+ - **Learning Rate:** 1e-4
149
+ - **Batch Size:** 16
150
+ - **Loss Function:** CrossEntropyLoss with class weights
151
+ - **Device:** CUDA (GPU) Nvidia GeForce RTX 4060 8GB
152
+ - **Training Strategy:** Transfer learning with partial fine-tuning
153
+
154
+ ### Training Details
155
+ 1. **Layer Freezing:** All layers frozen except layer4 and final FC layer
156
+ 2. **Class Imbalance Handling:**
157
+ - Weighted random sampling during training
158
+ - Class-weighted loss function
159
+ 3. **Validation:** Evaluated on test set after each epoch
160
+ 4. **Early Stopping:** Not implemented (trained for full 10 epochs)
161
+
162
+ ### Computational Requirements
163
+ - **Training Time:** Hardware dependent
164
+ - **GPU Memory:** Suitable for single GPU training
165
+ - **Inference Time:** Fast inference suitable for real-time applications
166
+
167
+ ## Limitations and Biases
168
+
169
+ ### Technical Limitations
170
+ 1. **Input Constraints:**
171
+ - Requires specific image dimensions (224x224)
172
+ - Expects RGB format with ImageNet normalization
173
+ - May not handle varying image qualities well
174
+
175
+ 2. **Performance Limitations:**
176
+ - Trained on limited dataset size
177
+ - May not generalize to images from different scanners or protocols
178
+ - Performance on edge cases and rare tumor types unknown
179
+
180
+ 3. **Architectural Limitations:**
181
+ - ResNet18 is relatively shallow; deeper models might capture more complex patterns
182
+ - Single-view classification (doesn't utilize 3D MRI volumes)
183
+ - No attention mechanisms or interpretability features
184
+
185
+ ### Potential Biases
186
+ 1. **Dataset Bias:**
187
+ - Training data may not represent global population diversity
188
+ - Potential geographical, demographic, or institutional biases
189
+ - Scanner and imaging protocol biases
190
+
191
+ 2. **Class Imbalance:**
192
+ - Despite weighted sampling, model may still favor majority classes
193
+ - Rare tumor presentations underrepresented
194
+
195
+ 3. **Annotation Bias:**
196
+ - Dependent on original dataset annotation quality
197
+ - May inherit labeling errors or inconsistencies
198
+
199
+ ### Medical and Ethical Considerations
200
+ 1. **NOT Clinically Validated:**
201
+ - No regulatory approval (FDA, CE, etc.)
202
+ - Not tested in real clinical workflows
203
+ - Performance on real-world clinical data unknown
204
+
205
+ 2. **Risk of Misuse:**
206
+ - Should never replace professional medical judgment
207
+ - False positives/negatives could lead to inappropriate actions if misused
208
+ - Requires proper medical context for interpretation
209
+
210
+ 3. **Privacy Considerations:**
211
+ - Ensure patient data privacy when using model
212
+ - Comply with HIPAA, GDPR, and local regulations
213
+ - Anonymize any input images appropriately
214
+
215
+ ## Recommendations
216
+
217
+ ### For Researchers and Developers
218
+ - Use as baseline or comparison model for brain tumor classification research
219
+ - Experiment with different architectures, hyperparameters, or training strategies
220
+ - Combine with other models or modalities for improved performance
221
+ - Conduct thorough validation on your specific use case
222
+
223
+ ### For Educators
224
+ - Excellent demonstration of transfer learning in medical imaging
225
+ - Shows importance of handling class imbalance
226
+ - Good example of CNN fine-tuning strategies
227
+ - Can be used to teach medical AI ethics and limitations
228
+
229
+ ### Best Practices
230
+ 1. Always validate model predictions with ground truth when available
231
+ 2. Use ensemble methods or multiple models for critical applications
232
+ 3. Implement uncertainty quantification to identify low-confidence predictions
233
+ 4. Continuously monitor model performance on new data
234
+ 5. Maintain human oversight for all predictions
235
+
236
+ ## How to Use
237
+
238
+ ### Loading the Model
239
+ ```python
240
+ import torch
241
+ import torch.nn as nn
242
+ from torchvision import models
243
+
244
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
245
+
246
+ # Load model architecture
247
+ model = models.resnet18(pretrained=False)
248
+ num_ftrs = model.fc.in_features
249
+ model.fc = nn.Linear(num_ftrs, 4)
250
+ model = model.to(device)
251
+
252
+ # Load trained weights
253
+ model.load_state_dict(torch.load("multi_class_resnet.pth"))
254
+ model.eval()
255
+ ```
256
+
257
+ ### Image Preprocessing
258
+ ```python
259
+ from torchvision import transforms
260
+
261
+ test_transforms = transforms.Compose([
262
+ transforms.Resize((224, 224)),
263
+ transforms.ToTensor(),
264
+ transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
265
+ ])
266
+ ```
267
+
268
+ ### Making Predictions
269
+ ```python
270
+ with torch.no_grad():
271
+ image = test_transforms(pil_image).unsqueeze(0).to(device)
272
+ output = model(image)
273
+ _, prediction = torch.max(output, 1)
274
+
275
+ class_names = ['glioma', 'meningioma', 'notumor', 'pituitary']
276
+ predicted_class = class_names[prediction.item()]
277
+ ```
278
+
279
+ ## Citation
280
+
281
+ If you use this model in your research, please cite:
282
+
283
+ ```bibtex
284
+ @misc{brain_tumor_classifier_2025,
285
+ title={BRAINet - Brain Tumor Multi-Class Classification using ResNet18},
286
+ author={Thisen Ekanayake},
287
+ year={2025},
288
+ url={https://brainet.thisenekanayake.me},
289
+ note={Educational and research purposes only}
290
+ }
291
+ ```
292
+
293
+ ### Dataset Citation
294
+ ```bibtex
295
+ @misc{brats20_dataset,
296
+ author={Awsaf},
297
+ title={Brain Tumor Segmentation(BraTS2020)},
298
+ year={2020},
299
+ url={https://www.kaggle.com/datasets/awsaf49/brats2020-training-data}
300
+ }
301
+ ```
302
+
303
+ ## Contact and Support
304
+
305
+ - **Demo Application:** https://brainet.thisenekanayake.me
306
+ - **GitHub Repository:** https://github.com/Thisen-Ekanayake/BRAINet
307
+ - **Binary Classification Model:** Available in the repository with complete training and evaluation scripts
308
+ - **Issues:** Submit issues via the GitHub repository
309
+ - **Contributions:** Welcome via pull requests to the [BRAINet GitHub repository](https://github.com/Thisen-Ekanayake/BRAINet.git)
310
+
311
+ ## Model Card Version
312
+
313
+ - **Version:** 1.0
314
+ - **Date:** February 2026
315
+ - **Last Updated:** February 2026
316
+
317
+ ## Glossary
318
+
319
+ - **Glioma:** A type of tumor that occurs in the brain and spinal cord
320
+ - **Meningioma:** A tumor that arises from the meninges (membranes surrounding the brain and spinal cord)
321
+ - **Pituitary Tumor:** A growth in the pituitary gland
322
+ - **Transfer Learning:** Using a pre-trained model and adapting it for a new task
323
+ - **Fine-tuning:** Training select layers of a pre-trained model on new data
324
+ - **Class Imbalance:** When training data has unequal numbers of samples per class
325
+
326
+ ---
327
+
328
+ ## ⚠️ CRITICAL DISCLAIMER
329
+
330
+ **THIS MODEL IS FOR RESEARCH AND EDUCATIONAL PURPOSES ONLY**
331
+
332
+ This model has NOT been validated for clinical use and should NEVER be used for:
333
+ - Medical diagnosis
334
+ - Treatment planning
335
+ - Patient care decisions
336
+ - Clinical decision support
337
+
338
+ Always consult qualified healthcare professionals for medical advice, diagnosis, and treatment. The developers assume no liability for misuse of this model in clinical or medical settings.
339
+
340
+ ---
341
+
342
+ *This model card follows the framework proposed by Mitchell et al. (2019) and adapted for medical AI applications.*