{'fraction_non_alphanumeric': 0.023507063991451978, 'fraction_numerical': 0.014127982903953461, 'mean_word_length': 4.6347826086956525, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Classification of Diabetic Retinopathy Severity in Fundus Images with DenseNet121 and ResNet50

In this work, deep learning algorithms are used to classify fundus images in terms of diabetic retinopathy severity. Six different combinations of two model architectures, the Dense Convolutional Network-121 and the Residual Neural Network-50 and three image types, RGB, Green, and High Contrast, were tested to find the highest performing combination. We achieved an average validation loss of 0.17 and a max validation accuracy of 85 percent. By testing out multiple combinations, certain combinations of parameters performed better than others, though minimal variance was found overall. Green filtration was shown to perform the poorest, while amplified contrast appeared to have a negligible effect in comparison to RGB analysis. ResNet50 proved to be less of a robust model as opposed to DenseNet121.


Introduction
Diabetic Retinopathy (DR), is a form of vision impairment caused by high blood sugar. The high amount of blood sugar damages the blood vessels in the retina, and causes blood leakage in the eye. This can lead to vision loss and if untreated, can lead to blindness.
DR is the leading cause of vision impairment in working-age adults, and it is estimated that 200 million people in the world will suffer from DR by 2050. So far, the safest and most accurate way to check for DR has been DR screenings, where human assessors check the retina to make sure it is not damaged. Unfortunately, this method is not widely performed because of a lack of qualified assessors, which led us to seek a machine learning model to solve this issue. Most of our models perform well, with an average testing/validation accuracy of 80%, which is impressive considering the amount of time we had to experiment.

Overview of Proposed Study
To solve the problem of a lack of human assessors for DR, we compiled a neural network in Python to classify DR severity levels in different fundus images. We obtained our data from kaggle.com, where the dataset was hosted [1]. It was hosted by the Asia Pacific Tele-Ophthalmology Society (APTOS) as a competition to increase awareness for Diabetic Retinopathy. For our experiment, we tested 6 different combinations of CNN model architectures and image types to find the combination with the best validation accuracy and loss. The table below shows all of the combinations that we tested on our fundus image dataset.

Preprocessing Stage
Before training our models with the 3662 RGB fundus images from the Kaggle dataset [1], we had to preprocess our images to help the We also had to resize all of our images to a 244x244 resolution to make the images smaller and easier to process, and to match the default input dimensions for DenseNet121 and ResNet50, the architectures we used to compile our models.

Network Architecture
In our research, we used neural networks to help us with our machine learning algorithms. Neural networks are a subset of machine learning and consists of neurons in the form of where a is the output, z is the weighted sum, f is the activation function, w is the weight, and x ∈ R m is the m-dimensional input vector. We can train a neuron by optimizing its loss function through gradient descent, which we chose to be binary cross-entropy, defined by where t is the output size, given by W −K+2P S + 1, W is the input size which is initially 224, K is the kernel size, which varies from 3 to 7 from convolution layer to layer, and P is the image padding, which we set to 10 so the original 244x244 images fit our DenseNet121 and ResNet50 implementation requirements. y represents a vector of expected outcome whereasŷ represents a vector of predictions. Due to its memory advantages with respect to the positive classes we defined, we used the rectified linear unit (ReLU) activation function defined as The convolutional neural network (CNN), commonly used to analyze images, was utilized to process fundus images used in DR screenings. The main concept behind CNNs is convolution, which is a math operation that lets us find a pattern in a portion of the image. To perform it, we multiply each number in an image tile by the corresponding number in the kernel, which is the pattern we are looking for. In the end, we add them together, and get an output. We do this for each pixel in an image, which allows us to find where the object in the image. The equation for convolution is defined as where f is the input image, h is the kernel, m is the index of the row, and n is the index of the column.
The 2 types of model architectures we used were DenseNet121 and ResNet50. In a DenseNet121 architecture, each layer is connected to every other layer, while layers only connect to the next layer in traditional CNNs [8]. This allows for fewer parameters, making DenseNet more efficient than traditional CNNs. In a ResNet50 architecture, shortcut connections are introduced that skip one or more layers, which allows the network to be trained much deeper than normal [5].

Model Compilation and Training Process
In our code, we used Tensorflow and Keras to compile our Sequential models, along with DenseNet121 and ResNet50. Many hyperparameters needed to be changed for our model, including the learning rate, optimizer and number of epochs. The learning rate is an optimization algorithm that controls how much the model is changed in response to a prediction error [3]. The optimizer we used was Adam, introduced in 2015 as an alternative to the stochastic gradient descent procedure (SGD). We chose Adam as the optimizer because it is memory-efficient and easy to implement. For our number of epochs, we chose 15 because it gave all of our combinations a chance to reach its highest validation accuracy. We also chose a batch size of 32, as it is an optimal batch size for image classification models.

Results
Below are the plots for our model statistics.

Result Analysis
From the table of results, we can see that there is no significant advantage that one combination has over the others, but only slight advantages in different categories. ResNet50 + RGB had the highest average validation accuracy, but DenseNet121 + RGB had the lowest average validation loss. As a result, we come to the conclusion that we simply do not have enough data to get a firm answer as to which combination performs the best. However, we did acheive fairly high results throughout most of our slides, but these numbers can always be improved.

Future Works
In the future, it is possible for us to add more datasets to our collection to increase our accuracy and decrease our loss. It is also possible for us to test out different architectures, as we only tried two, DenseNet121 and ResNet50. We could try out AlexNet or VGG in the future, as they are both well-respected model architectures in the field of image classification. Also, it may be possible for us to use our model to classify for other diseases like glaucoma and age-related macular degeneration (AMD) in the future. These are both eye diseases related to vision loss and blindness in adults. Most importantly, implementing feature extraction into these architectures could make our model much stronger by quantitatively analyzing the diabetic retinopathy image data.

Activation Functions
Below is the graph for the rectified linear unit function, R(z) := max(0, z), which is the primary activation function that was applied through each layer in both DenseNet121 and ResNet50. We additionally applied Softmax at the end junction of our DenseNet121 network, defined as the vector-valued function σ with the following calculable indices: where σ is the Softmax function, z is the input vector from the penultimate layer of the network, and K = 5 ({0, 1, 2, 3, 4}) is the number of classes in our multi-class classifier. We can additionally define the above function in a more compact sense defining the exponential of a vector:

Acknowledgments
We would like to thank our mentors Rahul Ram and David Liang for their continued support and guidance throughout our research project. We would also like to thank Camp Illumina and its co-founders Amber Luo and Amy Liu for this opportunity to connect with others through research as a common field of passion. Finally, we would like to thank all of the RSI alumnus who acted as nobodies and gave us feedback during our posterless and final symposium presentations.