In the process of assembling the lotion pump,problems such as surface oil pollution,lack of glue on plastic parts and surface wear of the lotion pump sometimes occur.Therefore,after the whole assembly of the lotion pump is completed,it is necessary to check whether its appearance is defective to ensure the beauty and quality of the product.At present,factories have two methods,manual and machine vision,for visual inspection of emulsion pumps.Although the manual inspection method is simple,the speed is slow and the rate of missed inspection is high.Although the existing machine vision can realize automatic inspection,the surface texture of the emulsion pump is difficult to detect.It is relatively complex,and there are many problems such as inappropriate selection of features and poor algorithm robustness when artificially designed algorithms to extract image features.Based on this,this topic aims at the problem of surface defects in the production process of emulsion pumps,uses convolutional neural network to extract the surface defects of emulsion pumps,and studies defect classification and detection algorithms.The research work and contributions of this thesis are as follows:(1)Analyze the structure and surface defects of the emulsion pump,design a defect detection system for the emulsion pump,collect the image of the emulsion pump sample in an all-round way,and preprocess the image to improve the quality of the image data.(2)The defect classification algorithm based on Res Net50 model is studied to judge whether the lotion pump is defective.By analyzing the insufficiency of the hybrid attention mechanism CBAM(Convolutional Block Attention Module),a lightweight hybrid attention mechanism EBAM(Efficient Convolutional Block Attention Module)is proposed.Through the control experiment of the classic classification model,Res Net50 is selected as the basic model of emulsion pump defect classification,and the problem of downsampling information loss is reduced by improving the residual structure in the Res Net50 model,and the attention mechanism EBAM is introduced to give higher weights to the defect area of the emulsion pump.,using Grad-CAM to compare the heat map before and after the model improvement,and explain the effectiveness of the improved model.The accuracy of the improved model is 95.84%,and the average detection time of each lotion pump is 0.38 seconds,which meets the task requirements of real-time detection of lotion pumps.(3)Research the defect detection algorithm based on the YOLOv4 model to detect the type and location of defects.The target detection algorithm is comprehensively analyzed,combined with the actual production situation of the emulsion pump in the factory,and the YOLOv4 model is used as the basic framework for defect detection.By analyzing the principle of the YOLOv4 algorithm,the CSPDarknet53 backbone structure and the PANet feature fusion structure of YOLOv4 are improved,and the classification loss function is optimized..Perform a matting operation on the small defects of the lotion pump dataset.Through multiple sets of comparative experiments,the effects of introducing attention mechanism,PANet structure improvement and classification loss function optimization on the accuracy and speed of the model are verified.The experimental results show that the improved model has better detection effect on small scratches and oil stains.Compared with the original model,the m AP(average precision)is increased by 8.22%,and the inference speed meets the real-time detection requirements.(4)A software system for defect classification and detection of emulsion pump is designed.The software interface consists of several modules such as login,classification,detection and data query.The feasibility of the algorithm in this thesis is verified by practical tests. |