# Pavement Disease Visual Detection by Structure Perception and Feature Attention Network
## 3 Structure Perception and Feature Attention Network
### Structure Perception with DCNv2  
For detecting disease in pavement images, traditional convolution operations struggle to accurately perceive shapes of diseases with large deformations such as pavement cracks. In fact, geometric changes such as scale, posture, perspective, and partial deformation pose significant challenges to pavement disease visual detection tasks, and all of these can easily result in low detection performance. To this end, this paper integrates the updated version of deformable convolution [36] in SPFAN, which can convolve pavement images with positions that are close to the true structures of diseases and better adapt to their geometric changes, contributing to capturing and describing detailed deformations like pavement cracks. Figure 3 illustrates the difference between conventional and deformable convolution. As shown in Figure 3a, conventional convolutions usually operate on a predefined rectangular grid that is often instantiated as a square with a fixed shape and size. During the convolution process, the convolution kernel traverses the input image or feature map with a specified step size, covering fixed grid positions and generating output values by weighting and summing the input feature values. It is clear that the size and shape of receptive field of convolution kernels are limited since they can only sample feature values at these predetermined points. By contrast, DCNv2 optimizes the sampling process of traditional convolution by incorporating additional offsets. As shown in Figure 3b, DCNv2 not only considers the feature values at fixed positions within the convolution kernel, but also dynamically adjusts the positions of the sampling points according to the local features of the input feature map. This adjustment is achieved by learning the offsets, ensuring that each sampling point has a corresponding offset. These offsets can be fractional, indicating the displacement of the sampling point relative to the original grid position. Due to the dynamic adjustment of sampling point positions, DCNv2 is able to sample features from farther distances, which can effectively expand the receptive field. Meanwhile, since the sampling point positions are dynamically determined based on the local features of the input feature map, SPFAN is capable of adapting to pavement diseases of different shapes and sizes, thus improving its generalization capability. On the whole, the integration of deformable convolution and adjustment mechanism allows DCNv2 to perform precise region of interest pooling operations on target disease areas, and the improvements particularly in the ability to perform non-regular sampling through directional offsets can effectively enhance the perception of structure transformations, which are exactly needed for visual detection of pavement diseases with varying shapes and sizes. Figure 3: Illustration of traditional and deformable convolution. (**a**) traditional convolution; (**b**) deformable convolution. Formally, DCNv2 optimizes the convolution operations through two closely connected steps, as shown in Figure 4a. Firstly, the convolution layer generates dynamic offsets along the x and y axes for the convolution kernels on the input feature map. Based on the generated offsets, it can precisely locate the sampling points using bilinear interpolation techniques and perform convolution operations at these points, achieving more flexible and efficient data processing. On this basis, this paper proposes the C2f_DCNv2 module by integrating DCNv2 with C2f, as illustrated in in Figure 4b. At the architecture level, the last C2f module in the neck of the YOLOv8n is replaced with the proposed C2f_DCNv2 module, which is expected to minimize the impact of additional parameters such as offsets introduced by DCNv2 and thus effectively control the increase in model complexity.