Miniproject
Miniproject
Miniproject
DEPARTMENT OF
ELECTRONICS & COMMUNICATION
ENGINEERING
®
DEPARTMENT OF
ELECTRONICS AND COMMUNICATION ENGINEERING
CERTIFICATE
Certified that the project work titled “RECOGNITION OF DIABETIC
RETINOPATHY USING CNN ALGORITHM” is carried out by AKSHAT
GUPTA(1RF20EC003),MOHAMMED NADEEM(1RF20EC028), SHIVAM
KUMAR RAI(1RF20EC042), and VIKRANT RANA(1RF20EC053), who are
bonafide students of RV Institute of Technology and Management, Bangalore, in partial
fulfillment for the award of degree of Bachelor of Engineering in Electronics and
Communication Engineering of the Visvesvaraya Technological University, Belagavi during
the year 2022-2023. It is certified that all corrections/suggestions indicated for the internal
Assessment have been incorporated in the report deposited in the departmental library. The
project report has been approved as it satisfies the academic requirements in respect of project
work prescribed by the institution for the said degree.
External Viva
2
RV INSTITUTE OF TECHNOLOGY AND MANAGEMENT®
(Affiliated to Visvesvaraya Technological University, Belagavi & Approved by AICTE, NewDelhi)
Bengaluru-560076
DEPARTMENT OF
ELECTRONICS AND COMMUNICATION ENGINEERING
DECLARATION
Name: Signature:
Place: Bengaluru
1. AKSHAT GUPTA
Date:
2. MOHAMMED NADEEM
4. VIKRANT RANA
ACKNOWLEDGEMENT
We would like to thank our Project Guide, Dr. Kavitha N, Assistant Professor,
Department of Electronics and Communication Engineering, RV Institute of
Technology and Management, Bengaluru, for her constant guidance and inputs.
We would like to thank all the Teaching and Non-Teaching Staff for their
cooperation.
Finally, we extend our heartfelt gratitude to our family for their encouragement and
support without which we wouldn’t have come so far. Moreover, we thank all our
friends for their invaluable support and cooperation.
AKSHAT GUPTA-1RF20EC003
MOHAMMED NADEEM-1RF20EC028
SHIVAM KUMAR RAI-1RF20EC042
VIKRANT RANA-1RF20EC053
ABSTRACT
Diabetes is a chronic end organ disease that occurs when the pancreas does not secrete
enough insulin or the body is unable to process it properly. Over time, diabetes affects the
circulatory system, including that of the retina. Diabetic retinopathy (DR) is a medical
condition where the retina is damaged because fluid leaks from blood vessels into the
retina. Ophthalmologists recognize diabetic retinopathy based on features, such as blood
vessel area, exudes hemorrhages, microaneurysms and texture. Early detection and
treatment can limit the potential for significant vision loss from diabetic retinopathy.
CNN algorithms are widely used for the detection of diabetic retinopathy (DR), it helps in
analyzing fundus images in diagnosis. The proposed approach includes 3 stages:
Preprocessing, Feature extraction and Classification. The proposed method is evaluated
on a publicly available dataset. Image pre-processing is the steps taken to format images
before they are used by model training and inference. Image preprocessing may also
decrease model training time and increase model inference speed. Feature extraction is a
part of the dimensionality reduction process, in which, an initial set of the raw data is
divided and reduced to more manageable groups. The last step includes a classification
algorithm which classifies the images into 5 categories namely: No DR, Mild DR,
Moderate DR, Severe DR and Prolific DR.
The manual process of periodic DR diagnosis and detection for necessary treatment, is
time consuming and unreliable due to unavailability of resources and expert opinion.
Therefore, computerized diagnostic systems which use Convolutional Neural Network
(CNN) architectures, are proposed to learn DR patterns from fundus images and identify
the severity of the disease. We have successfully been able to achieve a maximum of
95.40% accuracy using the model that we have developed. Thus, we have minimized
erroneous outputs and maximized accuracy to provide better result analysis and help
medical workers choose the required treatment accordingly.
)i
TABLE OF CONTENTS
Abstract………………………………………………………………….. i
List of Abbreviations…………………………………………………….iii
2.1.2 Complication……………………………..................................8
2.1.3 Prevention……………………………………………………...9
2.2 Deep Learning - An overview…………………………………...10-13
2.2.1 Introduction to Deep Learning (DL)………….........................10
2.2.2 About Convolution Neural Network(CNN)………………......11
7. References……………………………………………………...39-40
LIST OF FIGURES
FIGURE NO. DESCRIPTION PAGE NO.
different iterations
Term Description
of the symptoms
TP True Positive
TN True Negative
FP False Positive
FN False Negative
ii)iii
Term Description
TP True Positive
TN True Negative
FP False Positive
FN False Negative
)iv
Detection of Diabetic retinopathy using CNN algorithm R V Institute of Technology and Management®
CHAPTER 1
INTRODUCTION
This section briefly describes the background, definition of the problem statement, motivation
behind choosing the domain. It also consists of the important problem formulations and
objectives along with the scope of the project.
Diabetic retinopathy is an eye disease caused by diabetes that can lead to loss of vision or even
complete blindness. Diabetic retinopathy accounts for 12% of all new cases of blindness in the
United States, and is the leading cause of blindness for people aged 20 to 64 years. If caught
early enough, progression to vision impairment can be slowed if not altogether stopped,
however, this is often difficult because symptoms may appear too late to provide effective
treatment. Diabetic retinopathy (DR) has been estimated to affect about 93 million people
globally, though only half are aware of it.
CNN, hybrid CNN with ResNet, hybrid CNN with DenseNet are used on a huge dataset
with around 3662 train images to automatically detect which stage DR has progressed.
Five DR stages, which are 0 (No DR), 1 (Mild DR), 2 (Moderate), 3 (Severe) and 4
(Proliferative DR) are processed in the proposed work. The patient’s eye images are fed
as input to the model. The proposed deep learning architectures like CNN, hybrid CNN
with ResNet, hybrid CNN with DenseNet 2.1 are used to extract the features of the eye
for effective classification. The models achieved an accuracy of 96.22%, 93.18% and
75.61% respectively. The [2] paper concludes with a comparative study of the CNN,
hybrid CNN with ResNet, hybrid CNN with DenseNet architectures that highlights
hybrid CNN with DenseNet as the perfect deep learning classification model for
automated DR detection.
To help patients with the early detection of diabetic retinopathy, paper [3],they
proposed a computer vision-based technique to analyze and predict diabetes from the
retinal input images. Image preprocessing, segmentation, and feature extraction steps
are applied. Convolutional neural networks (CNN) and Support Vector Machine (SVM)
are trained with diabetic and non-diabetic retinal images. Results show CNN reports
better accuracy in DR compared to SVM.
In examining said models, the results alluded to an over-fitting phenomenon, and the
outcome of the work demonstrates that the performance of the revised ResNet-50
(Train accuracy: 0.8395 and Test accuracy: 0.7432) is better than other common CNNs
(that is, the revised structure of ResNet-50 could avoid the overfitting problem, decease
the loss value, and reduce the fluctuation problem).
To solve the classification problems, many different types of ResNets are used, with
different numbers of layers: specifically, 18, 34, 50, 101, and 152 layers [7]. The
current deep learning framework for detecting and grading DR is ResNet-50. However,
the disadvantages of ResNet-50 are overfitting and fluctuations in accuracy, which
affect its accuracy in detecting DR. This study proposes three strategies to improve the
performance of ResNet-50, as follows:
Adaptive learning rate in ResNet-50. 2) Regularization: Regularization can be
employed to minimize the overfitting of the training model. 3) Obtain suitable features
from conv5_block1_out and conv5_block2_out in ResNet-50.
The proposed [8] approach uses deep features of ResNet-50 along with Random Forest
as a classifier for the detection and grading of diabetic retinopathy. High-level features
obtained from the average pooling layer of trained ResNet-50 are fed to a random
forest classifier. The depth of the deep network plays a pivotal role in their
performance. With the increase in layers, the model gives better performance.
However, it has also been observed that the addition of layers may increase the error
rate. This is named as an issue of vanishing gradients. The residual neural network,
also known as ResNet, was introduced to address this problem. Residual Network uses
the skip connection to indiscriminately allow some input to the layer to incorporate the
flow of information and also to prevent its loss, hence, addressing the problem of
vanishing gradients (which also suppresses the generation of some noise). Suppressing
the noise means averaging the models, which keeps a balance between precision and
generalization. To achieve higher precision and an estimated level of traversal, the most
efficient way is to increase more labeled data. The structure of ResNet speeds up the
training of ultra-deep neural networks and increases the model’s accuracy on large
training data.
The resolution of the input image has a direct impact on the DR grading
performance[9]. Generally, ResNet50 is designed for images of 224×224 input
resolution (He et al., 2016). In ResNet-50, a convolution layer with 6 a kernel size of
7×7 and a stride of 2 followed by a max-pooling layer is applied to dramatically
down sample the input image first. Therefore, using images with very small input
resolution may lose key features for DR grading, such as tiny lesions. In contrast, a
network fed with large resolution images can extract more fine-grained and dense
features at the cost of a smaller receptive field and a higher computational cost. In
this work, a range of resolutions is evaluated to identify the trade-off. Applying data
augmentation during training can increase the distribution variability of the input
images to improve the generalization capacity and robustness of a model of interest.
After the training of the residual network with 20 epochs, the features can extracted
from their average global pooling layer. These features will be detailed and unique as
this model averaged out all the activations of the final convolution layer. Due to
parameter limitations, the global average pooling does not require optimization.
Moreover, owing to spatial translation, it is more robust to the input as it summarizes
spatial information. The dropout was set to 0.2 to reduce the overfitting [10].
1.3 MOTIVATION
According to the World Health Organization, diabetic retinopathy is the leading cause of
blindness among working-age adults, affecting up to 35% of people with diabetes worldwide. In
2021, Approximately 537 million adults (20-79 years) are living with diabetes. The total
number of people living with diabetes is projected to rise to 643 million by 2030 and 783
million by 2045. 3 in 4 adults with diabetes live in low- and middle-income countries. One out
of two people suffering from diabetes has been diagnosed with some stage of DR. Detection of
DR symptoms in time can avert the vision impairment in majority of cases, however such
revelation is difficult with present tools and methods. There has been a need for comprehensive
and automated DR detection tools and methods.
By developing an accurate and reliable method for detecting diabetic retinopathy using deep
learning techniques, One can potentially make a significant impact on patient outcomes and
improve the quality of life for many people. Generally this is what happens, suppose you have
to show your eyes to ophthalmologist , eyes are dilated and then there is consultation with the
ophthalmologist and this entire process takes a lot of time for diagnosis and the scarcity of
ophthalmologist makes it harder and expensive. By our technique we can simplify the process
of detection and make the entire consultation more efficient and cost effective.
1.4 OBJECTIVES
• Explore and optimize the performance of the CNN algorithm by experimenting with
different network architectures, hyperparameters, and data augmentation techniques.
• Assess the interpretability of the CNN algorithm by analyzing the learned features
and generating visual explanations for the algorithm's predictions.
• Develop a user-friendly software or application that integrates the CNN algorithm for easy
deployment and utilization by healthcare professionals.
Chapter 1 deals with the introduction to Diabetic retinopathy and briefly describes the
background, definition of the problem statement, motivation behind choosing the
domain. It also consists of the important problem formulations and objectives of the
project.
Chapter 2 deals with the Theory and fundamentals of the area related to the problem
statement, it covers the working of existing methods. This chapter discussed the
problems that are faced by the people in different places.
Chapter 3 include the methodology implemented in the proposed project. It contains the
steps that are followed by the algorithm.
Chapter 4 deals with the implementation of the design model and development of the
fronted of the project.
Chapter 5 deals with the results and discussion of the project. It’s been discussed about
the output that has been achieved using the developed CNN model. It contains detailed
graphical representation of the accuracy and losses.
Chapter 6 deals with the conclusion and future scope of the work carried out. The
conclusion is a critical section that provides a summary of the key findings and
outcomes of the project. the future scope section outlines potential areas for future
research or improvement based on the results and findings of the project.
Chapter 2
This chapter highlights all the basic fundamentals, theory and principles of the
project in brief, starting from the introduction to what Diabetic Retinopathy is and
what CNN are.
2.1 Diabetic Retinopathy
2.1.1 Introduction
Diabetic retinopathy is a diabetes complication that affects the eyes. It's caused by
damage to the blood vessels of the light-sensitive tissue at the back of the eye
(retina).At first, diabetic retinopathy might cause no symptoms or only mild vision
problems. But it can lead to blindness. The condition can develop in anyone who has
type 1 or type 2 diabetes. The longer you have diabetes and the less controlled your
blood sugar is, the more likely you are to develop this eye complication[1].
According to a 2018 American Eye-Q ® survey conducted by the AOA, nearly half
of Americans didn't know whether diabetic eye diseases have visible symptoms
(often which the early stages of diabetic retinopathy does not). The same survey
found that more than one-third of Americans didn't know a comprehensive eye exam
is the only way to determine if a person's diabetes will cause blindness[2].
Symptoms:
You might not have symptoms in the early stages of diabetic retinopathy. As the
condition progresses, you might develop:
• Spots or dark strings floating in your vision (floaters)
• Blurred vision
• Fluctuating vision
• Dark or empty areas in your vision
• Vision loss
2.1.2 Complications
Diabetic retinopathy involves the growth of abnormal blood vessels in the retina.
Complications can lead to serious vision problems such as:
• Vitreous hemorrhage: The new blood vessels may bleed into the clear, jelly like
substance that fills the center of your eye. If the amount of bleeding is small, you
might see only a few dark spots (floaters). In more-severe cases, blood can fill the
vitreous cavity and completely block your vision. Vitreous hemorrhage by itself
usually doesn't cause permanent vision loss. The blood often clears from the eye
within a few weeks or months. Unless your retina is damaged, your vision will
likely return to its previous clarity.
• Glaucoma: New blood vessels can grow in the front part of your eye (iris) and
interfere with the normal flow of fluid out of the eye, causing pressure in the eye
to build. This pressure can damage the nerve that carries images from your eye to
your brain (optic nerve).
You can't always prevent diabetic retinopathy. However, regular eye exams, good
control of your blood sugar and blood pressure, and early intervention for vision
problems can help prevent severe vision loss.
If you have diabetes, reduce your risk of getting diabetic retinopathy by doing the
following:
• Manage your diabetes: Make healthy eating and physical activity part of your daily
routine. Try to get at least 150 minutes of moderate aerobic activity, such as
walking, each week. Take oral diabetes medications or insulin as directed.
• Monitor your blood sugar level: You might need to check and record your blood
sugar level several times a day, or more frequently if you're ill or under stress. Ask
your doctor how often you need to test your blood sugar.
• Keep your blood pressure and cholesterol under control: Eating healthy foods,
exercising regularly and losing excess weight can help. Sometimes medication is
needed, too.
• Pay attention to vision changes: Contact your eye doctor right away if your vision
suddenly changes or becomes blurry, spotty or hazy.
Deep learning imitates how humans gain knowledge. Deep learning is part of data
science, which covers statistics and predictive modelling. Deep learning helps data
scientists acquire, analyze, and interpret massive amounts of data. Deep learning
automates predictive analytics. Deep learning algorithms are hierarchical, increasing
in complexity and abstraction. Iterate till output is accurate. Data processing layers
inspired the name deep.
Deep learning models can be made using several ways. Learning rate decay, transfer
learning, starting again, and dropout are approaches.
Deep learning models process information like the brain and can be used for
numerous tasks. Most image recognition, NLP, and speech recognition tools use deep
learning. Self-driving cars and language translation services are using these tools.
A multilayer perceptron-like system that has been optimized for low processing
demands is used by a CNN. An input layer, an output layer, and a hidden layer with
several convolutional layers, pooling layers, fully connected layers, and normalizing
layers make up a CNN's layers. A system that is significantly more effective and
easier to train for image processing and natural language processing is produced by
the removal of restrictions and increase in efficiency for image processing[2,13].
Pooling
It is the step of down sampling the image’s features through summing up the
information. The operation is carried out through each channel and thus it only affects
the dimensions (n_H, n_W)and keeps n_C intact.
Convolutional layer:
A convolutional layer contains a set of filters whose parameters need to be learned.
The height and weight of the filters are smaller than those of the input volume. Each
filter is convolved with the input volume to compute an activation map made of
neurons. We apply convolutional products, using many filters this time, on the input
followed by an activation function ψ. Fig 2.3 illustrates each layer involved in
convolution filter.
Padding:
The pixels on the corner of the image (2D matrix) are less used than the pixels in the
middle of the picture which means that the information from the edges is thrown away.
To solve this problem, we often add padding around the image in order to take the
pixels on the edges into account. In convention, we pad with zeros and denote with p
the padding parameter which represents the number of elements added on each of the
four sides of the image. The following picture illustrates the padding of a grayscale
image (2D matrix) where p=1,
Chapter 3
This chapter gives us an insight about the methodology followed in the project along
with the details of the basic requirements needed to start working on the project.
3.1 Methodology
Based on the inputs provided, we initially recognize the features of diabetic
retinopathy .Later steps involve algorithms from deep learning like Convolutional
Neural Networks (CNN) with a combination of Artificial Neural Networks to
develop an integrated network which extracts the input features and produces the
required output. This will help in classifying the data into i)NO DR ii) MILD
DR iii) MODERATE DR iv)SEVERE DR v)PROLIFERATIVE DR based
on the stages and making use of the data provided.
3.2 Algorithm
The general algorithm followed for executing the project is:
Step 1: Obtaining appropriate Data sets
Step 3: Split the Data sets into Train and Test sets
Step 5: Feed the training set to the model for feature extraction
Step 9: Generate heat and confusion matrix for the obtained results
Step 10: Give any test set input to the network to check the predictions and
classifications into five categories into i)NO DR ii) MILD DR iii) MODERATE
DR iv)SEVERE DR v)PROLIFERATIVE DR .
13
Department of Electronics and Communication Engineering 14
|
114
Detection of Diabetic retinopathy using CNN algorithm R V Institute of Technology and Management®
Pre-processing is a crucial process done before putting scanned fundus images into the deep
convolutional neural network. The model reads the image files (stored in data folder). After
decoding the PNG content it yields RGB grids of channels for the pixels. Convolution and
pooling layers are the standard layers in deep convolutional neural networks. Input feature maps
are convolved by convolution layers with kernel filters, which then generate output feature maps
with an optional non-linear function. The pooling layer only uses one value from the input map,
forcing the feature maps' resolution to drop so that the output feature maps can maintain their
local deformation invariance. Following the extraction of features from convolutional and
pooling layers, fully connected layers combine the output features into a complete feature vector
using maximum and average pooling operations.
JUPYTER NOTEBOOK
Jupyter notebook lets anyone create and execute arbitrary Python code in the browser.
It's ideal for machine learning, data analysis, and education. A notebook is saved with
an .jpynb extension.
Python 3.10.0
Python libraries and frameworks offer a reliable environment which reduces software
development time significantly. Python is consistent, simple, flexible, platform
independent and has wide community which makes it most appropriate for machine
learning Python includes a modular machine learning library PyBrain, Tensorflow,
Keras, NumPy etc which offers many algorithms for machine learning task. Version
VS CODE
Visual Studio Code, also commonly referred to as VS Code is a source-code editor
made by Microsoft with the Electron Framework, for Windows, Linux and macOS.
It is used for compiling the HTML code for frontend.
15
Department of Electronics and Communication Engineering 16
116
Detection of Diabetic retinopathy using CNN algorithm R V Institute of Technology and Management®
FLASK
Flask is a micro web framework written in python. It is classified as a
microframework because it does not require particular tools or libraries. It has no
database abstraction layer, form validation, or any other components where pre-
existing third-party libraries provide common functions. However, Flask supports
extensions that can add application features as if they were implemented in Flask
itself. Extensions exist for object relational framework, form validation, upload
handling, various open authentication technologies and several common framework
related tools.
Python Frontend framework that helps in converting the backend machine learning
model to web app that make the classification more interactive and gives a better user
experience.
15
Department of Electronics and Communication Engineering 17
117
Detection of Diabetic retinopathy using CNN algorithm R V Institute of Technology and Management®
Chapter 4
4.1 CODE:
4.1.1 Libraries
import pandas as pd
import numpy as np
import tensorflow as tf
from tensorflow import keras
import os
import matplotlib.pyplot as plt
import PIL
import seaborn as sns
import plotly
import plotly.graph_objs as go
from sklearn.model_selection import train_test_split
from sklearn.utils import shuffle
from plotly.offline import iplot, init_notebook_mode
from tensorflow.keras.preprocessing.image import ImageDataGenerator
from tensorflow.keras.applications.resnet50 import ResNet50
from tensorflow.keras.applications.inception_resnet_v2 import InceptionResNetV2
from tensorflow.keras.layers import *
from tensorflow.keras.models import Model, load_model
from tensorflow.keras.initializers import glorot_uniform
from tensorflow.keras.utils import plot_model
from IPython.display import display
from tensorflow.keras import backend as K
from tensorflow.keras.optimizers import SGD
from tensorflow.keras.preprocessing.image import ImageDataGenerator
from tensorflow.keras.models import Model, Sequential
from tensorflow.keras.callbacks import ReduceLROnPlateau, EarlyStopping,
ModelCheckpoint,LearningRateScheduler
# Convolutional_block
X_copy = X
f1 , f2, f3 = filter
# Main Path
X = Conv2D(f1, (1,1),strides = (1,1), name ='res_'+str(stage)+'_conv_a',
kernel_initializer= glorot_uniform(seed = 0))(X)
X = MaxPool2D((2,2))(X)
X = BatchNormalization(axis =3, name = 'bn_'+str(stage)+'_conv_a')(X)
X = Activation('relu')(X)
# Short path
X_copy = Conv2D(f3, kernel_size = (1,1), strides =(1,1),name ='res_'+str(stage)
+'_conv_copy', kernel_initializer= glorot_uniform(seed = 0))(X_copy)
X_copy = MaxPool2D((2,2))(X_copy)
X_copy = BatchNormalization(axis =3, name = 'bn_'+str(stage)+'_conv_copy')
(X_copy)
# ADD
X = Add()([X,X_copy])
X = Activation('relu')(X)
# Identity Block 1
X_copy = X
# Main Path
X = Conv2D(f1, (1,1),strides = (1,1), name ='res_'+str(stage)+'_identity_1_a',
kernel_initializer= glorot_uniform(seed = 0))(X)
X = BatchNormalization(axis =3, name = 'bn_'+str(stage)+'_identity_1_a')(X)
X = Activation('relu')(X)
# ADD
X = Add()([X,X_copy])
X = Activation('relu')(X)
# Identity Block 2
X_copy = X
# Main Path
X = Conv2D(f1, (1,1),strides = (1,1), name ='res_'+str(stage)+'_identity_2_a',
kernel_initializer= glorot_uniform(seed = 0))(X)
X = BatchNormalization(axis =3, name = 'bn_'+str(stage)+'_identity_2_a')(X)
X = Activation('relu')(X)
# ADD
X = Add()([X,X_copy])
X = Activation('relu')(X)
return X
input_shape = (256,256,3)
#Zero-padding
X = ZeroPadding2D((3,3))(X_input)
# 1 - stage
# 2- stage
# 3- stage
# 4- stage
# # 5- stage
#Average Pooling
#Final layer
X = Flatten()(X)
X = Dense(5, activation = 'softmax', name = 'Dense_final', kernel_initializer=
glorot_uniform(seed=0))(X)
model.summary()
4.1.7 Testing
prediction = []
image = []
#Enter filepath
testpic = "./train/Moderate/00e4ddff966a.png"
img = PIL.Image.open(testpic)
plt.imshow(img)
img = img.resize((256,256))
# converting image to array
img = np.asarray(img, dtype= np.float32)
# normalizing the image
img = img / 255
4.1.9 Visualization
In the frontend application for the report on diabetic retinopathy classification, the user interface
(UI) is designed to provide a user-friendly experience. The UI is shown in Fig 4.2. It includes an
image upload feature that allows users to upload retinal images for classification as shown in
Fig 4.4. After the image is uploaded, the frontend displays the uploaded image, performs
classification using a trained ML model, and presents the classification result to the user. The
end output is displayed in Fig 4.6. The frontend also handles error cases, as shown in Fig 4.3,
gracefully, such as when no image is uploaded. The design focuses on simplicity, usability, and
delivering accurate classification results to assist in the diagnosis of diabetic retinopathy.
Chapter 5
The dataset comprised of 3662 retinal fundus images.Out of which 2490 images are
used for training ,439 images for validation and 733 for testing. An epoch means
training the neural network with all the training data for one cycle. In an epoch, we
use all of the data exactly once. A forward pass and a backward pass together are
counted as one pass: An epoch is made up of one or more batches, where we use a
part of the dataset to train the neural network.
The Fig. 5.1 represents the number of iterations or Epochs which the training data was
passed through. A total of 32 batches of data were trained with 15 epochs running for
each batch and obtaining the accuracy of prediction and model loss/accuracy.
At the end of the compilation of all the epoch cycles, the values for the model
accuracy, model loss, validation accuracy and validation loss efficiencies are obtained
as depicted in the Table 5.1.
Table 5.1: Results of accuracy and loss obtained after all the epochs
The last Epoch shows us the results at the end of 15 iterations. As we can see that the
result obtained is about 88.13%.
Fig 5.1: Results of accuracy and loss obtained after each epoch
ii. Model loss: The loss function in a neural network quantifies the difference
between the expected outcome and the outcome produced by the machine
learning model. From the loss function, we can derive the gradients which are
used to update the weights. The average over all losses constitutes the cost.
iii. Validation Accuracy: It is the sum of errors made for each example in training
or validation sets. Loss value implies how poorly or well a model behaves
after each iteration of optimization. An accuracy metric is used to
measure the algorithm's performance in an interpretable way.
iv. Validation Loss: "Validation loss" is the loss calculated on the validation set,
when the data is split to train / validation / test sets using cross-validation.
When comparing test accuracy to training accuracy, test accuracy refers to how
well the trained model recognises independent images that were not utilised in
training. A
Accuracy = Number of correct predictions/ Total number predictions.
Loss is measured with the help of the loss function.
The difference between the outcome produced by the machine learning model
and the intended outcome is measured by the loss function in a neural network.
25
Department of Electronics and Communication Engineering 31
|P
131
ag
e
Detection of Diabetic retinopathy using CNN algorithm R V Institute of Technology and Management®
Fig 5.2: Graph for Model accuracy of the ML model for different iterations
The model accuracy as depicted, has 2 main features, curve 1 which is for the training
set represented in blue and curve 2 which is the test set represented in yellow. As it can
be seen that both the curves increase exponentially which denotes that the accuracy of
our model increases periodically with every passing epoch. By comparing the model
predictions with the actual values in terms of a percentage, it determines how well our
model predicts. The graphs in Fig 5.2 shows the plot of training and validation
accuracy when the patience parameter was set to 5, 15, 25 respectively.
26
Department of Electronics and Communication Engineering 32
|P
132
ag
e
Detection of Diabetic retinopathy using CNN algorithm R V Institute of Technology and Management®
Fig 5.3: Graph for Model loss of ML model for different iterations
The model loss as depicted, has 2 main features, curve 1 which is for the training set
represented in blue and curve 2 which is the test set represented in yellow. As it can be
seen in Fig. 5.3 both the curves decrease with every passing epoch. This denotes that
the model and validation loss of our model decreases from time to time and hence
reduces erroneous outputs. The graphs in Fig 5.3 shows the plot of training and
validation loss when the patience parameter was set to 5, 15, 25 respectively.
27
Department of Electronics and Communication Engineering 33
|P
133
ag
e
Detection of Diabetic retinopathy using CNN algorithm R V Institute of Technology and Management®
FN: A class's False-negative value is the sum of the values in the relevant rows,
excluding the TP value. FP: A class's False-positive value is the total of all of the
values in the relevant column, excluding the TP value. TN: The total of all columns
and rows, excluding those for the class for which we are computing the values, will
represent the True Negative value for a given class. TP: When the actual value and the
anticipated value are the same, that is a true positive value.
28
Department of Electronics and Communication Engineering 34
|P
134
ag
e
Detection of Diabetic retinopathy using CNN algorithm R V Institute of Technology and Management®
The figures shown in this section depicts the expected outputs of the test data set for
the five cases:0)mild DR 1)moderate DR 2)no DR 3) proliferative DR 4)severe DR.
The Fig. 5.5 shows the output for the test case image which is rightly predicted as mild
DR. Once the input image of the test set is passed to the output variable, the image is
processed through all the convolutional network layers and gives the correct
prediction at the end of the process. It also mentions the class 0 to which it belongs.
The Fig. 5.6 shows the output for the test case image which is rightly predicted as
moderate DR. Once the input image of the test set is passed to the output variable, the
image is processed through all the convolutional network layers and gives the correct
prediction at the end of the process. It also mentions the class 1 to which it belongs.
30
Department of Electronics and Communication Engineering 35
|P
135
ag
e
Detection of Diabetic retinopathy using CNN algorithm R V Institute of Technology and Management®
Prediction: No DR original: No DR
Fig. 5.7: Output image for no DR prediction vs original
The Fig 5.7 shows the output for the test case image which is rightly prediction as no
DR. The class for the image is 3.
The Fig 5.8 shows the output for the test case image which is rightly predicted as
proliferative DR. The class for the image is 4.
31
Department of Electronics and Communication Engineering 36
|P
136
ag
e
Detection of Diabetic retinopathy using CNN algorithm R V Institute of Technology and Management®
The Fig 5.9 shows the output for the test case image which is rightly predicted as
severe DR. The class for the image is 5.
31
Department of Electronics and Communication Engineering 37
|P
137
ag
e
Detection of Diabetic retinopathy using CNN algorithm R V Institute of Technology and Management®
Chapter 6
Our project aimed at giving a suitable solution to aid the process of predicting the
correct stage of Diabetic Retinopathy by obtaining inputs from the fundus images.
Hence, we have come up with a user-friendly approach in which we have trained
our model in different supervised classification algorithms to improve its accuracy.
We have been able to increase our accuracy to 95.40% which is a very efficient
number to rely on. We have also optimized the number of epochs and training
cycles for our input fundus images which reduces the error and improves the
model’s overall performance. Our main objective for taking up this project has
been achieved which was of making a user-friendly interface where the user gives
the input fundus images and our model predicts the stage of the DR.
With the advent of India’s own electronic health record system (EHR). EHR will
facilitate automatic screening and diagnosis of diabetic retinopathy. This can assist
medical professionals in identifying at-risk individuals and initiating quick actions
that improve patient outcomes.
India's very own telemedicine program eSanjeevani will play a major role in our
project as. The created project may be connected with telemedicine platforms,
allowing for remote diabetic retinopathy screening and diagnosis. For patients in
rural and underdeveloped areas in particular, this may boost access to affordable
healthcare. By enhancing the model, it is possible to diagnose diabetic retinopathy
in real-time, which would increase screening effectiveness and reduce the burden
on healthcare providers. The project can be further extended to be able to directly
be applied to a fundus camera where after taking an image of the retina of the
patient , the algorithm can easily detect to which stage of DR it is. Thereby
reducing the time spent on diagnosis of a patient and result in more efficiency and
accuracy.
REFERENCES
[1] Dolly Das, Saroj Kumar Biswas, and Sivaji Bandyopadhyay “ Detection of Diabetic
Retinopathy using Convolutional Neural Networks for Feature Extraction and
Classification (DRFEC), ”IEEE Trans Geosci Remote Sens, vol.15,no. 3, pp.18-21, 29
Nov 2022.
[5] Saleh Albahli, Ghulam Nabi Ahmad Hassan Yar “ Detection of Diabetic Retinopathy
Using Custom CNN to Segment the Lesions,” Int. J. Eng. Adv. Technol., vol. 8, no. 6,
pp. 100-104,25 November 2021.
[9] Yijin Huanga, Li Lina,c, Pujin Chenga , Junyan Lyua,d, Roger Tamb, Xiaoying
Tanga “ Identifying the key components in ResNet-50 for diabetic retinopathy grading
from fundus images: a systematic investigation, ” International Conference on Expert
System Application, Geneva, Switzerland,17 Oct 2022,pp 212-219.
[11] C. Stauffer and W. E. L. Grimson, “Adaptive background mixture models for real-
time tracking,” in Proceedings. 2021 IEEE Computer Society Conference on Computer
Vision and Pattern Recognition, Collins, Colorado,USA, June 2021, pp. 246–252.
[13] Yashal Shakti Kanungo, Bhargav Srinivasan, Dr. Savita Choudhary, “Detecting
Diabetic Retinopathy using Deep Learning” International Conference on Expert System
Application, Chennai, India, Sept 2021,pp.260-267.
[16] D. Y. Carson Lam, “Automated detection of diabetic retinopathy using deep learning,”
AMIA Summits on Translational Science Proceedings, vol. 13,no. 6,pp 100-105, Feb 2020.
[17] F. Zabihollahy, A. Lochbihler, and E. Ukwatta, “Deep learning based approach for
fully automated detection and segmentation of hard exudate from retinal images,”
Proceedings of the Medical Imaging 2019: Biomedical Applications in Molecular,
Structural, and Functional Imaging vol.2020, Springer, San Diego, CA, USA, January
2020,pp. 403-408.
[18] Kumar, S. and Kumar, B., 2020, February. Diabetic Retinopathy Detection by
Extracting Area and Number of Microaneurysm from Colour Fundus Image. In 2020 5th
International Conference on Signal Processing and Integrated Networks (SPIN),San
Francisco, USA, 10 Jan 2020,pp. 359-364.
[19] Asiri, N., Hussain, M. and Abualsamh, H.A., 2022. Deep Learning based Computer-
Aided Diagnosis Systems for Diabetic Retinopathy in 25th International conference on
Medical electronics,Putrajaya,Malaysia,19 April 2022 , pp. 67-71.
[20] Gulshan, V., Peng, L., Coram, M., Stumpe, M.C., Wu, D., Narayanaswamy, A.,
Venugopalan, S., Widner, K., Madams, T., Cuadros, J. and Kim, R., Development and
validation of a deep learning algorithm for detection of diabetic retinopathy in retinal
fundus photographs. Jama, 316(22),pp.2402-2410, 2022.
[21] Mohammadian, S., Karsaz, A. and Roshan, Y.M., 2020, November. Comparative
Study of Fine-Tuning of Pre-Trained Convolutional Neural Networks for Diabetic
Retinopathy Screening. In 2020 24th National and 2nd International Iranian Conference
on Biomedical Engineering (ICBME),Tehran, Iran,12 Feb 2020, pp. 1-6.
[22] Wan, S., Liang, Y. and Zhang, Y., 2018. Deep convolutional neural networks for
diabetic retinopathy detection by image classification. Computers & Electrical
Engineering journal, vol. 24, pp.274-282, 17 July 2018
[24] Dutta, S., Manideep, B.C., Basha, S.M., Caytiles, R.D. and Iyengar, N.C.S., 2021.
Classification of Diabetic Retinopathy Images by Using Deep Learning Models.
International Journal of Grid and Distributed Computing, vol. 11,Nov 2021, pp.89-
106.
[25] Gao, Z., Li, J., Guo, J., Chen, Y., Yi, Z. and Zhong, J.,“2020. Diagnosis of
Diabetic Retinopathy Using Deep Neural Networks”, Proc. 7th Int. Conf. Bio Signals
Images Instrum. (ICBSII),Beijing, China,12 Mar 2021, pp. 1-4 .
[27] C. Stauffer and W. E. L. Grimson, “Adaptive background mixture models for real-
time tracking,” in 2021 IEEE Computer Society Conference on Computer Vision and
Pattern Recognition, IEEE, Collins, Colorado, June 2021, , pp. 246–252.