# A Novel Deep Learning Method for Detecting Strawberry Fruit
## 2 Materials and Methods
### RFT-YOLO for Detecting Strawberry  
This paper proposes a novel RTF-YOLO model derived from YOLOv5. The framework of RTF-YOLO is shown in Figure 3, and the specific module structures of YOLOv5 are shown in Figure 4.  
YOLOv5 is a convolutional neural network mainly comprising three parts: a backbone network, a neck network, and a detection head. The backbone network consists of the Conv,  
\begin{table}
\begin{tabular}{c c c c c} \hline \hline \multirow{2}{*}{**Dataset**} & \multirow{2}{*}{**No. Images**} & \multicolumn{3}{c}{**Label**} \\ \cline{3-5}  & & **Ripen** & **Unripen** & **Total** \\ \hline Training & 1428 & 3240 & 2952 & 6192 \\ Validation & 408 & 962 & 738 & 1700 \\ Test & 204 & 370 & 450 & 820 \\ \hline \hline \end{tabular}
\end{table}
Table 1: Details of the strawberry dataset used for training, validating, and testing the proposed model.  
Figure 3: The overall framework of the RTF-YOLO model. The backbone network consists of QARepNeXt, Conv, and SPPF modules. The neck network consists of FPN and PAN structures and the triplet attention mechanism. The head network includes three detection heads with different resolutions and utilizes the focal loss function for target classification.  
Figure 2: Image augmentation methods: (**a**) original image, (**b**) horizontal mirror, (**c**) 90\({}^{\circ}\) clockwise rotation, (**d**) 180\({}^{\circ}\) clockwise rotation, (**e**) 270\({}^{\circ}\) clockwise rotation, and (**f**) random transformation of saturation and brightness.  
C3 (cross-stage partial), and SPPF (spatial pyramid pooling--fast) modules. The Conv and C3 modules are the primary feature extractors, while the SPPF is employed to extract multi-scale features to improve the detection accuracy for objects of varying sizes.  
YOLOv5s's neck part was constructed by PANet, which employs a hierarchical FPN (feature pyramid network) structure [24] and PAN (path aggregation network) structure [25] to transmit distinctive semantic attributes and positional characteristics from top to bottom and vice versa. PANet enhances the receptive field and provides a richer input representation. YOLOv5s's detection head comprises three convolutional layers to detect objects at distinct scales. This multi-scale design, coupled with varied aspect ratio anchor boxes, enhances the detection performance across diverse object sizes and shapes. YOLOv5 utilizes a compound loss function, which comprises localization loss, confidence loss, and classification loss. The CE (cross-entropy) loss and GIOU (generalized intersection over union) method were selected for the classification loss and localization loss, respectively.  
The RTF-YOLO model essentially follows YOLOv5s's architecture due to its superiority and enhances the backbone network, neck network, and loss function. First, the C3 module was replaced by the proposed QARepNeXt module to reduce the computational complexity based on structure reparameterization technology. Then, the triplet attention mechanism was embedded in the neck network to enhance feature fusion. Lastly, the focal loss function was introduced to replace the CE loss function, which can balance the positive and negative examples and strengthen the learning ability of challenging examples.