0% found this document useful (0 votes)
8 views86 pages

CSE C-18 Updated Report

The document presents a project report on a hybrid transfer learning model for predicting Chronic Kidney Disease (CKD) using DenseNet121 and InceptionV3, submitted for a Bachelor of Technology degree in Computer Science and Engineering. It outlines the project's objectives, methodologies, and outcomes, highlighting the model's accuracy of 98.9% and its potential for early CKD detection. The report emphasizes the importance of effective education and research in the field of Computer Science and Engineering, as well as the ethical responsibilities of professionals.

Uploaded by

ramabathinadiesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views86 pages

CSE C-18 Updated Report

The document presents a project report on a hybrid transfer learning model for predicting Chronic Kidney Disease (CKD) using DenseNet121 and InceptionV3, submitted for a Bachelor of Technology degree in Computer Science and Engineering. It outlines the project's objectives, methodologies, and outcomes, highlighting the model's accuracy of 98.9% and its potential for early CKD detection. The report emphasizes the importance of effective education and research in the field of Computer Science and Engineering, as well as the ethical responsibilities of professionals.

Uploaded by

ramabathinadiesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 86

A HYBRID TRANSFER LEARNING MODEL FOR

PREDICTING CHRONIC KIDNEY DISEASE USING


DENSENET121 AND INCEPTIONV3
A Project Report Submitted to

JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY ANANTAPUR

In partial fulfillment of the requirements for the Award of the degree of

BACHELOR OF TECHNOLOGY
IN
COMPUTER SCIENCE AND ENGINEERING

Submitted by
Batch No-C18

NAGURU FATHIMA (21121A05G8)


SANGEETHAM PAVANI (21121A05M5)
MENDA MAHESH (21121A05F1)
MUNAGAPATI LIKHITHA (21121A05G1)

Under the Guidance of

Dr. P. Dhana Lakshmi


Professor
Department of CSE

Department of Computer Science and Engineering


SREE VIDYANIKETHAN ENGINEERING COLLEGE
Sree Sainath Nagar, Tirupati – 517 102
(2021-2025)
DEPARTMENT OF COMPUTER SCIENCE AND
ENGINEERING
VISION AND MISSION

VISION
To become a Centre of Excellence in Computer Science and
Engineering by imparting high quality education through teaching, training
and research.

MISSION
 The Department of Computer Science and Engineering is established
to provide undergraduate and graduate education in the field of
Computer Science and Engineering to students with diverse
background in foundations of software and hardware through a broad
curriculum and strongly focused on developing advanced knowledge
to become future leaders.

 Create knowledge of advanced concepts, innovative technologies and


develop research aptitude for contributing to the needs of industry
and society.

 Develop professional and soft skills for improved knowledge and


employability of students.

 Encourage students to engage in life-long learning to create


awareness of the contemporary developments in computer science
and engineering to become outstanding professionals.

 Develop attitude for ethical and social responsibilities in professional


practice at regional, National and International levels

i
PROGRAM EDUCATIONAL OBJECTIVES (PEO’S)

1. Pursuing higher studies in Computer Science and Engineering and related


disciplines

2. Employed in reputed Computer and I.T organizations and Government or


have established startup companies.

3. Able to demonstrate effective communication, engage in team work,


exhibit leadership skills, ethical attitude, and achieve professional
advancement through continuing education.
PROGRAM SPECIFIC OUTCOMES (PSO’S)

1. Demonstrate knowledge in Data structures and Algorithms, Operating


Systems, Database Systems, Software Engineering, Programming Languages,
Digital systems, Theoretical Computer Science, and Computer Networks.
(PO1)

2. Analyze complex engineering problems and identify algorithms for providing


solutions (PO2)

3. Provide solutions for complex engineering problems by analysis,


interpretation of data, and development of algorithms to meet the desired
needs of industry and society. (PO3, PO4)

4. Select and Apply appropriate techniques and tools to complex engineering


problems in the domain of computer software and computer based system

iii
PROGRAM OUTCOMES (PO’S)

1. Apply the knowledge of mathematics, science, engineering


fundamentals, and an engineering specialization to the solution of
complex engineering problems (Engineering knowledge).

2. Identify, formulate, review research literature, and analyze complex


engineering problems reaching substantiated conclusions using first
principles of mathematics, natural sciences, and engineering sciences
(Problem analysis).

3. Design solutions for complex engineering problems and design system


components or processes that meet the specified needs with appropriate
consideration for the public health and safety, and the cultural, societal,
and environmental considerations (Design/development of
solutions).

4. Use research-based knowledge and research methods including design


of experiments, analysis and interpretation of data, and synthesis of the
information to provide valid conclusions (Conduct investigations of
complex problems).

5. Create, select, and apply appropriate techniques, resources, and


modern engineering and IT tools including prediction and modeling to
complex engineering activities with an understanding of the limitations
(Modern tool usage)

6. Apply reasoning informed by the contextual knowledge to assess


societal, health, safety, legal and cultural issues and the consequent
responsibilities relevant to the professional engineering practice (The
engineer and society)

iv
7. Understand the impact of the professional engineering solutions in
societal and environmental contexts, and demonstrate the knowledge of,
and need for sustainable development (Environment and
sustainability).

8. Apply ethical principles and commit to professional ethics and


responsibilities and norms of the engineering practice (Ethics).

9. Function effectively as an individual, and as a member or leader in


diverse teams, and in multidisciplinary settings (Individual and team
work).

10. Communicate effectively on complex engineering activities with the


engineering community and with society at large, such as, being able to
comprehend and write effective reports and design documentation, make
effective presentations, and give and receive clear instructions
(Communication).

11. Demonstrate knowledge and understanding of the engineering and


management principles and apply these to one’s own work, as a member
and leader in a team, to manage projects and in multidisciplinary
environments (Project management and finance).

12. Recognize the need for, and have the preparation and ability to
engage in independent and life-long learning in the broadest context of
technological change (Life-long learning).

v
COURSE OUTCOMES (CO’S)

CO1. Knowledge on the project topic (PO1)

CO2. Analytical ability exercised in the project work.(PO2) CO3. Design skills

applied on the project topic. (PO3)

CO4. Ability to investigate and solve complex engineering problems faced


during the project work. (PO4)

CO5. Ability to apply tools and techniques to complex engineering activities


with an understanding of limitations in the project work. (PO5)

CO6. Ability to provide solutions as per societal needs with consideration to


health, safety, legal and cultural issues considered in the project work. (PO6)

CO7. Understanding of the impact of the professional engineering solutions in


environmental context and need for sustainable development experienced
during the project work. (PO7)

CO8. Ability to apply ethics and norms of the engineering practice as applied
in the project work.(PO8)

CO9. Ability to function effectively as an individual as experienced during the


project work. (PO9)

CO10. Ability to present views cogently and precisely on the project work.
(PO10)

CO11. Project management skills as applied in the project work. (PO11)

CO12. Ability to engage in life-long leaning as experience during the project


work. (PO12)

vi
CO-PO Mapping

(Note: 3-High, 2-Medium, 1-Low)

vii
DECLARATION

We hereby declare that the project report titled A hybrid transfer


learning model for predicting chronic kidney disease using
Densenet121 and Inceptionv3 is the genuine work carried out by us, in
B.Tech(Computer Science and Engineering) degree course of
JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY ANANTAPUR and
has not been submitted to any other college or University for the award of
any degree or diploma.

We declare that this written submission represents our ideas in our own
words and where others' ideas or words have been included, we have
adequately cited and referenced the original sources. We also declare that we
have adhered to all principles of academic honesty and integrity and have not
misrepresented or fabricated or falsified any idea / data / fact / source in our
submission. We understand that any violation of the above will be cause for
disciplinary action by the Institute and can also evoke penal action from the
sources which have thus not been properly cited or from whom proper
permission has not been taken when needed.

Signature of the students

1. NAGURU FATHIMA

2. SANGEETHAM PAVANI

3. MENDA MAHESH

4. MUNAGAPATI LIKHITHA

viii
SREE VIDYANIKETHAN ENGINEERING COLLEGE
(Affiliated to JNTUA, Ananthapuramu, Approved by AICTE,
Accredited by NBA & NAAC)
Sree Sainath Nagar, Tirupati – 517 102, A.P., INDIA

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

CERTIFICATE
This is to certify that the project report entitled

A HYBRID TRANSFER LEARNING MODEL FOR PREDICTING


CHRONIC KIDNEY DISEASE USING DENSENET121 AND
INCEPTIONV3
is the Bonafide work done by

NAGURU FATHIMA (21121A05G8)


SANGEETHAM PAVANI (21121A05M5)
MENDA MAHESH (21121A05F1)
MUNAGAPATI LIKHITHA (21121A05G1)

In the Department of Computer Science and Engineering, and submitted to


Jawaharlal Nehru Technological University Anantapur, Ananthapuramu in partial
fulfillment of the requirements for the award of the degree of Bachelor of Technology
in Information Technology during the academic year 2024-2025.
This work has been carried out under my supervision.
The results of this project work have not been submitted to any university for the
award of any degree or diploma.

Guide: Head:

Dr. P. Dhana Lakshmi Dr. B. NarendraKumar Rao


Professor Professor& Head
Dept. of CSE Dept. of CSE
SVEC SVEC
Tirupati Tirupati

INTERNAL EXAMINER EXTERNAL EXAMINER

ix
ACKNOWLEDGEMENTS

We are extremely thankful to our beloved Chairman and founder Dr. M.


Mohan Babu who took keen interest to provide us the infrastructural
facilities for carrying out the project work.

I am extremely thankful to our beloved Chief executive officer Sri Vishnu


Manchu of Sree Vidyanikethan Educational Institutions who took keen
interest in providing better academic facilities in the institution.

We are highly indebted to Dr. Y. Dileep Kumar, Principal of Sree


Vidyanikethan Engineering College for his valuable support and guidance in all
academic matters.

We are very much obliged to Dr. B. Narendrakumar Rao, Professor &


Head, Department of CSE, for providing us the guidance and encouragement
in completion of this project.

We would like to express our indebtedness to the project coordinator, Dr. P.


Dhana Lakshmi, Professor, Department of CSE for his valuable guidance
during the course of project work.

We would like to express our deep sense of gratitude to Dr. P. Dhana


Lakshmi, Professor, Department of CSE, for the constant support and
invaluable guidance provided for the successful completion of the project.

