# Semi-Supervised Method for Underwater Object Detection Algorithm Based on Improved YOLOv8
## 3 Materials and Methods
### The Proposed Detection Model, SUD-YOLO
#### 3.2.1 The Proposed Semi-Supervised Learning Method for Training SUD-YOLO  
In the task of underwater object detection, existing datasets have relatively few images, and manual labeling is costly in terms of both labor and financial resources. We introduced the Mean Teacher semi-supervised learning method [16] and proposed a multi-scale pseudo-label box enhancement method to improve the semi-supervised results, effectively utilizing a large amount of unlabeled data. Figure 5: RFEConv module architecture. Figure 6: TAE head module architecture. The semi-supervised object detection learning framework proposed in this paper is shown in Figure 2.  
In this study, the data are divided into two parts: unlabeled data and labeled data. The labeled data undergo strong augmentation, while the unlabeled data undergo both weak and strong augmentations [32]. Weak augmentation includes mosaic augmentation, random flipping, and other augmentations that significantly affect the bounding boxes, while strong augmentation includes random color changes, grayscale changes, and other augmentations that affect the color significantly. The teacher network generates pseudo-labels using weakly augmented unlabeled data, treating these pseudo-labels as the ground truth for the unlabeled data to guide the student network's learning. Specifically, the teacher network generates pseudo-labels for the weakly augmented unlabeled data, which serve as the learning reference for the student network. During training, the student network not only uses the strongly augmented labeled data for supervised learning but also leverages the pseudo-labels generated by the teacher network to perform unsupervised learning with the strongly augmented unlabeled data, thereby enabling the effective use of the unlabeled data. To ensure that the pseudo-label generation is not affected by network fluctuations, the parameters of the teacher network are updated using the exponential moving average (EMA) of the student network's parameters [18]. The EMA technique smooths the update process of the teacher network's parameters, making the pseudo-labels more stable and reducing the uncertainty caused by sharp fluctuations in the teacher network's parameters during training. This stability enhances the reliability of the pseudo-labels, thereby improving the overall performance of the semi-supervised learning framework. The loss function of this semi-supervised learning framework consists of two parts: one part is the supervised learning loss, which measures the performance of the student network on the strongly augmented labeled data; the other part is the unsupervised learning loss, which evaluates the learning effectiveness of the student network on the strongly augmented unlabeled data and pseudo-labels. \[Loss=L_{s}+\lambda\ L_{u} \tag{1}\]  
where \(L_{s}\) and \(L_{u}\) denote the supervised loss and unsupervised loss, and \(\lambda\) denotes the weight of the unsupervised loss. \(L_{s}\) is defined as  
\[L_{s}=L_{s}^{cls}+L_{s}^{bbox}+L_{s}^{DFL} \tag{2}\]  
where \(L_{s}^{cls}\) denotes the classification supervised loss, \(L_{s}^{bbox}\) denotes the bounding box supervised loss, and \(L_{s}^{DFL}\) denotes the DFL supervised loss. \(L_{u}\) is defined as  
\[L_{u}=L_{u}^{cls}+L_{u}^{bbox}+L_{u}^{DFL} \tag{3}\]  
where \(L_{s}^{cls}\) denotes the classification unsupervised loss, \(L_{s}^{bbox}\) denotes the bounding box unsupervised loss, and \(L_{s}^{DFL}\) denotes the DFL unsupervised loss. One significant change in YOLOv8 compared to YOLOv5 is the transition from an anchor-based to an anchor-free approach. Without prior anchors, YOLOv8 generates fewer anchor boxes, which is disadvantageous for semi-supervised learning because this approach relies on the pseudo-anchor boxes generated by the model. With fewer pseudo-anchor boxes, the model is more likely to learn incorrect knowledge, leading to a decrease in both accuracy and recall [33]. Therefore, the semi-supervised improvement effect in YOLOv8 is relatively smaller than that in YOLOv5.