Microsoft Word - Minor Project Report Final Edited

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 48

ENCHANCING DIABETIC RETINOPATHY DETECTION

AND CLASSIFICATION THROUGH DEEP LEARNING


MODEL

A MINOR PROJECT REPORT

Submitted by

DIYA GIRI [RA2011026010144]


PADMAPRIYA VENKATESH
[RA20110260155]

Under the guidance of


Mrs Vidhya J. V.
Asst Professor, CINTEL Dept

in partial fulfillment for the award of the degree of

BACHELOR OF TECHNOLOGY
in

COMPUTATIONAL INTELLIGENCE
of

FACULTY OF ENGINEERING AND TECHNOLOGY

S.R.M.Nagar, Kattankulathur, Chengalpattu District


NOVEMBER 2023
SRM INSTITUTE OF SCIENCE AND
TECHNOLOGY
(Under Section3 of UGC Act,1956)

BONAFIDE CERTIFICATE

Certified that 18CSP107L minor project report titled “ENCHANCING DIABETIC


RETINOPATHY DETECTION AND CLASSIFICATION THROUGH DEEP
LEARNING MODEL” is the bonafide work of “DIYA GIRI [RA2011026010144],
PADMAPRIYA VENKATESH [RA2011026010155]” who carried out the minor project work
under my supervision. Certified further, that to the best of my knowledge the work
reported herein does not form any other project report or dissertation on the basis of
which a degree or award was conferred on an earlier occasion on this or any other
candidate.

SIGNATURE
Mrs Vidhya J. V. SIGNATURE
GUIDE Dr.R. Annie Uthra
Asst. Professor HEAD OF THE
Dept. of Computational DEPARTMENT
Intelligence Professor
Dept. of Computational
Intelligence

Signature of the Panel Head


Dr.R. Annie Uthra
HEAD OF THE
DEPARTMENT
Professor
Dept. of Computational
Intelligence
ABSTRACT

This design introduces a slice-edge system for perfecting the discovery and bracket of
DR using a Deep literacy model, specifically the ResNet50 armature within a CNN.
With over 3200 fundus images in the dataset, preprocessing ways similar to Gaussian
blur and image cropping are used to ameliorate data quality. To prop in understanding
the data distribution, the study employs t-SNE visualisation, which generates eight
plots. The QWK score, a robust metric for assessing the agreement between
prognosticated and factual groups, is used to estimate the model's performance.

This design aims to amend the accuracy of DR opinion by using the power of deep
learning and the ResNet50 armature. The objectification of preprocessing ways and
advanced evaluation criteria represents a comprehensive approach to perfecting the
model's robustness and trustability for accurate DR bracket and discovery in fundus
images.

iii
TABLE OF CONTENTS

Chapter No. Title Page No.

ABSTRACT iii

TABLE OF CONTENTS iv

LIST OF FIGURES v

LIST OF TABLES vi

ABBREVIATIONS vii
1 INTRODUCTION 1
1.1 Diabetic Retinopathy 1
1.2 Genetic Data 2

2 LITERATURE SURVEY 3
2.1 survey 1 3
2.2. survey 2 3
2.3 survey 3 4
2.4. survey 4 5
2.5 survey 5 5
2.6. survey 6 6
2.7 survey 7 6
2.8 survey 8 7
2.9 survey 9 8
2.10. survey 10 9
2.11. Inference

3 SYSTEM ARCHITECTURE DESIGN 11


3.3 System Architecture
3.3.1 Image Processing 19
3.3.2Use Case 20
3.4 Design of Modules
4 METHODOLOGY
4.3 Modules 21
4.3.1 Image Pre-Processing 23
22
5 CODING AND TESTING
6 RESULTS AND DISCUSSIONS 40

CONCLUSION AND FUTURE 45


7 ENHANCEMENT

8 REFERENCES 44

APPENDIX

A PLAGIARISM REPORT 50
4.3.2 Model Training 25
LIST OF FIGURES
Figure No. Figure Name Page No.

● 1.1 Classes of DR 1
● 3.1 System Architecture Diagram 11
● 3.2 Image Processing 12
● 3.3 Use Case Diagram 13
● 4.1.1 Applying Gausian Blur 14
● 4.1.2 TSNE Visualization 15
● 4.2.1 ResNet50 Architecture 18
● 4.2.2 Model Description 19
● 4.2.3 Model Summartization 20
● 4.2.4 Model Accuracy 21
● 5.1 Output class distribution TRAIN DATA 27
● 5.2 QWK Score 29
● 5.3 Confusion Matrix 30
LIST OF TABLES

Table No. Table Name Page No.

2.1 Model Description 19


2.2 Model Summartization 20
ABBREVIATIONS

CNN Convolutional Neural Network


DR Diabetic Retinopathy
PDR Proliferative Diabetic Retinopathy
QWK Quadratic Weighted Kappa
UI User Interface
VEGF Vascular Endothelial Growth
Factor SVM Support Vector Machine
t-SNE t-Distributed Stochastic Neighbor Embedding
CHAPTER 1

INTRODUCTION

1.1 DR