We are also thankful to all the faculty members of the CSE Department, who
have cooperated in carrying out our project. We would like to thank our
parents and friends who have extended their help and encouragement either
directly or indirectly in completion of our project work.

x
ABSTRACT

Chronic Kidney Disease (CKD) is a destructive disorder that causes


kidney function to decline over time. If treatment is not taken in time, kidney
failure will eventually follow. Improving patient outcomes and enabling
immediate treatment depend on early detection and precise CKD prognosis.
Many algorithms, including transfer learning models like VGG16, ResNet,
EfficientNet, CNN, and MobileNet, have been used to predict chronic kidney
disease (CKD). Though these models have demonstrated potential, they
frequently have trouble obtaining high accuracy and generalization on
medical imaging data relating to chronic kidney disease, especially when
dealing with intricate patterns and class imbalances.

In order to overcome these difficulties, a hybrid model for CKD prediction


that combines DenseNet121 and InceptionV3 is suggested. Both InceptionV3
and DenseNet121 improve model performance by extracting multi-scale
features and efficiently capturing hierarchical feature representations. The
model is more capable to handle the subtle characteristics of CKD-related
images and generalize by utilizing transfer learning, which has been
pretrained on numerous image datasets. With a 98.9% accuracy rate and
remarkable F1-score, precision and recall values of 99%, the hybrid
technique performs better than previously employed algorithms. These
findings show how well the model performs, providing an effective choice for
early CKD identification and possible clinical uses.

Keywords - DenseNet121, InceptionV3, Hybrid model, Early detection,


Transfer Learning, Medical image analysis, chronic kidney disease (CKD).

xi
TABLE OF CONTENTS
Title Page No.

ACKNOWLEDGEMENTS x
ABSTRACT xi
TABLE OF CONTENTS
LIST OF FIGURES
LIST OF TABLES
ORGANIZATION OF THESIS
CHAPTER 1 INTRODUCTION 1-7
1.1 Introduction
1.2 Problem Statement
1.3 Motivation
1.4 Objectives of Project Work
CHAPTER 2 LITERATURE REVIEW 8-11
CHAPTER 3 METHODOLOGY 12-26
3.1 Existing Methodology
3.1.1 Convolution Neural Networks(CNN)
3.1.2 VGG16(Visual Geometry Group)
3.1.3. EfficientNetB5
3.2 Proposed Methodology
3.2.1 Overview
3.2.2 Dataset Overview
3.2.3 Data Preprocessing
3.2.4 Hybrid Model Architecture
3.2.5. Performance Evaluation
CHAPTER 4 SYSTEM DESIGN AND IMPLEMENTATION 27-37
4.1 System Design
4.2 UML Diagrams
4.2.1 Sequence Diagram
4.2.2 Activity Diagram
4.2.3 Class Diagram
4.2.4 Usecase Diagram
CHAPTER 5 RESULTS AND DISCUSSION 38-45
CHAPTER 6 CONCLUSION AND FUTURE WORK 46
ABBREVIATIONS 47-48
NOTATIONS 49
REFERENCES 50-52
IMPLEMENTATION 53-61
LIST OF FIGURES

Figure No. Title Page No.


Figure1.1.1 Structure of Kidney 2
Figure1.1.2 Stages of Kidney 4
Figure 1.2 Kidney Architecture 6
Figure3.1.1.1 Architecture of CNN 13
Figure3.1.1.2 Global Max Pooling 13
Figure3.1.1.3 Pseudocode of CNN 14
Figure3.1.2.1 Architecture of VGG16 16
Figure3.1.2.2 Pseudocode of VGG16 17
Figure3.1.3.1 Architecture of EfficientB5 19
Figure3.1.3.2 Pseudocode of EfficientB5 20
Figure3.2.2.1 Class Distribution 21
Figure3.2.3.1 Augumented Images 22
Figure3.2.4.1 Hybrid Model Architecture 23
Figure3.4.4.2 PseudoCode of Hybrid Model 26
Figure4.3.1 Sequence Diagram 31
Figure4.4.1 Activity Diagram 33
Figure4.5.1 Class Diagram 35
Figure4.6.1 Usecase Diagram 36
Figure 5.1 Training and Validation Accuracy 38
Figure 5.2 Training and Validation Loss 39
Figure 5.3 Performance Metrics 40
Figure 5.4 AUC-ROC Curve 41
Figure 5.5 Stone, Cyst and Tumor Images 41
Figure 5.6 Layer wise structure of the hybrid model
combining Densenet121 and InceptionV3 42
Figure 5.7 Number of features extracted per each epoch 43
Figure 5.8 Comparison with other models 44
Figure 5.9 Average Accuracy and Loss comparison 45
LIST OF TABLES

Table No. Title Page No.

5.8 Comparison with other Models…………………............................... 44


Organization of Thesis

This thesis focuses on building a deep learning model to predict Chronic


Kidney Disease (CKD) from CT scan images. Since detecting kidney issues
early is so important, and manual analysis can be slow or inconsistent, this
work uses artificial intelligence to help doctors make faster and more
accurate decisions.

Chapter 1 Introduces the background and motivation for the study. It


explains different kidney conditions - normal, cyst, tumor, and stone and
discusses the challenges of correctly distinguishing between them. It
highlights the need for AI-based approaches and sets the overall objectives of
the project.

Chapter 2 Reviews previous research and existing techniques related to


kidney disease prediction using medical imaging and deep learning. It
identifies the limitations in current methods and shows how the proposed
work aims to address them.

Chapter 3 Explains how the project was actually carried out. It covers the
data preparation steps like resizing CT images, normalizing pixel values, and
using data augmentation to make the model more robust. It then describes
how two powerful models, DenseNet121 and InceptionV3, were combined to
create a strong feature extractor, leading to better prediction performance.

Chapter 4 Presents the overall system workflow, model architecture, and


technical design. It describes how the feature extraction, merging, and
prediction layers are organized, and discusses considerations like data
privacy, fairness, and system scalability.

Chapter 5 Evaluates the model’s performance using metrics such as accuracy,


precision, recall, F1-score, and ROC curves. It also includes analysis and
visualizations to show how well the model distinguishes between different
kidney conditions.
Chapter 6 Summarizes the findings of the research, discusses the significance
of the results, and suggests future enhancements. It explores possibilities like
expanding the system for real-time medical use, supporting multi-organ
analysis, and integrating the model into cloud platforms for remote
healthcare access.
CHAPTER 1

INTRODUCTION
1.1 Introduction

Chronic Kidney Disease (CKD) is a long-term medical condition in


which the kidneys gradually lose their ability to function properly over time.
The kidneys are vital organs responsible for filtering waste products, excess
fluids, and toxins from the blood, maintaining electrolyte balance, and
regulating blood pressure. When the kidneys become damaged, they cannot
perform these essential functions effectively, leading to a buildup of harmful
substances in the body. CKD is a progressive disease, meaning that without
proper medical intervention, kidney function continues to decline, ultimately
resulting in kidney failure.
At this stage, patients require dialysis or a kidney transplant to survive. CKD
often begins silently, with little to no symptoms in its early stages. It usually
develops as a result of other underlying health conditions that place
excessive strain on the kidneys. The most common causes of CKD are
diabetes and hypertension, both of which damage the delicate blood vessels
in the kidneys, reducing their ability to filter waste efficiently. Over time, this
damage leads to scarring and reduced kidney function.
Other factors, such as chronic infections, autoimmune diseases, genetic
conditions, and prolonged use of certain medications (like non-steroidal anti-
inflammatory drugs), can also contribute to kidney deterioration. Since the
initial stages of CKD are often asymptomatic, many people are unaware that
they have the disease until significant damage has already occurred.Living
with CKD can be physically, emotionally, and financially challenging. As the
disease progresses, patients may experience persistent fatigue, swelling in
different parts of the body due to fluid retention, and frequent urination,
particularly at night.
These symptoms can interfere with daily activities, making it difficult for
individuals to work, exercise, or even complete simple household tasks. In
advanced stages, dietary restrictions become crucial, requiring patients to
limit their intake of salt, potassium, phosphorus, and protein to reduce the
strain on their kidneys. This can significantly impact meal planning and social
eating habits.
1
Dept. of CSE
The financial burden of CKD is also considerable, as patients may need regular
check-ups, medications, and, in severe cases, costly dialysis treatments
multiple times a week. Furthermore, CKD increases the risk of developing
cardiovascular diseases, bone disorders, and mental health issues such as
depression and anxiety, as the chronic nature of the illness affects overall
well-being. To better understand the diseases discussed in this project, the
basic anatomy of the kidney is illustrated in Figure 1.1.1

Fig 1.1.1 Structure of Kidney

Kidney ultrasounds, CT scans, and MRIs are examples of medical imaging


modalities that offer rich visual data that might highlight structural and
functional abnormalities suggestive of chronic kidney disease. Through the
examination of these pictures, machine learning methods are able to find
minute forms and disease-related biomarkers, providing an additional
diagnostic tool to traditional techniques. Nevertheless, there are particular
difficulties in creating reliable and accurate predictive models using medical
imaging data, such as high dimensionality, a lack of labeled datasets, and the
requirement for models that perform well across a variety of patient
demographics.
Additionally, recurrent kidney infections (pyelonephritis) can cause scarring,
while obesity increases the risk of diabetes and hypertension, both of which
contribute to CKD. Long-term use of certain medications, such as non-
steroidal anti-inflammatory drugs (NSAIDs) like ibuprofen and naproxen, can
also damage kidney tissues when used excessively. Other risk factors include

