# Research on Innovative Apple Grading Technology Driven by Intelligent Vision and Machine Learning
## 2 Materials and Methods
### Stem Detection and Fruit Body Subsidiary Positioning
#### 2.3.2 DBB-PANet Feature Fusion Network  
The size and shape of fruit stems vary, and the C3 module in the YOLOv5s neck network (PANet) is a single-branch structure. It often focuses more on feature information within a single locality during feature fusion, which results in poor capability for capturing information of different-sized objects. To address this issue, this paper introduces a multi-scale approach and structural re-parameterization technique to innovate the C3 module. The C3 module is restructured with a DBB [17] module, resulting in a more competitive C3-DBB feature fusion module, as shown in Figure 5a. This approach effectively captures feature information of stems of various sizes. The core component, the DBB module during the training phase, is illustrated in Figure 5b.  
Figure 3: FDNet network structure and subsidiary positioning.  
In the training phase, the C3-DBB module uses a multi-scale approach to capture rich feature information. It employs four different strategies to extract feature information: (I) 1 \(\times\) 1 conv-bn, (II) 1 \(\times\) 1 conv-bn + AVG-bn, (III) 1 \(\times\) 1 conv-bn + 3 \(\times\) 3 conv-bn, and (IV) 3 \(\times\) 3 conv-bn. During the inference phase, structural re-parameterization is used to merge the four different multi-branch structures into a single-branch structure. Among these, strategies (2) and (3) require merging within the branches first. Assuming that two inputs are \(F^{(1)}\in\mathbb{R}^{D_{1}\times C\times 1\times 1},b^{(1)}\in\mathbb{R}^{D_{1}}\) and \(F^{(2)}\in\mathbb{R}^{D_{2}\times C\times K\times K},b^{(2)}\in\mathbb{R}^{D_ {2}}\), the output is as shown in Equation (1):  
\[\mathrm{O}^{\prime}=(Input\odot F^{(1)}+REP(b^{(1)}))\odot F^{(2)}+REP(b^{(2)}) \tag{1}\]  
In this context, \(\odot\) represents the convolution operation, while \(REP(\cdot)\) denotes the padding operation applied to the batch normalization (bn) layer.  
Since \(F^{(1)}\) represents the 1 \(\times\) 1 convolution, a linear recombination strategy is used to merge the parameters into the convolution kernel of \(F^{(2)}\), as shown in Equation (2):  
\[F^{\prime}\gets F^{(2)}\odot T(F^{(1)}),T(F^{(1)})\in\mathbb{R}^{C\times D _{1}\times 1\times 1} \tag{2}\]  
In this context, \(T\) denotes the dimension transformation operation and the symbol \"\(<\)-\" indicates the transformation process and has the same meaning in the following text.  
Figure 4: FasterBlock module structure. * means operation.  
Figure 5: C3-DBB module. (**a**) Detailed structure of the C3-DBB module. (**b**) Structure of the DBB module during the training phase. (**c**) Re-parameterization operation of the DBB module. (**d**) Structure of the DBB module during the inference phase.  
To construct the partial bias term, \(\overset{\wedge}{b}\), it is represented as shown in Equation (3):  
\[\hat{b}\leftarrow\sum_{d=1}^{D}\sum_{m=1}^{K}\sum_{n=1}^{K}b^{(1)}F_{j,d,m,n}^{(2 )},1\leq j\leq D_{2} \tag{3}\]  
Merge all bias terms as shown in Equation (4):  
\[b^{\prime}\leftarrow\hat{b}+b^{(2)} \tag{4}\]  
Finally, merge within the branch to form a new convolution operation, as shown in Equation (5):  
\[Concat(\cdot)=Input\odot F^{\prime}+REP(b^{\prime}) \tag{5}\]  
The merging methods among the four branches align with the strategy used in RepVGG [18]. The specific diagram of branch merging is illustrated in Figure 5c. The DBB module reduces the model's parameter count without losing accuracy, and the structure after structural re-parameterization is shown in Figure 5d. By utilizing the C3-DBB module, the feature fusion network (PANet) was improved, leading to the proposal of the DBB-PANet network to enhance the feature fusion capability of the model.