## 1 Introduction
Furthermore, these simple fusion operations fail to take both channel and spatial attention into account simultaneously. So these methods are unable to determine what and where to emphasize or suppress features effectively. In this work, a multi-scale feature adaptive fusion (MFAF) is proposed. MFAF can adaptively extract and integrate the features from different layers and scales, and take both channel and spatial attention into account. Specifically, the MFAF makes use of a cascade of different kernels and dilated convolution layers to capture multi-scale contextual information. Then, the channel attention weights of the features with different scales are extracted by the SEWeight [17], and these channel weights are re-calibrated by using the Softmax operation to establish long-range channel dependency. Finally, an improved spatial attention module SAM [18] is utilized. Thus, the channel-wise and spatial-wise features with different receptive fields can be acquired. In recent years, CNN has achieved outstanding success for computer vision [6]. Meanwhile, many significant CNN architectures are proposed, such as, VGG [19], Inception-v4 [20], ResNet [21], and HRNet [22]. However, these CNN backbones still suffer from some drawbacks. For example, a convolution unit only samples the feature map at fixed shapes  
Figure 1: Three kinds of surface defect detection tasks. (**a**) Image-level defect classification task. (**b**) Region-level defect detection. (**c**) Pixel-level defect segmentation. and locations. As a result, the receptive field of a convolution unit cannot be adjusted according to different surface defects. Inspired by Deformable convolutional networks (DCN) [23], we design an adaptive convolution module (ACM) with fewer parameters and lower computational cost to enhance CNNs' capability of extracting features of surface defects. Specifically, 4-channel offsets are added in the traditional convolution, and then the offsets are utilized to accommodate the positions and shapes of convolution units respectively. The offsets can be learned from the input feature maps via a convolutional block. To further enhance the capability of ACM, MFAF is employed to obtain the offsets. Recently, the success of most state-of-the-art (SOTA) modern detectors [24; 25; 26] derived from the use of anchors. However, these anchor-based detectors suffer from some drawbacks. For instance, a set of anchor boxes are uniformly predefined with fixed scales and shapes, which increases the difficulties of bounding box regression. Inspired by Guided Anchoring (GA) [25], a more efficient adaptive anchor module (AAM) is proposed in this paper. Specifically, AAM first identifies the locations that may contain surface defects and then determines the anchor shapes at different locations. In addition, a location-guided shape adaptation component is designed, which can utilize the location information to yield more suitable anchors. Therefore, AAM is able to yield more accurate preset anchors for different surface defects adaptively, rather than using hand-designed preset anchor boxes blindly. In addition, only one anchor is predicted by AAM at each location of the feature map, which decreases computational cost effectively. In summary, the principal contributions of this work are as follows:  
(1) A multi-scale feature adaptive fusion (MFAF) is proposed. It can adaptively extract and integrate the features from different layers and scales, and meanwhile take both channel and spatial attention into account. (2) An adaptive convolution module (ACM) is proposed in this work, which can adjust the location and shape of the convolution unit according to surface defects with different shapes and locations. (3) An adaptive anchor module (AAM) is proposed, which is capable of adjusting the shapes and scales of anchor for different surface defects instead of using fixed preset anchors blindly.