2
Dept. of CSE
smoking, excessive alcohol consumption, and a family history of kidney
disease, all of which can increase susceptibility to CKD.
As CKD progresses, many patients become increasingly dependent on family
members, caregivers, or medical professionals for their daily needs. In later
stages, when dialysis is required, individuals need to visit a hospital or
dialysis center multiple times a week, requiring assistance with
transportation. Those who opt for home dialysis still need support from
trained caregivers or family members. Simple activities such as cooking,
grocery shopping, and household chores become exhausting, forcing patients
to rely on others for help. In severe cases, individuals may need assistance
with mobility, personal hygiene, and medication management.
Many patients experience persistent high blood pressure, shortness of breath,
and muscle cramps, particularly at night. A declining appetite, unintended
weight loss, nausea, and vomiting are also common as toxins accumulate in
the body. Some individuals may suffer from severe itching, dry skin, and
difficulty concentrating (brain fog), making daily tasks challenging. In
advanced stages, anemia can develop due to reduced red blood cell
production, leading to dizziness, cold intolerance, and paleness. If CKD
remains untreated, it can result in fluid overload, lung congestion, seizures,
confusion, and even coma, severely impacting the quality of life. Regular
kidney function tests are essential to detect CKD early and prevent these
complications.
The financial burden of CKD is another major challenge. The cost of
medications, routine tests, and, in advanced stages, dialysis or a kidney
transplant, can be overwhelming, especially for those without adequate
health insurance. This financial strain often leads to increased anxiety and
stress, affecting mental well-being. Individuals with CKD must also follow
strict dietary guidelines, avoiding high-sodium, high-potassium, and high-
protein foods. This makes meal planning difficult, particularly when dining out
or attending social gatherings, leading to feelings of isolation.
Chronic kidney disease progresses through five stages, starting with mild
damage and normal function (Stage 1) to complete kidney failure (Stage 5)
as shown in Fig 1.1.2.
3
Dept. of CSE
As kidney function (measured by eGFR) declines, symptoms become more
noticeable and treatment becomes more intensive, ranging from lifestyle
changes to dialysis or transplant in the final stage.
A branch of machine learning called transfer learning has shown great
promise in tackling these issues. Transfer learning makes use of pre-trained
models, which are frequently created for massive datasets like ImageNet,
and refines them for particular applications like medical image analysis.
Through the use of knowledge acquired in pre-trained models, this method
enables researchers to overcome the restrictions of small datasets, lowering
the time and computer resources needed for training while increasing model
performance. By effectively extracting pertinent information from kidney
pictures, transfer learning can optimize testing models' accuracy and
reliability for CKD prediction.

Fig 1.1.2 Stages of Kidney


To predict CKD, modern transfer learning algorithms are used in conjunction
with an image dataset of kidney scans. To guarantee quality and consistency,
the methodology preprocesses the image data using techniques including
segmentation, augmentation, and normalization. The dataset is then used to
fine-tune already trained CNNs, such VGG16, EfficientNetB5, and Resnet to
identify patterns unique to a given disease. Metrics including AUC-ROC,
specificity, sensitivity, and accuracy are used to examine the predictive
performance of these models. A detailed overview of the kidney structure
along with common causes of kidney diseases is presented in Figure 1.2.

4
Dept. of CSE
The best method for CKD prediction is determined by comparing different
transfer learning models. To get the best results, the entails experimenting
with various architectures, fine-tuning tactics, and hyper parameter
optimization techniques. By improving the results interpretability, this meets
a crucial need for the advantage of machine learning algorithms in
therapeutic circumstances.
Different transfer learning models are compared to determine the most
effective approach for CKD prediction. In order to get optimal outcomes, this
involves testing different architectures, fine-tuning strategies, and
hyperparameter optimization methodologies. This satisfies an important
demand for the application of machine learning techniques in therapeutic
contexts by making the results easier to interpret. Medical imaging
breakthroughs could be greatly aided by these developments in CKD
prognosis and treatment.
With advancements in artificial intelligence, machine learning (ML) and
transfer learning have become powerful tools in the early detection and
prediction of Chronic Kidney Disease (CKD). These technologies help analyze
large datasets, identify patterns, and make accurate predictions, which can
improve early diagnosis, treatment planning, and patient outcomes. By using
transfer learning, healthcare professionals can reduce the need for extensive
data collection, improve prediction accuracy, and speed up diagnosis, making
it a cost-effective solution for CKD detection.

5
Dept. of CSE
Fig 1.2. Kidney Architecture

1.2 Problem Statement

To predict chronic kidney disease from medical images, a hybrid transfer


learning model with DenseNet121 and InceptionV3 is used, where other
traditional deep learning models face challenges in complex patterns and
imbalanced data.

1.3 Motivation

Chronic Kidney Disease (CKD) is a serious health condition that often goes
unnoticed in its early stages due to the lack of clear symptoms. Early
detection plays a key role in slowing down its progression and improving
patient outcomes. However, analyzing CT scan images manually is time-
consuming, requires expert knowledge, and can sometimes lead to errors or
missed details—especially in busy clinical environments. This creates a need
for automated systems that can assist doctors by providing fast, accurate,
and consistent results.

The application of deep learning techniques has shown significant potential in


improving the diagnosis of chronic kidney disease (CKD). By integrating the
6
Dept. of CSE
capabilities of two pre-trained convolutional neural networks, DenseNet121
and InceptionV3, the objective is to develop a robust and efficient diagnostic
system capable of accurately classifying various kidney conditions from CT
imaging data. This methodology aims not only to enhance the accuracy of
disease prediction but also to accelerate the diagnostic workflow, thereby
increasing scalability and accessibility in clinical settings where the availability
of expert radiologists may be limited.

1.4 Objectives of Project Work

 To preprocess CT scan images through resizing, normalization, and data


augmentation to ensure consistent input quality and enhance model
performance.
 To utilize pre-trained deep learning models (DenseNet121 and
InceptionV3) for extracting rich and meaningful features from the
processed images
 To design a hybrid classification model by merging features from both
networks and adding dense layers to classify kidney conditions into
normal, cyst, tumor, and stone.
 To evaluate the model’s effectiveness using performance metrics such as
accuracy, precision, recall, F1-score, and ROC-AUC for validating its
reliability in a medical context.

7
Dept. of CSE
CHAPTER 2
LITERATURE REVIEW
Sohaib Asif [1], proposes two ensemble models, StackedEnsembleNet and
PSOWeightedAvgNet, for kidney stone classification using CT images. A
dataset of 1799 CT scans that were classified as either healthy or kidney
stones was preprocessed using techniques like partitioning, augmentation,
and resizing. Using concatenation and meta-learning with deep layers,
StackedEnsembleNet combines transfer learning models (InceptionV3,
InceptionResNetV2, MobileNet, and Xception). In order to aggregate
predictions from the same basic models, PSOWeightedAvgNet uses Particle
Swarm Optimization (PSO) to optimize a weighted average ensemble. These
strategies improve generalization, resilience, and classification accuracy. The
drawbacks includes it requires more computational power and time to
process.
Monali Gulhane[2], proposed an integrated method combining traditional
machine learning models and Deep Neural Networks to improve kidney stone
detection by capturing both simple and complex patterns in medical data.
This hybrid approach allows for the identification of subtle relationships in
patient history, symptoms, and test results, which are crucial for accurate
diagnosis. The Improved DNN model provides high accuracy and precision,
ensuring early detection and better treatment outcomes. However, it has
limitations with a small dataset and can't fully distinguish between kidney
stone types, finally leading to over fitting.

Feng Zhou [3], proposed diplin model by combining Wasserstein GAN


(WGAN), transfer learning, and EfficientNetV2 for elderly individuals in
nursing homes. It uses WGAN to create synthetic medical images, increasing
the diversity of the dataset, and then preprocesses them to maintain
important properties. Binary cross-entropy loss is then used by the model to
refine an EfficientNetV2 that has already been trained for CKD classification.
Its performance is assessed using AUC, recall, specificity, accuracy, and
precision. The drawbacks include that the models’s reliability is affected by
the limited variety of disease types and insufficient diversity.
Dina Saif [4], developed a deep ensemble model for CKD prediction which it
uses three different algorithms (CNN, LSTM, and LSTM-BLSTM) together to

8
Dept. of CSE
predict kidney disease up to a year. The dataset is collected from Taiwan’s
National Health Insurance Research Database. LSTM manages temporal
relationships, whereas CNN records spatial patterns. The ensemble model
uses majority vote to combine predictions, increasing accuracy. Metrics such
as recall, precision, accuracy, F1-score, and specificity are used to assess the
models; the ensemble model performs better. The drawbacks include it faces
limitations in resource demands and addressing individual risk factors like
family history.
Smith J., Patel R.[5] developed a Random forest model to predict CKD
progression using clinical and laboratory data. The model performed well in
handling complex relationships among features and achieved high accuracy.
However, it struggled with missing values and imbalanced class distribution,
which affected its reliability in certain cases.

Ying Chen [6], uses VGG16 for automated IgA nephropathy image analysis.
Immunofluorescence image features are extracted by VGG16, and the model
is assisted by SE modules. BN layers enhance learning while stabilizing
training. Transfer learning and data augmentation are used to improve
performance as the system classifies IgAN images by combining deep
learning and image feature design. By fusing medical expertise with machine
learning, the approach improves CKD prediction by guaranteeing consistent
results. The drawbacks of this technique is it has challenges with learning
accuracy and concerns about privacy and ethics in AI-based diagnosis.
Kumar P., Singh A.[7] designed a Decision tree-based model for early CKD
detection, leveraging simple rule-based classification. The model was easy to
interpret and provided quick predictions, making it suitable for clinical
settings. However, it tended to overfit when trained on small datasets,
reducing its generalizability and also includes pruning techniques and
ensemble learning approaches to enhance robustness.

Md. Sakib Bin Islam [8], to classify kidney conditions like stones, tumors,
cysts, and normal findings from CT images. The dataset is collected from the
hospital in Bangladesh. Following preprocessing, six models were trained and
assessed, including both conventional models and Visual Transformers. The
9
Dept. of CSE
models were evaluated using ROC-AUC, F1-score, recall, accuracy, and
precision. Important areas of the image were visualized using GradCAM. The
drawbacks include the models may need further refinement for broader
clinical use.
Jyotismita Chaki [9], proposes an ensemble of pre-trained DNNs for
achieving high accuracy in CT images. This approach uses advanced pre-
trained models to extract important details from kidney CT images and
combines these features into a single dataset. It then selects the most useful
features and uses an optimized classifier to detect kidney stones. The method
faces limitations in generalizing to diverse data and lacks the ability to locate
kidney stones within images.

Rodriguez C., Lopez D.[10] implemented a k-nearest neighbors algorithm


for CKD classification using patient symptoms and lab test results. The model
was simple and effective, especially for small datasets, but was highly
sensitive to noisy data and irrelevant features. It also required careful
selection of the number of neighbors (K) to balance accuracy and
computational efficiency and also include automated feature selection and
hybrid models to improve robustness.

Monali Gulhane[11], proposed an integrated method combining traditional