Blindness is a ruinous consequence of DR( DR), a common complication among individualities with diabetes.
Its early discovery and precise assessment are consummate to help unrecoverable vision loss and ameliorate
patient issues. using the power of deep literacy, a subset of machine literacy, this design trials to automate the
discovery of DR- related blindness by assaying complex data patterns, primarily in the realm of medical image
analysis. The evaluation standard of choice for estimating the performance of the DL model is QWK, a
statistical measure uniquely suited for quantifying the agreement between different raters or styles inmulti- class
problems, offering a robust tool to gauge the effectiveness of the model in diagnosing DR and predicting
blindness.
To this end, a dataset comprising 3,200 eye images, each paired with a corresponding inflexibility scale
reflecting the stage of DR progression, will suffer scrupulous image processing and analysis. Image
preprocessing ways will be employed to enhance image quality by removing noise, and convolutional neural
networks( CNNs), a class of deep literacy models, will be assigned with rooting material features and patterns
from these images. The CNN models will be trained to distinguish between colorful stages of DR inflexibility,
marking a vital step towards accurate opinion and prognostic in the hunt to combat DR- related blindness.

Fig1.1:Classes of DR

1
CHAPTER 2

LITERATURE SURVEY

2.1 Genetic Algorithm-Based Model for DR Detection

"One form of eye disease that can cause vision loss in people with diabetes is called DR (DR). Routine diagnosis and
DR identification are difficult tasks that may require multiple screenings. Early detection of DR may be able to stop
or postpone vision loss. To help and minimize potential human errors, an automated DR identification method is
needed for real-time applications.

In this study, we suggest a feature selection method based on deep neural networks and genetic algorithms. AlexNet,
NASNet-Large, VGG-19, Inception V3, and ShuffleNet are the five sophisticated convolutional neural network
architectures that are utilized to extract features from the fundus images. A genetic algorithm is then used to select
features and rank them into high rank (optimal) and lower rank (unsatisfactory). Next, the training and validation
feature vectors' non-optimal feature attributes are removed. A DR recognition model is developed using a support
vector machine (SVM) based classification model. The model's accuracy, precision, recall, and F1 score are used to
assess its performance.

Three distinct datasets are used to test the suggested model: the Kaggle dataset, a custom dataset that was created by
the user, and an improved custom dataset that had accuracy values of 97.9%, 94.76%, and 96.4%, respectively.
Because the enhanced custom dataset is smaller than the original, data augmentation has been done to reduce noise in
the fundus images."

2.2 Combining Transcriptomics and Genomics Predicts Genes Associated


with DR Susceptibility

"In people with type 1 diabetes, the study looked into the genetic and gene expression variations linked to DR.
Through a genome-wide association study and analysis of changes in gene expression in response to elevated glucose
levels, the

2
researchers discovered FLCN as a susceptibility gene for DR.

They found that, particularly in those with DR, FLCN expression rose in response to glucose. Mendelian
randomization analysis revealed a direct positive effect of elevated FLCN expression on retinopathy, and this
association was further validated in independent cohorts of diabetic individuals.

These results demonstrate FLCN's possible involvement as a major contributor to the onset of DR."

2.3 An Ensemble Deep Learning Method for DR Identification

DR is a complaint that attacks the blood vessels in the retina, leading to disabled vision and implicit blindness if not
detected beforehand. The homemade opinion of DR by experts is a time- consuming and error-prone process. To
address this, computer vision- grounded ways have been developed to automatically describe and classify DR stages
using retinal images.

In this study, we employed a intimately available dataset to train an ensemble of five CNN models (Resnet50,
Inceptionv3, Xception, Dense121, and Dense169). These models were designed to capture the complex features of
DR and ameliorate bracket delicacy for each stage.

The experimental results demonstrate that the model outperforms being styles on the same Kaggle dataset,
successfully detecting all stages of DR. This advancement allows for more accurate and effective opinion of the
complaint, potentially perfecting patient issues.

3
2.4 Automated DR Early Detection

"To assess the efficacy of automated DR (DR) detection by contrasting the algorithm currently employed in
EyeCheck, a sizable computer-aided early DR detection project, with the one that emerged victorious in the 2009
Retinopathy Online Challenge Competition, or Challenge2009.

A single retinal expert examined the fundus photographic set from every visit; 793 out of 16 670 sets were found to
have more than minimal DR (threshold for referral). Following their individual applications to the dataset, the results
of the two algorithmic detectors were compared using accepted statistical methods.

The examination results showing more than minimal DR were detected with a statistically nonsignificant difference
(z- score of 1.91), with an AUC of 0.839 for the EyeCheck algorithm and 0.821 for the Challenge2009 algorithm. The
agreement was high. The AUC for detection was 0.86, which is the same as the theoretically predicted maximum, if
both algorithms detected DR in tandem. The EyeCheck algorithm's specificity was 47.7% at 90% sensitivity, while
the Challenge2009 algorithm's was 43.6%."

2.5 Automated DR Early Detection: An advancement in the diagnosis of DR by


image processing and identifying exudates in colour fundus photos of the
human retina
We introduce and talk about a novel exudate detection algorithm for diagnosis of DR. The presence of exudates in the
macular region is one of the main indicators of DME and contributes to its high sensitivity of detection. Exudate
detection is therefore an important diagnostic method for which computer assistance may be very beneficial.

Exudates can be distinguished by their high variation in grey levels, and their

4
contours can be determined through morphological reconstruction techniques. The optic disc has to be found in order
for this technique to function.

Using the watershed transformation and morphological filtering methods, we identify the optic disc. A small image
database was used to test the algorithm, the results were compared to those of a human.

We thus get a mean predictive value of 92.4% and a mean sensitivity of 92.8%. Robustness concerning algorithmic
parameter modifications has been assessed."

2.6 A data-driven method for the detection of referable DR

