<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE article PUBLIC "-//NLM//DTD Journal Publishing DTD v2.3 20070202//EN" "journalpublishing.dtd">
<?covid-19-tdm?>
<article xml:lang="EN" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" article-type="research-article">
<front>
<journal-meta>
<journal-id journal-id-type="publisher-id">SAPARS</journal-id>
<journal-title>Scientiarum: A Multidisciplinary Journal</journal-title>
<abbrev-journal-title abbrev-type="pubmed">SAPARS</abbrev-journal-title>
<issn pub-type="epub">0000-0000</issn>
<publisher>
<publisher-name>BOHR</publisher-name>
</publisher>
</journal-meta>
<article-meta>
<article-id pub-id-type="doi">10.54646/SAPARS.2026.30</article-id>
<article-categories>
<subj-group subj-group-type="heading">
<subject>Research</subject>
</subj-group>
</article-categories>
<title-group>
<article-title>Transfer learning methods for classifying medical images and identifying illnesses with minimal annotated data</article-title>
</title-group>
<contrib-group>
<contrib contrib-type="author" corresp="yes">
<name><surname>Akula</surname> <given-names>Manikanta</given-names></name>
<xref ref-type="aff" rid="aff1"><sup>1</sup></xref>
<xref ref-type="corresp" rid="c001"><sup>&#x002A;</sup></xref>
</contrib>
<contrib contrib-type="author">
<name><surname>Kadiyala</surname> <given-names>Deekshitha</given-names></name>
<xref ref-type="aff" rid="aff2"><sup>2</sup></xref>
</contrib>
</contrib-group>
<aff id="aff1"><sup>1</sup><institution>Department of Information Systems, University of Memphis</institution>, <addr-line>Memphis, TN</addr-line>, <country>United States</country></aff>
<aff id="aff2"><sup>2</sup><institution>Department of Computer Science, University of Memphis</institution>, <addr-line>Memphis, TN</addr-line>, <country>United States</country></aff>
<author-notes>
<corresp id="c001">&#x002A;Correspondence: Manikanta Akula, <email>manikantaakula78@gmail.com</email></corresp>
</author-notes>
<pub-date pub-type="epub">
<day>23</day>
<month>04</month>
<year>2026</year>
</pub-date>
<volume>2</volume>
<issue>2</issue>
<fpage>11</fpage>
<lpage>28</lpage>
<history>
<date date-type="received">
<day>27</day>
<month>03</month>
<year>2026</year>
</date>
<date date-type="accepted">
<day>10</day>
<month>04</month>
<year>2026</year>
</date>
</history>
<permissions>
<copyright-statement>Copyright &#x00A9; 2026 Akula and Kadiyala.</copyright-statement>
<copyright-year>2026</copyright-year>
<copyright-holder>Akula and Kadiyala</copyright-holder>
<license xlink:href="https://creativecommons.org/licenses/by/4.0/"><p>&#x00A9; The Author(s). 2024 Open Access This article is distributed under the terms of the Creative Commons Attribution 4.0 International License (https://creativecommons.org/licenses/by/4.0/), which permits unrestricted use, distribution, and reproduction in any medium, provided you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license, and indicate if changes were made.</p></license>
</permissions>
<abstract>
<p>Medical image classification is often constrained by the unavailability of large, annotated data-sets owing to the unreasonable cost of expert labeling and class discrepancy in rare conditions. One of the interesting techniques to overcome these drawbacks is the procedure of transfer learning (TL) which utilizes the knowledge gained from deep learning (DL) models that were formerly trained. DL has achieved significant success in feature representation from complex data, but it generally involves a considerable amount of annotated information for effective training. Using small and imbalanced data-sets, this paper investigates the performance of TL for medical image classification tasks using VGG16, ResNet50, and EfficientNet. A scratch-built baseline Convolutional Neural Network (CNN) is adopted as a reference to compare TL models. COVID-19 chest X-ray databases are utilized in experiments. Accuracy, F1-score, and training efficiency are applied to measure performance. While TL has illustrated impressive performance, often similar to or exceeding diagnosis, its configuration in numerous studies has been defined as arbitrary. Previous studies have revealed that TL is better than scratch-built models on tiny medical datasets, resulting in a COVID-19 detection precision of &#x003E;96% using ResNet50. Also pointed out the usefulness of ensemble TL approaches. This paper shows that TL is a practicable and effective means to expand medical image solutions in cases with limited data. That makes it probable to quickly deploy artificial intelligence (AI) tools into real-world healthcare applications.</p>
</abstract>
<kwd-group>
<kwd>deep learning</kwd>
<kwd>convolutional neural networks</kwd>
<kwd>VGG 16</kwd>
<kwd>EfficientNet</kwd>
<kwd>COVID-19 chest X-rays</kwd>
<kwd>ResNes50</kwd>
<kwd>imbalanced data</kwd>
<kwd>feature extraction</kwd>
</kwd-group>
<counts>
<fig-count count="10"/>
<table-count count="9"/>
<equation-count count="7"/>
<ref-count count="25"/>
<page-count count="18"/>
<word-count count="8061"/>
</counts>
</article-meta>
</front>
<body>
<sec id="S1" sec-type="intro">
<title>Introduction</title>
<p>In the area of medical image analysis, deep learning (DL) techniques have attained remarkable success in learning complex and task-specific feature representation from intricate data, allowing impressive outcomes in disease diagnosis (<xref ref-type="bibr" rid="B1">1</xref>, <xref ref-type="bibr" rid="B2">2</xref>). Convolutional Neural Networks (CNNs), in particular, have demonstrated their capacity to learn intricate patterns from scans like magnetic resonance imaging (MRI) and X-ray images, generating them a powerful utility for automated disease detection (<xref ref-type="bibr" rid="B3">3</xref>). However, a significant and continual bottleneck for these DL processes is their substantial reliance on large, high-quality annotated data-sets for effective training. This challenge is additional compounded by the intrinsic scarcity and class imbalance of information for uncommon conditions (<xref ref-type="bibr" rid="B4">4</xref>). To address this crucial data scarcity problem, the process of transfer learning (TL) has emerged as a highly effective and generally accepted method in medical imaging (<xref ref-type="bibr" rid="B5">5</xref>, <xref ref-type="bibr" rid="B6">6</xref>). TL operates on the theory of leveraging knowledge gained from a DL model that has been formerly trained on a large and diverse source data-set, such as ImageNet, and using that knowledge to a new, but related, target task in this case, medical image classification (<xref ref-type="bibr" rid="B6">6</xref>, <xref ref-type="bibr" rid="B7">7</xref>). For medical imaging applications, the transfer of information from ImageNet has become a de-facto approach, despite the notable deviations in tasks and image characteristics between the domains. The effectiveness of TL has been illustrated across a extensive range of medical imaging applications (<xref ref-type="bibr" rid="B8">8</xref>). Similarly, in response to the international health crisis, TL has played a pivotal role in the fast and automatic finding of the innovative corona virus disease 2019 (COVID-19) from chest X-ray images (<xref ref-type="bibr" rid="B9">9</xref>, <xref ref-type="bibr" rid="B10">10</xref>). This capability of these models to rapidly and precisely classify disease from medical scans has proven to be a viable method for detecting multiple abnormalities even with tiny medical data-sets, often yielding impressive results (<xref ref-type="bibr" rid="B10">10</xref>, <xref ref-type="bibr" rid="B11">11</xref>).</p>
<p>However, despite its widespread adoption and proven benefits, the role of TL in medical imaging is not without its challenges and areas for additional research. The factors that ascertain whether and to what extent TL to the medical domain is advantageous remain unclear, and the long-standing hypothesis that features from source domains are directly reusable for medical images has lately been called into question (<xref ref-type="bibr" rid="B12">12</xref>).</p>
<p>This study seeks to provide a thorough review of the purpose of TL in medical image classification, concentrating on its efficacy in addressing the difficulty of data scarcity. A core baseline model, a scratch-built CNN, will be used as a reference point for comparing the performance of TL models, as found in some of the appraised studies. The performance metrics, such as accuracy, F1-score, and training efficiency, will be considered to estimate the suitability of the TL approach (<xref ref-type="bibr" rid="B13">13</xref>).</p>
<p>The core approach for TL comprises using pre-trained CNN models, such as VGG, ResNet, INceptionV3, MobileNet, and Xception, as feature extractors (<xref ref-type="bibr" rid="B14">14</xref>). This fine-tuning procedure allows the model to adapt the high-level features learned from the source domain to the nuances of the medical images while retaining the low-level features extraction capabilities. To further alleviate the tiny sample size drawback inherent in medical imaging, data augmentation methods are commonly used to the training information to increase the size and diversity of the data-set (<xref ref-type="bibr" rid="B15">15</xref>).</p>
<p>This study mainly focuses on exploring the usage of TL. This technique can be used to apply knowledge from models predefined on large data-sets. In this work, comparing a systematic experiments as a small CNN trained from scratch to several transfer-learning techniques, such as (a) a frozen feature extractor with a new classifier head, (b) full fine-tuning, and (c) partial fine-tuning of higher layers.</p>
<p>Medical imaging data-sets that are used for experimentation is:</p>
<p><bold>COVID-19 Chest X-ray images</bold>: These are used to classify infected versus non-infected cases.</p>
<p>This study evaluates the performance of widely used models such as VGG16, ResNet50 and EfficientNet, comparing them against the baseline of a CNN model trained from scratch. The assessment is measured with specific performance metrics. It mainly insists that TL must achieve outcomes with scalability, speed and accuracy rather than poor results. It will enable faster deployment of artificial intelligence (AI) tools in the healthcare setting, where big data is very challenging to achieve.</p>
</sec>
<sec id="S2">
<title>Literature review</title>
<p>Many researchers are utilizing DL approaches to learn highly intricate pattern. It has also been observed that an group of predictions from many models gives better performance than that of a single model. However, two major bottlenecks for developing ensemble DL models are their excessive computational complexity and the establishment of a large sample size for better generalization. It effectively tells the patient about disease treatment, health tracking, and continuously monitoring. With the use of annotated data-sets that are limited, even though they effectively benefit DL models. It enables researchers to assess TL as a practical solution that uses knowledge from a pre-trained model with specified conditions on large data-sets like ImageNet (<xref ref-type="fig" rid="F1">Figure 1</xref>).</p>
<fig id="F1" position="float">
<label>FIGURE 1</label>
<caption><p>Work-flow.</p></caption>
<graphic mimetype="image" mime-subtype="tiff" xlink:href="sapars-2026-30-g001.tif"/>
</fig>
<p>The application of DL in medical imaging has significant advantages, but it is limited by annotated data-sets. It highlights the expert-labeled data and presence of rare conditions that can hinder the effectiveness of models trained from scratch. It developed a DL platform with the advantage of optical coherence tomography (OCT) images that automatically helps to identify medical conditions. Demonstrate the CNN potential in dermatology and their reliance on large data-sets that may replicate difficult domains such as radiology. To handle these issues, researchers have turned to TL as a practical solution (<xref ref-type="bibr" rid="B16">16</xref>).</p>
<p>It explains the importance of CNNs in imaging. Emphasizes how CNNs are superior to traditional machine learning tasks in image classification, segmentation, etc. For the past few years, researchers have been using the advantage of CNN-based models to extract and gather unique features for the diagnosis of various diseases. Using a convolutional network-based model achieved a good level of accuracy in comparison with traditional machine learning and many other techniques that are manually performed by physicians (<xref ref-type="bibr" rid="B17">17</xref>).</p>
<p>It explains about the first segmented the MRI image into two segments: gray and white matter. They used a multiscale ConvNet for the diagnosis of Alzheimer&#x2019;s Disease (AD). In terms of accuracy, MSCNet has a higher performance level than ResNet-50 in the NC and MCI classes of matter (gray and white) is about 98.85% and 98.11% and ResNet accuracy is about 96.01% and 95.88%. This study shows that lower computational power and fewer parameters, the CNN- based MSCNet model performs well for the medical image data-set (<xref ref-type="bibr" rid="B18">18</xref>) (<xref ref-type="table" rid="T1">Table 1</xref>).</p>
<table-wrap position="float" id="T1">
<label>TABLE 1</label>
<caption><p>Summary of recent transfer learning (TL) approaches for medical image classification, including data sets, models, performance outcomes and limitations.</p></caption>
<table cellspacing="5" cellpadding="5" frame="hsides" rules="groups">
<thead>
<tr>
<td valign="top" align="left">Study/reference</td>
<td valign="top" align="left">Year</td>
<td valign="top" align="left">Domain/modality</td>
<td valign="top" align="left">TL approach</td>
<td valign="top" align="left">Key insight/performance outcomes and contribution</td>
<td valign="top" align="left">Limitation/gap</td>
</tr>
</thead>
<tbody>
<tr>
<td valign="top" align="left">Apostolopoulos and Mpesiana</td>
<td valign="top" align="left">2020</td>
<td valign="top" align="left">COVID-19 chest X-ray</td>
<td valign="top" align="left">ResNet50 pre-trained on ImageNet</td>
<td valign="top" align="left">Achieved &#x003E;96% accuracy on small COVID data sets</td>
<td valign="top" align="left">Achieved &#x003E;96% accuracy on small COVID data sets</td>
</tr>
<tr>
<td valign="top" align="left">Wang et al.</td>
<td valign="top" align="left">2021</td>
<td valign="top" align="left">Pneumonia X-ray</td>
<td valign="top" align="left">DenseNet121 TL</td>
<td valign="top" align="left">Improved pneumonia detection with &#x003E;90% accuracy</td>
<td valign="top" align="left">Required significant computational power</td>
</tr>
<tr>
<td valign="top" align="left">Chowdhury et al.</td>
<td valign="top" align="left">2022</td>
<td valign="top" align="left">COVID-19 and pneumonia X-ray</td>
<td valign="top" align="left">VGG19 + ResNet TL</td>
<td valign="top" align="left">Highlighted benefit of ensemble TL models</td>
<td valign="top" align="left">Limited generalization to multi-institution data sets</td>
</tr>
</tbody>
</table></table-wrap>
<p>From the computational perspective, using TL with a CNN model tends to significantly reduce the time and resources that are needed to train a CNN model from scratch. It also improves the network performance. It is because of the presence of TL allows us to efficiently transfer knowledge from pre-trained models to our new tasks. It results in less usage of data and increases computation with good levels of accuracy. It mainly highlights how CNN automatically extracts advanced features through the effective usage, and supports CNN baseline and CNN TL in our experiment. The results from the experimentation where CNNs and TL techniques are involved are referred to as &#x201C;black-box&#x201D; it is because features learned by the network are very difficult to interpret by medical experts. Its advantage is the limited availability of annotated image data with accuracy (<xref ref-type="bibr" rid="B19">19</xref>). High-performing CNNs typically require large annotated data-sets. However, class imbalance is a natural problem for rare diseases, and medical data annotation is costly and requires subject-matter expertise. It has the major drawback for developing and deploying AI models in healthcare because of its high cost and time that are needed for data collection and expert annotation, the privacy concerns that surround sensitive patient information and the limited prevalence of rare diseases (<xref ref-type="bibr" rid="B20">20</xref>).</p>
<p>The major reasons for the scarcity will be:</p>
<list list-type="simple">
<list-item>
<label>i</label>
<p>High annotation and acquisition costs.</p>
</list-item>
<list-item>
<label>ii</label>
<p>Overuse of the imaging procedures due to the potential radiation risks that can indirectly contribute to the limited data availability in certain cases.</p>
</list-item>
<list-item>
<label>iii</label>
<p>Poor resolution is also an issue in the medical imaging.</p>
</list-item>
</list>
<p>This makes use of models that have been trained on natural image data-sets like ImageNet. Much architecture like ResNet, EfficientNet and VGG can be used to optimize for medical applications and used as feature extractors. TL performs CNNs that are trained from scratch in medical imaging tasks with sample sizes. TL is an important feature where the source and data-sets are interrelated. It is possible to perform large, unrelated data-sets with moderately sized medical data. It is an important strategy for building accurate models along with limited labeled samples (<xref ref-type="bibr" rid="B21">21</xref>). Many recent studies highlight the use of ResNet and DenseNet to achieve strong generalization rather than other medical modalities due to their skip connections and effective usage. This choice depends mainly on the trade-off between accuracy and resources rather than clinical deployment (<xref ref-type="bibr" rid="B21">21</xref>, <xref ref-type="bibr" rid="B22">22</xref>). While freezing older convolutional layers during training, it is less effective on small data-sets. However, there is still an issue with features obtained from natural photos not translating perfectly to medical domains, which calls for domain-specific pre-training on large medical corpora (<xref ref-type="bibr" rid="B23">23</xref>).</p>
<p>To overcome certain challenges, it is good to use layer-wise learning rate adaptation has been used in which early layers are updated with small learning rates, which helps to prevent general visual features, rather than depending on higher layers on medical data (<xref ref-type="bibr" rid="B24">24</xref>). In conclusion, studies show that TL consistently enhances performance on data-poor medical tasks. More comprehensive bench-marking of different designs and fine-tuning methods is needed to provide recommendations for small clinical data-sets.</p>
</sec>
<sec id="S3">
<title>Methodology</title>
<sec id="S3.SS1">
<title>Data-sets</title>
<p>In this study, the selection of data sets was illustrated by three key criteria to guarantee reliability and clinical relevance: the accessibility of expert-annotated samples to promote DL training, a concentrate on chest x-ray images of COVID-19 and pneumonia owing to their importance in respiratory illness diagnosis, and the addition of balanced data sets with normal, pneumonia, and COVID-19 cases to diminish bias and improve model generalization. Data-sets are more than 300 medical image data-sets are in the collection. It seems to have challenges with the data between 2004 and 2020. The time of these medical image data-sets can be split into two. It started from 2013, providing the excellent AlexNet in the ILSVRC competition from 2012. The success of this data-set motivates more researchers to solve the major challenges with the different DL methods. In addition to these analyses, many researchers focus on analyzing medical images with the adoption of DL methods is another important driving factor that resonates for the release of another set of medical data-sets (<xref ref-type="bibr" rid="B25">25</xref>).</p>
</sec>
<sec id="S3.SS2">
<title>Covid-19 chest X-ray data-sets</title>
<list list-type="simple">
<list-item>
<label>&#x2022;</label>
<p>COVID-ChestXray is a set of frontal and lateral chest X-ray images that include hundreds of COVID-19 cases and are annotated with meta-data (e.g., ICU status and survival).</p>
</list-item>
<list-item>
<label>&#x2022;</label>
<p>COVIDx data-set: A collection of multiple data-sets, including Italian Society of Medical and Interventional Radiology (SIRM), Radiological Society of North America (RSNA) pneumonia, Cohen&#x2019;s, and others, for multi-class classification (normal, pneumonia, and COVID-19). There are thousands of pictures in each class.</p>
</list-item>
<list-item>
<label>&#x2022;</label>
<p>The COVID-19 Radiography Database (Kaggle) is a balanced collection of images of COVID-19, viral pneumonia, and normal images that can be used for TL tasks (<xref ref-type="table" rid="T2">Table 2</xref>).</p></list-item>
</list>
<table-wrap position="float" id="T2">
<label>TABLE 2</label>
<caption><p>Medical image datasets summary.</p></caption>
<table cellspacing="5" cellpadding="5" frame="hsides" rules="groups">
<thead>
<tr>
<td valign="top" align="left">Category</td>
<td valign="top" align="left">Dataset</td>
<td valign="top" align="left">Modality</td>
<td valign="top" align="left"># Images/patches</td>
<td valign="top" align="left">Classes</td>
<td valign="top" align="left">Notes</td>
</tr>
</thead>
<tbody>
<tr>
<td valign="top" align="left">Pneumonia</td>
<td valign="top" align="left">Kaggle chest X-ray (pediatric dataset)</td>
<td valign="top" align="left">X-ray</td>
<td valign="top" align="left">&#x223C;5,863 images (train/test split used)</td>
<td valign="top" align="left">Normal, pneumonia</td>
<td valign="top" align="left">Standard benchmark dataset, publicly available</td>
</tr>
<tr>
<td valign="top" align="left">COVID-19</td>
<td valign="top" align="left">COVID-chest X-ray</td>
<td valign="top" align="left">X-ray</td>
<td valign="top" align="left">Hundreds</td>
<td valign="top" align="left">COVID-19</td>
<td valign="top" align="left">Annotated metadata, small but widely used</td>
</tr>
<tr>
<td valign="top" align="left">General chest</td>
<td valign="top" align="left">NIH chest X-ray 14</td>
<td valign="top" align="left">X-ray</td>
<td valign="top" align="left">100,000+</td>
<td valign="top" align="left">14 disease categories</td>
<td valign="top" align="left">Multi-label dataset</td>
</tr>
</tbody>
</table></table-wrap>
<p>These data-sets are very useful for testing TL models on small amounts of COVID-19-related images.</p>
</sec>
<sec id="S3.SS3">
<title>Major challenges</title>
<p>The major challenges of TL are overparameterization means that deep CNNs like ResNet have improved accuracy, but they exhibit slow and inefficient training. Expensive computations need costly hardware to be implemented, but it gives a deeper architecture with excellent performance. Insufficient labeled data means it is hard to annotate images in comparison to natural images, which makes it difficult for models to generalize well. The approaches like lightweight architectures and multistage TL, can help to handle these issues (<xref ref-type="table" rid="T3">Table 3</xref>).</p>
<table-wrap position="float" id="T3">
<label>TABLE 3</label>
<caption><p>Major challenges for TL in medical imaging.</p></caption>
<table cellspacing="5" cellpadding="5" frame="hsides" rules="groups">
<thead>
<tr>
<td valign="top" align="left">Challenge</td>
<td valign="top" align="left">Description</td>
<td valign="top" align="left">Potential solutions</td>
</tr>
</thead>
<tbody>
<tr>
<td valign="top" align="left">Data scarcity</td>
<td valign="top" align="left">Limited annotated datasets in medical domain</td>
<td valign="top" align="left">Data augmentation, synthetic data generation</td>
</tr>
<tr>
<td valign="top" align="left">Domain shift</td>
<td valign="top" align="left">Medical images differ significantly from ImageNet</td>
<td valign="top" align="left">Domain adaptation, fine-tuning on medical-specific data</td>
</tr>
<tr>
<td valign="top" align="left">Interpretability</td>
<td valign="top" align="left">Black-box models reduce trust</td>
<td valign="top" align="left">Use Grad-CAM, SHAP, and other interpretability methods</td>
</tr>
<tr>
<td valign="top" align="left">Class imbalance</td>
<td valign="top" align="left">Normal vs. pneumonia samples may be skewed</td>
<td valign="top" align="left">Weighted loss functions, balanced sampling</td>
</tr>
</tbody>
</table></table-wrap>
</sec>
<sec id="S3.SS4">
<title>Research methodology: TL medical image classification</title>
<p>It is applied to gather memory dumps, images, and network packet captures. Medical imaging data-sets, such as MRI images, CT scans, are collected utilizing the freely accessible data repository. This model necessitates high-quality image data so that it will be beneficial to verify with labels. Data preprocessing is done in this for image re-sizing, normalization, etc., and it primarily ensures that information is ready for training. For maintaining data integrity, the hashing method is used. Data preservation is important in the TL model because it facilitates to store the reliability of original image, and copies can be produced for experimentation purposes. MD5, SHA256 are the hashing approaches that can be utilized to verify the data-set integrity and stop alterations. This stage guarantees that empirical results will be consistent and can be repeated additional through the study. For examination purpose, it utilizes forensic software like Volatility, WireShark, Autopsy. It also adopts some DL framework of Pytorch and TensorFlow. Data augmentation methods can be used so that images are flipped, rotated and scaled which facilitates to restrict generalization. Classification layers are updated so that it can able to use special medical imaging tasks. It involves evaluation and understanding of the images along with performance metrics such as accuracy, precision, area under curve (AUC), etc. The use of visual tools, such as receiver operating characteristic (ROC) curves, precision graphs, is generated to display the TL model&#x2019;s effectiveness. The results are documented in the well-structured reports, and they offer clear validation of how TL improves medical image classification (<xref ref-type="fig" rid="F2">Figure 2</xref>).</p>
<fig id="F2" position="float">
<label>FIGURE 2</label>
<caption><p>TL medical image classification.</p></caption>
<graphic mimetype="image" mime-subtype="tiff" xlink:href="sapars-2026-30-g002.tif"/>
</fig>
<sec id="S3.SS4.SSS1">
<title>Forensic/data handling steps</title>
<p>It is applied to gather memory dumps, images, and network packet captures. Medical imaging data-sets, such as MRI images, CT scans, are collected utilizing the freely accessible data repository. This model necessitates high-quality image data so that it will be beneficial to verify with labels. Data preprocessing is done in this for image re-sizing, normalization, etc., and it primarily ensures that information is ready for training. For maintaining data integrity, the hashing method is used. Data preservation is important in the TL model because it facilitates to store the reliability of original image, and copies can be produced for experimentation purposes. MD5, SHA256 are the hashing approaches that can be utilized to verify the data-set integrity and stop alterations. This stage guarantees that empirical results will be consistent and can be repeated additional through the study. For examination purpose, it utilizes forensic software like Volatility, WireShark, Autopsy. It also adopts some DL framework of Pytorch and TensorFlow. Data augmentation methods can be used so that images are flipped, rotated and scaled which facilitates to restrict generalization. Classification layers are updated so that it can able to use special medical imaging tasks. It involves evaluation and understanding of the images along with performance metrics such as accuracy, precision, AUC, etc. The use of visual tools, such as ROC curves, precision graphs, is generated to display the TL model&#x2019;s effectiveness. The results are documented in the well-structured reports, and they offer clear validation of how TL improves medical image classification (<xref ref-type="table" rid="T4">Table 4</xref>).</p>
<table-wrap position="float" id="T4">
<label>TABLE 4</label>
<caption><p>Forensic/data handling steps.</p></caption>
<table cellspacing="5" cellpadding="5" frame="hsides" rules="groups">
<thead>
<tr>
<td valign="top" align="left">Step</td>
<td valign="top" align="left">Description</td>
<td valign="top" align="left">Tools/methods</td>
<td valign="top" align="left">Purpose</td>
</tr>
</thead>
<tbody>
<tr>
<td valign="top" align="left">Information gathering</td>
<td valign="top" align="left">Collect memory dumps, magnetic resonance imaging (MRI), CT images</td>
<td valign="top" align="left">Freely accessible data repository.</td>
<td valign="top" align="left">Ensure high-quality labelled data</td>
</tr>
<tr>
<td valign="top" align="left">Preservation &#x0026; chain of custody</td>
<td valign="top" align="left">Maintain dataset integrity</td>
<td valign="top" align="left">MD5, SHA256 hashing</td>
<td valign="top" align="left">Maintain data integrity and reproducibility</td>
</tr>
<tr>
<td valign="top" align="left">Examination</td>
<td valign="top" align="left">Data preprocessing, cleaning, augmentation</td>
<td valign="top" align="left">OpenCV, TensorFlow, Keras</td>
<td valign="top" align="left">Ensure clean and balanced dataset</td>
</tr>
<tr>
<td valign="top" align="left">Reporting and reconstruction</td>
<td valign="top" align="left">Summarize findings and model interpretability</td>
<td valign="top" align="left">Grad-cam visualizations, classification masks</td>
<td valign="top" align="left">Clinical usability and explainability</td>
</tr>
</tbody>
</table></table-wrap>
</sec>
<sec id="S3.SS4.SSS2">
<title>Evaluation metrics</title>
<p>Evaluation metrics are quantitative measures used to test the performance of a classification model. Commonly applied in medical image analysis, these include: Accuracy, which indicated the rate of correctly classified samples; Precision, which quantifies how many of the predicted positives are essentially correct; Recall, which shows the capacity of the model to properly identify actual positives; F1-Score, the harmonic mean of accuracy and recall that balance both metrics; and AUC-ROC, which evaluates the models capability to distinguish between classes by plotting the true positive rate (TPR) against the false positive rate (FPR).</p>
<list list-type="simple">
<list-item>
<label>1.</label>
<p>Accuracy:</p>
</list-item>
</list>
<disp-formula id="S3.Ex1"><mml:math id="M1">
<mml:mrow>
<mml:mpadded width="+3.3pt">
<mml:mi>Accuracy</mml:mi>
</mml:mpadded>
<mml:mo rspace="5.8pt">=</mml:mo>
<mml:mfrac>
<mml:mrow>
<mml:mrow>
<mml:mi>T</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mpadded width="+5pt">
<mml:mi>P</mml:mi>
</mml:mpadded>
</mml:mrow>
<mml:mo>+</mml:mo>
<mml:mrow>
<mml:mi>T</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mi>N</mml:mi>
</mml:mrow>
</mml:mrow>
<mml:mrow>
<mml:mrow>
<mml:mi>T</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mpadded width="+5pt">
<mml:mi>P</mml:mi>
</mml:mpadded>
</mml:mrow>
<mml:mo>+</mml:mo>
<mml:mrow>
<mml:mi>T</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mpadded width="+5pt">
<mml:mi>N</mml:mi>
</mml:mpadded>
</mml:mrow>
<mml:mo>+</mml:mo>
<mml:mrow>
<mml:mi>F</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mpadded width="+5pt">
<mml:mi>P</mml:mi>
</mml:mpadded>
</mml:mrow>
<mml:mo>+</mml:mo>
<mml:mrow>
<mml:mi>F</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mi>N</mml:mi>
</mml:mrow>
</mml:mrow>
</mml:mfrac>
</mml:mrow>
</mml:math>
</disp-formula>
<list list-type="simple">
<list-item>
<label>2.</label>
<p>Precision (positive predictive value):</p>
</list-item>
</list>
<disp-formula id="S3.Ex2"><mml:math id="M2">
<mml:mrow>
<mml:mpadded width="+3.3pt">
<mml:mi>Precision</mml:mi>
</mml:mpadded>
<mml:mo rspace="5.8pt">=</mml:mo>
<mml:mfrac>
<mml:mrow>
<mml:mi>T</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mi>P</mml:mi>
</mml:mrow>
<mml:mrow>
<mml:mrow>
<mml:mi>T</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mpadded width="+5pt">
<mml:mi>P</mml:mi>
</mml:mpadded>
</mml:mrow>
<mml:mo rspace="7.5pt">+</mml:mo>
<mml:mrow>
<mml:mi>F</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mi>P</mml:mi>
</mml:mrow>
</mml:mrow>
</mml:mfrac>
</mml:mrow>
</mml:math>
</disp-formula>
<list list-type="simple">
<list-item>
<label>3.</label>
<p>Recall (sensitivity/TPR):</p></list-item>
</list>
<disp-formula id="S3.Ex3"><mml:math id="M3">
<mml:mrow>
<mml:mpadded width="+3.3pt">
<mml:mi>Recall</mml:mi>
</mml:mpadded>
<mml:mo rspace="5.8pt">=</mml:mo>
<mml:mfrac>
<mml:mrow>
<mml:mi>T</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mi>P</mml:mi>
</mml:mrow>
<mml:mrow>
<mml:mrow>
<mml:mi>T</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mpadded width="+5pt">
<mml:mi>P</mml:mi>
</mml:mpadded>
</mml:mrow>
<mml:mo rspace="7.5pt">+</mml:mo>
<mml:mrow>
<mml:mi>F</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mi>N</mml:mi>
</mml:mrow>
</mml:mrow>
</mml:mfrac>
</mml:mrow>
</mml:math>
</disp-formula>
<list list-type="simple">
<list-item>
<label>4.</label>
<p>F1-score (harmonic mean of precision and recall):</p>
</list-item>
</list>
<disp-formula id="S3.Ex4"><mml:math id="M4">
<mml:mrow>
<mml:mpadded width="+3.3pt">
<mml:mi>F1</mml:mi>
</mml:mpadded>
<mml:mo rspace="5.8pt">=</mml:mo>
<mml:mfrac>
<mml:mrow>
<mml:mn>2</mml:mn>
<mml:mo>&#x00D7;</mml:mo>
<mml:mrow>
<mml:mo stretchy="false">(</mml:mo>
<mml:mrow>
<mml:mrow>
<mml:mrow>
<mml:mi>P</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mi>r</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mi>e</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mi>c</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mi>i</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mi>s</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mi>i</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mi>o</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mi>n</mml:mi>
</mml:mrow>
<mml:mo rspace="7.5pt">&#x00D7;</mml:mo>
<mml:mi>R</mml:mi>
</mml:mrow>
<mml:mo>&#x2062;</mml:mo>
<mml:mi>e</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mi>c</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mi>a</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mi>l</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mi>l</mml:mi>
</mml:mrow>
<mml:mo stretchy="false">)</mml:mo>
</mml:mrow>
</mml:mrow>
<mml:mrow>
<mml:mrow>
<mml:mi>P</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mi>r</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mi>e</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mi>c</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mi>i</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mi>s</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mi>i</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mi>o</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mpadded width="+5pt">
<mml:mi>n</mml:mi>
</mml:mpadded>
</mml:mrow>
<mml:mo rspace="7.5pt">+</mml:mo>
<mml:mrow>
<mml:mi>R</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mi>e</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mi>c</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mi>a</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mi>l</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mi>l</mml:mi>
</mml:mrow>
</mml:mrow>
</mml:mfrac>
</mml:mrow>
</mml:math>
</disp-formula>
<list list-type="simple">
<list-item>
<label>5.</label>
<p>AUC-ROC:</p>
<p>The ROC cure plots:</p>
<p>TPR/recall:</p>
<p><disp-formula id="S3.Ex5"><mml:math id="M5">
<mml:mrow>
<mml:mpadded width="+3.3pt">
<mml:mi>TPR</mml:mi>
</mml:mpadded>
<mml:mo rspace="5.8pt">=</mml:mo>
<mml:mfrac>
<mml:mrow>
<mml:mi>T</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mi>P</mml:mi>
</mml:mrow>
<mml:mrow>
<mml:mrow>
<mml:mi>T</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mpadded width="+5pt">
<mml:mi>P</mml:mi>
</mml:mpadded>
</mml:mrow>
<mml:mo rspace="7.5pt">+</mml:mo>
<mml:mrow>
<mml:mi>F</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mi>N</mml:mi>
</mml:mrow>
</mml:mrow>
</mml:mfrac>
</mml:mrow>
</mml:math>
</disp-formula></p>
<p>FPR:</p>
<p><disp-formula id="S3.Ex6"><mml:math id="M6">
<mml:mrow>
<mml:mpadded width="+3.3pt">
<mml:mi>FPR</mml:mi>
</mml:mpadded>
<mml:mo rspace="5.8pt">=</mml:mo>
<mml:mfrac>
<mml:mrow>
<mml:mi>F</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mi>P</mml:mi>
</mml:mrow>
<mml:mrow>
<mml:mrow>
<mml:mi>F</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mpadded width="+5pt">
<mml:mi>P</mml:mi>
</mml:mpadded>
</mml:mrow>
<mml:mo rspace="7.5pt">+</mml:mo>
<mml:mrow>
<mml:mi>T</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mi>N</mml:mi>
</mml:mrow>
</mml:mrow>
</mml:mfrac>
</mml:mrow>
</mml:math>
</disp-formula></p>
<p>The AUC is the area under the ROC curve:</p>
<p><disp-formula id="S3.Ex7"><mml:math id="M7">
<mml:mrow>
<mml:mpadded width="+3.3pt">
<mml:mi>AUC</mml:mi>
</mml:mpadded>
<mml:mo rspace="5.8pt">=</mml:mo>
<mml:mrow>
<mml:msubsup>
<mml:mo largeop="true" symmetric="true">&#x222B;</mml:mo>
<mml:mn>0</mml:mn>
<mml:mn>1</mml:mn>
</mml:msubsup>
<mml:mrow>
<mml:mi>T</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mi>P</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mpadded width="+5pt">
<mml:mi>R</mml:mi>
</mml:mpadded>
<mml:mo>&#x2062;</mml:mo>
<mml:mrow>
<mml:mo stretchy="false">(</mml:mo>
<mml:mrow>
<mml:mi>F</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mi>P</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mi>R</mml:mi>
</mml:mrow>
<mml:mo rspace="7.5pt" stretchy="false">)</mml:mo>
</mml:mrow>
<mml:mo>&#x2062;</mml:mo>
<mml:mi>d</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mrow>
<mml:mo stretchy="false">(</mml:mo>
<mml:mrow>
<mml:mi>F</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mi>P</mml:mi>
<mml:mo>&#x2062;</mml:mo>
<mml:mi>R</mml:mi>
</mml:mrow>
<mml:mo stretchy="false">)</mml:mo>
</mml:mrow>
</mml:mrow>
</mml:mrow>
</mml:mrow>
</mml:math>
</disp-formula></p>
</list-item>
</list>
</sec>
</sec>
<sec id="S3.SS5">
<title>Transfer learning for medical image classification</title>
<p>There is an experimental workflow that helps to estimate the DL pipeline for pneumonia classification using ResNet50 and TL, and a baseline CNN for additional comparison.</p>
<p>The workflow to classify pneumonia from chest X-ray images. The data-set was organized into test sets, validation, and training with data augmentation to enhance generalization.</p>
<sec id="S3.SS5.SSS1">
<title>Mount google drive to google colab</title>
<p>This step provides direct access to the files that are stored in the drive. It is beneficial for the processing tasks of images with large data-sets. It used to eliminate the need to repeatedly upload data to the Colab environment (<xref ref-type="app" rid="A1">Appendices I</xref> and <xref ref-type="app" rid="A1">II</xref>). It mainly allows any code in our notebook to access any files that are present in the drive (<xref ref-type="app" rid="A1">Appendix III</xref>). In this case, the data-sets are found in the /content/data/chest-x-ray folder. It provides the easy access to the data-set and enables the project to store, process and maintain it in all the phases (<xref ref-type="app" rid="A1">Appendices IV</xref> and <xref ref-type="app" rid="A1">V</xref>).</p>
</sec>
<sec id="S3.SS5.SSS2">
<title>Importing the libraries</title>
<p>This step ensures that image processing involves the complex operations like filtering, image extraction, transformations, etc. It significantly reduces the complex development time and occurrence of potential errors. Importing several libraries not only helps in processing, but also effectively brings basic image editing to the advanced computer vision and reduces the heavy performance of machine learning tasks. In this model, importing all the necessary Python libraries to access experiments in DL, such as TensorFlow/Keras for neural networks, OpenCV for preprocessing images and NumPy for numerical computation and MatPlotLib for visualizations (<xref ref-type="app" rid="A1">Appendix VI</xref>).</p>
</sec>
<sec id="S3.SS5.SSS3">
<title>Data-set preparation</title>
<p>This step is the important one because it needs much time to process cleaning, organizing and transforming the raw data into the specialized format, which is also suitable for the processing of machine learning algorithms. It ensures that handling of missing values, feature extraction, data formatting and finalize the data-set with high-quality feature, thus providing accurate and reliable models.</p>
<p>In this case, the chest X-ray pneumonia data-set is trained, validated and organized into folder. It ensures that processing aligns with the Keras image data generator and facilitates the training and unbiased testing process (<xref ref-type="app" rid="A1">Appendix VII</xref>).</p>
</sec>
</sec>
</sec>
<sec id="S4" sec-type="results">
<title>Results</title>
<sec id="S4.SS1">
<title>Data augmentation</title>
<p>This step is used to expand the trained data-set by generating new, altered versions of the existing images. It is particularly helpful in the real-world data collection, which is limited and expensive. It enhances model robustness and generalization capabilities of machine learning, especially in DL models.</p>
<p>In this model, to minimize over-fitting, the data augmentation is used with the Keras ImageDataGenerator. This library is helpful to modify the images with zoom options, horizontal twists, flips, re-sizing, image scaling, etc. These can be applied only to the training data-set. The remaining test and validation data-sets are untouched and cannot able to alter the information (<xref ref-type="app" rid="A1">Appendix VIII</xref>).</p>
</sec>
<sec id="S4.SS2">
<title>Load data generators</title>
<p>The loading data generator allows us to randomly do image rotation without any specific degree between 0 and 360. It is an integer value with the rotation range argument. In this way, we can allow to feed data into Keras in real-time while training the model.</p>
<p>In this model, separator data generators are used for all three steps of data. Each generator specifies how to handle the tasks of images. It ensures efficient memory usage with a smooth transition flow.</p>
</sec>
<sec id="S4.SS3">
<title>Visualize the sample images</title>
<p>Visualizing sample images from an image processing data-set helps to understand the data characteristics. It includes various types of objects, lighting conditions and potential variations present. It helps to identify common image features and challenges within the data. It helps to reveal anomalies, inconsistencies within the images.</p>
<p>In this image processing model, random images from the training data-set are displayed. It helps to ensure that the model created has a quality image, and it will receive properly formatted inputs and prevent errors from occurring (<xref ref-type="table" rid="T5">Table 5</xref>).</p>
<table-wrap position="float" id="T5">
<label>TABLE 5</label>
<caption><p>Data augmentation and preprocessing summary.</p></caption>
<table cellspacing="5" cellpadding="5" frame="hsides" rules="groups">
<thead>
<tr>
<td valign="top" align="left">Step</td>
<td valign="top" align="left">Technique/method</td>
<td valign="top" align="left">Purpose</td>
<td valign="top" align="left">Notes</td>
</tr>
</thead>
<tbody>
<tr>
<td valign="top" align="left">Data augmentation</td>
<td valign="top" align="left">Zoom, flips, rotation, scaling, resizing</td>
<td valign="top" align="left">Expand dataset, reduce overfitting</td>
<td valign="top" align="left">Applied only to training set</td>
</tr>
<tr>
<td valign="top" align="left">Data generators</td>
<td valign="top" align="left">ImageDataGenerator (Keras)</td>
<td valign="top" align="left">Efficient batch loading and augmentation</td>
<td valign="top" align="left">Reduces memory usage</td>
</tr>
<tr>
<td valign="top" align="left">Visualization</td>
<td valign="top" align="left">Matplotlib, Grad-CAM</td>
<td valign="top" align="left">Understand training and feature focus</td>
<td valign="top" align="left">Improves interpretability</td>
</tr>
</tbody>
</table></table-wrap>
</sec>
<sec id="S4.SS4">
<title>Baseline CNN definition</title>
<p>CNNs are DL models that are designed to process data with a grid-like topology. It acts as the foundation of the most modern computer vision applications that are used to detect features within the visual data.</p>
<p>It is the kind of artificial neural network used for image recognition and processing because of its ability to recognize patterns in images.</p>
<p>In this step, a custom CNN was generated as the baseline model. It has multiple convolutional, pooling layers, thus help to extract spatial features. It is followed by a fully connected dense layer helps for classification. It mainly helps to reduce over-fitting and improve generalization (<xref ref-type="table" rid="T6">Table 6</xref>).</p>
<table-wrap position="float" id="T6">
<label>TABLE 6</label>
<caption><p>Baseline CNN setup and training.</p></caption>
<table cellspacing="5" cellpadding="5" frame="hsides" rules="groups">
<thead>
<tr>
<td valign="top" align="left">Aspect</td>
<td valign="top" align="left">Details</td>
<td valign="top" align="left">Purpose/notes</td>
</tr>
</thead>
<tbody>
<tr>
<td valign="top" align="left">Model architecture</td>
<td valign="top" align="left">Custom CNN with convolutional layers, pooling layers, and fully connected dense layer</td>
<td valign="top" align="left">Extract spatial features and perform classification</td>
</tr>
<tr>
<td valign="top" align="left">Compilation</td>
<td valign="top" align="left">Optimizer: Adam, Loss: Binary CrossEntropy, Metrics: Accuracy</td>
<td valign="top" align="left">Standard setup for binary classification</td>
</tr>
<tr>
<td valign="top" align="left">Training</td>
<td valign="top" align="left">Epochs: 20, Batch size: 32</td>
<td valign="top" align="left">Used training + validation split</td>
</tr>
<tr>
<td valign="top" align="left">Evaluation</td>
<td valign="top" align="left">Accuracy: 84.29%</td>
<td valign="top" align="left">Good baseline model</td>
</tr>
<tr>
<td valign="top" align="left">Visualization</td>
<td valign="top" align="left">Training/validation curves, Grad-CAM</td>
<td valign="top" align="left">To analyze over fitting and interpretability</td>
</tr>
</tbody>
</table></table-wrap>
</sec>
<sec id="S4.SS5">
<title>Compilation of baseline CNN</title>
<p>This is the image processing that serves as a simple standard model used to establish a performance benchmark for more complex thus enabling the evaluation of improvements and the quantification of their added value. The primary purpose provides the fundamental performance metric against which more advanced CNN architectures.</p>
<p>In this model, the baseline CNN is compiled using the Adam optimizer, performance metric, etc. This step enables the stable and efficient training for the pneumonia detection task.</p>
</sec>
<sec id="S4.SS6">
<title>Train baseline CNN</title>
<p>Train baseline CNN is helps to quickly converge the model during training and protect from inefficiency and enhance overall network stability (<xref ref-type="app" rid="A1">Appendix IX</xref>).</p>
<p>In this model, the baseline CNN was trained with five epochs using the validation data accuracy and information tracking after each epoch. It helps to identify the over-fitting early in the model processing.</p>
</sec>
<sec id="S4.SS7">
<title>Evaluate baseline CNN</title>
<p>This step is used to understand how the CNN generalizes the new unseen images, which helps to identify areas for improvement, and meets the specific performance goals for the given image processing application, such as classification or image recognition. Based on this evaluation, we can decide if the model needs more training, data augmentation to improve performance.</p>
<p>This step ensures that the baseline CNN model was evaluated on the unseen test data-sets. Performance accuracy was recorded, and it serves as the basis to measure further improvements based on the TL model (<xref ref-type="app" rid="A1">Appendix X</xref>).</p>
</sec>
<sec id="S4.SS8">
<title>Visualize baseline training curves</title>
<p>This is an important part of the image processing that serves to establish a performance basis to assess the complex models or the effectiveness of the model. These curves allow researchers to diagnose issues like over-fitting, under fitting, stability, convergence, and ultimately quantify improvements on the models.</p>
<p>In this model, graphs showing the training versus validation are plotted based on accuracy (<xref ref-type="fig" rid="F3">Figure 3</xref>) and loss (<xref ref-type="fig" rid="F4">Figure 4</xref>). These visualization gives deeper insights how into the model is learned and how it fits with the trained data (<xref ref-type="app" rid="A1">Appendix XI</xref>).</p>
<fig id="F3" position="float">
<label>FIGURE 3</label>
<caption><p>Training and validation accuracy.</p></caption>
<graphic mimetype="image" mime-subtype="tiff" xlink:href="sapars-2026-30-g003.tif"/>
</fig>
<fig id="F4" position="float">
<label>FIGURE 4</label>
<caption><p>Training and validation loss.</p></caption>
<graphic mimetype="image" mime-subtype="tiff" xlink:href="sapars-2026-30-g004.tif"/>
</fig>
</sec>
<sec id="S4.SS9">
<title>Load pretrained ResNet50</title>
<p>To load a pretrained ResNet50 model for image processing that we can utilize DL frameworks like Keras or PyTorch. It involves importing the necessary libraries, model instantiating and then preparing our input images for the model.</p>
<p>In this model, the architecture pertains to the ImageNet data-set with top classification layers removed. It allows features to be reused for medical image analysis (<xref ref-type="app" rid="A1">Appendix XII</xref>).</p>
</sec>
<sec id="S4.SS10">
<title>Freeze the convolutional base</title>
<p>Freezing the convolutional base in image processing, within the context of DL and CNNs, refers to the practice of preventing weights of convolutional layers from being updated during the training process. This technique is primarily employed in TL.</p>
<p>In this step, the CNN of ResNet50 was frozen so that it would not be updated during the training. It ensures that only the added layers will learn, and existing layer acts as the fixed feature extractor (<xref ref-type="app" rid="A1">Appendix XIII</xref>).</p>
</sec>
<sec id="S4.SS11">
<title>Add custom classification layers</title>
<p>Adding custom classification layers in the image processing in a DL model involves modifying the final layers of a pre-trained CNN. Compiling this model with an appropriate optimizer, such as Adam, loss function, and cross-entropy for multi-class.</p>
<p>In this model, custom dense layers were added to the top of the frozen ResNet50 base. This layer is used predominantly in classifying the images as Pneumonia, making the model task-specific rather than understanding the pre-trained visual features (<xref ref-type="app" rid="A1">Appendix XIV</xref>).</p>
</sec>
<sec id="S4.SS12">
<title>Compile transfer learning model</title>
<p>This step involves compiling a TL model in image processing by configuring the model for training after the architecture is defined and modified. Compiling is done by selecting an optimization algorithm to update the model&#x2019;s weights during training.</p>
<p>In this model, using the Adam optimizer, binary cross-entropy, and accuracy as the performance metric. This configuration not only acts as a baseline it also creates a fair and direct comparison with performance (<xref ref-type="app" rid="A1">Appendix XIV</xref>).</p>
</sec>
<sec id="S4.SS13">
<title>Train transfer learning model</title>
<p>The primary purpose of this step is to understand a pre-trained model with learned features for new, related work, thus leads to faster development, better performance with less data and improves quality and accuracy by utilizing the visual features of images. This model was trained for five epochs on the same training data-sets. It first understands the pre-trained knowledge and the ResNet59 converged faster and achieved accuracy in comparison with the baseline CNN.</p>
</sec>
<sec id="S4.SS14">
<title>Evaluate transfer learning model</title>
<p>This step is much needed in the TL model because it is used to improve performance, reduce training time and computation costs and overcome data scarcity by understanding the features such as semantic information, textures, etc. It accelerates the development with effective computer vision, image classification, medical imaging, etc. In this model, ResNet50 is fine-tuned and tested on the same data-set. Performance metrics were recorded, and it clearly shows improvement of ResNet50 is better in comparison with baseline CNN and confirms it is suitable for small data-sets.</p>
</sec>
<sec id="S4.SS15">
<title>Plot ResNet50 training curves</title>
<p>Plotting ResNet50 training curves illustrates the accuracy and loss curves during the training of the model using TensorBoard. In this step, training and validation curves for ResNet50 are plotted with accuracy and loss. It highlights the stable behavior with minimized over-fitting in comparison with the baseline CNN (<xref ref-type="fig" rid="F5">Figure 5</xref>; <xref ref-type="app" rid="A1">Appendix XV</xref>).</p>
<fig id="F5" position="float">
<label>FIGURE 5</label>
<caption><p>Accuracy comparison.</p></caption>
<graphic mimetype="image" mime-subtype="tiff" xlink:href="sapars-2026-30-g005.tif"/>
</fig>
</sec>
<sec id="S4.SS16">
<title>Compare baseline vs. ResNet50</title>
<p>It means baseline model serves better in comparison with ResNet50. It is because baseline CNN provide foundational approach whereas ResNet50 use existing information to create accuracy in classifying image objects.</p>
<p>In this model, both models are evaluated simultaneously. Here, ResNet50 performs less in compare with baseline CNNs thus confirming better generalization, providing the effectiveness of using pre-trained architecture for classification (<xref ref-type="table" rid="T7">Table 7</xref>).</p>
<table-wrap position="float" id="T7">
<label>TABLE 7</label>
<caption><p>Model performance comparison.</p></caption>
<table cellspacing="5" cellpadding="5" frame="hsides" rules="groups">
<thead>
<tr>
<td valign="top" align="left">Model</td>
<td valign="top" align="left">Accuracy (%)</td>
<td valign="top" align="left">Notes</td>
</tr>
</thead>
<tbody>
<tr>
<td valign="top" align="left">Baseline CNN</td>
<td valign="top" align="left">84.29%</td>
<td valign="top" align="left">Higher recall for Pneumonia (0.96), robust baseline</td>
</tr>
<tr>
<td valign="top" align="left">ResNet50 (TL)</td>
<td valign="top" align="left">86.22%</td>
<td valign="top" align="left">More balanced precision-recall, improved generalization</td>
</tr>
</tbody>
</table></table-wrap>
</sec>
<sec id="S4.SS17">
<title>Grad-CAM implementation setup</title>
<p>Grad-CAM is the technique that is used in image processing to help us to visualize the regions of the image that the CNN focuses on to make specific prediction. It provides interpretability to DL models.</p>
<p>In this model, this technique is used to visualize the image-specific regions. To enhance, interpretability Grad-CAM was implemented.</p>
</sec>
<sec id="S4.SS18">
<title>Grad-CAM function definition</title>
<p>This function is the technique that is used to make CNN-based models more transparent, rather than visualizing the input regions, and it is very much used for predictions. It uses the specific gradient to create novel high-resolution and class-discriminative visualization. This function makes the black-box model more explainable. In this model, a custom function was created to compute heat maps from immediate convolutional activations and class specific gradients (<xref ref-type="app" rid="A1">Appendix XVI</xref>).</p>
</sec>
<sec id="S4.SS19">
<title>Generate grad-CAM for baseline CNN</title>
<p>This step involves visualizing the regions which has an input image that are helpful for specific class prediction. This Grad-Cam requires access to the feature maps and the gradients. It involves overlaying the resulting heat maps onto the original image. These heat maps revealed the baseline focused on detecting pneumonia (<xref ref-type="app" rid="A1">Appendix XVII</xref>).</p>
</sec>
<sec id="S4.SS20">
<title>Generating grad-CAM for ResNet50</title>
<p>This step involves Grad-CAM heatmap for this model. First it is important to train this model on an input image, and the last convolutional layer&#x2019;s output feature map. It results with the generation of a heatmap of important regions in an image (<xref ref-type="fig" rid="F6">Figure 6</xref>; <xref ref-type="app" rid="A1">Appendix XVIII</xref>; <xref ref-type="table" rid="T8">Table 8</xref>).</p>
<fig id="F6" position="float">
<label>FIGURE 6</label>
<caption><p>Grad- CAM heatmap.</p></caption>
<graphic mimetype="image" mime-subtype="tiff" xlink:href="sapars-2026-30-g006.tif"/>
</fig>
<table-wrap position="float" id="T8">
<label>TABLE 8</label>
<caption><p>Grad-CAM visualization and interpretability.</p></caption>
<table cellspacing="5" cellpadding="5" frame="hsides" rules="groups">
<thead>
<tr>
<td valign="top" align="left">Model</td>
<td valign="top" align="left">Grad-CAM applied</td>
<td valign="top" align="left">Observations/focus areas</td>
<td valign="top" align="left">Interpretation/notes</td>
</tr>
</thead>
<tbody>
<tr>
<td valign="top" align="left">Baseline CNN</td>
<td valign="top" align="left">Yes</td>
<td valign="top" align="left">Heatmaps highlight pneumonia regions, but coarse</td>
<td valign="top" align="left">Useful for localization but less detailed</td>
</tr>
<tr>
<td valign="top" align="left">ResNet50</td>
<td valign="top" align="left">YES</td>
<td valign="top" align="left">Focuses sharply on affected lung regions</td>
<td valign="top" align="left">Provides finer granularity, more clinically relevant</td>
</tr>
<tr>
<td valign="top" align="left">Random test samples</td>
<td valign="top" align="left">Yes</td>
<td valign="top" align="left">Some false positives due to background noise</td>
<td valign="top" align="left">Highlights need for more robust training</td>
</tr>
</tbody>
</table></table-wrap>
</sec>
<sec id="S4.SS21">
<title>Overlay heatmaps</title>
<p>This step involves with heatmap that helps to better visualize the volume of locations that are present within the data-set and helps in directing viewers towards the data visualization that matters most. These are superimposed onto the original X-ray images. It is used to visually represent the lung region.</p>
</sec>
<sec id="S4.SS22">
<title>Compare baseline vs. ResNet50 heatmaps</title>
<p>It involves with visualization of parts of the image that a model focuses on for classification (<xref ref-type="fig" rid="F7">Figure 7</xref>; <xref ref-type="app" rid="A1">Appendices XIX</xref> and <xref ref-type="app" rid="A1">XX</xref>). In this comparison, ResNet50 exhibits deeper and more complex neural network features, whereas the baseline shows simpler and more generic visualization. ResNET50 localized pneumonia regions with accurate images and supports reliability (<xref ref-type="fig" rid="F8">Figures 8</xref> and <xref ref-type="fig" rid="F9">9</xref>).</p>
<fig id="F7" position="float">
<label>FIGURE 7</label>
<caption><p>Classification report - baseline CNN.</p></caption>
<graphic mimetype="image" mime-subtype="tiff" xlink:href="sapars-2026-30-g007.tif"/>
</fig>
<fig id="F8" position="float">
<label>FIGURE 8</label>
<caption><p>Confusion matrix - baseline CNN.</p></caption>
<graphic mimetype="image" mime-subtype="tiff" xlink:href="sapars-2026-30-g008.tif"/>
</fig>
<fig id="F9" position="float">
<label>FIGURE 9</label>
<caption><p>Confusion matrix - ResNet50 TL.</p></caption>
<graphic mimetype="image" mime-subtype="tiff" xlink:href="sapars-2026-30-g009.tif"/>
</fig>
</sec>
<sec id="S4.SS23">
<title>Visualize random test sample</title>
<p>In this step, arbitrary test images are selected, and the Grad-Cam overlays heat maps are generated. This analysis illustrates robustness across patient&#x2019;s unseen scans (<xref ref-type="app" rid="A1">Appendix XXI</xref>; <xref ref-type="fig" rid="F10">Figure 10</xref>).</p>
<fig id="F10" position="float">
<label>FIGURE 10</label>
<caption><p>Sample predictions.</p></caption>
<graphic mimetype="image" mime-subtype="tiff" xlink:href="sapars-2026-30-g010.tif"/>
</fig>
</sec>
<sec id="S4.SS24">
<title>Summarize model accuracy</title>
<p>In this model, baseline CNN and ResNet50 comparison, baseline attain accuracy 84% than ResNet50. It highlights the pre-trained deep architectures will exhibit more in compare with recent developing model (<xref ref-type="app" rid="A1">Appendix XXII</xref>).</p>
</sec>
<sec id="S4.SS25">
<title>Summarize results</title>
<p>From this analysis, we can ensure that ResNet50 works better as it tends to attain high precision with improved interoperability function. It gives a clear image visualization in the lung regions.</p>
</sec>
<sec id="S4.SS26">
<title>Highlighting the clinical implications</title>
<p>ResNet50 has the most improved performance in comparison with all the methods. It suggests that this technique can be deployed in medical image screening for resource-limited settings (<xref ref-type="table" rid="T9">Table 9</xref>).</p>
<table-wrap position="float" id="T9">
<label>TABLE 9</label>
<caption><p>Clinical relevance of model.</p></caption>
<table cellspacing="5" cellpadding="5" frame="hsides" rules="groups">
<thead>
<tr>
<td valign="top" align="left">Model</td>
<td valign="top" align="left">Key advantage</td>
<td valign="top" align="left">Limitation</td>
<td valign="top" align="left">Clinical implication/use case</td>
</tr>
</thead>
<tbody>
<tr>
<td valign="top" align="left">Baseline CNN</td>
<td valign="top" align="left">Simple, interpretable, lightweight</td>
<td valign="top" align="left">Lower generalization, may miss subtle cases</td>
<td valign="top" align="left">Educational tool, initial screening</td>
</tr>
<tr>
<td valign="top" align="left">ResNet50 (TL)</td>
<td valign="top" align="left">Higher accuracy, robust detection</td>
<td valign="top" align="left">Computationally heavy, risk of over fitting on small data</td>
<td valign="top" align="left">Useful for decision support in radiology</td>
</tr>
</tbody>
</table></table-wrap>
</sec>
</sec>
<sec id="S5" sec-type="discussion">
<title>Discussion</title>
<p>The comparison between the baseline CNN and the ResNEt50 TL model underscores the purpose of using pre-trained architectures for medical image classification. The baseline CNN was 84.29% precise and is a valid citation point for comparison because it had a considerable recall (0.96) for pneumonia detection, which is clinically appropriate for scientific applications. Training CNNs from scratch with tiny medical datasets is problematic due to their shortcomings in generalization and their propensity to overfitting.</p>
<p>The data was fine-tines to achieve 86.22% accuracy, which illustrates a better tradeoff between precision and recall. Previous studies have revealed that TL is better than scratch-built models on tiny medical datasets, resulting in a COVID-19 detection precision of &#x003E;96% using ResNet50. Also pointed out the usefulness of ensemble TL approaches. Although our results are Somewhat less accurate than these benchmarks, the advancement over the baseline CNN indicates the resilience of TL to limited and imbalanced datasets.</p>
<p>Interpretability through Grad-CAM revealed that ResNEt50 enhanced classification precision and pinpointed pathological regions with fine granularity than the baseline CNN. The capability to visualize strengthens trust in clinical adoption, where predictability is equally important as explainability.</p>
<p>This research advocates that TL is a practicable and effective way for locating medical images in environments with little data. To achieve high-quality performance similar to the highest outcomes in existing literature, it is recommended to improve model selection, dine-tune strategies, and domain adaptation.</p>
</sec>
<sec id="S6" sec-type="conclusion">
<title>Conclusion</title>
<p>This research explored the purpose of TL to categorize medical images using COVID-19 chest X-ray datasets, comparing a baseline CNN to ResNet50. The baseline CNN was able to achieve 84.29% accuracy, but ResNet50&#x2019;s performance improved to 86.22%, concluding that TL is effective in optimizing classification accuracy, robustness, and interpretability with limited annotated datasets. When compared with prior studies, reported &#x003E;96% accuracy for COVID-19 detection with ResNet50, and achieved &#x003E;90% accuracy using DenseNet121, this findings illustrate competitive performance, though nit yet surpassing the highest benchmarks. This research corroborates that TL invariability improves generalization over baseline CNN&#x2019;s even in instances with limited resources. In summary, TL not just bridges the gap synthesized by limited annotated medical datasets but also presents a scalable, accurate, and explicable means to advance AI-assisted healthcare solutions.</p>
</sec>
</body>
<back>
<sec id="S7" sec-type="funding-information">
<title>Funding</title>
<p>The authors declare that no financial support was received for the research, authorship, and/or publication of this article.</p>
</sec>
<sec id="S8">
<title>Conflict of interest</title>
<p>The authors declare that the research was conducted in the absence of any commercial or financial relationships that could be construed as a potential conflict of interest.</p>
</sec>
<ref-list>
<title>References</title>
<ref id="B1"><label>1.</label><citation citation-type="journal"><person-group person-group-type="author"><name><surname>Mehmood</surname> <given-names>A</given-names></name> <name><surname>Yang</surname> <given-names>S</given-names></name> <name><surname>Feng</surname> <given-names>Z</given-names></name> <name><surname>Wang</surname> <given-names>M</given-names></name> <name><surname>Ahmad</surname> <given-names>AS</given-names></name> <name><surname>Khan</surname> <given-names>R</given-names></name> <etal/> </person-group> <article-title>A transfer learning approach for early diagnosis of Alzheimer&#x2019;s disease on MRI images.</article-title> <source><italic>Neuroscience.</italic></source> (<year>2021</year>) <volume>460</volume>:<fpage>43</fpage>&#x2013;<lpage>52</lpage>.</citation></ref>
<ref id="B2"><label>2.</label><citation citation-type="journal"><person-group person-group-type="author"><name><surname>Malik</surname> <given-names>H</given-names></name> <name><surname>Farooq</surname> <given-names>MS</given-names></name> <name><surname>Khelifi</surname> <given-names>A</given-names></name> <name><surname>Abid</surname> <given-names>A</given-names></name> <name><surname>Qureshi</surname> <given-names>JN</given-names></name> <name><surname>Hussain</surname> <given-names>M</given-names></name></person-group>. <article-title>A comparison of transfer learning performance versus health experts in disease diagnosis from medical imaging.</article-title> <source><italic>IEEE Access.</italic></source> (<year>2020</year>) <volume>8</volume>:<fpage>139367</fpage>&#x2013;<lpage>86</lpage>.</citation></ref>
<ref id="B3"><label>3.</label><citation citation-type="journal"><person-group person-group-type="author"><name><surname>Tanveer</surname> <given-names>M</given-names></name> <name><surname>Rashid</surname> <given-names>AH</given-names></name> <name><surname>Ganaie</surname> <given-names>MA</given-names></name> <name><surname>Reza</surname> <given-names>M</given-names></name> <name><surname>Razzak</surname> <given-names>I</given-names></name> <name><surname>Hua</surname> <given-names>KL</given-names></name></person-group>. <article-title>Classification of Alzheimer&#x2019;s disease using ensemble of deep neural networks trained through transfer learning.</article-title> <source><italic>IEEE J Biomed Health Informat.</italic></source> (<year>2021</year>) <volume>26</volume>(<issue>4</issue>):<fpage>1453</fpage>&#x2013;<lpage>63</lpage>.</citation></ref>
<ref id="B4"><label>4.</label><citation citation-type="journal"><person-group person-group-type="author"><name><surname>Alzubaidi</surname> <given-names>L</given-names></name> <name><surname>Al-Amidie</surname> <given-names>M</given-names></name> <name><surname>Al-Asadi</surname> <given-names>A</given-names></name> <name><surname>Humaidi</surname> <given-names>AJ</given-names></name> <name><surname>Al-Shamma</surname> <given-names>O</given-names></name> <name><surname>Fadhel</surname> <given-names>MA</given-names></name> <etal/> </person-group> <article-title>Novel transfer learning approach for medical imaging with limited labeled data.</article-title> <source><italic>Cancers.</italic></source> (<year>2021</year>) <volume>13</volume>(<issue>7</issue>):<fpage>1590</fpage>.</citation></ref>
<ref id="B5"><label>5.</label><citation citation-type="journal"><person-group person-group-type="author"><name><surname>Kim</surname> <given-names>HE</given-names></name> <name><surname>Cosa-Linan</surname> <given-names>A</given-names></name> <name><surname>Santhanam</surname> <given-names>N</given-names></name> <name><surname>Jannesari</surname> <given-names>M</given-names></name> <name><surname>Maros</surname> <given-names>ME</given-names></name> <name><surname>Ganslandt</surname> <given-names>T</given-names></name></person-group>. <article-title>Transfer learning for medical image classification: a literature review.</article-title> <source><italic>BMC Med Imaging.</italic></source> (<year>2022</year>) <volume>22</volume>(<issue>1</issue>):<fpage>69</fpage>.</citation></ref>
<ref id="B6"><label>6.</label><citation citation-type="journal"><person-group person-group-type="author"><name><surname>Matsoukas</surname> <given-names>C</given-names></name> <name><surname>Haslum</surname> <given-names>JF</given-names></name> <name><surname>Sorkhei</surname> <given-names>M</given-names></name> <name><surname>S&#x00F6;derberg</surname> <given-names>M</given-names></name> <name><surname>Smith</surname> <given-names>K</given-names></name></person-group>. <article-title>What makes transfer learning work for medical images: feature reuse &#x0026; other factors.</article-title> In: <source><italic>Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition.</italic></source> (<year>2022</year>). p. <fpage>9225</fpage>&#x2013;<lpage>34</lpage>.</citation></ref>
<ref id="B7"><label>7.</label><citation citation-type="journal"><person-group person-group-type="author"><name><surname>Hosna</surname> <given-names>A</given-names></name> <name><surname>Merry</surname> <given-names>E</given-names></name> <name><surname>Gyalmo</surname> <given-names>J</given-names></name> <name><surname>Alom</surname> <given-names>Z</given-names></name> <name><surname>Aung</surname> <given-names>Z</given-names></name> <name><surname>Azim</surname> <given-names>MA</given-names></name></person-group>. <article-title>Transfer learning: a friendly introduction.</article-title> <source><italic>J Big Data.</italic></source> (<year>2022</year>) <volume>9</volume>(<issue>1</issue>):<fpage>102</fpage>.</citation></ref>
<ref id="B8"><label>8.</label><citation citation-type="journal"><person-group person-group-type="author"><name><surname>Mehmood</surname> <given-names>S</given-names></name> <name><surname>Ghazal</surname> <given-names>TM</given-names></name> <name><surname>Khan</surname> <given-names>MA</given-names></name> <name><surname>Zubair</surname> <given-names>M</given-names></name> <name><surname>Naseem</surname> <given-names>MT</given-names></name> <name><surname>Faiz</surname> <given-names>T</given-names></name> <etal/> </person-group> <article-title>Malignancy detection in lung and colon histopathology images using transfer learning with class selective image processing.</article-title> <source><italic>IEEE Access.</italic></source> (<year>2022</year>) <volume>10</volume>:<fpage>25657</fpage>&#x2013;<lpage>68</lpage>.</citation></ref>
<ref id="B9"><label>9.</label><citation citation-type="journal"><person-group person-group-type="author"><name><surname>Taresh</surname> <given-names>MM</given-names></name> <name><surname>Zhu</surname> <given-names>N</given-names></name> <name><surname>Ali</surname> <given-names>TAA</given-names></name> <name><surname>Hameed</surname> <given-names>AS</given-names></name> <name><surname>Mutar</surname> <given-names>ML</given-names></name></person-group>. <article-title>Transfer learning to detect COVID-19 automatically from X-Ray images using convolutional neural networks.</article-title> <source><italic>Int J Biomed Imaging.</italic></source> (<year>2021</year>) <volume>2021</volume>(<issue>1</issue>):<fpage>8828404</fpage>.</citation></ref>
<ref id="B10"><label>10.</label><citation citation-type="journal"><person-group person-group-type="author"><name><surname>Apostolopoulos</surname> <given-names>ID</given-names></name> <name><surname>Mpesiana</surname> <given-names>TA</given-names></name></person-group>. <article-title>Covid-19: automatic detection from x-ray images utilizing transfer learning with convolutional neural networks.</article-title> <source><italic>Phys Eng Sci Med.</italic></source> (<year>2020</year>) <volume>43</volume>(<issue>2</issue>):<fpage>635</fpage>&#x2013;<lpage>40</lpage>.</citation></ref>
<ref id="B11"><label>11.</label><citation citation-type="journal"><person-group person-group-type="author"><name><surname>Valverde</surname> <given-names>JM</given-names></name> <name><surname>Imani</surname> <given-names>V</given-names></name> <name><surname>Abdollahzadeh</surname> <given-names>A</given-names></name> <name><surname>De Feo</surname> <given-names>R</given-names></name> <name><surname>Prakash</surname> <given-names>M</given-names></name> <name><surname>Ciszek</surname> <given-names>R</given-names></name> <etal/> </person-group> <article-title>Transfer learning in magnetic resonance brain imaging: a systematic review.</article-title> <source><italic>J Imaging.</italic></source> (<year>2021</year>) <volume>7</volume>(<issue>4</issue>):<fpage>66</fpage>.</citation></ref>
<ref id="B12"><label>12.</label><citation citation-type="journal"><person-group person-group-type="author"><name><surname>Alzubaidi</surname> <given-names>L</given-names></name> <name><surname>Fadhel</surname> <given-names>MA</given-names></name> <name><surname>Al-Shamma</surname> <given-names>O</given-names></name> <name><surname>Zhang</surname> <given-names>J</given-names></name> <name><surname>Santamar&#x00ED;a</surname> <given-names>J</given-names></name> <name><surname>Duan</surname> <given-names>Y</given-names></name> <etal/> </person-group> <article-title>Towards a better understanding of transfer learning for medical imaging: a case study.</article-title> <source><italic>Appl Sci.</italic></source> (<year>2020</year>) <volume>10</volume>(<issue>13</issue>):<fpage>4523</fpage>.</citation></ref>
<ref id="B13"><label>13.</label><citation citation-type="journal"><person-group person-group-type="author"><name><surname>Horry</surname> <given-names>MJ</given-names></name> <name><surname>Chakraborty</surname> <given-names>S</given-names></name> <name><surname>Paul</surname> <given-names>M</given-names></name> <name><surname>Ulhaq</surname> <given-names>A</given-names></name> <name><surname>Pradhan</surname> <given-names>B</given-names></name> <name><surname>Saha</surname> <given-names>M</given-names></name> <etal/> </person-group> <article-title>COVID-19 detection through transfer learning using multimodal imaging data.</article-title> <source><italic>IEEE Access.</italic></source> (<year>2020</year>) <volume>8</volume>:<fpage>149808</fpage>&#x2013;<lpage>24</lpage>.</citation></ref>
<ref id="B14"><label>14.</label><citation citation-type="journal"><person-group person-group-type="author"><name><surname>Pathak</surname> <given-names>Y</given-names></name> <name><surname>Shukla</surname> <given-names>PK</given-names></name> <name><surname>Tiwari</surname> <given-names>A</given-names></name> <name><surname>Stalin</surname> <given-names>S</given-names></name> <name><surname>Singh</surname> <given-names>S</given-names></name></person-group>. <article-title>Deep transfer learning based classification model for COVID-19 disease.</article-title> <source><italic>IRBM.</italic></source> (<year>2022</year>) <volume>43</volume>(<issue>2</issue>):<fpage>87</fpage>&#x2013;<lpage>92</lpage>.</citation></ref>
<ref id="B15"><label>15.</label><citation citation-type="journal"><person-group person-group-type="author"><name><surname>Bansal</surname> <given-names>M</given-names></name> <name><surname>Kumar</surname> <given-names>M</given-names></name> <name><surname>Sachdeva</surname> <given-names>M</given-names></name> <name><surname>Mittal</surname> <given-names>A</given-names></name></person-group>. <article-title>Transfer learning for image classification using VGG19: caltech-101 image data set.</article-title> <source><italic>J Ambient Intel Hum Comput.</italic></source> (<year>2023</year>) <volume>14</volume>(<issue>4</issue>):<fpage>3609</fpage>&#x2013;<lpage>20</lpage>.</citation></ref>
<ref id="B16"><label>16.</label><citation citation-type="journal"><person-group person-group-type="author"><name><surname>Liang</surname> <given-names>G</given-names></name> <name><surname>Zheng</surname> <given-names>L</given-names></name></person-group>. <article-title>A transfer learning method with deep residual network for pediatric pneumonia diagnosis.</article-title> <source><italic>Comput Methods Prog Biomed.</italic></source> (<year>2020</year>) <volume>187</volume>:<fpage>104964</fpage>.</citation></ref>
<ref id="B17"><label>17.</label><citation citation-type="journal"><person-group person-group-type="author"><name><surname>Salehi</surname> <given-names>AW</given-names></name> <name><surname>Khan</surname> <given-names>S</given-names></name> <name><surname>Gupta</surname> <given-names>G</given-names></name> <name><surname>Alabduallah</surname> <given-names>BI</given-names></name> <name><surname>Almjally</surname> <given-names>A</given-names></name> <name><surname>Alsolai</surname> <given-names>H</given-names></name> <etal/></person-group> (<year>2023</year>). <article-title>A study of CNN and transfer learning in medical imaging: advantages, challenges, future scope.</article-title> <source><italic>Sustainability.</italic></source> (<year>2020</year>) <volume>15</volume>(<issue>7</issue>):<fpage>5930</fpage>.</citation></ref>
<ref id="B18"><label>18.</label><citation citation-type="journal"><person-group person-group-type="author"><name><surname>Liu</surname> <given-names>X</given-names></name> <name><surname>Song</surname> <given-names>L</given-names></name> <name><surname>Liu</surname> <given-names>S</given-names></name> <name><surname>Zhang</surname> <given-names>Y</given-names></name></person-group>. <article-title>A review of deep-learning-based medical image segmentation methods.</article-title> <source><italic>Sustainability.</italic></source> (<year>2021</year>) <volume>13</volume>(<issue>3</issue>):<fpage>1224</fpage>.</citation></ref>
<ref id="B19"><label>19.</label><citation citation-type="journal"><person-group person-group-type="author"><name><surname>Hossain</surname> <given-names>MB</given-names></name> <name><surname>Iqbal</surname> <given-names>SHS</given-names></name> <name><surname>Islam</surname> <given-names>MM</given-names></name> <name><surname>Akhtar</surname> <given-names>MN</given-names></name> <name><surname>Sarker</surname> <given-names>IH</given-names></name></person-group>. <article-title>Transfer learning with fine-tuned deep CNN ResNet50 model for classifying COVID-19 from chest X-ray images.</article-title> <source><italic>Informat Med Unlocked.</italic></source> (<year>2022</year>) <volume>30</volume>:<fpage>100916</fpage>.</citation></ref>
<ref id="B20"><label>20.</label><citation citation-type="journal"><person-group person-group-type="author"><name><surname>Wang</surname> <given-names>J</given-names></name> <name><surname>Zhu</surname> <given-names>H</given-names></name> <name><surname>Wang</surname> <given-names>SH</given-names></name> <name><surname>Zhang</surname> <given-names>YD</given-names></name></person-group>. <article-title>A review of deep learning on medical image analysis.</article-title> <source><italic>Mobile Netw Appl.</italic></source> (<year>2021</year>) <volume>26</volume>(<issue>1</issue>):<fpage>351</fpage>&#x2013;<lpage>80</lpage>.</citation></ref>
<ref id="B21"><label>21.</label><citation citation-type="journal"><person-group person-group-type="author"><name><surname>Abbas</surname> <given-names>A</given-names></name> <name><surname>Abdelsamea</surname> <given-names>MM</given-names></name> <name><surname>Gaber</surname> <given-names>MM</given-names></name></person-group>. <article-title>Detrac: transfer learning of class decomposed medical images in convolutional neural networks.</article-title> <source><italic>IEEE Access.</italic></source> (<year>2020</year>) <volume>8</volume>:<fpage>74901</fpage>&#x2013;<lpage>13</lpage>.</citation></ref>
<ref id="B22"><label>22.</label><citation citation-type="journal"><person-group person-group-type="author"><name><surname>Srinivas</surname> <given-names>C</given-names></name> <name><surname>Nandini Prasad</surname> <given-names>KS</given-names></name> <name><surname>Zakariah</surname> <given-names>M</given-names></name> <name><surname>Alothaibi</surname> <given-names>YA</given-names></name> <name><surname>Shaukat</surname> <given-names>K</given-names></name> <name><surname>Partibane</surname> <given-names>B</given-names></name> <etal/> </person-group> <article-title>Deep transfer learning approaches in performance analysis of brain tumor classification using MRI images.</article-title> <source><italic>J Health Care Eng.</italic></source> (<year>2022</year>) <volume>2022</volume>(<issue>1</issue>):<fpage>3264367</fpage>.</citation></ref>
<ref id="B23"><label>23.</label><citation citation-type="journal"><person-group person-group-type="author"><name><surname>Gour</surname> <given-names>N</given-names></name> <name><surname>Khanna</surname> <given-names>P</given-names></name></person-group>. <article-title>Multi-class multi-label ophthalmological disease detection using transfer learning based convolutional neural network.</article-title> <source><italic>Biomed Sig Process Control.</italic></source> (<year>2021</year>) <volume>66</volume>:<fpage>10</fpage> <fpage>2329</fpage>.</citation></ref>
<ref id="B24"><label>24.</label><citation citation-type="journal"><person-group person-group-type="author"><name><surname>Kaur</surname> <given-names>T</given-names></name> <name><surname>Gandhi</surname> <given-names>TK</given-names></name></person-group>. <article-title>Deep convolutional neural networks with transfer learning for automated brain image classification.</article-title> <source><italic>Mach Vision Appl.</italic></source> (<year>2020</year>) <volume>31</volume>(<issue>3</issue>):<fpage>20</fpage>.</citation></ref>
<ref id="B25"><label>25.</label><citation citation-type="journal"><person-group person-group-type="author"><name><surname>Mei</surname> <given-names>X</given-names></name> <name><surname>Liu</surname> <given-names>Z</given-names></name> <name><surname>Robson</surname> <given-names>PM</given-names></name> <name><surname>Marinelli</surname> <given-names>B</given-names></name> <name><surname>Huang</surname> <given-names>M</given-names></name> <name><surname>Doshi</surname> <given-names>A</given-names></name> <etal/> </person-group> <article-title>RadImageNet: an open radiologic deep learning research data-set for effective transfer learning.</article-title> <source><italic>Radiol Artific Intel.</italic></source> (<year>2022</year>) <volume>4</volume>(<issue>5</issue>):<fpage>e210315</fpage>.</citation></ref>
</ref-list>
<app-group>
<app id="A1">
<title>Appendix</title>
<list list-type="simple">
<list-item><p><bold>I.</bold> .<bold>STEP 1:</bold></p>
</list-item>
</list>
<p># Step 1: Install Kaggle API (Colab usually doesn&#x2019;t have it pre-installed)</p>
<p>!pip install -q kaggle</p>
<list list-type="simple">
<list-item><p><bold>II.</bold> .<bold>STEP 2:</bold></p>
</list-item>
</list>
<p># Step 2: Upload kaggle.json (API key file)</p>
<p>from google.colab import files</p>
<p>files.upload() # &#x003C;&#x2014; Upload kaggle.json from your computer</p>
<list list-type="simple">
<list-item><p><bold>III.</bold> .<bold>STEP 3:</bold></p>
</list-item>
</list>
<p># Step 3: Move kaggle.json to the correct directory</p>
<p>!mkdir -p &#x223C;/.kaggle</p>
<p>!cp kaggle.json &#x223C;/.kaggle/</p>
<p>!chmod 600 &#x223C;/.kaggle/kaggle.json</p>
<list list-type="simple">
<list-item><p><bold>IV.</bold> .<bold>STEP 4:</bold></p>
</list-item>
</list>
<p># Step 4: Download dataset from Kaggle</p>
<p>!kaggle datasets download -d paultimothymooney/chest-xray-pneumonia -p ./data</p>
<list list-type="simple">
<list-item><p><bold>V.</bold> .<bold>STEP 5:</bold></p>
</list-item>
</list>
<p># Step 5: Unzip dataset</p>
<p>import zipfile</p>
<p>with zipfile.ZipFile(&#x201D;./data/chest-xray-pneumonia.zip&#x201D;, &#x2018;r&#x2019;) as zip_ref:</p>
<p>zip_ref.extractall(&#x201D;./data&#x201D;)</p>
<p>print(&#x201D;Dataset downloaded and extracted successfully!&#x201D;)</p>
<list list-type="simple">
<list-item><p><bold>VI.</bold> .<bold>STEP 6:</bold></p>
</list-item>
</list>
<p># Step 6: Import libraries</p>
<p>import tensorflow as tf</p>
<p>from tensorflow.keras.preprocessing.image import ImageDataGenerator</p>
<p>from tensorflow.keras.applications import ResNet50</p>
<p>from tensorflow.keras.models import Sequential</p>
<p>from tensorflow.keras.layers import Dense, GlobalAveragePooling2D, Dropout</p>
<p>from tensorflow.keras.optimizers import Adam</p>
<p>import matplotlib.pyplot as plt</p>
<list list-type="simple">
<list-item><p><bold>VII.</bold> .<bold>STEP 7:</bold></p>
</list-item>
</list>
<p># Step 7: Define paths</p>
<p>train_dir = &#x201C;./data/chest_xray/train&#x201D;</p>
<p>val_dir = &#x201C;./data/chest_xray/val&#x201D;</p>
<p>test_dir = &#x201C;./data/chest_xray/test&#x201D;</p>
<list list-type="simple">
<list-item><p><bold>VIII.</bold> .<bold>STEP 8:</bold></p>
</list-item>
</list>
<p># Step 8: Data Augmentation</p>
<p>train_datagen = ImageDataGenerator(</p>
<p>rescale=1./255,</p>
<p>rotation_range=20,</p>
<p>width_shift_range=0.2,</p>
<p>height_shift_range=0.2,</p>
<p>shear_range=0.2,</p>
<p>zoom_range=0.2,</p>
<p>horizontal_flip=True</p>
<p>)</p>
<p>val_datagen = ImageDataGenerator(rescale=1./255)</p>
<p>test_datagen = ImageDataGenerator(rescale=1./255)</p>
<p>train_generator = train_datagen.flow_from_directory(</p>
<p>train_dir, target_size=(224,224), batch_size=32, class_mode=&#x2019;binary&#x2019;</p>
<p>)</p>
<p>val_generator = val_datagen.flow_from_directory(</p>
<p>val_dir, target_size=(224,224), batch_size=32, class_mode=&#x2019;binary&#x2019;</p>
<p>)</p>
<p>test_generator = test_datagen.flow_from_directory(</p>
<p>test_dir, target_size=(224,224), batch_size=32, class_mode=&#x2019;binary&#x2019;, shuffle=False</p>
<p>)</p>
<list list-type="simple">
<list-item><p><bold>IX.</bold> .<bold>STEP 9:</bold></p>
</list-item>
</list>
<p>Step 9: Train a Baseline CNN (No Transfer Learning)</p>
<p>from tensorflow.keras.models import Sequential</p>
<p>from tensorflow.keras.layers import Conv2D, MaxPooling2D, Flatten, Dense, Dropout</p>
<p># Baseline CNN Model (without transfer learning)</p>
<p>baseline_model = Sequential([</p>
<p>Conv2D(32, (3,3), activation=&#x2019;relu&#x2019;, input_shape=(224,224,3)),</p>
<p>MaxPooling2D(2,2),</p>
<p>Conv2D(64, (3,3), activation=&#x2019;relu&#x2019;),</p>
<p>MaxPooling2D(2,2),</p>
<p>Conv2D(128, (3,3), activation=&#x2019;relu&#x2019;),</p>
<p>MaxPooling2D(2,2),</p>
<p>Flatten(),</p>
<p>Dense(128, activation=&#x2019;relu&#x2019;),</p>
<p>Dropout(0.5),</p>
<p>Dense(1, activation=&#x2019;sigmoid&#x2019;)</p>
<p>])</p>
<p>baseline_model.compile(optimizer=&#x2019;adam&#x2019;,</p>
<p>loss=&#x2019;binary_crossentropy&#x2019;,</p>
<p>metrics=[&#x2019;accuracy&#x2019;])</p>
<p>print(baseline_model.summary())</p>
<p># Train baseline CNN</p>
<p>history_baseline = baseline_model.fit(</p>
<p>train_generator,</p>
<p>epochs=5,</p>
<p>validation_data=val_generator</p>
<p>)</p>
<p># Evaluate baseline CNN</p>
<p>loss, acc = baseline_model.evaluate(test_generator)</p>
<p>print(f&#x201D;Baseline CNN Test Accuracy: {acc&#x002A;100:.2f}%&#x201D;)</p>
<list list-type="simple">
<list-item><p><bold>X.</bold> .<bold>STEP 10:</bold></p>
</list-item>
</list>
<p># Step 10: Evaluate on Test Data</p>
<p>loss, acc = model.evaluate(test_generator)</p>
<p>print(f&#x201D;Test Accuracy: {acc&#x002A;100:.2f}%&#x201D;)</p>
<list list-type="simple">
<list-item><p><bold>XI.</bold> .<bold>STEP 11:</bold></p>
</list-item>
</list>
<p># Step 11: Plot Accuracy &#x0026; Loss</p>
<p>plt.plot(history.history[&#x2019;accuracy&#x2019;] + history_fine.history[&#x2019;accuracy&#x2019;], label=&#x201D;Train Acc&#x201D;)</p>
<p>plt.plot(history.history[&#x2019;val_accuracy&#x2019;] + history_fine.history[&#x2019;val_accuracy&#x2019;], label=&#x201D;Val Acc&#x201D;)</p>
<p>plt.legend()</p>
<p>plt.title(&#x201D;Training &#x0026; Validation Accuracy&#x201D;)</p>
<p>plt.show()</p>
<p>plt.plot(history.history[&#x2019;loss&#x2019;] + history_fine.history[&#x2019;loss&#x2019;], label=&#x201D;Train Loss&#x201D;)</p>
<p>plt.plot(history.history[&#x2019;val_loss&#x2019;] + history_fine.history[&#x2019;val_loss&#x2019;], label=&#x201D;Val Loss&#x201D;)</p>
<p>plt.legend()</p>
<p>plt.title(&#x201D;Training &#x0026; Validation Loss&#x201D;)</p>
<p>plt.show()</p>
<list list-type="simple">
<list-item><p><bold>XII.</bold> .<bold>STEP 12:</bold></p>
</list-item>
</list>
<p># Step 12: Train Transfer Learning Model (ResNet50)</p>
<p>from tensorflow.keras.applications import ResNet50</p>
<p>from tensorflow.keras.models import Model</p>
<p>from tensorflow.keras.layers import Dense, Flatten, Dropout, GlobalAveragePooling2D</p>
<p>from tensorflow.keras.optimizers import Adam</p>
<p># Load pre-trained ResNet50 model (without top classifier layers)</p>
<p>base_model = ResNet50(weights=&#x201D;imagenet&#x201D;, include_top=False, input_shape=(224,224,3))</p>
<p># Freeze base model layers (so only custom layers train initially)</p>
<p>for layer in base_model.layers:</p>
<p>layer.trainable = False</p>
<p># Add custom layers on top</p>
<p>x = base_model.output</p>
<p>x = GlobalAveragePooling2D()(x)</p>
<p>x = Dense(256, activation=&#x201D;relu&#x201D;)(x)</p>
<p>x = Dropout(0.5)(x)</p>
<p>predictions = Dense(1, activation=&#x201D;sigmoid&#x201D;)(x)</p>
<p>model = Model(inputs=base_model.input, outputs=predictions)</p>
<p># Compile</p>
<p>model.compile(optimizer=Adam(learning_rate=0.0001),</p>
<p>loss=&#x201D;binary_crossentropy&#x201D;,</p>
<p>metrics=[&#x201D;accuracy&#x201D;])</p>
<p># Train the transfer learning model</p>
<p>history_resnet = model.fit(</p>
<p>train_generator,</p>
<p>validation_data=val_generator,</p>
<p>epochs=5</p>
<p>)</p>
<p># Evaluate on test data</p>
<p>loss_resnet, acc_resnet = model.evaluate(test_generator)</p>
<p>print(f&#x201D;ResNet50 Transfer Learning Test Accuracy: {acc_resnet&#x002A;100:.2f}%&#x201D;)</p>
<p><bold>XIII STEP 13:</bold></p>
<p># Step 13: Build Model (Transfer Learning with ResNet50)</p>
<p>base_model = ResNet50(weights=&#x201D;imagenet&#x201D;, include_top=False, input_shape=(224,224,3))</p>
<p>base_model.trainable = False # Freeze base model layers</p>
<p>model = Sequential([</p>
<p>base_model,</p>
<p>GlobalAveragePooling2D(),</p>
<p>Dropout(0.5),</p>
<p>Dense(128, activation=&#x201D;relu&#x201D;),</p>
<p>Dropout(0.3),</p>
<p>Dense(1, activation=&#x201D;sigmoid&#x201D;)</p>
<p>])</p>
<p>model.compile(optimizer=Adam(learning_rate=0.0001),</p>
<p>loss=&#x201D;binary_crossentropy&#x201D;,</p>
<p>metrics=[&#x201D;accuracy&#x201D;])</p>
<p>model.summary()</p>
<p><bold>XIV STEP 14:</bold></p>
<p># Step 14: Fine-tuning (Unfreeze last few ResNet50 layers for better accuracy)</p>
<p>base_model.trainable = True</p>
<p>for layer in base_model.layers[:-30]: # keep most frozen</p>
<p>layer.trainable = False</p>
<p>model.compile(optimizer=Adam(learning_rate=1e-5),</p>
<p>loss=&#x201D;binary_crossentropy&#x201D;,</p>
<p>metrics=[&#x201D;accuracy&#x201D;])</p>
<p>history_fine = model.fit(</p>
<p>train_generator,</p>
<p>validation_data=val_generator,</p>
<p>epochs=5</p>
<p>)</p>
<p><bold>XV STEP 15:</bold></p>
<p>#Step 15: Plot Training Curves</p>
<p>plt.figure(figsize=(12,5))</p>
<p># Baseline CNN</p>
<p>plt.plot(history_baseline.history[&#x2019;accuracy&#x2019;], label=&#x201D;Baseline Train Acc&#x201D;)</p>
<p>plt.plot(history_baseline.history[&#x2019;val_accuracy&#x2019;], label=&#x201D;Baseline Val Acc&#x201D;)</p>
<p># ResNet50</p>
<p>plt.plot(history.history[&#x2019;accuracy&#x2019;], label=&#x201D;ResNet50 Train Acc&#x201D;)</p>
<p>plt.plot(history.history[&#x2019;val_accuracy&#x2019;], label=&#x201D;ResNet50 Val Acc&#x201D;)</p>
<p>plt.title(&#x201D;Accuracy Comparison&#x201D;)</p>
<p>plt.xlabel(&#x201D;Epochs&#x201D;)</p>
<p>plt.ylabel(&#x201D;Accuracy&#x201D;)</p>
<p>plt.legend()</p>
<p>plt.show()</p>
<p><bold>XVI STEP 16:</bold></p>
<p># Step 16: Grad-CAM Function</p>
<p>import cv2</p>
<p>from tensorflow.keras.models import Model</p>
<p>def make_gradcam_heatmap(img_array, model, last_conv_layer_name, pred_index=None):</p>
<p># Create model mapping input -&#x003E; last conv layer outputs &#x0026; predictions</p>
<p>grad_model = Model(</p>
<p>[model.inputs],</p>
<p>[model.get_layer(last_conv_layer_name).output, model.output]</p>
<p>)</p>
<p># Forward pass</p>
<p>with tf.GradientTape() as tape:</p>
<p>conv_outputs, predictions = grad_model(img_array)</p>
<p>if pred_index is None:</p>
<p>pred_index = tf.argmax(predictions[0])</p>
<p>class_channel = predictions[:, pred_index]</p>
<p># Compute gradients</p>
<p>grads = tape.gradient(class_channel, conv_outputs)</p>
<p># Mean intensity of gradients across each feature map</p>
<p>pooled_grads = tf.reduce_mean(grads, axis=(0, 1, 2))</p>
<p># Weight activation maps with pooled gradients</p>
<p>conv_outputs = conv_outputs[0]</p>
<p>heatmap = conv_outputs @ pooled_grads[&#x2026;, tf.newaxis]</p>
<p>heatmap = tf.squeeze(heatmap)</p>
<p># Normalize between 0 and 1</p>
<p>heatmap = tf.maximum(heatmap, 0) / tf.math.reduce_max(heatmap)</p>
<p>return heatmap.numpy()</p>
<p>def display_gradcam(img_path, model, last_conv_layer_name=&#x201D;conv5_block3_out&#x201D;):</p>
<p># Load and preprocess image</p>
<p>img = tf.keras.utils.load_img(img_path, target_size=(224, 224))</p>
<p>img_array = tf.keras.utils.img_to_array(img)</p>
<p>img_array = np.expand_dims(img_array, axis=0)</p>
<p>img_array = img_array / 255.0</p>
<p># Generate heatmap</p>
<p>heatmap = make_gradcam_heatmap(img_array, model, last_conv_layer_name)</p>
<p># Overlay heatmap on image</p>
<p>img = cv2.imread(img_path)</p>
<p>img = cv2.resize(img, (224, 224))</p>
<p>heatmap = cv2.resize(heatmap, (img.shape[1], img.shape[0]))</p>
<p>heatmap = np.uint8(255 &#x002A; heatmap)</p>
<p>heatmap = cv2.applyColorMap(heatmap, cv2.COLORMAP_JET)</p>
<p>superimposed_img = cv2.addWeighted(img, 0.6, heatmap, 0.4, 0)</p>
<p>plt.figure(figsize=(6,6))</p>
<p>plt.imshow(cv2.cvtColor(superimposed_img, cv2.COLOR_BGR2RGB))</p>
<p>plt.axis(&#x201D;off&#x201D;)</p>
<p>plt.show()</p>
<p><bold>XVII STEP 17:</bold></p>
<p># Step 17: Grad-CAM on Baseline CNN</p>
<p>import numpy as np</p>
<p>from tensorflow.keras.preprocessing import imag</p>
<p># Make sure the model has seen an input before Grad-CAM</p>
<p>_ = baseline_model.predict(np.zeros((1,224,224,3)))</p>
<p># Pick test image</p>
<p>test_dir = &#x201C;/content/data/chest_xray/test/PNEUMONIA&#x201D;</p>
<p>sample_img = random.choice(os.listdir(test_dir))</p>
<p>img_path = os.path.join(test_dir, sample_img)</p>
<p>print(&#x201D;Baseline CNN - Grad-CAM for:&#x201D;, sample_img)</p>
<p># Run Grad-CAM</p>
<p>display_gradcam(img_path, baseline_model, last_conv_layer_name=&#x201D;conv2d_2&#x201D;)</p>
<p><bold>XVIII STEP 18:</bold></p>
<p># Step 18: Grad-CAM on ResNet50 Transfer Learning</p>
<p>test_dir = &#x201C;/content/data/chest_xray/test/NORMAL&#x201D;</p>
<p>sample_img = random.choice(os.listdir(test_dir))</p>
<p>img_path = os.path.join(test_dir, sample_img)</p>
<p>print(&#x201D;ResNet50 - Grad-CAM for:&#x201D;, sample_img)</p>
<p>display_gradcam(img_path, model, last_conv_layer_name=&#x201D;conv5_block3_out&#x201D;)</p>
<p><bold>XIX STEP 19:</bold></p>
<p># Step 19: Confusion Matrix &#x0026; Classification Report</p>
<p>import numpy as np</p>
<p>from sklearn.metrics import confusion_matrix, classification_report</p>
<p>import seaborn as sns</p>
<p># Get predictions</p>
<p>y_pred = model.predict(test_generator)</p>
<p>y_pred_classes = (y_pred &#x003E; 0.5).astype(&#x201D;int32&#x201D;).reshape(-1) # Convert probabilities &#x2192; class labels</p>
<p>y_true = test_generator.classes</p>
<p># Confusion Matrix</p>
<p>cm = confusion_matrix(y_true, y_pred_classes)</p>
<p>plt.figure(figsize=(6,5))</p>
<p>sns.heatmap(cm, annot=True, fmt=&#x201D;d&#x201D;, cmap=&#x201D;Blues&#x201D;,</p>
<p>xticklabels=[&#x201D;Normal&#x201D;, &#x201C;Pneumonia&#x201D;],</p>
<p>yticklabels=[&#x201D;Normal&#x201D;, &#x201C;Pneumonia&#x201D;])</p>
<p>plt.xlabel(&#x201D;Predicted&#x201D;)</p>
<p>plt.ylabel(&#x201D;Actual&#x201D;)</p>
<p>plt.title(&#x201D;Confusion Matrix&#x201D;)</p>
<p>plt.show()</p>
<p># Classification Report</p>
<p>print(&#x201D;? Classification Report:\n&#x201D;)</p>
<p>print(classification_report(y_true, y_pred_classes, target_names=[&#x201D;Normal&#x201D;, &#x201C;Pneumonia&#x201D;]))</p>
<p><bold>XX STEP 20:</bold></p>
<p># Step 20: Confusion Matrix (ResNet50 Transfer Learning)</p>
<p>cm_resnet = confusion_matrix(y_true, y_pred_resnet)</p>
<p>plt.figure(figsize=(6,5))</p>
<p>sns.heatmap(cm_resnet, annot=True, fmt=&#x2019;d&#x2019;, cmap=&#x2019;Greens&#x2019;,</p>
<p>xticklabels=[&#x2019;Normal&#x2019;, &#x2018;Pneumonia&#x2019;],</p>
<p>yticklabels=[&#x2019;Normal&#x2019;, &#x2018;Pneumonia&#x2019;])</p>
<p>plt.title(&#x201D;Confusion Matrix - ResNet50 Transfer Learning&#x201D;)</p>
<p>plt.ylabel(&#x2019;True Label&#x2019;)</p>
<p>plt.xlabel(&#x2019;Predicted Label&#x2019;)</p>
<p>plt.show()</p>
<p>print(&#x201D;Classification Report - ResNet50 Transfer Learning&#x201D;)</p>
<p>print(classification_report(y_true, y_pred_resnet, target_names=[&#x2019;Normal&#x2019;, &#x2018;Pneumonia&#x2019;]))</p>
<p><bold>XXI STEP 21:</bold></p>
<p># Step 21: Sample Predictions Visualization</p>
<p>import random</p>
<p>import os</p>
<p># Get filenames from test set</p>
<p>filenames = test_generator.filenames</p>
<p>true_labels = test_generator.classes</p>
<p>class_labels = list(test_generator.class_indices.keys())</p>
<p># Pick 9 random samples</p>
<p>plt.figure(figsize=(12, 12))</p>
<p>for i in range(9): idx = random.randint(0, len(filenames) - 1)</p>
<p>img_path = os.path.join(test_dir, filenames[idx])</p>
<p># Load and preprocess the image (resize to 224x224 for ResNet50)</p>
<p>img = tf.keras.utils.load_img(img_path, target_size=(224, 224))</p>
<p>img_array = tf.keras.utils.img_to_array(img) / 255.0</p>
<p>img_array = np.expand_dims(img_array, axis=0)</p>
<p># Prediction</p>
<p>pred_prob = model.predict(img_array, verbose=0)[0][0]</p>
<p>pred_class = 1 if pred_prob &#x003E; 0.5 else 0</p>
<p># Plot</p>
<p>plt.subplot(3, 3, i + 1)</p>
<p>plt.imshow(tf.keras.utils.load_img(img_path, target_size=(224, 224)))</p>
<p>plt.axis(&#x201D;off&#x201D;)</p>
<p>plt.title(</p>
<p>f&#x201D;Actual: {class_labels[true_labels[idx]]}\nPredicted: {class_labels[pred_class]} ({pred_prob:.2f})&#x201D;,</p>
<p>color=&#x201D;green&#x201D; if pred_class == true_labels[idx] else &#x201C;red&#x201D;</p>
<p>)</p>
<p>plt.suptitle(&#x201D;Sample Predictions (Green = Correct, Red = Wrong)&#x201D;, fontsize=16)</p>
<p>plt.tight_layout()</p>
<p>plt.show()</p>
<p><bold>XXII STEP 22:</bold></p>
<p># Step 22: Compare Both Models(Compare Baseline CNN vs ResNet50)</p>
<p>loss_base, acc_base = baseline_model.evaluate(test_generator, verbose=0)</p>
<p>loss_resnet, acc_resnet = model.evaluate(test_generator, verbose=0)</p>
<p>print(&#x201D;?? Model Performance Comparison:&#x201D;)</p>
<p>print(f&#x201D;Baseline CNN Accuracy: {acc_base&#x002A;100:.2f}%&#x201D;)</p>
<p>print(f&#x201D;ResNet50 Transfer Learning Accuracy: {acc_resnet&#x002A;100:.2f}%&#x201D;)</p>
</app>
</app-group>
</back>
</article>
