# DBCW-YOLO: A Modified YOLOv5 for the Detection of Steel Surface Defects
## 3 Method
### Dbcw-Yolo
#### 3.2.1 Improved Feature Fusion  
Feature fusion performs an essential role in target detection tasks. In YOLOv5, the PANet architecture is utilized for feature fusion. This cascade of feature maps transformed by the same size is not fully utilized for features between different sizes, making the detection accuracy limited. Moreover, the nearest neighbor interpolation method is the original up-sampling algorithm of the adopted neck network in YOLOv5. However, relying on the nearest neighbor pixel values does not allow us to obtain the subtle information of the image; the feature-aware domain is relatively small, and the edge information in the image produces an obvious jagged effect. To improve the detection abilities of the model, this paper proposes an enhanced feature fusion network, which introduces the idea of BiFPN [32] multi-scale feature fusion in the YOLOv5 neck. Moreover, this paper introduces a lightweight up-sampling module called CARAFE to improve the up-sampling algorithm for feature fusion in YOLOv5 without incurring additional computational costs. BiFPN uses bidirectional cross-scale connectivity and weighted feature map fusion to optimize the model. Bidirectional fusion is used to construct top-down and bottom-up bidirectional channels to fuse information from different scales of the backbone network. The fusion scales are up-sampled and down-sampled for the same feature resolution scale, and horizontal connections are added between the input and output nodes of the same feature to fuse as many features as possible simply without increasing the cost. In this study, the strategy of BiFPN is used, which establishes forward and backward cross-layer feature transfer paths at different layers using bidirectional connectivity to enhance  
Figure 2: DBCW-YOLO network architecture. semantic representation and differentiation. The use of shallow features and fusion of multi-scale information are improved to enhance the model's ability to recognize targets at different scales. The structure of PANet is shown in Figure 2(a). BiFPN's structure is shown in Figure 2(b). For the problem of lost up-sampling information, this paper adopts a lightweight up-sampling module, CARAFE, to enhance the up-sampling algorithm of YOLOv5, which fully captures the semantic information in steel defect images and enhances the feature mapping capability, and it does not require more computational cost. CARAFE is an up-sampling operator that utilizes feature adaptation and feature reorganization. It is mainly composed of two parts: a content-aware reorganization module and a kernel prediction module. Its function is mapped from the input features of shape \(H\times W\times C\), and the feature map with shape \(\delta H\times\delta W\times C\) (\(\delta\) denotes the up-sampling ratio) is output by up-sampling kernel prediction and feature reorganization. Moreover, the newly generated feature map includes more semantic information. The network comparison of the original network and the improved network is illustrated in Figure 4.  
In Figure 4, Module 1 stands for the part of the kernel prediction module and Module 2 stands for the part of the content-aware reassembly, whose structures are illustrated in Figure 5. The parameters are explained as follows: \(N\): batch size, \(C\): input channel of the feature mapping, \(H\): image height, \(W\): image width, \(Cm\): compression channel, \(k_{cn}^{2}\): encoder size, \(\delta\): up-sample ratio, and \(k_{up}^{2}\): recombination core size. Figure 4: Original network (**left**) and improved network (**right**). Figure 3: Comparison of structural diagrams. The function of the kernel prediction module is to generate a reorganized convolutional kernel. The input feature mapping is first compressed by a \(1\times 1\) convolution operation to reduce the computational effort.