The existing approaches for screening of DR and decision-making have demonstrated potential, according to earlier
research. These techniques, however, frequently rely on intricately designed features that are difficult to use
effectively in a variety of situations.

We suggest a method that progressively expands on convolutional neural networks to solve this. To improve the
performance, we apply a number of strategies, including robust feature-extraction, training, data augmentation, and
patient-specific analysis.

Our method's outcomes are quite promising. Using a rigorous cross-dataset methodology, we obtained an outstanding
area under the ROC curve of 98.2% . This methodology shows that our technique can successfully generalize, since it
was trained on the Kaggle dataset and tested on the Messidor-2 dataset.

2.7 Zoom-in-Net: Utilizing Deep Mining Lesions to Identify DR

5
A groundbreaking algorithm grounded on convolutional neural networks has been developed for the
contemporaneous opinion of DR and identification of suspicious regions. The algorithm, called Zoom- in- Net,
replicates the process of a clinician zooming in to examine retinal images. Impressively, drone- in- Net is trained
using only image- position supervision,

yet it can induce attention charts that punctuate suspicious regions and directly prognosticate the inflexibility of the
complaint by assaying both the entire image and high- resolution suspicious patches.

also, the attention maps produced by drone- in- Net exhibition excellent localization capabilities. By exercising just
four bounding boxes, deduced from the attention maps, a remarkable 80 of the lesions linked by educated
ophthalmologists can be effectively captured. This demonstrates the robustness of the attention maps in directly
setting areas of concern in DR.

also, through the clustering of features at locales with high responses on the attention maps, meaningful clusters
containing implicit lesions in DR are uncovered. This innovative approach enhances the algorithm's capability to
identify and dissect critical regions.

Experimental results have stressed the superior performance of our algorithm, on both the EyePACS and Messidor
datasets. This achievement further validates the effectiveness and implicit impact of our groundbreaking algorithm in
diagnosing and localizing DR.

2.8 Creating and Verifying a DL Algorithm to Identify DR in Fundus Images

6
"An algorithm trained via deep learning.The reference standard of the majority decision of the ophthalmologist panel
was used to generate the algorithm's sensitivity and specificity for detecting referable DR (RDR), which is defined as
moderate and worse DR, referable diabetic macular edema, or both. Two operating points were chosen from the
development set to evaluate the algorithm: one for high specificity and the other for high sensitivity.The data set for
EyePACS-1 included 9963 images from 4997 patients (mean age: 54.4 years; women: 62.2%); the data set for
Messidor-2 included 1748 images from 874 patients (mean age: 57.6 years; women: 42.6%; the prevalence of RDR,
254/1745 fully gradable images [14.6%]).

The algorithm used in this study achieved impressive results in detecting referable DR (RDR) through the analysis of
retinal fundus photographs. It had a high sensitivity and specificity rate, with an area under the receiver operating
curve of 0.991 for EyePACS-1 and 0.990 for Messidor-2.

For EyePACS-1, using the first operating cut point with high specificity, the algorithm achieved a sensitivity of
90.3% and a specificity of 98.1%. In the case of Messidor-2, the sensitivity was 87.0% and the specificity was 98.5%.

Furthermore, when using a second operating point with high sensitivity, the algorithm demonstrated a sensitivity of
97.5% for EyePACS-1 and 96.1% for Messidor-2, with specificities of 93.4% and 93.9%, respectively.

These findings highlight the potential of deep machine learning algorithms in detecting DR accurately. However,
further research is needed to determine the practicality of implementing this algorithm in a clinical setting and to
examine whether its use could lead to improved care and outcomes compared to traditional ophthalmologic
assessment methods.

