# Dense Small Object Detection Based on an Improved YOLOv7 Model
## 3 Proposed Method
### Multi-Scale Feature Extraction Module  
Considering that the fine-granularity of feature graphs at different levels contributes differently to small objects, blending features only at equal levels may produce redundant information and conflicts, affect context information, interfere with the network's learning of small objects, and slow down the inference speed. For that purpose, this paper introduces Res2 Net to redesign the residual structure within C3. As depicted in Figure 2, Res2 Net employs grouped convolutions within a single residual block to evenly distribute channels across the input feature map. Utilizing a series of compact convolutional kernels ensures model efficiency. Furthermore, employing a ladder structure expands the range of scales represented by the output feature map, enhancing the model's ability to capture multi-scale features that are essential for detecting small objects.  
The calculation formula for Res2 Net is as follows:  
\[y_{i}=\begin{cases}\begin{gathered} x_{i},i=1;\\ k_{i}(x_{i}),i=2;\\ k_{i}(x_{i}+y_{i-1}),2<i<s.\end{gathered}\end{cases} \tag{1}\]  
Suppose that the number of output channels of the feature graph of Res2 Net after a 1 \(\times\) 1 convolution becomes n; then, the split operation is used to divide the input feature graph into \(s\) subsets equally along the channel direction, which are represented by \(x_{i}\), where \(i=\{1,2,...,s\}\). Each feature graph subset \(x_{i}\) has the same scale as the feature graph, but the number of channels becomes \(n/s\). There is a corresponding 3 \(\times\) 3 convolution after each \(x_{i}\) except for the first set of convolution \(x_{i}\). The convolution layer is represented by \(k_{i}()\), and the output after \(x_{i}\) is represented by \(y_{i}\), where \(i=\{1,2,...,s\}\). Forthe output current \(x_{i}\) and the last \(y_{i-1}\), the result of the combination is \(k_{i}()\) input, so each \(k_{i}()\) before the input contains \(\{x_{i},j\leq i\}\) or fewer group characteristics and adopts hierarchical multiple-connection mode again at the same time so that each \(y_{i}\) can extract more abundant and more scale features on the basis of \(y_{i-1}\).  
As can be seen from Formula (1), the larger the value of \(s\), the larger receptive field can be learned. However, the larger the \(s\) value, the more redundant the network will be. We  
Figure 2: Structure of Res2 Net module.  
set \(s\) to 4 so that the output feature map contains different sizes and quantities of receptive fields. This hierarchical residual structure makes the feature information of a single scale no longer extracted from each level but represents multi-scale features at a finer granularity level, inhibits the generation of conflicting information, and enables the fused feature map to have more powerful and rich semantic information and texture details, thus improving the attention of the network to small objects.  
Combining C3 and Res2 Net, we designed a module called the C3R2N, as illustrated in Figure 3. The input feature map passes through two convolution layers with a convolution kernel of the same size and the number of output channels halved, and it is divided into two branches by normalization and a Sigmoid operation to achieve the purpose of reduction and feature extraction. One branch then passes through the Res2 Net module to concatenate the channel dimension with the other branch. Finally, the combined output is processed through the convolution, normalization, and Sigmoid functions to generate a feature map that is rich in multi-scale information.  
This module is used to replace the feature fusion ELAN_1 and ELAN_2 modules with 16-fold downsampling of the original YOLOv7. This method can effectively improve the detection effect of small and medium-sized targets.