Ampoules are one of the common medicinal containers and are widely used in the pharmaceutical industry.In the production process,ampoules are affected by factors such as stress and temperature,and are prone to defects such as scratches and bottle mouth damage.Therefore,it is very important to detect defects in ampoules.However,the main manual or machine vision methods currently used still have low detection accuracy and detection speed.In this paper,improving the accuracy and speed of ampoule defect detection are the research goals.Based on the YOLOv3 algorithm,an algorithm for ampoule defect detection is proposed,and the detection system is implemented using Python language.The main research contents of this paper are as follows:(1)Aiming at the problem of low image quality,bilateral filtering and high-pass filtering are used to complete image preprocessing.Through the data enhancement technology,the production of the ampoule defect data set is completed.(2)On the basis of the YOLOv3 algorithm,the Mobile Net network is used to realize the lightweight of the algorithm and improve the detection speed of the algorithm.Aiming at the large amount of point-by-point convolution calculation in Mobile Net network,the convolution module is redesigned.Experiments show that the improved Mobile Net network has better detection accuracy and higher speed.(3)In order to improve the detection accuracy of the algorithm,the feature pyramid of YOLOv3 is improved,and the attention mechanism is embedded in the network.Experiments show that for the actual production line of ampoules defect detection,the improved YOLOv3 algorithm is used for detection,and the m AP value reaches 87.75%,which is 4.39% higher than the traditional YOLOv3 algorithm,and the detection speed is increased by 3.9 frames/s.(4)On the basis of the above research,combined with the needs of ampoule production,a set of ampoule defect detection system is realized.The system realizes the real-time defect detection and result display function of ampoules,and also has the function of displaying the trend of ampoules defects. |