[Citation: Original text from "Evaluation of Deep Learning for the Automated Detection of DR in a Population-Based
Sample" by Gulshan et al. (2016), JAMA]

2.9 DR Detection Using VGG-NIN a Deep Learning Architecture

7
Diabetes can cause damage to the blood vessels in the retina, which can result in blindness, or DR (DR). Typically,
fundus photos in various colors are used to identify this incurable illness. Clinicians must manually analyze the
aforementioned images, which is tedious and prone to mistakes. Therefore, a variety of computer vision practical
engineering techniques are used to automatically predict the DR's occurrences and stages. However, due to their high
computational costs and inability to extract highly nonlinear features, these methods are unable to accurately classify
the various stages of DR.

In order to expedite training and model convergence, the main goal of this paper is to classify the various stages of
the DR using the fewest learnable parameters.

8.

The highly nonlinear scale-invariant deep model known as the VGG-NiN model is created by stacking the VGG16,
the spatial pyramid pooling layer (SPP), and the network-in-network (NiN). Because of the virtue of the SPP layer,
the proposed VGG-NiN model can process a DR image at any scale. Furthermore, stacking NiN tends to improve
classification by adding additional nonlinearity to the model.

The experimental findings demonstrate that, when compared to cutting-edge techniques, the suggested model
performs better in terms of accuracy and computational resource utilization."

2.10 An improved CNN method for the detection and classification of DR

The end of this study is to present a new approach to diagnose DR using a combination of image processing and deep
literacy. Detecting DR from digital fundus images has been a grueling task in the field of medical image processing,
taking significant homemade interpretation and moxie. To address this, the proposed system utilizes histogram
equalization ways for image processing,

8
followed by bracket using a CNN.

The effectiveness of this system was tested using 400 retinal fundus images from the MESSIDOR dataset, with
emotional performance evaluation parameters attained, including an delicacy of 97, perceptivity of 94, particularity of
98, perfection of 94, FScore of 94, and GMean of 95. likewise, a comparison with former studies highlights the
effectiveness and success of the introduced system in diagnosing DR from fundus images.

By combining image processing and DL, this study makes precious benefactions to the being literature on DR opinion.

9
INFERENCE

It is evident that over the past few years, automated and computer-assisted DR detection have advanced quickly.
While the fundamental methods remain largely unchanged, advancements in cutting-edge areas such as the
identification of rare diseases and additional lesions as well as confounding are being made. Indeed, some groups
have made progress in the direction of clinical deployment and commercialization.

Evaluations and validations of algorithms on high-quality datasets, potentially involving multifield stereo images with
reading centre assessment of images, where images are obtained in populations with a greater ethnic and cultural
diversity and with various camera types in various locations. The combination of various algorithms to improve the
performance of discovery as well as the combination of image-based algorithms with other, nonimage-derived
features, such as age, blood-HbA1C probability, inheritable threat information, and length of diabetes. objectification
of novel, cutting-edge features inferred from images that predict early-onset diabetic retinopathy (DR), akin to retinal
blood vessel tortuosity and other vessel attributes that could predict DR development previously.

10
CHAPTER 3

SYSTEM ARCHITECTURE AND DESIGN

Fig3.1:System Architecture Diagram

The text discusses the complexity of generating comprehensive system architecture diagrams for detecting DR
through fundus images. The actual schematic can diversify based on specific implementations and technologies
incorporated, yet it is possible to develop a simplified version illustrating key components of such systems.

The text describes a process for detecting signs of DR using artificial intelligence. First, fundus images are collected
from the patient's eyes with various imaging devices, which undergo preprocessing tasks such as resizing and noise
reduction to enhance image quality. A Convolutional Neural Network (CNN), key part in this context, is used to
extract features from these preprocessed images essential for identifying signs of disease.

11
These prepared images constitute an extensive database meant both for training and testing purposes; it importantly
includes labeled data representing different stages of DR giving diversity into consideration.

11.

Fig3.2:Image-Preprocessing

In terms of model training, CNN learns feature extraction through acquiring knowledge on classification based upon
categories being normal or varying levels – mild to severe - related to proliferative DR via intake labeled dataset i.e.,
accurately classifying corresponding retina states grounding learned patterns thereby drawing meaningful outcomes
helping towards diagnostics methods.

The text details a two-part process involved in creating a medical image analysis system. The first stage involves
model evaluation and validation, in which metrics (including accuracy, precision, recall, and F1-score) are used to
assess the trained model's efficiency and overall performance on an unknown dataset. The second phase covers user
interface development crafted specifically for easy usage by

12
medical professionals who can upload fundus images seamlessly onto it; receive diagnostic results; or visualize them
effectively with this UI tool developed during this stage of creation.

However, real-world applications potentially require extra components addressing privacy/security concerns apart
from seamless integration into existing healthcare systems while abiding by ethical/regulatory guidelines throughout
their deployment processes.

Fig3.3:Use Case Diagram

13
CHAPTER 4

METHODOLOGY

Module 1: Data Preprocessing and Image Analysis


In Module 1, the primary ideal is to prepare and dissect the dataset for detecting blindness grounded on eye images. A
comprehensive and strategic approach to data preprocessing and image analysis is essential to insure the success of
the posterior deep literacy model. This module initiates with a thorough disquisition of the dataset to gain
perceptivity into its structure, distribution, and characteristics. Understanding the class distribution is pivotal as it
provides critical information about the balance of different inflexibility situations of blindness within the dataset.
similar understanding is vital for addressing issues related to class imbalance.

To further enhance the quality of the images and ameliorate the visibility of applicable features, colorful image
processing ways are applied using the OpenCV library. These ways include Gaussian blur, which acts as a smoothing
sludge that removes high- frequence noise from the images while conserving the beginning structures. also, indirect
cropping is employed to concentrate on the most instructional regions of the eye images. This step is particularly
essential to insure that the model's literacy is grounded on the most applicable features in the images.

14
Fig4.1.1 Applying Gaussian Blur

14.

Reused images are also resized and saved to reduce storehouse conditions. The original images may be fairly large
and enthrall a significant quantum of fragment space. Resizing the images to a standardized dimension not only saves
storehouse space but also ensures that all images are harmonious in size, making them suitable for deep literacy
model input. also, image accruals are applied to produce fresh images for data addition. ways similar as gyration,
flipping, cropping, and padding are used to induce a more expansive and different dataset, which helps the model
generalize well on new data.
likewise, features are uprooted from the images, which will serve as the input for the deep literacy model. point birth
is a pivotal step as it defines what aspects of the images the model should concentrate on. These features may include
details about retinal structures, textures, and other important information that aids in the bracket and retrogression
tasks. To better understand the dataset's separability in relation to the various classes of blindness inflexibility, t- SNE
is used to fantasise the data in two confines. By converting the RGB scale images to grayscale and also leveling them,
a vector representation of the images is attained. This vector representation can be used as a point set for visualization
using t- SNE. This provides perceptivity into whether the images belonging to different inflexibility classes are
divisible and how well the model might be suitable to distinguish between them.

15
16
Fig4.1.2 TSNE visualization

In conclusion, Module 1 plays a critical part in laying the foundation for the blindness discovery model. It involves
thorough data disquisition, image processing, visualization, point birth, and data addition. These way are essential in
preparing the dataset and features for posterior model development and training, icing that the model is able of
effectively detecting and classifying blindness inflexibility grounded on eye images.

Module 2: Model Architecture and Training with ResNet50

Module 2 is devoted to the design and training of a deep literacy model using the ResNet50 armature, a important
CNN, for the purpose of detecting the inflexibility of blindness grounded on eye images. The application of the
ResNet50 armature brings robustness and high performance to the model, making it well- suited for this critical
medical operation.

ResNet50, short for" Residual Network 50," is apre-trained CNN model that has shown remarkable success in
colorful computer vision tasks, particularly in image bracket. The use of residual blocks, which allows for the training
of truly deep networks without the evaporating grade problem, is one of its distinguishing

17
features. This makes ResNet50 an ideal choice for rooting meaningful features from complex eye images.

Fig4.2.1 ResNet50 Architecture

18
18.
Fig4.2.2 Model Description

The module begins with the first stage, known asPre-Training. During this stage, ResNet50 serves as the encoder for
point birth. The model armature is extended to incorporate custom affair layers for retrogression, bracket, and ordinal
retrogression tasks. Training, still, is performed simply over to these affair heads, leaving the ResNet50 encoder
layers unaltered. This stage frequently involves usingpre-trained weights from the ImageNet dataset as initializers,
which enables the model to influence the knowledge gained from millions of images in a broad range of orders.

The alternate stage, appertained to as Main Training, involves several critical way. To handle class imbalance, the
loss functions are transitioned to focal loss, a technical loss function that has proven effective in similar scripts. In this
stage, the training process occurs in twosub-stages. First, the ResNet50 encoder layers are firmed , precluding farther
updates to their weights. This effectively allows the model to perform transfer literacy on a small dataset, serving
from the formerly

19
learned features. In the alternatesub-stage, all layers of the model, including ResNet50, are defrosted, and training is
continued. Fine- tuning the entire model, including the important ResNet50 armature, is essential to acclimatize it to
the specific task of detecting blindness inflexibility in eye images.

The third and final stage,Post-Training, focuses on combining the labors from the three heads — retrogression,
bracket, and ordinal retrogression. These labors are integrated into a single cohesive vaticination. A single thick
neuron with direct activation is introduced to minimize mean squared error, icing that the model can make precise
prognostications. Training is continued for fresh ages in this stage, farther refining the model's capability to descry
and classify the inflexibility of blindness grounded on eye images.

Fig4.2.2 Model Summarization

By opting the ResNet50 armature as the core point extractor, this module optimizes the model's capability to learn
and prize meaningful features from the complex eye images. ResNet50's deep armature, coupled with the knowledge
transfer capabilities ofpre-trained weights, significantly enhances the model's performance and effectiveness in the
task of blindness inflexibility discovery.

Module 3: Model Evaluation and Testing

Module 3 is devoted to the evaluation and testing of the trained deep literacy model for detecting blindness
inflexibility in eye images. The primary thing of this module is to assess the model's performance and its capability to
make accurate prognostications grounded on the inflexibility of blindness in cases. This step is essential for validating
the model's clinical mileage and its

20
implicit to be applied in a real- world medical setting.

Fig4.2.3 Model Accuracy

21
CHAPTER 6

CODING AND

TESTING

import warnings warnings.filterwarnings("ignore")


import pandas as pd
import numpy as np
from tqdm import tqdm,tqdm_notebook from prettytable
import PrettyTable import pickle
import os
print('CWD is ',os.getcwd())

from sklearn.manifold import TSNE import seaborn as


sns
import matplotlib.pyplot as plt
%matplotlib inline plt.rcParams["axes.grid"] = False

from PIL import Image import cv2


CWD is c:\Users\giri2\OneDrive\Desktop\diabetic retinopathy

6.1. Business Study: Division into classes

0 - No Diabethic Retinopathy or DR

1 - Mild DR
2 - Moderate DR
3 - Severe DR
4 - Proliferative DR
Training data contains 3662 images, test data contains 1928 images

6.2. Visualization of Images

def load_data():
train = pd.read_csv('train.csv')

22
test = pd.read_csv('test.csv')

train_dir = os.path.join('./','train_images/') test_dir =


os.path.join('./','test_images/')

train['file_path'] = train['id_code'].map(lambda x:
os.path.join(train_dir,'{}.png'.format(x))) test['file_path'] =
test['id_code'].map(lambda x: os.path.join(test_dir,'{}.png'.format(x)))

train['file_name'] = train["id_code"].apply(lambda x: x + ".png") test['file_name'] =


test["id_code"].apply(lambda x: x + ".png")

train['diagnosis'] = train['diagnosis'].astype(str) return train,test

21.
df_train,df_test = load_data()
print(df_train.shape,df_test.shape,'\n') df_train.head(6)

(3662, 4) (1928, 3)

id_code diagnosis file_path file_name


0 000c1434d8d7 2 ./train_images/000c1434d8d7.png
000c1434d8d7.png
1 001639a390f0 4 ./train_images/001639a390f0.png
001639a390f0.png
2 0024cdab0c1e 1 ./train_images/0024cdab0c1e.png
0024cdab0c1e.png
3 002c21358ce6 0 ./train_images/002c21358ce6.png
002c21358ce6.png
4 005b95c28852 0 ./train_images/005b95c28852.png
005b95c28852.png
5 0083ee8054ee 4 ./train_images/0083ee8054ee.png
0083ee8054ee.png

6.2.1 Class Distribution

23
def plot_classes(df):
df_group = pd.DataFrame(df.groupby('diagnosis').agg('size').reset_index())
df_group.columns = ['diagnosis','count']

sns.set(rc={'figure.figsize':(10,5)}, style = 'whitegrid') sns.barplot(x =


'diagnosis',y='count',data = df_group,palette =
"Blues_d")
plt.title('Output Class Distribution') plt.show()

plot_classes(df_train)

Plot Summary - As we can see, the output class distribution has a class imbalance. We will take this
into account when training the models with data augmentation / class balancing methods.

6.2.2 Visualize Images

IMG_SIZE = 200

def conv_gray(img):
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) img
= cv2.resize(img, (IMG_SIZE,IMG_SIZE)) return img

