| With the increasing impact of mobile phones on people’s lives,society’s requirements for the quality of key components of mobile phone lens surfaces are also getting higher and higher.Therefore,it is necessary to detect the surface defects of mobile phone lenses during the production process to improve yield.At present,manual inspection and traditional machine vision inspection are widely used in mobile phone lens production lines.Among them,manual inspection consumes human resources and has a high error rate,while traditional machine vision inspection requires experts to design special defects for specific defects,which is not universal and can only be used.The shallow features are extracted,so the performance is limited.Because deep learning can realize self-learning of deep features of images and is versatile for various defects,this paper studies the detection algorithm of surface defects of mobile phone lenses based on deep learning.The research contents mainly include the following aspects:(1)Since the deep learning algorithm requires a large amount of sample data for learning and training,if there are few samples available for learning,the advantages of the deep learning algorithm cannot be fully exerted,and the phenomenon of overfitting is faced.In view of the problem of insufficient data,this paper uses the Vector Quantized Variational Auto Encoder-2(VQ-VAE-2)algorithm to generate high-quality sample data,and the generated data can effectively alleviate the small sample problem.(2)In view of the situation that high-precision and high-speed detection algorithms are required on the mobile phone lens production line,this paper designs a supervised lens defect detection algorithm based on the improved YOLOv4,which realizes end-to-end detection.The algorithm selects YOLOv4 as the basic architecture for subsequent improvements.First of all,the attention mechanism is introduced to improve the network’s feature extraction ability for both space and channel,which can improve the algorithm’s ability to locate and identify defects,thereby enhancing its detection performance.Then,by improving the feature fusion network,the shallow features and the deep features can be fully combined,thereby enhancing the detection ability of the algorithm for small targets.Finally,in order to improve the detection speed of the algorithm,the network structure is simplified by trimming redundant convolutions,which can effectively improve the detection speed.By training on the lens dataset,the improved model has better results,and the detection accuracy and speed can meet the needs of actual industrial production.(3)Aiming at the problem that the defect samples in the mobile phone lens production line are few and difficult to obtain,and the supervised algorithm requires a lot of labor and time to mark defects,this paper proposes an unsupervised lens defect detection algorithm based on the improved Patch Distribution Modeling(PaDiM).The algorithm uses PaDiM as the benchmark method,and improves the three aspects respectively,and proves the effectiveness of the improvement by comparing the classification and detection indicators of the algorithm.First,replacing the feature extraction network with a ResNeSt network that combines cross-channel and attention mechanisms enables the algorithm to better extract the representative features of the image,which can improve the overall performance of the algorithm.Then,if the algorithm cannot accurately judge whether the pixel is abnormal,using the standard score(Z-Score)as the threshold calculation method can improve the detection performance.Finally,in order to estimate the overall covariance problem more accurately,Oracle Approximate Shrinkage(OAS)is used instead of the sample covariance matrix to estimate the covariance,which further improves the overall performance of the algorithm.The proposed algorithm realizes unsupervised detection of lens defects,which can be trained with only good products,which reduces labor and time costs,and can classify whether images are abnormal and detect defects.The experimental results show that this paper can generate high-quality sample data and effectively alleviate the problem of few samples.The designed supervised detection algorithm has a detection accuracy of 98.23% for streak lines,90.72% for linear defect,and the speed is 39 frames/s on a 2080 Ti graphics card,which meets the actual production requirements.The proposed unsupervised detection algorithm has an AUC of 0.956 and a recall of 71.85%,which can achieve only good quality training and is easy to deploy quickly in actual production. |