machine learning models and Deep Neural Networks to improve kidney stone
detection by capturing both simple and complex patterns in medical data.
This hybrid approach allows for the identification of subtle relationships in
patient history, symptoms, and test results, which are crucial for accurate
diagnosis. The Improved DNN model provides high accuracy and precision,
ensuring early detection and better treatment outcomes. However, it has
limitations with a small dataset and can't fully distinguish between kidney
stone types, finally leading to over fitting.

Ahmed S., Rahman K.[12] developed an XGBoost model to identify CKD


risk factors from electronic health records. The model achieved high
predictive performance by leveraging gradient boosting and handling missing
data effectively. However, it required careful hyperparameter tuning to

10
Dept. of CSE
prevent overfitting and only focusses on explainability methods such as SHAP
values to enhance clinical trust.

Kailash Kumar [13], developed a hybrid fuzzy deep neural network model
for early-stage CKD prediction. It makes use of a large set of patient records
that have been min-max normalized. A hybrid fuzzy neural network (FNN)
combines neural networks for pattern recognition with fuzzy logic to manage
uncertainty. By examining medical factors, such as Ghrelin levels, this
method forecasts the course of chronic kidney disease (CKD) and resolves
issues with inadequate data, ultimately enhancing CKD diagnosis and
treatment. Drawbacks include this is limited by the small sample size,
requiring larger datasets for more reliable outcomes.
Brown E., Williams G.[14] built a hybrid model combining genetic
algorithms and deep learning for CKD prediction. The genetic algorithm
optimized feature selection, while deep learning enhanced predictive
accuracy. Despite its strong performance, the model was computationally
expensive and required large datasets for training and reducing complexity
through model pruning and knowledge distillation techniques.

Ping Liang[15], developed a deep learning model for predicting CKD


progression to ESRD within 3 years. After being trained on 1765 individuals,
the algorithm can predict ESRD within three years and classify the stages of
CKD. In order to enhance interpretability, attribution techniques such as
Feature Ablation, Gradient SHAP, DeepLIFT, and Integrated Gradients are
used to describe each feature's contribution. The accuracy and explainability
of the DNN model for clinical decision-making are evaluated against those of
conventional machine learning models. The drawbacks include it require
further refinement to improve consistency in feature interpretation.

11
Dept. of CSE
CHAPTER 3
METHODOLOGY
3.1 EXISTING METHODOLOGIES

Chronic Kidney Disease (CKD) is a long-term condition where the kidneys


gradually lose their function over time. It is often caused by conditions like
diabetes and hypertension. Convolutional Neural Networks (CNNs) are used
in medical imaging to detect CKD by analyzing images such as ultrasounds,
CT scans, or MRIs, automatically identifying patterns and abnormalities that
could indicate the disease.

3.1.1Convolutional Neural Networks(CNN):

CNNs help in the early detection of CKD by analyzing medical images for
subtle signs of kidney damage, which may be difficult for human eyes to
detect. By training on large datasets of labeled kidney images, CNN models
can accurately classify stages of CKD. Additionally, CNNs enable automated,
efficient screening, reducing the time and effort needed for diagnosis, and
assisting healthcare professionals in making more accurate decisions. Fig
3.1.1.1 gives the overall architecture of how CNN works to predict Chronic
Kidney Disease.
An input image of size 150x150 pixels, representing a cross-sectional scan of
the kidneys, is used as the starting point. The image is passed through
multiple convolution and pooling layers, where the model begins extracting
important low-level features. Convolution layers apply multiple filters to the
input image, detecting patterns such as edges, textures, and shapes that are
essential for identifying abnormalities in kidney structures. After each
convolution operation, a ReLU (Rectified Linear Unit) activation function is
applied to introduce non-linearity, allowing the model to learn complex
representations that would not be possible with purely linear operations.

12
Dept. of CSE
Fig 3.1.1.1 Architecture of CNN
Pooling layers, likely using max-pooling techniques, are used after
convolution to down-sample the feature maps. This reduces the spatial
dimensions of the data, decreasing the computational load and helping to
prevent overfitting. Global Max Pooling, as shown in Fig 3.1.1.2 also makes
the detection of features more invariant to slight translations and distortions
in the input images. As the image passes through successive convolution and
pooling stages, the model learns increasingly abstract and high-level features
that represent important aspects of the kidney scans relevant for detecting
Chronic Kidney Disease (CKD).

Fig 3.1.1.2 Global max Pooling

13
Dept. of CSE
After feature extraction, the final set of feature maps is flattened into a one-
dimensional vector. This vector is then passed through fully connected layers,
where neurons combine the learned features to make the final classification
decision. The output layer produces a probability score indicating whether the
input image corresponds to a CKD case or a Non-CKD case. Through this
layered learning process, the model is able to automatically identify and
classify kidney scans, aiding in the early detection and diagnosis of
Chronic Kidney Disease. The pseudocode for CNN is outlined in Fig 3.1.1.3,
which describes the process of image preprocessing, feature extraction, and
classification, where D is the dataset path, (H, W) are the image dimensions,
B is the batch size, and E is the number of training epochs. D_train and D_val
represent the training and validation splits of the dataset, while θ denotes the
model parameters optimized using the Adam optimizer.

Pseudocode:

Fig 3.1.1.3 Pseudocode for CNN

14
Dept. of CSE
While CNNs are highly effective in detecting patterns from medical images for
CKD prediction, they come with notable limitations. They require large, well-
annotated datasets and significant computational power, making them less
accessible in resource-constrained settings. Overfitting is a common issue
with limited data, and their lack of interpretability can hinder clinical trust.
Additionally, differences in imaging protocols can impact model
generalization, and relying solely on image data may overlook important
clinical information. Addressing these challenges through better data
integration, interpretability methods, and robust model design is essential for
advancing CNN-based CKD diagnostics.

3.1.2 VGG16(Visual Geometry Group)

VGG16 is a deep convolutional neural network (CNN) architecture that is


often used for image classification tasks, including medical image analysis. In
the context of CKD prediction, VGG16 can be utilized to extract hierarchical
features from kidney images, helping identify early signs of the disease. It
consists of stacked convolutional layers followed by fully connected layers,
makes it suitable for transfer learning when applied to CKD prediction. Fig
3.1.2.1 gives the overall architecture of how VGG16 works to predict Chronic
Kidney Disease.
The CT Scan image is first passed through a convolution layer, where multiple
filters are applied to extract important visual features like edges, textures,
and shapes. These filters help the network recognize structural patterns that
could indicate kidney abnormalities. Immediately after convolution, an
activation function — specifically the ReLU function (Rectified Linear Unit,
defined as f(x) = max(0, x)) — is applied to introduce non-linearity, allowing
the model to learn more complex and varied patterns that exist in kidney
imaging data.

15
Dept. of CSE
Fig 3.1.2.1 Architecture of VGG16

Following the activation step, the data moves into a pooling layer, which
reduces the spatial dimensions of the feature maps while retaining the most
important information. This step, often done using max-pooling, makes the
feature detection process more efficient and helps the model become less
sensitive to minor variations in the input image. By compressing the feature
maps, pooling not only speeds up computation but also helps in minimizing
overfitting, which is crucial when working with relatively small datasets in the
medical domain. After pooling, the extracted features represent a
compressed and meaningful summary of the input kidney scan.

The pooled feature maps are then passed into a fully connected layer, where
all neurons are interconnected to learn the final high-level representations
necessary for classification. A softmax activation function is applied to the
output of the fully connected layers, converting the raw model outputs into
probability scores for each class (e.g., CKD or Non-CKD). The final output
layer presents the classification result based on the highest probability score,
thereby assisting in automatically diagnosing Chronic Kidney Disease from
medical images. This entire pipeline helps streamline CKD detection, offering
potential support for early diagnosis and timely treatment planning. The

16
Dept. of CSE
Pseudocode for VGG16 is outlined in Fig 3.1.2.2, which describes the process
of image preprocessing, feature extraction, and classification, where
train_data and val_data are the training and validation datasets for training
the VGG16-based CKD model. M₀ is the pretrained VGG16 model, M₆ is the
modified model with custom layers, α is the learning rate, and E is the
number of epochs.

Pseudocode:

Fig 3.1.2.2 Pseudocode of VGG16

While pretrained VGG16 offer strong performance in CKD prediction through


transfer learning, they also present several limitations. These architectures
are computationally intensive and require significant memory, making them
less ideal for deployment in real-time or low-resource clinical settings. VGG
models also have a large number of parameters, increasing the risk of
overfitting, especially when trained on relatively small or imbalanced datasets

17
Dept. of CSE
Like those from PACS systems. Additionally, they lack built-in mechanisms for
handling variability in medical imaging quality, and their limited
interpretability can pose challenges in clinical validation and trust. Despite
their success in feature extraction, newer and more efficient architectures
may offer better performance with lower computational cost.

3.1.3 EfficientNetB5

EfficientNet-B5 is a state-of-the-art convolutional neural network (CNN)


known for its efficiency in terms of accuracy and computational cost.
EfficientNet-B5 can be used to analyze kidney images, as its architecture is
designed to balance model size and performance. It excels in extracting
relevant features from medical images, enabling accurate and faster
identification of CKD. Fig 3.1.3.1 gives the overall architecture of how
EfficientNetB5 works to predict Chronic Kidney Disease.
The kidney CT scan as the input image is first passed through a data
preprocessing stage. This stage involves rescaling and normalization of pixel
values to ensure that the data is properly scaled and standardized for
efficient learning. Preprocessing helps improve model performance and
stability by making the input images consistent. After preprocessing, the
dataset is split into training data and testing data, ensuring that the model
can learn from one set and be evaluated on another unseen set for fair
performance measurement.

18
Dept. of CSE
Fig 3.1.3.1 Architecture of EfficientB5

Inside the EfficientNetB5 model, the training data goes through several
stages starting with feature extraction, where important patterns like edges,
textures, and organ structures relevant to CKD detection are identified. After
that, batch normalization is applied to speed up training and reduce internal
covariate shifts, leading to a more stable learning process. The convolutional
layers then further extract complex features by applying multiple filters,
helping the model understand deeper patterns in the kidney scans. Finally,
softmax activation is used to produce probabilities for different output
classes, such as CKD or non-CKD.

