| In the field of industrial inspection,algorithms based on deep learning have been widely used in surface defect detection.However,it is difficult to obtain a sufficient number of defect samples in some industrial fields,making it difficult for data-driven deep learning methods to solve surface defect detection tasks.This paper analyzes in detail the problems faced by the current defect detection algorithms in practical applications,and proposes a surface defect detection algorithm based on transfer learning and a surface defect classification algorithm based on metric learning under the condition of few samples.First of all,in view of the low probability of defects in the actual industrial production environment,which makes it difficult to collect defect samples,resulting in poor detection accuracy and insufficient generalization ability of conventional deep learning-based defect models,this paper proposes a surface defect detection based on transfer learning algorithm.This method improves the Faster-RCNN network according to the characteristics of surface defects.First,the backbone network is replaced with Res Net-50,and based on the characteristics of surface defects,the feature pyramid network FPN and deformable convolution networks are fused to extract features at different scales of defects of different sizes.Then a regularization term is added to the original loss function to limit the influence of the background on the detection accuracy.The NEU-DET surface defect data set is used as the source domain data for training to obtain the model weight.Subsequently,the model network is fine-tuned using the model transfer method in transfer learning to adapt it to the surface defect detection task in the target domain.The experimental results show that the method proposed in this paper solves the problem of insufficient samples in the target defect detection task,has high accuracy and efficiency,and can effectively complete the surface defect detection task.Next,inspired by relational networks,this paper proposes an improved metric learning network to classify surface defects.The basic architecture of the model consists of a feature embedding module and a feature similarity measurement module.First,the inception module is introduced on the basis of the feature embedding module to enhance the feature expression ability of the model.Aiming at the flexible and changeable surface defect size,the dilated Convolution module and skip connection operation are added.Second,In the feature metric module,two attention mechanisms are introduced to strengthen the correlation between features.Then the original loss function of the relational network is improved.The model is pretrained using the Omniglot dataset,and the pretrained model is fine-tuned with the NEU-CLS defect dataset for the target classification task.The accuracy rate reached 0.8642 under the 5-way 1-shot training strategy,and 0.8825 under the 5-way 5-shot training strategy.The experimental results show that the model proposed in this paper achieves relatively advanced classification performance on few sample surface defect detection.Based on deep learning technology,this paper realizes the detection of surface defects under the condition of small samples,which has certain reference value and practical value for the development of industrial surface defect detection technology. |