# Skin Lesion Segmentation in Dermoscopic Images with Combination of YOLO and GrabCut Algorithm
## 3 Materials and Methods
### Yolo Architecture
\[\Pr(Class_{i}|Object)*\Pr(Object)*IOU_{predicted}^{ground\ truth}=\Pr(Class_{i})* IOU_{predicted}^{ground\ truth} \tag{2}\]  
The architecture of Yolo was inspired by GoogLeNet [66]. It consists of 24 convolutional layers for feature extraction and two fully connected layers to predict the output of probabilities and coordinates. While Yolo uses a linear activation function for the last layer, the following leaky rectified linear activation (LReLU) function is used for the other layers as seen in the following formula. \[\beta(x)= \begin{cases}x,&if\ x>\ 0\\ 0.1*x,&otherwise\end{cases}  \tag{3}\]  
Also, Yolo utilizes sum-squared error as the loss function. The detailed loss function of Yolo is as follows:  
\[ \begin{array}{ll}\textit{loss}=&\lambda_{\textit{coord}}\sum\limits_{i=0}^{ S^{2}}\sum\limits_{j=0}^{B}1_{ij}^{obj}\Big{[}(x_{i}-\hat{x})^{2}+(y_{i}- \hat{y}_{i})^{2}\Big{]}\\ &+\lambda_{\textit{coord}}\sum\limits_{i=0}^{S^{2}}\sum\limits_{j=0}^{B}1_{ij} ^{obj}\bigg{[}\big{(}\sqrt{w_{i}}-\sqrt{w_{i}}\big{)}^{2}+\bigg{(}\sqrt{h_{i} }-\sqrt{\hat{h}_{i}}\bigg{)}^{2}\bigg{]}\\ &+\sum\limits_{i=0}^{S^{2}}\sum\limits_{j=0}^{B}1_{ij}^{obj}\big{(}C_{i}- \hat{C}_{i}\big{)}^{2}+\lambda_{\textit{moobj}}\sum\limits_{i=0}^{S^{2}}\sum \limits_{j=0}^{B}1_{ij}^{noobj}\big{(}C_{i}-\hat{C}_{i}\big{)}^{2}\\ &+\sum\limits_{i=0}^{S^{2}}1_{i}^{obj}\sum\limits_{\textit{ecclasses}}(p_{i}( c)-\hat{p}_{i}(c))^{2}\end{array}  \tag{4}\]  
Figure 6: A simple representation of how You Only Look Once (Yolo) detects skin lesion location. Firstly, it divides the image into the \((S\times S)\) grids, each grid cell is responsible for creating \(B\) possible bounding boxes with their confidence score and \(C\) class probabilities. where \(x_{i}\) and \(y_{i}\) represent the coordinates of the central point of the bounding box while \(w_{i}\) and \(h_{i}\) symbolize width and height. The \(C_{i}\) is the confidence score and \(p_{i}(c)\) classification loss. The \(\lambda\) values are the constants to be used to increase the loss of bounding box coordinate predictions and to decrease the loss of the confidence predictions from boxes that contain no objects. These values are set as \(\lambda_{coont}=5\) and \(\lambda_{noobj}=0.5\). Lastly \(1^{obj}_{i}\) indicates appearance of an object appears in the cell \(i\) and \(1^{obj}_{ij}\) indicates that the \(j\)th bounding box predictor in cell \(i\) is responsible for that prediction. The first two layers compute the localization loss, while the third layer calculates the confidence loss and the final layer determines the classification loss in the loss formula of Yolo [65]. The Yolo is extremely fast when compared to other object detection and classification algorithms since it looks at the image once and does not require complex processes. Also, it makes more accurate predictions as it scans the entire image. This study employed Yolov3 [13] model, the latest and an improved version of previous Yolo networks [65; 67]. In line with recent advances in object detection algorithms, few but effective developments in the previous Yolo versions have given way to Yolov3. The major changes in Yolov3 are listed below:  
* Yolov3 uses logistic regression as loss function while predicting the confidence scores of bounding boxes. Figure 8: The yellow frame is a bounding box created by the red grid that is responsible for the detection of the lesion. It creates a certain number of bounding boxes. Every bounding box has such parameters as x and y, central coordinates, of the bounding box, w and h, width and height of the bounding box, \(\text{p}_{\text{o}}\) confidence score and \(\text{p}_{\text{cn}}\) class probability scores. Figure 7: Visual representation of intersection over union (IOU), which is a metric used for measuring object detection performance. * Yolov3 utilizes multiple independent logistic classifiers instead of softmax function for the prediction of the class confidence probabilities. This improvement is very important when there are multiple objects in the image.