def visualize_imgs(df,pts_per_class,color_scale):
df = df.groupby('diagnosis',group_keys = False).apply(lambda df: df.sample(pts_per_class))
df = df.reset_index(drop = True)

plt.rcParams["axes.grid"] = False for pt


in range(pts_per_class):
f, axarr = plt.subplots(1,5,figsize = (15,15)) axarr[0].set_ylabel("Sample Data
Points")

df_temp = df[df.index.isin([pt + (pts_per_class*0),pt + (pts_per_class*1), pt + (pts_per_class*2),pt


+ (pts_per_class*3),pt +
(pts_per_class*4)])] for i in
range(5):
if color_scale == 'gray':

24
img = conv_gray(cv2.imread(df_temp.file_path.iloc[i]))
axarr[i].imshow(img,cmap = color_scale)
else:

22.

axarr[i].imshow(Image.open(df_temp.file_path.iloc[i]).resize((IMG_SIZ E,IMG_SIZE)))
axarr[i].set_xlabel('Class '+str(df_temp.diagnosis.iloc[i]))

plt.show() visualize_imgs(df_train,3,color_scale = None)

visualize_imgs(df_train,2,color_scale = 'gray')

6.3. Image Processing

6.3.1 Gaussian Blur

rn = np.random.randint(low = 0,high = len(df_train) - 1) img =

cv2.imread(df_train.file_path.iloc[rn])
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) img = cv2.resize(img,
(IMG_SIZE,IMG_SIZE))
img_t = cv2.addWeighted(img,4, cv2.GaussianBlur(img , (0,0) , 30) ,-4
,128)
f, axarr = plt.subplots(1,2,figsize = (11,11))
axarr[0].imshow(img) axarr[1].imshow(img_t)
plt.title('After applying Gaussian Blur') plt.show()