19
Dept. of CSE
The trained EfficientNetB5 model is then evaluated using the testing data.
The model predicts the output by processing the test images and assigning
them to specific categories based on the learned features. The final output
layer shows the prediction results, helping doctors or systems identify
whether a patient has signs of Chronic Kidney Disease. This end-to-end
system automates the analysis of kidney images, assisting in early detection
and diagnosis of CKD with high accuracy. The pseudocode for EfficientNetB5
is outlined in Fig 3.1.3.2, which describes the process of image
preprocessing, feature extraction, and classification, where Xtrain, Xval, and
Xtest are the training, validation, and test image datasets, respectively. E is
the number of training epochs and B is the batch size.
Pseudocode

Fig 3.1.3.2 Pseudocode of EfficientNetB5


While pretrained EfficientNet-B5 offers strong CKD prediction performance, it
requires significant computational resources, making it challenging for real-
time or low-resource clinical use. Its large number of parameters can lead to
overfitting on small or imbalanced datasets. Additionally, it lacks mechanisms
to
20
Dept. of CSE
handle variations in image quality and has limited interpretability, which can
hinder clinical validation.

3.2 PROPOSED METHODOLOGY


3.2.1 Overview

It the prediction of Chronic Kidney Disease (CKD) from medical imaging using
a hybrid deep learning model that combines DenseNet121 and InceptionV3.
While many existing methods focus on either shallow feature extraction or
single-model classification, they often fail to capture both fine-grained local
patterns and broader structural features critical for CKD diagnosis. The
proposed hybrid model leverages DenseNet121 for efficient feature
propagation and reuse, while InceptionV3 captures multi-scale spatial
features through parallel convolutions. This fusion enhances the model’s
ability to detect subtle renal abnormalities and improves classification
accuracy. By integrating the strengths of both architectures, the model
supports more robust, interpretable, and clinically relevant CKD prediction.

3.2.2 Dataset Overview

The dataset was gathered from PACS (Picture Archiving and Communication
System) institutes in Dhaka, Bangladesh, where patients had previously been
diagnosed with kidney tumors, cysts, normal results, or stones. Total there
are 12,446 distinct images, of which 3,709 are cyst-related, 1,377 are
stones, 2,283 are tumors and 5,077 are normal as shown in Fig 3.2.2.1

Fig 3.2.2.1 Class Distribution


21
Dept. of CSE
3.2.3 Data Preprocessing

Data augmentation involves applying random transformations to images to


increase dataset diversity. Common techniques include flipping images
horizontally, rotating them slightly, and zooming in or out as shown in Fig
3.2.3.1 All of the images are minimized to 150x150 pixels.

Fig 3.2.3.1 Augmented Images


For image data, the original pixel values typically range from 0 to 255 (for 8-
bit images), and the max value is 255. This scales the pixel values to a
range of 0 to 1.

Auto tuning process optimizes data handling by storing datasets in memory


for faster retrieval and loading data in advance while the model trains. It
ensures smooth, uninterrupted training by minimizing delays, allowing the
model to focus on learning without waiting for data to be processed.

3.2.4 Hybrid Model Architecture

The hybrid model for Chronic Kidney Disease (CKD) prediction integrates two
powerful pre-trained convolutional neural networks—DenseNet121 and
InceptionV3—to enhance feature extraction and classification performance.

22
Dept. of CSE
These models are known for their ability to learn rich, hierarchical features
from medical images and are fine-tuned through transfer learning for the
specific task of CKD classification. The input medical images, such as renal
ultrasound, MRI, or CT scans, are first preprocessed by resizing them to a
fixed dimension of 224×224 pixels. This resizing ensures uniformity across
the dataset and compatibility with both DenseNet121 and InceptionV3
architectures. The pixel values are normalized by dividing by 255, scaling
them to a range between 0 and 1 to improve training stability. The overall
architecture of the hybrid model is illustrated in Fig 3.2.4.1

Fig 3.2.4.1 Hybrid Model Architecture

In the feature extraction stage, only the convolutional layers of both


DenseNet121 and InceptionV3 are used, while the original fully connected
(FC) layers of these models are removed. DenseNet121 captures fine-grained
features using densely connected layers that promote feature reuse, while
InceptionV3 utilizes a multi-branch structure with filters of different sizes to
capture spatial features at multiple scales.

23
Dept. of CSE
These complementary architectures allow the model to extract diverse and
meaningful patterns such as kidney shape, texture irregularities, and
structural abnormalities. The convolutional layers are frozen during training
to retain their pre-trained weights and prevent overfitting on the CKD
dataset.

The output feature maps from both models are passed through Global
Average Pooling layers to reduce their dimensionality while retaining the most
informative statistics. The pooled feature vectors from DenseNet121 and
InceptionV3 are then concatenated to form a unified feature representation
that combines the strengths of both models. This merged vector is then
forwarded through newly added dense layers, starting with a fully connected
layer followed by a ReLU activation function to introduce non-linearity. Batch
normalization is applied to stabilize learning, and a dropout layer is used to
randomly deactivate neurons during training, thus reducing overfitting and
improving generalization.

The final output layer is a dense layer with a softmax activation function that
predicts the probability distribution over four CKD-related classes: cyst,
stone, tumor, and normal. The model is trained using the sparse categorical
cross-entropy loss function, which is suitable for multi-class classification with
integer-encoded labels. The pseudocode outlining the training procedure is
provided in Fig 3.2.4.2 The Adam optimizer is employed for efficient and
adaptive gradient-based optimization. An early stopping strategy is used
along with a learning rate scheduler to ensure efficient convergence during
training.

24
Dept. of CSE
The Adam Optimizer, sparse categorical cross-entropy loss, and accuracy are
used to evaluate the hybrid model, Adam Optimizer combines adaptive
learning rates with momentum to optimize well.

Sparse Categorical Cross-Entropy Loss: The entropy loss is measured


using the following formula.

To evaluate the model's performance, metrics such as accuracy, precision,


recall, and F1-score are calculated on a separate validation dataset. These
metrics provide insights into the model’s classification quality and its ability to
distinguish between different CKD conditions. The use of data augmentation
techniques like rotation, flipping, and brightness adjustment during training
further enhances the robustness of the model by simulating real-world
variations in medical imaging.

This hybrid approach, by combining DenseNet121 and InceptionV3,


successfully leverages the strengths of both architectures for superior feature
learning and classification. It demonstrates an efficient and accurate
framework for CKD prediction from medical images, supporting early
diagnosis and personalized treatment planning in clinical settings.

The pseudocode for EfficientNetB5 is outlined in Fig 3.2.4.2, which describes


the process of image preprocessing, feature extraction, and classification,
where Dtrain and Dval represent the training and validation datasets, while E,
B, and α denote the number of epochs, batch size, and learning rate,
respectively.X is the input layer, and Fconcat is the concatenated feature
output from DenseNet121 and InceptionV3 models used to build the hybrid
model.

25
Dept. of CSE
Fig 3.2.4.2 Pseudocode of hybrid Model

26
Dept. of CSE
CHAPTER 4
SYSTEM DESIGN
4.1 System Design:

Data is first loaded from medical imaging datasets, such as MRI images,
aimed at predicting Chronic Kidney Disease (CKD). OpenCV is used for
loading and resizing the images, NumPy is utilized for numerical processing,
and TensorFlow is employed for model development and training. During
preprocessing, all images are resized to a uniform 150x150 pixels and
normalized to ensure consistent input into the model. To improve robustness
and generalization, data augmentation techniques like rotation, zoom, and
horizontal flipping are applied. Auto-tuning is implemented to cache datasets
in memory and preload them during training, reducing delays and ensuring
smoother model updates. The dataset is split into training and validation sets
while maintaining a balanced distribution across the different classes.

A hybrid transfer learning approach combining DenseNet121 and InceptionV3


is used to develop the model. Images are resized, normalized, and
augmented before being fed into the model. Both DenseNet121 and
InceptionV3, pretrained on ImageNet, serve as frozen feature extractors,
outputting deep features through global average pooling. These features are
concatenated to create a fused feature vector that captures the strengths of
both models. A dense classification head is added, consisting of a 512-unit
dense layer with ReLU activation, followed by batch normalization, dropout,
and a softmax output layer for four-class prediction. Sparse categorical cross-
entropy is used as the loss function, and the Adam optimizer ensures efficient
training convergence.

Training parameters are initialized before the training process begins to guide
model learning effectively. The number of epochs is typically set to 10,
allowing the model multiple passes over the entire dataset to learn patterns
thoroughly. A batch size of 32 is selected to optimize between computational
efficiency and stability during training updates. The learning rate is carefully
chosen to control the size of updates to the model weights after each batch.
Setting these parameters properly ensures that the model learns efficiently

27
Dept. of CSE
without overfitting or getting stuck in local minima. Together, they form the
backbone of a stable training strategy.

During training, CKD medical images are passed through the convolutional
layers of DenseNet121 and InceptionV3 for deep feature extraction. The
features are fused and sent through the dense layers to classify images into
categories like cyst, stone, tumor, or normal. The model calculates sparse
categorical cross-entropy loss by comparing predicted labels to actual labels,
indicating how well the model is performing. Backpropagation is applied to
update the weights of newly added layers, while the pre-trained convolutional
layers remain frozen. Training progresses across several epochs, and
performance is evaluated after each epoch using metrics like accuracy,
precision, recall, and F1-score. This monitoring helps fine-tune the model
progressively toward better results.

Once training is complete, the hybrid model is evaluated on the test data
using a variety of performance metrics. Accuracy measures the percentage of
correctly classified instances out of all predictions made by the model.
Precision evaluates the proportion of true positive results among all positive
predictions, while recall focuses on the proportion of true positives detected
among all actual positives. The F1-score, which balances precision and recall,
offers a more comprehensive performance overview. Additionally, the AUC-
ROC curve is plotted to assess the model’s capability to distinguish between
different classes by analyzing the true positive rate versus the false positive
rate. These evaluations provide a detailed understanding of the model's
effectiveness.

If the performance metrics are found to be below expectations, the model


undergoes further tuning by adjusting hyperparameters like learning rate,
batch size, or augmentation strategies. Retraining with new configurations
helps the model better capture the underlying patterns in the data and
improve its predictive capabilities. This iterative refinement ensures that the
model achieves optimal accuracy, precision, recall, F1-score, and AUC-ROC

28
Dept. of CSE
Values. Ultimately, the goal is to deliver a robust and reliable hybrid model
for Chronic Kidney Disease prediction based on medical imaging. The
continuous improvement loop ensures the final model is both accurate and
dependable for clinical applications.

4.2 UML Diagrams

