| Detecting defects on fabric surfaces poses numerous challenges due to their multifaceted nature.This makes feature extraction difficult,especially when dealing with small defects and those that are difficult to detect due to high fabric fusion.Although the development of deep learning and computer vision has offered new possibilities for fabric defect detection,it has exposed challenges related to high computational requirements and algorithmic complexity.This has led to slow defect detection speeds that fail to meet the actual operational needs of textile enterprises.To overcome these challenges,this article proposes a lightweight fabric defect detection model based on an attention mechanism,aimed at achieving high accuracy and rapid defect detection.The main works of this project include:A fabric defect detection algorithm based on improved Firstly,in view of the large number of small-scale textile defects and the significant variation in the scale of textile defects,an improved fabric defect detection model based on YOLOv4 is designed.On the basis of the original YOLOv4,a multi-scale fusion network is used to combine shallow and deep features to generate a new feature layer of scale,which reduces the feature loss caused by small defects with the increase of model layers.Secondly,according to the multi-scale characteristics of fabric defects,the Kmeans algorithm is used to calculate the anchor boxes required by the model,making the model more sensitive to the boundaries of defects,and improving the accuracy of their localization,thus achieving end-to-end detection.A fabric defect detector based on attention machanism has been proposed.Some fabric defects have high fusion with the fabric and others are even difficult to detect with the naked eye,which makes defect detection challenging.To address this issue,we first studied the attention mechanism that emphasizes the fabric defect area by leveraging the characteristic that the higher level of the model network contains more abundant semantic information regarding the defects.Additionally,a novel technique called Soft Pool was introduced to perform multi-scale pooling on the feature map output of the backbone network.This technique retains pixel values based on weights in the feature map,addressing prevalent issues such as information loss during traditional pooling and weakened target feature strength.As a result,the model’s ability to extract multi-scale fabric defects is greatly enhanced.The model achieved an accuracy of 83.31% on the test set of 12 fabric defect types,effectively improving the detection of small and highly integrated defects with the fabric.A more lightweight fabric defect detector called YOLO-SDP has been proposed.A novel SPP(Spatial Pyramid Pooling)structure was proposed in the study,which replaces the single large pooling kernel with multiple small-sized ones arranged in a cascade.This allows for extraction of multi-scale defect information with only one feature extraction step,ensuring the functionality of multi-scale pooling while enhancing the model’s inference speed.Moreover,depthwise separable convolutions were introduced in suitable locations to address the challenge of a large feature enhancement network within the model,yielding a much lighter model.Compared to YOLOv4,the proposed model YOLO-SDP shows an 8.49% improvement in average precision,while occupying only half the volume,thus vastly improving detection speed. |