Plot summary - As we can see, using Gaussian Blur allows us to bring out the features/image details
in the eye much more clearly.

3.2 Gaussian Blur with Circular Cropping

def crop_image_from_gray(img,tol=7): if img.ndim


==2:
mask = img>tol
return img[np.ix_(mask.any(1),mask.any(0))]

25
elif img.ndim==3:
gray_img = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY) mask = gray_img>tol

check_shape = img[:,:,0][np.ix_(mask.any(1),mask.any(0))].shape[0]

if (check_shape == 0):
return img else: img1=img[:,:,0]
[np.ix_(mask.any(1),mask.any(0))]
img2=img[:,:,1][np.ix_(mask.any(1),mask.any(0))]
img3=img[:,:,2][np.ix_(mask.any(1),mask.any(0))] img =
np.stack([img1,img2,img3],axis=-1)

return img

def circle_crop(img, sigmaX):


img = crop_image_from_gray(img)
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) height, width, depth =

img.shape

x = int(width/2) y =
int(height/2)
r = np.amin((x,y)) 23.

circle_img = np.zeros((height, width), np.uint8) cv2.circle(circle_img, (x,y), int(r), 1,


thickness=-1)
img = cv2.bitwise_and(img, img, mask=circle_img) img =
crop_image_from_gray(img)
img=cv2.addWeighted(img,4, cv2.GaussianBlur( img , (0,0) , sigmaX)
,-4 ,128)
return img

rn = np.random.randint(low = 0,high = len(df_train) - 1) #img = img_t


img = cv2.imread(df_train.file_path.iloc[rn]) img_t =
circle_crop(img,sigmaX = 30)

26
f, axarr = plt.subplots(1,2,figsize = (11,11)) axarr[0].imshow(cv2.resize(cv2.cvtColor(img,
cv2.COLOR_BGR2RGB),(IMG_SIZE,IMG_SIZE)))
axarr[1].imshow(img_t)
plt.title('After applying Circular Crop and Gaussian Blur') plt.show()
def visualize_img_process(df,pts_per_class,sigmaX):
df = df.groupby('diagnosis',group_keys = False).apply(lambda df: df.sample(pts_per_class))
df = df.reset_index(drop = True)

plt.rcParams["axes.grid"] = False for pt


in range(pts_per_class):
f, axarr = plt.subplots(1,5,figsize = (15,15)) axarr[0].set_ylabel("Sample Data
Points")

df_temp = df[df.index.isin([pt + (pts_per_class*0),pt + (pts_per_class*1), pt + (pts_per_class*2),pt +


(pts_per_class*3),pt + (pts_per_class*4)])]
for i in range(5):
img = cv2.imread(df_temp.file_path.iloc[i]) img =
circle_crop(img,sigmaX) axarr[i].imshow(img)
axarr[i].set_xlabel('Class '+str(df_temp.diagnosis.iloc[i]))

plt.show() visualize_img_process(df_train,5,sigmaX = 30)

6.4. TSNE Visualization


from tqdm import tqdm
npix = 224 # resize to npix x npix (for now) X_train
= np.zeros((df_train.shape[0], npix, npix)) for i in
tqdm(range(df_train.shape[0])):
# load an image
img = cv2.imread(df_train.file_path.iloc[i])
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) X_train[i, :, :] =
cv2.resize(img, (npix, npix))