UML (Unified Modeling Language) diagrams are essential tools in our chronic
kidney disease (CKD) prediction project for visualizing system components
and workflows. They help in designing the system’s architecture and
capturing the interactions between different elements. By using UML
diagrams, we can clearly define functional requirements, class structures, and
data flows. These diagrams also assist in understanding the step-by-step
processes involved in CKD prediction.

A sequence diagram is crucial in our CKD prediction project for illustrating the
interactions between system components over time. It shows how data flows
through the system, detailing the sequence of operations from medical image
input to CKD prediction. By mapping out the exchanges between the feature
extraction models, classification layers, and output generation, it provides a
clear view of the system’s behavior. This diagram helps ensure that the
process is well-understood and efficiently executed. Ultimately, it enhances
communication and guides system development.

An activity diagram is used to model the workflow of the CKD prediction


process in our project. It provides a visual representation of the sequence of
actions, from data acquisition and preprocessing to model evaluation and
prediction. The diagram outlines decisions, loops, and parallel processes,
ensuring all steps are logically organized. By visualizing the workflow, we can
identify potential bottlenecks or inefficiencies, making the system more
streamlined. It plays a critical role in guiding the development and improving
the overall user experience.

The class diagram is vital for defining the structure of our CKD prediction
system by modeling its core components. It identifies the system’s main
29
Dept. of CSE
classes, attributes, and the relationships between them, forming the blueprint
for the object-oriented design. This diagram provides insights into how data
will be stored, accessed, and manipulated within the system. It ensures that
the design is well-organized, scalable, and easy to maintain. The class
diagram plays a key role in shaping the foundation of the system’s backend
architecture.

The use case diagram is essential for capturing the functional requirements of
the CKD prediction system. It outlines how different users, such as healthcare
professionals, will interact with the system, specifying the actions they can
perform and the outcomes they expect. By clearly defining the system’s
functionality, it helps in identifying user needs and ensuring the project
meets its objectives. The use case diagram serves as a foundation for
designing the user interface and guiding the system's development process.

4.3 Sequence Diagram

The sequence diagram for the Chronic Kidney Disease (CKD) prediction
system outlines the step-by-step interaction among various entities involved
in the prediction process. The main actors are the Data Scientist, the User,
the Medical Data Source, the CKD Prediction Model, and two deep learning
architectures: DenseNet121 and InceptionV3. This diagram represents how
data and control flow sequentially from the initial data collection phase to the
final validation of prediction results. Fig 4.3.1 gives the clear sequence
diagram to predict CKD.

Initially, the Data Scientist retrieves medical data from the Medical Data
Source and performs preprocessing to ensure data quality and readiness for
model development. Once preprocessing is complete, the CKD Prediction
Model extracts features from the dataset using DenseNet121 and InceptionV3
models. The extracted features are then returned and combined to create a
robust feature set that enhances the training of the hybrid CKD prediction
model.

30
Dept. of CSE
Fig 4.3.1 Sequence Diagram

Subsequently, the Data Scientist proceeds to train the hybrid model using the
combined features. After successful training, the model is provided to the
User for making new predictions. When the User submits new data, the
system again performs feature extraction through DenseNet121 and
InceptionV3, combines these features, and generates the final prediction
based on the trained hybrid model.

Finally, the User receives the prediction results and validates them to ensure
the model’s reliability and accuracy in real-world conditions. This structured
sequence ensures a systematic and logical flow of operations within the CKD

31
Dept. of CSE
prediction framework, making the system reliable, transparent, and efficient
for practical use.

4.4 Activity Diagram

An activity diagram for CKD prediction visually outlines the sequence of steps
from data collection to disease prediction. It shows how data scientists,
models, and users interact at each stage. This helps in clearly understanding,
organizing, and optimizing the CKD detection process. Fig 4.4.1 gives the
clear Activity diagram to predict CKD.

Participants (Swimlanes)

1. Data Scientist
2. CKD Prediction Model
3. User

Each participant has its own responsibilities in the prediction workflow.

The data scientist collects raw medical data and transforms it through precise
preprocessing to build a strong foundation for the model. With clean and
structured data in hand, the model begins its work by extracting meaningful
features using two advanced convolutional neural networks: DenseNet121
and InceptionV3. Each network captures different patterns and characteristics
from the data, and their outputs are intelligently combined to create a richer,
more detailed feature set. This fusion of features strengthens the model’s
ability to detect subtle signs of chronic kidney disease that might otherwise
be missed.

Once the feature extraction and combination are complete, a hybrid model is
trained using this enhanced information. The data scientist then rigorously
evaluates the model’s performance, ensuring it meets high standards of
accuracy, reliability, and robustness. After successful validation, the model is
finalized and prepared for deployment. The emphasis on combining multiple

32
Dept. of CSE
feature extractors and thorough evaluation ensures that the model is not only
powerful but also generalizes well to unseen patient cases.

Fig 4.4.1 Activity Diagram

The final stage involves handing the trained hybrid model over to the user.
Users input new medical data into the system, where it undergoes the same
dual feature extraction and merging process before the model generates a
prediction. These predictions are then validated in real-world settings, either
by clinical professionals or through further diagnostic testing. This
streamlined collaboration between data science, deep learning, and user
validation creates a strong, efficient pipeline for early and accurate CKD
prediction.

33
Dept. of CSE
4.5 Class Diagram

The class diagram represents the architectural blueprint of the Chronic Kidney
Disease (CKD) prediction system. It illustrates the key components, their
attributes, operations, and relationships, helping to ensure the system’s
design is modular, scalable, and maintainable. Fig 4.5.1 gives the clear Class
diagram to predict CKD.

The system begins with the DatasetLoader class, which is responsible for
loading the raw medical dataset and splitting it into training and validation
subsets. This structured dataset is then passed to the ImagePreprocessor
class, where images or data samples are resized, normalized, and optionally
augmented to enhance model performance. The preprocessed data is then
fed into the HybridModel class, which serves as the core of the system.

This model integrates two powerful feature extraction networks —


DenseNet121 and InceptionV3 — and combines their outputs to form a
merged model capable of robust CKD detection. The HybridModel supports
key operations such as building individual models, combining features,
training with datasets, and performing forward passes.

34
Dept. of CSE
Fig 4.5.1 Class Diagram

To train the model effectively, the ModelTrainer class orchestrates the


training process and allows the saving of the trained model for future use.
Post-training, the ModelEvaluator class is utilized to assess the performance
of the hybrid model on the validation set, calculating essential metrics like
accuracy, precision, and recall.

Finally, the ImagePredictor class uses the trained hybrid model to make real-
time predictions on new patient data and facilitates the loading of saved
model for inference.

35
Dept. of CSE
4.6 Usecase Diagram

The use case diagram for the Chronic Kidney Disease (CKD) prediction
system highlights the key interactions between different actors and the
system functionalities. It offers a clear representation of how various entities
work together to accomplish the overall goal of developing and utilizing a
predictive model for CKD. The main actors involved are the Medical Data
Source, Data Scientist, CKD Prediction Model, and the User. Fig 4.6.1 gives
the clear usecase diagram to predict CKD.

Initially, the Medical Data Source and the Data Scientist collaborate to
preprocess the raw medical data to ensure its quality and usability. The Data
Scientist then uses this prepared data to train the prediction model and
further evaluates the model's performance to ensure it meets the necessary
accuracy standards. The CKD Prediction Model is central to making
predictions once the training process is complete.

Fig 4.6.1 Usecase Diagram

36
Dept. of CSE
Following model training, the User interacts with the system to make new
predictions based on unseen data. After predictions are generated, the User
also validates the results to assess their clinical reliability and relevance. Each
use case — Preprocessing Data, Training Model, Evaluating Model, Making
Predictions, and Validating Results — is critical for ensuring the system
functions effectively and meets its objective of accurately predicting CKD.

This structured flow of activities and actor interactions, as represented in the


use case diagram, ensures that the CKD prediction system is both efficient
and user-centric, addressing both technical performance and real-world
application needs.

37
Dept. of CSE
CHAPTER 5

RESULTS AND DISCUSSION


Using a random seed for reproducibility, the dataset is divided into training
(80%, or 11202 files) and validation (20%, or 2489 files). The training
images are randomly flipped, rotated, and zoomed to increase the model's
adaptability and provide more varied instances for improved learning. In
order to ensure consistency in the data input into the model for better
performance, the pixel values are then scaled down from the range 0-255 to
0-1.

Evaluation Metrics:

Following training, metrics such as accuracy, precision, recall, F1 score,


confusion matrix and AUC-ROC curve are used to assess the model's
performance. These measurements offer a thorough grasp of the model's
performance in several areas. When combined, they aid in identifying areas
of strength and growth. Fig 5.1 gives the performance obtained by the model
using performance metrics such as precision, Recall, F1-score.
Accuracy: Accuracy is defined as the proportion of correct estimates to all
estimates. The frequency with which the model's estimated class corresponds
to the actual label is measured.

The model learns well and performs well on new data, as evidenced by the
accuracy increasing progressively during the first few epochs, with both
training and validation accuracy reaching roughly 98–99% as shown in the fig
5.1.

Fig 5.1 Training and Validation Accuracy

Dept. of CSE 38
In addition, the loss drops rapidly at first and then remains low, indicating
that the model produces relatively few errors as shown in the fig 5.2. The
model avoids overfitting and performs consistently, as evidenced by the
similarity between training and validation results.

Fig 5.2 Training and Validation Loss

Precision: 99% of the cases that are predicted to have CKD are indeed CKD-
positive, according to the model precision. By reducing false positives, this
high precision helps to prevent healthy people from receiving an inaccurate
CKD diagnosis.

Recall: The model accurately recognizes 99% of all real CKD cases, with a
recall of 99%. This shows how well the model can identify CKD patients,
which is important for early diagnosis and care.

F1 score: An F1-Score of 99% indicates that recall and precision are well-
balanced. This suggests that the model is very dependable for clinical usage
since it does a good job of both detecting actual CKD cases and preventing
misclassification as shown in the fig 5.3.

39
Dept. of CSE
Fig 5.3 Performance Metrics

AUC ROC Curves:

As illustrated in Fig 5.4, the DenseNet and InceptionV3 model's ROC curve
demonstrates exceptional performance in CKD prediction. The AUC of 1.00
indicates perfect categorization for all classes (0, 1, 2, and 3). Consistent
performance in every class is confirmed by the macro-average AUC of 1.00.
The model is highly reliable for CKD prediction because of its high sensitivity
and low false positive rates, as seen by the curve's location close to the top-
left corner.

