September 30, 2026
Transfer Learning in Computer Vision for the Classification of Alzheimer’s Stages with MRI.
Transfer Learning in Computer Vision for the Classification of Alzheimer’s Stages with MRI.
André Pirini Spadaro; Gabriel Gomes de Oliveira
DOI: 10.22167/2675-6528-202602694
Article derived from a Course Conclusion Work (TCC), with content based on the student’s original work and adapted to the editorial format of the E&S Magazine with the support of the ResumeAI tool, an artificial intelligence solution developed by Instituto Pecege for textual synthesis and organization.
Summary
Alzheimer’s disease is one of the greatest global health challenges, with early and accurate diagnosis being crucial for patient management. A deep learning model was developed and validated for the automatic classification of the four stages of the disease, using 6400 brain magnetic resonance imaging (MRI) scans. Transfer learning methodology was employed, with the pre-trained Convolutional Neural Network (CNN) ResNet18 architecture. The model was trained in two phases, feature extraction followed by fine-tuning, on a public dataset divided into training, validation, and test sets, with no additional patient information. The results on the test set were promising, achieving an overall accuracy of 99.3% and a Cohen’s Kappa coefficient of 0.988. The model demonstrated remarkable generalization capability, perfectly identifying the rarest class, Moderate Alzheimer’s, with a precision and sensitivity of 1.000. It was concluded that the approach is highly effective and holds great potential as a support tool for the clinical diagnosis of Alzheimer’s disease, contributing to the improvement of patients’ quality of life through early detection.
Keywords: Deep Learning; Convolutional Neural Networks (CNN); ResNet18; Brain Magnetic Resonance Imaging (MRI); Transfer Learning.
1. Introduction
Alzheimer’s disease (AD) is recognized as the leading cause of major neurocognitive disorder on a global scale. With the progressive aging of the world’s population, the prevalence of AD shows an exponential increasing trend, intensifying the social, economic, and emotional impact on patients, their families, and healthcare systems (World Health Organization, 2023). In this context, early diagnosis and accurate classification of the disease stages become crucial, as they enable the implementation of therapeutic strategies that can delay symptom progression and optimize patient care planning (Alzheimer’s Association, 2022).
Pathophysiologically, Alzheimer’s disease is characterized by two primary neuropathological markers: the extracellular accumulation of plaques formed by beta-amyloid peptide (Aβ) and the formation of intracellular neurofibrillary tangles, resulting from the hyperphosphorylation of Tau protein (BERTRAM et al., 2005; HAINFELLNER et al., 1998). The aggregation of hyperphosphorylated Tau protein compromises cellular integrity and axonal transport, culminating in synaptic dysfunction and neuronal death (GUPTA et al., 2010). This dual cellular aggression process leads to progressive cerebral atrophy, which is macroscopically visible in Magnetic Resonance Imaging (MRI) and serves as one of the main biomarkers for the diagnosis and staging of the disease, justifying the use of computational methods for its detection.
Current diagnostic methods often integrate MRI images with the patient’s clinical history and neuropsychological tests. However, the interpretation of these images depends on the radiologist’s and physician’s experience, which can be particularly challenging in the early stages of the disease, where brain changes are subtle (Jack Jr. et al., 2018). Clinicopathological studies indicate that clinicians’ diagnostic sensitivity varies between 70.9% and 87.3%, and specificity between 44.3% and 70.8% (BEACH et al., 2012), highlighting the need for complementary tools that improve diagnostic accuracy and objectivity.
Artificial intelligence (AI), and more specifically computer vision, has emerged as a promising ally in diagnostic medicine. With the development of deep learning models, such as convolutional neural networks (CNNs), it has become feasible to create systems capable of identifying complex patterns in medical images with a level of precision that can be comparable or superior to that of human experts (Litjens et al., 2017). The application of CNNs in the analysis of MRI images for the detection and classification of AD has been documented in several works, demonstrating the potential of these algorithms to assist in diagnosis (Jo et al., 2019).
However, training a high-accuracy CNN from scratch requires a substantial volume of data, which is often a limitation in the medical context due to the scarcity of publicly available data. To circumvent this restriction, the methodology of transfer learning is recognized as a gold standard approach. This technique involves using a neural network pre-trained on a large dataset, such as ImageNet, and adapting it for a new specific task (SHIN et al., 2016). Architectures like ResNet, which incorporate residual connections to optimize gradient flow, have proven effective in this application, enabling the training of deep networks (HE et al., 2016; RAMALHO et al., 2024).
Given the growing prevalence of Alzheimer’s disease and the inherent limitations of traditional diagnostic methods, the application of advanced artificial intelligence techniques, such as transfer learning, presents a promising path for improving diagnosis. This work aimed to develop, train, and validate a deep learning model, based on the Transfer Learning methodology with the ResNet18 architecture, for the automatic classification of the four stages of Alzheimer’s disease: No Alzheimer’s, Very Mild Alzheimer’s, Mild Alzheimer’s, and Moderate Alzheimer’s, from MRI, aiming to create a highly accurate computational tool to support clinical diagnosis.
2. Material and Methods
This study was characterized as a research of an applied nature, with a quantitative methodological approach, focused on the development and validation of a deep learning model. The central objective was the automatic classification of the four stages of Alzheimer’s disease, namely: No Alzheimer’s, Very Mild Alzheimer’s, Mild Alzheimer’s, and Moderate Alzheimer’s, using brain magnetic resonance imaging (MRI) as the empirical object.
The dataset employed was obtained from the Kaggle data science platform, titled “Alzheimer’s Dataset (4 class of Images)” (SINGH, 2019). This public dataset comprised a total of 6,400 brain MRI images. The distribution of images per class was as follows: 3,200 images for No Alzheimer’s (50%), 2,240 for Very Mild Alzheimer’s (35%), 896 for Mild Alzheimer’s (14%), and 64 for Moderate Alzheimer’s (1%). The unbalanced distribution of classes was a factor considered in the data splitting and evaluation strategy.
For data preprocessing and structuring, the entirety of the 6,400 images was programmatically divided into three independent sets: training, validation, and testing. The `train_test_split` function from the Scikit-learn library (version 1.3.2) was used with stratification (70/10/20), ensuring the preservation of the original proportion of each class in all subsets. The sets comprised 4,480 images for training (70%), 640 for validation (10%), and 1,280 for testing (20%). To ensure reproducibility, a global random seed (seed = 42) was applied.
Additionally, data augmentation techniques were dynamically applied to the training set to mitigate overfitting and enhance the model’s generalization capability. The transformations included random rotations of up to 15 degrees and horizontal flips. All images were resized to 224×224 pixels. Subsequently, pixel values were converted to the [0, 1] range and normalized using the mean and standard deviation of the color channels from the ImageNet dataset, a standard procedure in transfer learning.
The development environment used was the Google Colaboratory (Colab) platform, Pro version, which provided an NVIDIA A100-SXM4-80GB Graphics Processing Unit (GPU). The development was carried out in the Python programming language (version 3.10.12), with the support of open-source libraries. The main libraries included PyTorch (version 2.3.0+cu121) for building and training the neural network, Torchvision (version 0.18.0+cu121) for accessing datasets and pre-trained architectures, Pandas (version 2.0.3) for tabular data manipulation, Matplotlib (version 3.7.1) and Seaborn (version 0.13.1) for graphical visualizations, and Numpy (version 1.25.2) for numerical computation.
The project’s core methodology was transfer learning, a consolidated strategy for scenarios with limited datasets (SHIN et al., 2016). A model pre-trained on a classification task of thousands of distinct objects from the ImageNet dataset was reused as a starting point. This approach allowed leveraging the network’s ability to extract generic visual features, accelerating learning for the new task and combating overfitting on a limited dataset.
The selected base architecture was ResNet18, a convolutional neural network with 18 layers (HE et al., 2016). The ResNet family, or Residual Networks, introduced residual connections (skip connections), which allow the output of a previous layer to be summed directly to the output of a subsequent layer. This mechanism creates a “shortcut” for information flow, optimizing gradient flow and enabling the training of very deep networks without the vanishing gradient problem.
The original architecture of ResNet18 was modified for the specific task. The original classification layer, designed for the 1000 ImageNet categories, was removed. In its place, a custom classification “head” was added, adapted for the four classes of Alzheimer’s disease. This “head” consisted of a dense layer with 512 input neurons and 128 output neurons, using the ReLU activation function. This was followed by a dropout layer with a probability of 0.20 (SRIVASTAVA et al., 2014) for regularization, and a final dense layer with 128 input neurons and 4 output neurons, corresponding to the number of classes, with a Softmax activation function.
The model training was performed in two distinct phases. In Phase 1, named Feature Extraction (10 epochs), the ResNet18 base was kept “frozen” (its pre-trained weights were not altered), and the training focused exclusively on the custom classification “head”. The Adam optimizer (KINGMA; BA, 2014) was used with an initial learning rate of 0.001. In Phase 2, Fine-Tuning (15 epochs), all model layers (ResNet base and custom head) were “unfrozen”, allowing adjustments to all weights with a drastically lower learning rate of 0.0001. This strategy aimed to refine the model for the specific task, avoiding “catastrophic forgetting” of pre-trained knowledge.
The loss function used to quantify the model’s error during training was Categorical Cross-Entropy (CrossEntropyLoss in PyTorch). The Adam optimizer (Adaptive Moment Estimation) was responsible for adjusting the model’s weights, adapting the learning rate for each network parameter, which contributed to faster and more stable model convergence.
The final model’s performance was rigorously evaluated on the test set, which consisted of data unseen by the model. The evaluation metrics calculated included overall accuracy, precision, sensitivity (recall), specificity, F1-Score, ROC curve, AUC (area under the curve), Youden’s index, Cohen’s Kappa coefficient, and Matthews correlation coefficient (MCC). The confusion matrix was also used to summarize the performance of the classification algorithm.
3. Results and Discussion
The evaluation of the deep learning model for the classification of Alzheimer’s disease stages, using brain magnetic resonance imaging (MRI), revealed exceptional performance, validating the transfer learning approach with the ResNet18 architecture. The development process was carried out in the Google Colaboratory environment, which, with the aid of an NVIDIA A100-SXM4-80GB GPU, allowed for a remarkably efficient training time of 2 minutes and 48 seconds. The final model incorporated a total of 11,178,564 trainable parameters, demonstrating the complexity and learning capacity of the adapted convolutional neural network.
The model training was structured in two distinct phases, aiming to optimize feature extraction and fine-tuning. In the first phase, which comprised the first ten epochs, the ResNet18 base was kept “frozen”, meaning its pre-trained weights were not altered. This initial stage focused on adjusting the custom classification “head”, allowing it to adapt stably to the generic features already learned by ResNet. Rapid learning was observed, with validation accuracy showing a consistent rise and loss progressively decreasing, indicating an effective adaptation of the classifier.
The second phase, initiated from the tenth epoch, involved the “unfreezing” of all model layers, including the ResNet base and the custom head, and the continuation of training with a drastically reduced learning rate (0.0001). This fine-tuning strategy resulted in a significant leap in performance, with the training and validation accuracy curves converging to levels above 95%. The proximity between these curves at the end of the process is a robust indicator that the model has reached an excellent generalization point, mitigating the risk of overfitting, a common challenge in deep learning models with limited datasets.
The analysis of the evolution of accuracy and loss during training confirmed the expected inverse correlation: as the loss decreased, the accuracy increased, in both the training and validation sets. The two-phase strategy for the learning rate, with a higher rate in the initial phase and a drastic reduction in the fine-tuning phase, was crucial for this smooth and effective convergence. Although the Mild Alzheimer’s class exhibited greater initial variability in F1-Score during fine-tuning, all classes demonstrated significant improvement and convergence to high performance, reflecting the robustness of the method.
The final model evaluation was conducted on a test set composed of 1,280 images, which were completely new to the model, ensuring an unbiased assessment of its predictive capability. The quantitative results obtained were exceptional, with an overall accuracy of 99.3%. This high value, along with a weighted average F1-Score of 0.993, confirms the model’s excellent balance across all classes, indicating that the system is capable of maintaining high precision and sensitivity simultaneously, even in a scenario of imbalanced classes.
The specificity, with a weighted average of 0.994, demonstrated the model’s high capacity to correctly identify negative cases, i.e., patients without Alzheimer’s, minimizing the occurrence of false positives. This aspect is particularly relevant in the clinical context, where an incorrect diagnosis can generate unnecessary anxiety and invasive procedures. The Youden’s index, which integrates sensitivity and specificity, also presented a high value of 0.987 in the weighted average, reinforcing the model’s excellent overall diagnostic capacity and its utility as a support tool.
Cohen’s Kappa coefficient, which corrects for chance agreement, reached 0.988, indicating an almost perfect agreement between the model’s predictions and the actual labels. This value is significantly high and above the threshold of 0.80, which already denotes an almost perfect agreement, attesting to the robustness of the model’s learning and that its results are not merely random or influenced by class imbalance. Complementarily, the Matthews Correlation Coefficient (MCC) of 0.988, considered one of the most informative metrics for imbalanced datasets, also pointed to an almost perfect prediction, taking into account all types of outcomes (true positives, true negatives, false positives, and false negatives).
The detailed analysis by class revealed that the “No Alzheimer” class obtained an accuracy of 0.988 and sensitivity of 1.000, with an F1-Score of 0.994. For “Very Mild Alzheimer’s”, the accuracy was 1.000 and sensitivity of 0.982, resulting in an F1-Score of 0.991. The “Mild Alzheimer’s” class presented an accuracy of 0.994 and sensitivity of 0.994, with an F1-Score of 0.994. A particularly notable finding was the perfect performance for the “Moderate Alzheimer’s” class, which achieved accuracy, sensitivity, specificity, F1-Score, Youden’s index, and AUC of 1.000 for all metrics, despite being the rarest class in the dataset, representing only 1% of the total images.
The AUC (Area Under the ROC Curve) values for all classes were extremely close to 1.0000, with “Mild Alzheimer’s” and “Moderate Alzheimer’s” reaching 1.0000, and “No Alzheimer’s” and “Very Mild Alzheimer’s” achieving 0.9999. These results indicate an almost perfect discrimination capability between classes, suggesting that the model is highly effective in distinguishing the different stages of the disease. The proximity of the ROC curves to the upper-left corner of the graph visually reinforces the model’s high sensitivity and specificity across all categories.
The visual analysis of the confusion matrix corroborated the numerical results, displaying a strong main diagonal and very low values outside of it. This demonstrates the model’s high accuracy across all classes. The few errors identified in the matrix confirmed a slightly greater difficulty in distinguishing between the “Mild Alzheimer’s” and “Very Mild Alzheimer’s” stages, which is an expected behavior and reflects the continuous nature of the disease’s progression. The perfect performance for the “Moderate Alzheimer’s” class, despite its minority representation in the dataset, is a particularly significant result, indicating the robustness of ResNet18 and the effectiveness of fine-tuning in learning distinctive features even with few samples.
Compared to the existing literature, the performance achieved by this model surpassed many reported results for Alzheimer’s disease classification using transfer learning on MRI datasets. Previous studies that applied approaches based on deep CNNs and transfer learning on datasets such as OASIS and ADNI, frequently reported accuracies in the range of 85% to 96% (ISLAM; ZHANG, 2020; SALEHI; ERDOGMUS; GHOLIPOUR, 2020). The accuracy of 99.3%, Kappa of 0.988, and MCC of 0.988 obtained in this study represent a substantial improvement.
The model’s superiority can be attributed to the strategic combination of the ResNet18 architecture, which is recognized for its efficiency and ability to handle the vanishing gradient problem through residual connections, and the two-phase fine-tuning methodology. This approach allowed the model to specialize in the task of MRI image classification for Alzheimer’s, leveraging knowledge pre-trained on a vast dataset and adapting it in a refined manner. The training stability and absence of significant overfitting, evidenced by the learning curves, are strong points that contributed to the final model’s high generalization capability.
The ability to perfectly classify the “Moderate Alzheimer’s” class, despite its extreme rarity in the training dataset, is a particularly relevant result. Many works in the literature face significant challenges with minority classes, where reduced representativeness can lead to training bias. The robustness of ResNet18, combined with the effectiveness of fine-tuning, allowed the model to learn distinctive features with few samples, demonstrating significant potential for early and accurate diagnosis, especially in more advanced stages, where identification is crucial for patient management.
In summary, the results obtained demonstrate that the developed deep learning model is highly effective in classifying the four stages of Alzheimer’s disease from MRI images. The high accuracy, Cohen’s Kappa, and MCC, along with the excellent discrimination capability between classes, validate the employed methodology and position the model as a promising tool to assist clinical diagnosis, contributing to early detection and patient care planning.
4. Conclusion
The present study aimed at the development, training, and validation of a deep learning model, employing the Transfer Learning methodology with the ResNet18 architecture, for the automatic classification of the four stages of Alzheimer’s disease from brain magnetic resonance imaging (MRI) scans. Exceptional model performance was observed, achieving an overall accuracy of 99.3% and a Cohen’s Kappa coefficient of 0.988 on the test set. The two-phase training strategy, involving feature extraction followed by fine-tuning, proved to be highly effective, enabling the model to learn complex patterns and generalize robustly. Notably, perfect classification capability was identified for the Moderate Alzheimer’s class, despite it being the rarest in the dataset, with a precision and sensitivity of 1.000. These findings position the model as a high-accuracy computational tool with great potential to support the clinical diagnosis of Alzheimer’s disease, contributing to early detection and patient care planning.
However, the study presents some limitations that should be considered. The model’s evaluation was performed on a single public dataset, suggesting the need for validation on external datasets from different imaging centers and acquisition protocols to confirm its real-world generalization. Additionally, the analysis was conducted on 2D images, while magnetic resonance imaging is a 3D modality, which may imply a loss of contextual information. For future studies, it is recommended to build models capable of directly processing 3D volumes and integrating multimodal data, such as computed tomography and blood biomarkers, aiming for an even more comprehensive and precise diagnosis. It is essential to emphasize that the developed model constitutes a diagnostic support tool, not a substitute for specialized clinical evaluation.
Bibliographic References
ALZHEIMER’S ASSOCIATION. 2022 Alzheimer’s disease facts and figures. Alzheimer’s & Dementia, 18(4): 700-789, 2022.
BEACH, Thomas G. et al. Accuracy of the clinical diagnosis of Alzheimer disease at National Institute on Aging Alzheimer Disease Centers, 2005–2010. Journal of neuropathology and experimental neurology, v. 71, n. 4, p. 266-273, 2012.
BERTRAM, L. et al. The genetic epidemiology of neurodegenerative disease. The Journal of clinical investigation, v. 115, n. 6, p. 1449-1457, 2005.
GUPTA, S. et al. Alzheimer’s disease: Genes, proteins, and therapy. Physiological Reviews, v. 81, n. 2, p. 741-766, 2001.
HAINFELLNER, J. A. et al. Coexistence of Alzheimer-type neuropathology in Creutzfeldt-Jakob disease. Acta neuropathologica, v. 96, n. 2, p. 116-122, 1998.
HE, K.; ZHANG, X.; REN, S.; SUN, J. Deep Residual Learning for Image Recognition. In: Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), p. 770-778, 2016.
ISLAM, J.; ZHANG, Y. Brain MRI analysis for Alzheimer’s disease diagnosis using an ensemble system of deep convolutional neural networks. Brain Informatics, v. 7, n. 1, art. 2, 2020.
JACK JR., C. R.; BENNETT, D. A.; BLENNOW, K.; CARRILO, M. C.; FELDMAN, H. H.; FRISONI, G. B.; HAMPEL, H.; JEGATHEESAN, A.; PETERSEN, R. C.; SNYDER, P. J.; SPERLING, R. A.; TEPPA, F. A NIA-AA Research Framework: Toward a biological definition of Alzheimer’s disease. Alzheimer’s & Dementia, 14(4): 535-562, 2018.
JO, T.; NHO, K.; SAYKIN, A. J. Deep Learning in Alzheimer’s Disease: Diagnostic Classification and Prognostic Prediction Using Neuroimaging Data. Frontiers in Aging Neuroscience, 11(220): 1-18, 2019.
KINGMA, D. P.; BA, J. Adam: A Method for Stochastic Optimization. In: Proceedings of the 3rd International Conference on Learning Representations (ICLR), 2015.
LITJENS, G.; KOOI, T.; BEJINARIU, B. E.; SETIO, A. A. A.; CIOMPI, F.; GHAFOORIAN, M.; VAN DER LAAR, J. A. W. M.; VAN GINNEKEN, B.; SÁNCHEZ, C. I. A survey on deep learning in medical image analysis. Medical Image Analysis, 42(1): 60-88, 2017.
ORGANIZAÇÃO MUNDIAL DA SAÚDE (OMS). Global status report on the public health response to dementia. Genebra: World Health Organization, 2021.
RAMALHO, B. A. C. et al. The impact of the orientation of MRI slices on the accuracy of Alzheimer’s disease classification using convolutional neural networks (CNNs). Journal of Medical Artificial Intelligence, v. 7, art. 35, 2024.
SALEHI, A. W.; ERDOGMUS, D.; GHOLIPOUR, A. Auto-Transfer Learning for Alzheimer’s Disease Diagnosis Using Structural MRI. In: International Workshop on Machine Learning in Medical Imaging (MLMI 2020), Springer, Cham, p. 193-201, 2020.
SHIN, H. C. et al. Deep Convolutional Neural Networks for Computer-Aided Detection: CNN Architectures, Dataset Characteristics and Transfer Learning. IEEE Transactions on Medical Imaging, v. 35, n. 5, p. 1285-1298, 2016.
SINGH, P. P. Alzheimer’s Dataset (4 class of Images). Kaggle, 2019. Disponível em: https://www.kaggle.com/datasets/preetpalsingh25/alzheimers-dataset-4-class-of-images. Acesso em: 14 out. 2025.
SRIVASTAVA, N. et al. Dropout: A Simple Way to Prevent Neural Networks from Overfitting. Journal of Machine Learning Research, v. 15, n. 1, p. 1929-1958, 2014.
Article originating from the Final Course Project of the Specialization in Data Science and Analytics of the MBA USP/Esalq
To learn more about the course, click here and access the MBX Academy platform