print("X_train shape: " + str(np.shape(X_train)))

27
X_train shape: (3662, 224, 224)

# normalize
X = X_train / 255

# reshape
X = X.reshape(X.shape[0], -1) trainy
= df_train['diagnosis']

24.

per_vals = [2,5,10,15,20,30,40,50]

for per in tqdm(per_vals):


X_decomposed = TSNE(n_components=2,perplexity = per).fit_transform(X)
df_tsne = pd.DataFrame(data=X_decomposed,
columns=['Dimension_x','Dimension_y']) df_tsne['Score'] =
trainy.values

sns.FacetGrid(df_tsne, hue='Score', height=6).map(plt.scatter, 'Dimension_x',


'Dimension_y').add_legend()
plt.title('TSNE for perplexity = ' + str(per)) plt.show()

100%|██████████| 8/8 [06:24<00:00, 48.09s/it]

28
CHAPTER. 7

RESULTS AND DISCUSSIONS

The evaluation process begins with carrying model prognostications on a separate test dataset. These
prognostications are generated by passing the test images through the trained model, and the model's
labors are collected. Since the model is designed to give three types of prognostications —
retrogression, bracket, and ordinal retrogression — these prognostications need to be harmonized to
determine the final class markers for each image.

In numerous cases, retrogression prognostications give a nonstop value that represents the
prognosticated inflexibility of blindness. To gain a categorical class marker that aligns with the bracket
task, the retrogression prognostications may be subordinated to a rounding operation. This basically
maps the nonstop prognostications to separate classes. This rounding operation is an important step in
carrying the final class markers that can be compared to mortal raters' assessments.

29
Fig5.1 Output Class Distribution

The primary evaluation metric used in this module is the Quadratic Weighted Kappa( QWK) score.
The QWK score is a robust and extensively used metric for assessing the agreement between mortal
raters and model prognostications, especially in medical operations.

It quantifies the position of agreement between two sets of conditions or scores, and in this
environment, it measures the agreement between the conditions handed by mortal raters and the
prognosticated scores from the model.

The QWK score generally ranges from 0 to 1, with 0 indicating arbitrary agreement between raters and
1 indicating perfect agreement. It can also go below 0 when there's lower agreement than anticipated
by chance. In the environment of blindness inflexibility discovery, a advanced QWK score suggests a
stronger agreement between the model's prognostications

30
and the assessments made by mortal experts. This score is a pivotal index of the model's trustability in
diagnosing the inflexibility of blindness.

Fig5.2 QWK Score

In addition to QWK, a regularized confusion matrix is frequently generated to visually represent the
model's performance on the test data. The confusion matrix provides perceptivity into the number of
true cons, true negatives, false cons, and false negatives, allowing a more detailed analysis of the
model's performance for each class of blindness inflexibility.

31
Fig5.3 Confusion Matrix

In conclusion, Module 3 is a critical step in the development and confirmation of the deep literacy
model. It involves the practical assessment of the model's performance using the Quadratic Weighted
Kappa score and the visualization of its performance through the confusion matrix. These evaluation
criteria are essential in determining the model's felicity for clinical use and its implicit to ameliorate the
discovery and bracket of blindness inflexibility grounded on eye images.

These three modules together form a comprehensive approach to developing and assessing a deep
literacy model for the discovery of blindness inflexibility from eye images. From data preprocessing
and image analysis to model armature and evaluation, this channel provides a robust and methodical
frame for addressing a critical medical challenge with the eventuality to ameliorate patient care.

32
CHAPTER 8
CONCLUSION AND FUTURE ENHANCEMENT

The results attained from the trained ResNet- 50 model for diabetic retinopathy discovery are largely
promising. The Cohen Kappa score of 0.980 on the training dataset and0.904 on the test dataset
suggests a veritably strong agreement between the model's prognostications and the ground verity
markers. also, the high delicacy score of 0.965 on the training dataset and0.839 on the test dataset
indicates that the model is performing exceptionally well in classifying diabetic retinopathy.

These results indicate the eventuality of deep literacy, specifically convolutional neural networks(
CNNs), in medical image analysis tasks. The high Cohen Kappa score demonstrates the robustness and
trustability of the model's prognostications, which is pivotal for medical operations. With farther
advances, this diabetic retinopathy discovery design could have a significant impact on healthcare. It
could be integrated into clinical practice to prop medical professionals in the early opinion of diabetic
retinopathy, leading to timely treatment and bettered patient issues.

The unborn prospects for this design are promising, and several avenues can be explored

1. Enhanced Model infrastructures : nonstop exploration in deep literacy can lead


to the development of further advanced model infrastructures, conceivably achieving indeed advanced
delicacy and robustness.

33
2. Larger Datasets: Expanding the dataset to include a larger and further different set of
retinal images can further ameliorate the model's conception capabilities.

3. Real- Time Diagnostics : Integration of this technology into telemedicine or mobile


operations for real- time diabetic retinopathy webbing, making it accessible to a wider population.

In summary, the high performance of the CNN model in detecting diabetic retinopathy is a significant
step toward perfecting healthcare issues. Continued exploration and development in this field hold the
eventuality to revise the early opinion and operation of diabetic retinopathy, contributing to the well-
being of individualities affected by this condition.

34
CHAPTER 9
REFERENCE

