# Retinal Image Analysis for Diabetes-Based Eye Disease Detection Using Deep Learning
## 2 Proposed Methodology
### Localization Phase
#### 2.2.3 Localization of Glaucoma Regions  
For recognition of the third eye disease i.e., glaucoma, we have trained our method for three classes i.e., OD, OC, and background. FRCNN localized the OD and OC regions, and rest of the portion of retinal image is considered as background. The max-pooling and \(C_{\textit{conv}}\) layers produces the feature map, fixed-size feature vectors are extracted using the ROI pooling layer from the \(C_{\textit{conv}}\) feature map. And then supplied into a series of _fc_ layers before branching into separate output layers, the first layer computes Softmax-probability estimates over \(k=3\) region classes and the other layer produces \begin{table}
\begin{tabular}{c c c} \hline \hline
**DR** & **DME** & **Glaucoma** \\ \hline
0. Background 1. Microaneuryss & 0. Background & 0. Background \\
2. Soft exudates 3. Hard Exudates & 1. Macula Region & 1. OD \\
4. Hemorrhages & & 2. OC \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Classes of eye diseases. four real-valued numbers for three region classes which represent a position of the box for one of the glaucoma classes. Feature Extraction  
Object localization approaches employ a sliding window to identify the region of interest, i.e., vehicles, buildings, etc. However, advances of DL methods like CNN have replaced the earlier detection approaches with good performance. However, these techniques are economically expensive as they stick to the sliding window method for localizing the objects, so FRCNN proposes regions by a selective search approach to improve the performance and can train all network weights with backpropagation. FRCNN is initialized by the CNN network and experiences three conversions: (i) the RoI layer substitutes the max-pooling layer with \(h=w=7\) for VGG16. (ii) the \(fc\) and softmax layers are changed with two sibling output layers which are the \(fc\) and Softmax over the \(k+1\) category and bbox regressor. (iii) Our proposed method takes two inputs: the list of images I(x,y) and the list of ROIs from the input images [45]. FRCNN can train all weights with backpropagation, which does not appear in SPPnet [26] because the SPP layer becomes inefficient when RoI derives from different sample images. In FRCNN training, mini-batches are sampled by using the \"stochastic gradient descent\" (SGD), first \(N\) images, and then \(R/N\) ROIs are sampled through every retinal sample. Mini-batch computation decreases as \(N\) decreases. For example, If \(N=2\), \(R=128\), and \(R/N\) become 64, which means the training method is 64 times faster than sampling a single RoI from 128 diverse samples (i.e., RCNN and SPPnets) [44]. FRCNN is the end-to-end learning framework that uses multi-task loss function to learn the class of region and the related bbox position and size. Each ROI is labeled with class name \(u\) and bbox regression target \(v\). let \(p\) be the output of Softmax sibling layer that is the probability distribution over \(k\) classes including background class, and t be the result of regressor sibling layer that is bbox tuple for each class \(k\)[46]. We used a multi-task loss \(L\) on each labeled ROI to jointly train for classification loss and bbox regression loss as shown in Equation (1):  
\[L(p,u,t^{\mu},v)=L_{cls}(p,u)+\lambda[u\geq 1]L_{loc}(t^{\mu},v) \tag{1}\]  
The log loss for true class \(u\) is \(L_{cls}(p,u)=-\text{log}p_{u}\) and \(L_{loc}(t^{\mu},v)\) denotes a smooth \(L1\) loss (\(S_{L1}\)) for regression output as in Equation (2):  
\[L_{loc}(t^{\mu},v)=\sum_{i\in[x,y,w]_{i}}S_{L1}(t_{i}^{\mu}-v_{i}) \tag{2}\]  
where:  
\[S_{L1}(x)=\left\{ \begin{array}{ll}0.5x^{2}&\quad\text{if }\left|x\right|<1\\ |x|-0.5&\quad\text{otherwise}\end{array} \right\} \tag{3}\]  
In Equation (1), \(\lambda\) denotes a hypermeter that determines the relative weight of the regression loss versus the classification loss to the overall loss. we used \(\lambda=1\) for all experiments. The \([u>1]\) means that there is no \(L_{loc}\) defined for the background class.