False Positive Rate (FPR) for class i:

True Positive Rate (TPR) for class i:

AUC (Area Under the Curve): The classifier's capacity to differentiate


between classes is indicated by the area under the ROC curve, or AUC.
40
Dept. of CSE
Fig 5.4 AUC ROC Curve

The model gives all correct predictions, for example when we pass an image
to the model it correctly categorizes the kidney condition such as cyst,
normal, stone and tumor which is shown in Fig 5.5

Fig 5.5 Stone, Cyst, Tumor Images

The model has around 30 million parameters, but only about 1.5 million
parameters are trainable because the pretrained layers are frozen (not
updated during training) as shown in Fig 5.6. This approach helps the model
train faster and perform better, even with a smaller dataset. By using
pretrained models, we are able to take advantage of their powerful feature
extraction

41
Dept. of CSE
ability without needing to train from scratch. Overall, this hybrid design
improves accuracy and helps the model generalize well to unseen CKD data.

Fig 5.6 Layer-wise Structure of the Hybrid Model


Combining DenseNet121 and InceptionV3
The total number of features extracted per epoch during hybrid model
(Densenet121 and InceptionV3) training is shown in Fig 5.7. 12,446 images
are processed in each epoch, and each image produces 25,600 features
based on the final convolutional layer's output dimensions (5 × 5 × 1024).
Accordingly, roughly 318.6 million characteristics are extracted overall for
each epoch. The graph displays a flat line, signifying that the number of
features each epoch does not change over the course of the 10 epochs while
the dataset and model architecture stay constant during the training phase.

42
Dept. of CSE
Fig 5.7 Number of features extracted per each epoch

Comparing with Previous Models:

In terms of predicting chronic kidney disease (CKD), the hybrid model that
combined DenseNet121 and InceptionV3 outperformed individual models
such as DenseNet121, InceptionV3, EfficientNet, and VGG16. This model
offers a more comprehensive set of characteristics for prediction by utilizing
the feature reuse of DenseNet121 and the multi-scale feature extraction
capabilities of InceptionV3 as shown in the fig 5.8.
DenseNet121 and InceptionV3 were both pretrained on ImageNet, and their
layers were frozen in the hybrid model. After combining their results, more
layers were added to further enhance the features. The model can now
recognize complicated patterns in CKD data because of this method.
Combining the multi-scale feature extraction of InceptionV3 with the feature
reuse of DenseNet121 makes the hybrid model outstanding. This model
catches both varied and complex patterns, which makes it more accurate for
CKD prediction than EfficientNet, which might overlook features, or VGG16,
which is too simplistic.
With a 99.1% accuracy rate, 99% precision, recall, and F1-score, the hybrid
model outperformed the separate models across all important criteria. This

43
Dept. of CSE
demonstrates that the hybrid model is the most effective option for CKD
prediction because to its ability to reduce mistakes. Average Accuracy and
Loss Comparison with other models is explained in graph as shown in Fig 5.9.
In conclusion, integrating DenseNet121 and InceptionV3 improves
performance and generalization, making the hybrid model more dependable
for CKD prediction than the other models

Model Training Validation Training Validation


Accuracy Accuracy Loss Loss

DenseNet& 98.9 99.1 0.033 0.029


InceptionV3

VGG16 97.2 98.8 0.075 0.039


EfficientNet 47.6 29.6 1.227 1.377
InceptionV3 98.4 98.9 0.049 0.037
DenseNet 97.5 98.5 0.076 0.048

Fig 5.8 Comparison with other Models

44
Dept. of CSE
Fig 5.9 Average Accuracy and Loss Comparison

45
Dept. of CSE
CHAPTER 6

CONCLUSION AND FUTURE WORK


Conclusion

The hybrid model that combines DenseNet121 and InceptionV3 shows an


accurate strategy for predicting Chronic Kidney Disease (CKD) by utilizing the
complementing features of these pre trained architectures. InceptionV3
records multi-scale patterns, whereas DenseNet121 effectively recovers
hierarchical features. The combined feature space of these two models
improves prediction accuracy. In terms of precision, recall, and F1-score, the
model performs competitively, demonstrating its capacity to manage class
imbalances and generalize effectively to new data. This set of models
presents a viable way to diagnose chronic kidney disease (CKD), particularly
in medical imaging applications as pathology scans and kidney ultrasounds.
Nevertheless, additional enhancements including data enrichment, dataset
enlargement, and pre trained layer fine-tuning might boost model
performance and dependability. Furthermore, testing the model on external,
real-world datasets and clinical settings will help determine its robustness
and practical applicability, advancing the development of efficient AI-driven
CKD prediction tools for the medical field.

Future Work

Future enhancements aim to further improve the performance,


interpretability, and clinical applicability of the hybrid model. Integrating
attention mechanisms can help the model focus on critical regions of the
kidney, improving feature localization and diagnostic precision. Exploring 3D
imaging data, such as full-volume CT or MRI scans, could provide deeper
spatial context for more accurate CKD staging.

For real-world deployment, adapting the model for cloud or edge


computing would support real-time prediction, particularly useful in
telemedicine and remote healthcare environments. Finally, implementing
explainable AI (XAI) approaches can provide insights into the model’s
decision-making process, increasing clinician trust and facilitating clinical
integration.
46
Dept. of CSE
ABBREVIATIONS

CKD → Chronic Kidney Disease

ML → Machine Learning

DL → Deep Learning

CNN → Convolutional neural Network

VGG → Visual Geometry Group

SMOTE → Synthetic Minority Over-sampling Technique

AI → Artificial Intelligence

SVM → Support Vector Machine

AUC → Area Under the Curve

TL → Transfer Learning

F1-score → F1 Measure (Harmonic Mean of Precision and Recall)

AUC-ROC → Area Under the Receiver Operating Characteristic Curve

CT → Computed Tomography

MRI → Magnetic Resonance Imaging

EHR → Electronic Health Records

XAI → Explainable Artificial Intelligence

ReLu → Rectified Linear Unit

FC → Fully Connected Layer

47
Dept. of CSE
GPU → Graphics Processing Unit

Adam → Adaptive Moment Estimation

TPR → True Positive Rate

FPR → False Positive Rate

PACS → Picture Archiving and Communication System

API → Application Programming Interface

48
Dept. of CSE
NOTATIONS

μ(j) Mean of feature j in the dataset.


σ(j) Standard deviation of feature j.
x ∈ ℝᴴ×ᵂ×ᶜ Input image with height H, width W, and C channels
f_D(x) Feature representation extracted from DenseNet121 for
input image x.
f_I(x) Feature representation extracted from InceptionV3 for
input image x.
f_concat(x) Concatenated feature vector from DenseNet121 and
InceptionV3.
ŷ Predicted class probabilities from the model’s softmax
output.
y Ground truth label corresponding to the input image.
L_CE Cross-entropy loss computed between predicted label ŷ
and true label y.
α Learning rate used by the optimizer (Adam in this case).
Epoch One complete pass through the entire training dataset.
Batch size Number of samples used in one forward/backward pass
T_train Training dataset used for model learning.
T_val Validation dataset used to evaluate model performance.

49
Dept. of CSE
REFERENCES

[1] H. A. Al-Jamimi, "Synergistic Feature Engineering and Ensemble Learning for


Early Chronic Disease Prediction," in IEEE Access, vol. 12, pp. 62215-62233,
2024, doi: 10.1109/ACCESS.2024.3395512.

[2] Gogoi, P., Valan, J.A. Machine learning approaches for predicting and
diagnosing chronic kidney disease: current trends, challenges, solutions, and
future directions. Int Urol Nephrol (2024). https://doi.org/10.1007/s11255-
024-04281-5

[3] P. Liang et al., "Deep Learning Identifies Intelligible Predictors of Poor


Prognosis in Chronic Kidney Disease," in IEEE Journal of Biomedical and
Health Informatics, vol. 27, no. 7, pp. 3677-3685, July 2023, doi:
10.1109/JBHI.2023.3266587.

[4] A. Kumar, L. Nelson and V. S. Venu, "Enhancing Kidney Disease Classification


through Transfer Learning with VGG16," in IEEE Access, vol. 20, doi:
10.1109/IC457434.2024.10486470.

[5] S. A. Shammi, P. Ghosh, A. Sutradhar, F. M. J. M. Shamrat, M. A. Moni and T.


E. A. d. Oliveira, "Advances in Artificial Intelligence and Blockchain
Technologies for Early Detection of Human Diseases," in IEEE Transactions on
Computational Social Systems, doi: 10.1109/TCSS.2024.3449748.

[6] M. Aljaafari, S. E. El-Deep, A. A. Abohany and S. E. Sorour, "Integrating


Innovation in Healthcare: The Evolution of ―CURA’s‖ AI-Driven Virtual Wards
for Enhanced Diabetes and Kidney Disease Monitoring," in IEEE Access, vol.
12, pp. 126389-126414, 2024, doi: 10.1109/ACCESS.2024.3451369.

[7] Gogoi, P., Valan, J.A. Machine learning approaches for predicting and
diagnosing chronic kidney disease: current trends, challenges, solutions, and

50
Dept. of CSE
future directions. Int Urol Nephrol (2024). https://doi.org/10.1007/s11255-
024-04281-5

[8] P. Liang et al., "Deep Learning Identifies Intelligible Predictors of Poor


Prognosis in Chronic Kidney Disease," in IEEE Journal of Biomedical and
Health Informatics, vol. 27, no. 7, pp. 3677-3685, July 2023, doi:
10.1109/JBHI.2023.3266587.

[9] N. Ghaniaviyanto Ramadhan, Adiwijaya, W. Maharani and A. Akbar Gozali,


"Chronic Diseases Prediction Using Machine Learning With Data Preprocessing
Handling," in IEEE Access, vol. 12, pp. 80698-80730, 2024, doi:
10.1109/ACCESS.2024.3406748.

[10] S. K. Behfar, Q. Behfar, and M. Hosseinpour, "Architecture of Data