[1[ S. Qummar, F. G. Khan, S. Shah, A. Khan, S. Shamshirband, Z. U. Rehman, I. Ahmed Khan, and
W. Jadoon, "A Deep Learning Ensemble Approach for Diabetic Retinopathy Detection," *IEEE
Access*, vol. 7, pp. 150530- 150539, 2019, doi: 10.1109/ACCESS.2019.2947484.

[2] M. D. Abràmoff, J. M. Reinhardt, S. R. Russell, J. C. Folk, V. B. Mahajan, M. Niemeijer, G.


Quellec, "Automated Early Detection of Diabetic Retinopathy," *Ophthalmology*, vol. 117, no. 6, pp.
1147-1154, Jun.2010.

[3] T. Walter, J. C. Klein, P. Massin, and A. Erginay, "A contribution of image processing to the
diagnosis of diabetic retinopathy-detection of exudates in color fundus images of the human retina,"
*IEEE Transactions on Medical Imaging*, vol. 21, no. 10, pp. 1236-1243, Oct. 2002, doi:
10.1109/TMI.2002.806290.

[4] R. Pires, S. Avila, J. Wainer, E. Valle, M. D. Abramoff, and A. Rocha, "A data-driven approach to
referable diabetic retinopathy detection," *Artificial Intelligence in Medicine*,vol. 96, pp. 93-106,
2019, doi: 10.1016/j.artmed.2019.03.009.

[5[ Z. Wang, Y. Yin, J. Shi, W. Fang, H. Li, X. Wang, "Zoom-in-Net: Deep Mining Lesions in Diabetic
Retinopathy Detection," *Medical Image Computing and Computer Assisted Intervention − MICCAI
2017*.

[6] Gulshan, Varun; Peng, Lily; Coram, Marc; Stumpe, Martin C.; Wu, Derek Narayanaswamy,
Arunachalam; Venugopalan, Subhashini; Widner, Kasumi Madams, Tom; Cuadros, Jorge; Kim,
Ramasamy; Raman, Rajiv; Nelson, Philip C. Mega, Jessica L.; Webster, Dale R., "Development and
Validation of a Deep Learning Algorithm for Detection of Diabetic Retinopathy in Retinal Fundus
Photographs,"m *JAMA*, 2016;316(22):2402-2410.

[7] Z. Khan, F. G. Khan, A. Khan, Z. U. Rehman, S. Shah, S. Qummar, F. Ali, S. Pack, "Diabetic
Retinopathy Detection Using VGG-NIN a Deep Learning Architecture," *IEEE Access*, vol. 9, pp.
61408-61416, 2021, doi: 10.1109/ACCESS.2021.3074422.

[8] Hemanth, D.J., Deperlioglu, O. & Kose, U. An enhanced diabetic retinopathy detection and
classification approach using deep convolutional neural network. Neural Comput & Applic 32, 707–721
(2020). https://doi.org/10.1007/s00521-018-03974-0

[9] Moin, K., Shrivastava, M., Mishra, A., Jena, L., Nayak, S. (2023). Diabetic Retinopathy Detection
Using CNN Model. In: Swarnkar, T., Patnaik, S., Mitra, P., Misra, S., Mishra, M. (eds) Ambient
Intelligence in Health Care. Smart Innovation, Systems and Technologies, vol 317. Springer, Singapore.
https://doi.org/10.1007/978-981-19-6068-0_13

[10] R, Revathy. (2020). Diabetic Retinopathy Detection using Machine Learning. International Journal
of Engineering Research and. V9. 10.17577/IJERTV9IS060170.

[11] D. Doshi, A. Shenoy, D. Sidhpura and P. Gharpure, "Diabetic retinopathy detection using deep
convolutional neural networks," 2016 International Conference on Computing, Analytics and Security
Trends (CAST), Pune, India, 2016, pp. 261-266, doi: 10.1109/CAST.2016.7914977.

35
[12] Aquino-Brítez D, Gómez JA, Noguera JLV, García-Torres M, Román JCM, Gardel-Sotomayor PE,
Benitez VEC, Matto IC, Pinto-Roa DP, Facon J, Grillo SA. Automatic Diagnosis of Diabetic
Retinopathy from Fundus Images Using Neuro-Evolutionary Algorithms. Stud Health Technol Inform.
2022 Jun 6;290:689-693. doi: 10.3233/SHTI220166. PMID: 35673105.

[13] Kocur I, Resnikoff SVisual impairment and blindness in Europe and their preventionBritish
Journal of Ophthalmology 2002;86:716-722.

[14] R. Gargeya and T. Leng, “Automated identification of diabetic retinopathy using deep learning,”
Ophthalmology, vol. 124, no. 7, pp. 962–969, 2017.
View at: Publisher Site | Google Scholar

[15] M. Chetoui, M. A. Akhloufi, and M. Kardouchi, “Diabetic retinopathy detection using machine
learning and texture features,” in Proceedings of the 2018 IEEE Canadian Conference on Electrical
Computer Engineering (CCECE), vol. 13–16, pp. 1–4, Quebec, QC, Canada, 2018.

[16] David Ray, Manoj Mishra, Shirley Ralph, Ian Read, Robert Davies, Paul Brenchley; Association of
the VEGF Gene With Proliferative Diabetic Retinopathy But Not Proteinuria in Diabetes. Diabetes 1
March 2004; 53 (3): 861–864. https://doi.org/10.2337/diabetes.53.3.861

[17] APTOS-2019 dataset | Kaggle

36
37
38
39

You might also like