# EXOLOv3: An Efficient Real-Time Detection Model for Floating Object on River
## 3 Proposed Method
### EYOLOv3: Optimized YOLOv3 Model
#### 3.3.2 Anchor Box Design  
The YOLOv3 model used nine priori anchor boxes obtained by the dataset COCO, which are not suitable for floating objects on river. In the real scene, the shapes of the floating objects are varying and have the different aspect ratios from the objects in dataset COCO. We also manually set for anchor boxed may not be able to match the ground truth box of the floating, which affects the final detection as a result. Therefore, we design appropriate anchor boxes to improve the model faster and more accurate. The clustering  
Figure 4: Feature fusion module.  
Figure 5: The visualization process of feature fusion module. (**a**) original image, (**b**) visualization of the feature in Conv14 layer, (**c**) visualization of the feature in Conv16 layer, (**d**,**e**) show the visualization of the fused feature.  
algorithm is to maximize the IOU overlapping value between the anchor box and the ground truth box. The measurement function is shown in Formula (3):  
\[d(box,\ centroid)=1-\text{IoU}(box, centroid) \tag{3}\]  
Here, \(box\) is the ground truth box, and \(centroid\) is the cluster center. The value of the distance \(d\) decreases with the increase of the IOU value. According to the above method, K-means++ [34] is used to re-cluster the anchor boxes of the floating on river.  
The steps of the K-means++ in detail are as follows:  
1. Randomly select a sample from our dataset and take it as the initial clustering center;
2. Calculate the shortest distance between each data point and the existing clustering center;
3. Select a new data point as the clustering center. The selection principle is as follows: the greater the distance calculated in step 2, the greater the probability that it will be selected as the next clustering center. Then the next cluster center is determined by the method of polling scheme;
4. Repeat step 2 and step 3 until \(k\) clustering centers are selected;
5. Associate the each remaining sample point in the data set d with its nearest clustering center respectively and take it into the same clustering;
6. Calculate the mean value of each clustering, and take it as the clustering center of each group; and
7. Repeat step 5 and step 6 until the new clustering center is the same as the initial clustering center or less than a pre-set threshold.  
The K-means++ algorithm is shown in Algorithm 1.  
```
Repeat {  for \(i=1\) to \(m\) & \(k=1\) to \(K\) \(D^{(i)}\ :=\|x^{(i)}-\mu_{k}\|^{2}\) \(p^{(i)}\ :=\frac{D^{(i)}}{\sum_{i}D^{(i)^{2}}}\) for \(i=1\) to \(m\) \(c^{(i)}\ :=arg\cdot min_{k}\|x^{(i)}-\mu_{k}\|^{2}\) for \(k=1\) to \(K\) \(\mu^{(i)}\ :=\frac{\sum_{i}^{m}I\{c^{(i)}=k\}.x^{i}}{\sum_{i}I\{c^{(i)}=k\}}\) }
```  
**Algorithm 1** K-means++ algorithm  
Where \(D^{(1)},\ D^{(2)},\ldots,D^{(m)}\) represents the shortest distance between each data point and the existing clustering center, and \(P^{(1)},P^{(2)},\ldots,P^{(m)}\) represents the probability that each data point is selected as the next clustering center.  
The label format of floating object dataset created in this paper is shown in Table 1. Here, object-class indicates the object category label, (\(x\),\(y\)) indicates the center coordinate of the ground truth box, and width and height indicate the width and height of it, respectively.  
We use the values of width and height to get the clustering centers of the floating objects, and set the coordinates \(x\) and \(y\) to 0 at initialization phase. Figure 6 shows the aspect ratio distribution and the clustering process of the ground truth boxes of floating, where the horizontal ordinate is the width of the ground truth boxes, and the ordinate is the height of the ground truth boxes.  
\begin{table}
\begin{tabular}{c} \hline \hline
**Dataset Label Format** \\ \hline \hline \(<\)object-class\(>\)\(<\)\(x>\)\(<\)\(y\)\(<\)width\(>\)\(<\)height\(>\) \\ \hline \hline \end{tabular}
\end{table}
Table 1: Dataset label format.  
Considering the balance between calculation efficiency and accuracy of the network, we choose nine anchor boxes, as shown in Table 2: