abink commited on
Commit
e39aed8
Β·
verified Β·
1 Parent(s): 00d4bf5

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +370 -0
README.md CHANGED
@@ -0,0 +1,370 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Brain MRI Tumor Classification Using Deep Learning
2
+ ![head x ray hero](https://cdn-uploads.huggingface.co/production/uploads/65eea7642cc24ebc6dbf7400/h2rLOLfAqiJAlzdOvNlbr.jpeg)
3
+
4
+ ## 1. Introduction
5
+
6
+ Cancer remains one of the major global health challenges, and the increasing availability of medical imaging has created opportunities to support clinicians through computer-aided image analysis. In oncology, medical imaging plays an important role in the detection, characterization, treatment planning, and follow-up of tumors.
7
+
8
+ **Brain MRI** is particularly important in the assessment of brain tumors because MRI provides detailed soft-tissue contrast without exposing the patient to ionizing radiation. However, interpretation of large numbers of medical images can be time-consuming and requires considerable clinical expertise.
9
+
10
+ This project explores the use of **deep learning for automated brain MRI tumor classification**, combining concepts from **medical imaging, artificial intelligence, machine learning, and deep learning**.
11
+
12
+ The objective was not simply to train a CNN and report its accuracy, but to investigate how different pretrained deep-learning architectures perform on brain MRI data and how **transfer learning, layer selection, fine-tuning, optimization, and regularization** affect classification performance.
13
+
14
+ ---
15
+
16
+ ## 2. Medical Imaging Dataset
17
+
18
+ The project uses brain MRI images representing four classification categories:
19
+
20
+ 1. **Glioma**
21
+ 2. **Meningioma**
22
+ 3. **Pituitary tumor**
23
+ 4. **No Tumor**
24
+
25
+ Gliomas, meningiomas, and pituitary tumors represent three major tumor categories considered in this classification task, while the **No Tumor** class provides a non-tumor reference category.
26
+
27
+ The dataset was organized as a four-class image-classification problem with a balanced test set of **1,600 images (400 per class)**.
28
+
29
+ A consistent preprocessing and augmentation pipeline was maintained across the different architectures to make the model comparison more meaningful.
30
+
31
+ **Input image size:** `128 Γ— 128 Γ— 3`
32
+
33
+ ---
34
+
35
+ ## 3. Project Objective
36
+
37
+ The main objective was to investigate whether transfer-learning-based CNN architectures could effectively learn discriminative features from brain MRI images and determine which architecture provided the most reliable classification performance.
38
+
39
+ Rather than relying on a single neural network, multiple established architectures were evaluated:
40
+
41
+ * **VGG16**
42
+ * **ResNet50**
43
+ * **DenseNet121**
44
+ * **EfficientNetB0**
45
+
46
+ The models were first evaluated using their pretrained ImageNet features and subsequently investigated through **domain-specific fine-tuning**.
47
+
48
+ The project also examined how changing the classification head, trainable layers, learning rate, optimizer, regularization, and fine-tuning strategy affected performance.
49
+
50
+ ---
51
+
52
+ # 4. Transfer Learning and Model Development
53
+
54
+ All models used **ImageNet-pretrained convolutional backbones**. The original classification layers were removed and replaced with task-specific classification heads.
55
+
56
+ The general workflow was:
57
+
58
+ ```text
59
+ Brain MRI Dataset
60
+ ↓
61
+ Preprocessing & Augmentation
62
+ ↓
63
+ Train / Validation / Test Split
64
+ ↓
65
+ ImageNet-Pretrained CNN
66
+ ↓
67
+ Custom Classification Head
68
+ ↓
69
+ Initial Transfer Learning
70
+ ↓
71
+ Layer Unfreezing & Fine-Tuning
72
+ ↓
73
+ Performance Evaluation
74
+ ↓
75
+ Model Comparison
76
+ ```
77
+
78
+ For the classification heads, architectures using:
79
+
80
+ ```text
81
+ GlobalAveragePooling2D
82
+ ↓
83
+ Dense Layers
84
+ ↓
85
+ Batch Normalization
86
+ ↓
87
+ Dropout
88
+ ↓
89
+ 4-Class Softmax
90
+ ```
91
+
92
+ were investigated.
93
+
94
+ Fine-tuning was performed by selectively unfreezing deeper convolutional layers while keeping earlier feature-extraction layers frozen. Lower learning rates were used during fine-tuning to avoid excessively changing useful pretrained features.
95
+
96
+ ---
97
+
98
+ # 5. Model Comparison
99
+
100
+ The four architectures showed substantially different behavior on the brain MRI classification task.
101
+
102
+ | Model | Initial Accuracy | Fine-Tuned Accuracy | Final Status |
103
+ | ------------------ | ---------------: | ------------------: | --------------- |
104
+ | **VGG16** | 83.44% | **91.50%** | ⭐ Selected |
105
+ | **DenseNet121** | 83.00% | **83.00%** | Strong baseline |
106
+ | **ResNet50** | 68.00% | **81.00%** | Baseline |
107
+ | **EfficientNetB0** | 33.00% | **35.00%** | Not selected |
108
+
109
+ ### Best-performing model
110
+
111
+ **Fine-tuned VGG16**
112
+
113
+ * Test Accuracy: **91.50%**
114
+ * Macro F1: **0.91**
115
+ * Weighted F1: **0.91**
116
+
117
+ Fine-tuning improved VGG16 from **83.44% to 91.50%**, an improvement of **8.06 percentage points**.
118
+
119
+ ---
120
+
121
+ # 6. VGG16
122
+
123
+ VGG16 was the strongest architecture evaluated in this project.
124
+
125
+ ### Classification Architecture
126
+
127
+ ```text
128
+ VGG16 (ImageNet pretrained)
129
+ ↓
130
+ GlobalAveragePooling2D
131
+ ↓
132
+ Dense(256) + BatchNorm + Dropout(0.4)
133
+ ↓
134
+ Dense(128) + BatchNorm + Dropout(0.3)
135
+ ↓
136
+ Dense(4, Softmax)
137
+ ```
138
+
139
+ The initial VGG16 experiment used the pretrained backbone with a custom classification head.
140
+
141
+ The classification head was subsequently improved by replacing `Flatten()` with `GlobalAveragePooling2D`, reducing the number of parameters and helping control overfitting.
142
+
143
+ ### Fine-Tuning
144
+
145
+ The final convolutional block was unfrozen while earlier layers remained frozen.
146
+
147
+ Training used:
148
+
149
+ * Adam optimizer
150
+ * Initial learning rate: `1 Γ— 10⁻⁴`
151
+ * Fine-tuning learning rate: `1 Γ— 10⁻⁡`
152
+ * Early stopping
153
+ * ReduceLROnPlateau
154
+ * Model checkpointing
155
+
156
+ ### Performance
157
+
158
+ | Class | Precision | Recall | F1 |
159
+ | ---------- | --------: | -------: | -------: |
160
+ | Glioma | 0.95 | 0.98 | **0.97** |
161
+ | Meningioma | 0.92 | **1.00** | **0.96** |
162
+ | No Tumor | 0.84 | 0.93 | **0.88** |
163
+ | Pituitary | 0.97 | 0.75 | **0.84** |
164
+
165
+ **Final accuracy: 91.50%**
166
+
167
+ The strong performance across the tumor classes made VGG16 the selected architecture for subsequent stages of the project.
168
+
169
+ ---
170
+
171
+ # 7. ResNet50
172
+
173
+ ResNet50 was evaluated as an alternative deep residual architecture.
174
+
175
+ ### Architecture
176
+
177
+ ```text
178
+ ResNet50 (ImageNet pretrained)
179
+ ↓
180
+ GlobalAveragePooling2D
181
+ ↓
182
+ Dense(256) + BatchNorm + Dropout(0.4)
183
+ ↓
184
+ Dense(128) + BatchNorm + Dropout(0.3)
185
+ ↓
186
+ Dense(4, Softmax)
187
+ ```
188
+
189
+ The backbone was initially frozen and the classification head was trained. The final convolutional section was subsequently unfrozen for domain-specific fine-tuning.
190
+
191
+ ### Results
192
+
193
+ | Class | Precision | Recall | F1 |
194
+ | ---------- | --------: | -----: | ---: |
195
+ | Glioma | 0.89 | 0.91 | 0.90 |
196
+ | Meningioma | 0.78 | 0.99 | 0.87 |
197
+ | No Tumor | 0.78 | 0.66 | 0.72 |
198
+ | Pituitary | 0.77 | 0.68 | 0.72 |
199
+
200
+ **Initial accuracy:** 68.00%
201
+
202
+ **Fine-tuned accuracy:** 81.00%
203
+
204
+ Fine-tuning produced a substantial improvement of approximately **13 percentage points**, demonstrating that adaptation of pretrained features to the MRI domain was beneficial.
205
+
206
+ However, ResNet50 remained below the performance of fine-tuned VGG16.
207
+
208
+ ---
209
+
210
+ # 8. DenseNet121
211
+
212
+ DenseNet121 was included because dense feature reuse and hierarchical feature propagation make it an important architecture for medical-image classification.
213
+
214
+ ### Architecture
215
+
216
+ ```text
217
+ DenseNet121 (ImageNet pretrained)
218
+ ↓
219
+ GlobalAveragePooling2D
220
+ ↓
221
+ Dense(256) + BatchNorm + Dropout(0.4)
222
+ ↓
223
+ Dense(128) + BatchNorm + Dropout(0.3)
224
+ ↓
225
+ Dense(4, Softmax)
226
+ ```
227
+
228
+ ### Fine-Tuning Investigation
229
+
230
+ The initial fine-tuning strategy reduced performance from:
231
+
232
+ **83% β†’ 79%**
233
+
234
+ A more conservative DenseNet-specific strategy was then investigated:
235
+
236
+ * Later convolutional layers selectively unfrozen
237
+ * Batch Normalization layers kept frozen
238
+ * AdamW optimizer
239
+ * Learning rate: `3 Γ— 10⁻⁢`
240
+ * Weight decay: `1 Γ— 10⁻⁴`
241
+ * Early stopping
242
+ * ReduceLROnPlateau
243
+
244
+ The optimized configuration recovered the performance to **83%**, but did not provide a meaningful overall improvement over the original frozen-backbone configuration.
245
+
246
+ ### Best Results
247
+
248
+ | Class | Precision | Recall | F1 |
249
+ | ---------- | --------: | -----: | ---: |
250
+ | Glioma | 0.85 | 0.96 | 0.90 |
251
+ | Meningioma | 0.83 | 0.97 | 0.90 |
252
+ | No Tumor | 0.77 | 0.72 | 0.74 |
253
+ | Pituitary | 0.88 | 0.66 | 0.76 |
254
+
255
+ **Accuracy: 83.00%**
256
+
257
+ **Macro F1: 0.82**
258
+
259
+ DenseNet121 therefore provided a strong baseline but did not outperform the fine-tuned VGG16.
260
+
261
+ ---
262
+
263
+ # 9. EfficientNetB0
264
+
265
+ EfficientNetB0 was evaluated using the same dataset and general transfer-learning framework.
266
+
267
+ ### Architecture
268
+
269
+ ```text
270
+ EfficientNetB0 (ImageNet pretrained)
271
+ ↓
272
+ GlobalAveragePooling2D
273
+ ↓
274
+ Dense(256) + BatchNorm + Dropout(0.4)
275
+ ↓
276
+ Dense(128) + BatchNorm + Dropout(0.3)
277
+ ↓
278
+ Dense(4, Softmax)
279
+ ```
280
+
281
+ The backbone was initially frozen and subsequently partially fine-tuned.
282
+
283
+ ### Results
284
+
285
+ **Initial accuracy: 33%**
286
+
287
+ **Fine-tuned accuracy: 35%**
288
+
289
+ The model exhibited severe class-collapse behavior and failed to reliably identify some of the tumor categories.
290
+
291
+ Therefore, EfficientNetB0 was not selected for further development within this project.
292
+
293
+ ---
294
+
295
+ # 10. Overall Findings
296
+
297
+ The experiments demonstrated that **architecture selection and fine-tuning strategy have a major effect on medical-image classification performance**.
298
+
299
+ The results were:
300
+
301
+ | Architecture | Initial | Fine-Tuned | Improvement |
302
+ | -------------- | ------: | ---------: | -----------: |
303
+ | **VGG16** | 83.44% | **91.50%** | **+8.06 pp** |
304
+ | ResNet50 | 68.00% | 81.00% | +13.00 pp |
305
+ | DenseNet121 | 83.00% | 83.00% | 0 pp |
306
+ | EfficientNetB0 | 33.00% | 35.00% | +2.00 pp |
307
+
308
+ An important observation was that **fine-tuning did not improve every architecture equally**.
309
+
310
+ * VGG16 responded strongly to domain-specific fine-tuning.
311
+ * ResNet50 showed substantial improvement.
312
+ * DenseNet121 required a more conservative fine-tuning strategy and ultimately remained around its baseline performance.
313
+ * EfficientNetB0 showed severe classification difficulties under the tested configuration.
314
+
315
+ This demonstrates that pretrained architectures cannot simply be treated as interchangeable models; their layer structure, feature representations, and fine-tuning behavior need to be considered when applying deep learning to medical images.
316
+
317
+ ---
318
+
319
+ # 11. Final Model
320
+
321
+ Based on the comparative evaluation, **fine-tuned VGG16** was selected as the best-performing model.
322
+
323
+ ### Final Performance
324
+
325
+ **91.50% Test Accuracy**
326
+
327
+ **0.91 Macro F1**
328
+
329
+ | Class | F1-score |
330
+ | ---------- | -------: |
331
+ | Glioma | **0.97** |
332
+ | Meningioma | **0.96** |
333
+ | No Tumor | **0.88** |
334
+ | Pituitary | **0.84** |
335
+
336
+ The model demonstrated particularly strong recognition of Glioma and Meningioma, while Pituitary tumor classification remained the more challenging category because of its lower recall.
337
+
338
+ ---
339
+
340
+ # 12. Medical Physics and Future Development
341
+
342
+ This project was developed at the intersection of **medical imaging, deep learning, and quantitative analysis**, with relevance to the growing role of computational methods in modern medical physics.
343
+
344
+ The current model should be considered a **research/educational classification system rather than a clinical diagnostic tool**. High classification accuracy alone is not sufficient for clinical deployment.
345
+
346
+ The next stage of the project focuses on:
347
+
348
+ * **Confusion-matrix analysis**
349
+ * Sensitivity and specificity
350
+ * ROC-AUC analysis
351
+ * Precision-recall analysis
352
+ * False-positive and false-negative investigation
353
+ * **Grad-CAM explainability**
354
+ * Visualization of image regions influencing model predictions
355
+ * Model limitations and potential clinical considerations
356
+ * Development of a small **Streamlit demonstration interface**
357
+
358
+ Grad-CAM and error analysis are particularly important because they can help investigate whether the CNN is responding to medically meaningful regions of the MRI rather than irrelevant image characteristics.
359
+
360
+ ---
361
+
362
+ # Conclusion
363
+
364
+ This project demonstrated the application of **transfer learning and deep convolutional neural networks to brain MRI tumor classification**.
365
+
366
+ Four architectures were systematically evaluated under a consistent experimental framework. While DenseNet121 and ResNet50 provided useful comparative baselines, **fine-tuned VGG16 achieved the best performance with 91.50% test accuracy and a 0.91 macro F1-score**.
367
+
368
+ The project also demonstrated that successful medical-image deep learning requires more than selecting a powerful CNN. **Preprocessing, architecture selection, classification-head design, layer freezing, fine-tuning depth, learning rate, optimization and regularization** all influence model performance.
369
+
370
+ The final stage will focus on **model interpretability and clinically relevant evaluation**, moving the project beyond simple accuracy-based classification toward a more complete medical-imaging research workflow.