Anomaly Detection-Enhanced Decentralized Expert System for Early-Stage
Alzheimer's Disease Prediction," arXiv preprint arXiv:2311.00373, 2023.
[Online]. Available: https://arxiv.org/abs/2311.00373.
[11] S. Otoum, I. Al Ridhawi, and H. T. Mouftah, "Preventing and Controlling
Epidemics through Blockchain-Assisted AI-Enabled Networks," arXiv preprint
arXiv:2104.13224, 2021. [Online]. Available:
https://arxiv.org/abs/2104.13224.
[12] V. Stephanie, I. Khalil, M. Atiquzzaman, and X. Yi, "Trustworthy Privacy-
preserving Hierarchical Ensemble and Federated Learning in Healthcare 4.0
with Blockchain," arXiv preprint arXiv:2305.09209, 2023. [Online]. Available:
https://arxiv.org/abs/2305.09209.
[13] A. Hennebelle et al., "Secure and Privacy-Preserving Automated Machine
Learning Operations into End-to-End Integrated IoT-Edge-Artificial
Intelligence-Blockchain Monitoring System for Diabetes Mellitus Prediction,"
arXiv preprint arXiv:2211.07643, 2022. [Online]. Available:
https://arxiv.org/abs/2211.07643.

51
Dept. of CSE
[14] F. Lareyre et al., "Applications of Artificial Intelligence in Non-cardiac
Vascular Diseases: A Bibliographic Analysis," Angiology, vol. 73, no. 8, pp.
695–703, 2022. DOI: 10.1177/00033197211073267.
[15] D. S. Kermany et al., "Identifying Medical Diagnoses and Treatable
Diseases by Image-Based Deep Learning," Cell, vol. 172, no. 5, pp. 1122–
1131.e9, 2018. DOI: 10.1016/j.cell.2018.02.010.

52
Dept. of CSE
Implementation

Code Snippet:

1. Installing packages:

pip install numpy

pip install tensorflow

pip install opencv-python

pip install scikit-learn

2. Installing modules:

import pandas as pd

import numpy as np

import matplotlib.pyplot as plt

import cv2

import tensorflow as tf

import os

from tensorflow import keras

from tensorflow.keras import layers

from tensorflow.python.keras.layers import Dense, Flatten

from tensorflow.keras.models import Sequential

from tensorflow.keras.optimizers import Adam

from tensorflow.keras.layers import Flatten,Dense,Dropout,BatchNormalization

from tensorflow.keras.models import Model,Sequential

from tensorflow.keras.layers import Conv2D, MaxPooling2D

53
Dept. of CSE
from tensorflow.keras.layers import GlobalAveragePooling2D

3.Data preprocessing and cleaning:

#Data Augmentation

data_augmentation = keras.Sequential([

layers.RandomFlip("horizontal"),

layers.RandomRotation(0.1),

layers.RandomZoom(0.1),

])

#Batch Normalization

# Normalize images

normalization_layer = layers.Rescaling(1./255)

normalized_train = train.map(lambda x, y: (normalization_layer(x), y))

normalized_val = val.map(lambda x, y: (normalization_layer(x), y))

train=train.map(lambda x,y:(x/255,y))

val=val.map(lambda x,y:(x/255,y))

#Auto-Tuning

AUTOTUNE = tf.data.AUTOTUNE

train = train.cache().prefetch(buffer_size=AUTOTUNE)

val = val.cache().prefetch(buffer_size=AUTOTUNE)

4. Model training

data_dir="C:\\Users\\WELCOME\\Desktop\\Kidney Disease Prediction\\Dataset\\ckd\\CT-


KIDNEY-DATASET-Normal-Cyst-Tumor-Stone\\CT-KIDNEY-DATASET-Normal-Cyst-Tumor-
Stone"

train=tf.keras.utils.image_dataset_from_directory(data_dir,image_size=(img_height,img_width),

validation_split=0.1,

subset='training',seed=123)

54
Dept. of CSE
val=tf.keras.utils.image_dataset_from_directory(data_dir,image_size=(img_height,img_width),

validation_split=0.2,

subset='validation',seed=123)

5. Model Implementation

from tensorflow.keras import models

from sklearn.metrics import precision_score, recall_score, f1_score, classification_report

from tensorflow.keras.applications import DenseNet121, InceptionV3

# Load pretrained models

densenet = DenseNet121(include_top=False, input_shape=(150, 150, 3), pooling='avg',


weights='imagenet')

inception = InceptionV3(include_top=False, input_shape=(150, 150, 3), pooling='avg',


weights='imagenet')

# Freeze the pretrained models

densenet.trainable = False

inception.trainable = False

# Combine outputs

input_layer = layers.Input(shape=(150, 150, 3))

densenet_features = densenet(input_layer)

inception_features = inception(input_layer)

concat_features = layers.Concatenate()([densenet_features, inception_features])

# Add dense layers

x = layers.Dense(512, activation='relu')(concat_features)

x = layers.BatchNormalization()(x)

55
Dept. of CSE
x = layers.Dropout(0.5)(x)

output_layer = layers.Dense(4, activation='softmax')(x)

# Create model

combined_model = models.Model(inputs=input_layer, outputs=output_layer)

combined_model.compile(optimizer='adam', loss='sparse_categorical_crossentropy',
metrics=['accuracy'])

combined_model.summary()

# Train model

history_combined = combined_model.fit(

train,

validation_data=val,

epochs=10

6. Testing the model

img = cv2.imread(r"C:\Users\datma003\Desktop\projects1\Kidney Stone


Detection\Kidney Stone Detection\Dataset\CT-KIDNEY-DATASET-Normal-Cyst-
Tumor-Stone\Cyst\Cyst- (14).jpg")

plt.imshow(img)

plt.show()

resize = tf.image.resize(img, (150,150))

yhat = model.predict(np.expand_dims(resize/255, 0))

max_index = np.argmax(yhat)

label_to_class_name[max_index]

7. ROC AUC Curve

from sklearn.metrics import roc_curve, auc, roc_auc_score

from sklearn.preprocessing import label_binarize

56
Dept. of CSE
import matplotlib.pyplot as plt

import numpy as np

# Extract true labels and predictions

val_true_labels = []

val_probabilities = []

for images, labels in val: # Loop through the validation dataset

val_true_labels.extend(labels.numpy()) # Convert tensor to numpy and


append

val_probabilities.extend(combined_model.predict(images)) # Predict
probabilities

val_true_labels = np.array(val_true_labels)

val_probabilities = np.array(val_probabilities)

# Binarize the labels for multi-class AUC computation

n_classes = val_probabilities.shape[1] # Number of classes

val_true_labels_binarized = label_binarize(val_true_labels,
classes=np.arange(n_classes))

# Compute AUC for each class

fpr = {}

tpr = {}

roc_auc = {}

for i in range(n_classes):

fpr[i], tpr[i], _ = roc_curve(val_true_labels_binarized[:, i],


val_probabilities[:, i])

roc_auc[i] = auc(fpr[i], tpr[i])

57
Dept. of CSE
# Compute macro-average AUC

fpr["macro"], tpr["macro"], _ = roc_curve(

val_true_labels_binarized.ravel(), val_probabilities.ravel()

roc_auc["macro"] = auc(fpr["macro"], tpr["macro"])

# Plot the ROC curves

plt.figure(figsize=(10, 8))

# Plot ROC for each class

for i in range(n_classes):

plt.plot(

fpr[i],

tpr[i],

label=f"Class {i} (AUC = {roc_auc[i]:.2f})",

# Plot macro-average ROC curve

plt.plot(

fpr["macro"],

plt.title('Training and Validation Loss')

plt.xlabel('Epochs')

plt.ylabel('Loss')

plt.legend()

plt.show()

58
Dept. of CSE
9. Training and Validation Accuracy

# Plot results

plt.plot(history_combined.history['accuracy'], label='Training Accuracy')

plt.plot(history_combined.history['val_accuracy'], label='Validation
Accuracy')

plt.title('DenseNet + InceptionV3 Accuracy')

plt.legend()

plt.show()

# Predict on validation set

val_predictions = np.argmax(combined_model.predict(val), axis=1)

val_true_labels = val.labels # Assuming `val` is a


`tf.keras.preprocessing.image.DirectoryIterator`

# Compute metrics

precision = precision_score(val_true_labels, val_predictions,


average='weighted')

recall = recall_score(val_true_labels, val_predictions, average='weighted')

f1 = f1_score(val_true_labels, val_predictions, average='weighted')

print(f"Precision: {precision:.2f}")

print(f"Recall: {recall:.2f}")

print(f"F1-Score: {f1:.2f}")

# Detailed classification report

print(classification_report(val_true_labels, val_predictions))

10. Other performance Metrics

# Predict on validation set

val_predictions = np.argmax(combined_model.predict(val), axis=1)

59
Dept. of CSE
# Extract true labels from the validation dataset

val_true_labels = []

for _, label in val:

val_true_labels.extend(label.numpy()) # Collect all labels

val_true_labels = np.array(val_true_labels) # Convert list to numpy array

# Compute metrics

precision = precision_score(val_true_labels, val_predictions,


average='weighted')

recall = recall_score(val_true_labels, val_predictions, average='weighted')

f1 = f1_score(val_true_labels, val_predictions, average='weighted')

print(f"Precision: {precision:.2f}")

print(f"Recall: {recall:.2f}")

print(f"F1-Score: {f1:.2f}")

# Detailed classification report

print(classification_report(val_true_labels, val_predictions))

11.Comparison with Other Models:

from tensorflow.keras.applications import EfficientNetB5

efficient_model = Sequential()

pretrained_model = EfficientNetB5(include_top=False,

input_shape=(150, 150, 3),

pooling='max',

60
Dept. of CSE
classes=4,

weights='imagenet')

efficient_model.add(pretrained_model)

efficient_model.add(Flatten())

efficient_model.add(Dense(512, activation='relu'))

efficient_model.add(BatchNormalization()) # Batch Normalization layer

efficient_model.add(Dropout(0.5))

efficient_model.add(Dense(4, activation='softmax'))

pretrained_model.trainable = False

efficient_model.compile(optimizer='adam',
loss='sparse_categorical_crossentropy', metrics=['accuracy'])

efficient_model.summary()

# Training EfficientNet

history_efficient = efficient_model.fit(

train,

validation_data=val,

epochs=15

# Results

plt.plot(history_efficient.history['accuracy'], label='Training Accuracy')

plt.plot(history_efficient.history['val_accuracy'], label='Validation
Accuracy')

plt.title('EfficientNet Accuracy')

plt.legend()

plt.show()

61
Dept. of CSE

You might also like