| Using computer vision technology to detect the surface defects of ampoule is a key link in the intelligent transformation of pharmaceutical enterprises.However,the speed of melting and sealing ampoule in enterprise production is fast,the size of ampoule surface defects is small and has multi-scale characteristics,and there are certain requirements for real-time while ensuring the detection accuracy,which makes it difficult to implement the research on ampoule surface defect detection.Under the background of the rapid development of deep learning theory,the characteristics of surface defects of ampoule can be effectively learned by using deep convolution network,and higher detection accuracy can be obtained.In addition,given the high demand for real-time performance by enterprises,how to reduce model volume and accelerate model inference speed while ensuring model detection accuracy has become a focus of research and development of defect detection systems.This paper aims at the actual production demand of ampoule filling quality inspection,and based on the deep learning theory,studies the methods that can effectively detect the surface defects of ampoule.This paper designs a surface defect detection method for ampoule based on Faster R-CNN and a lightweight algorithm based on Faster R-CNN that can be deployed to Edge device.The main work of this article is as follows:(1)Aiming at the small size of surface defects of ampoule and the difficulty of multi-scale detection,a surface defect detection algorithm of ampoule that can effectively improve the detection accuracy was designed based on Faster R-CNN.Using convolutional neural network Res Ne Xt-50 as the backbone network;Using the K-means clustering algorithm to generate anchor box sizes and proportions suitable for the dataset in this article based on the annotated real boxes,improving the matching degree between the predicted box and the real box;Introducing a feature pyramid module and utilizing subpixel convolution for improvement,improving multi-scale detection capabilities while reducing channel information loss;At the same time,the attention mechanism is utilized to make the model pay more attention to the target defect area during the training process.Finally,through experimental verification,the proposed algorithm can effectively improve the accuracy of defect detection and visually display the network’s focus area on a certain target through thermal activation diagrams.(2)Aiming at the problem of large scale and redundant parameters of the target detection network model,which makes it difficult to deploy the ampoule bottle appearance defect detection model to the edge equipment,a lightweight ampoule bottle surface defect detection model is designed.The lightweight feature extraction network Mobile Net-V2 is used as the backbone network,and the model pruning strategy is used to reduce the complexity of the model and reduce the reasoning time of the model.In order to verify the performance of the lightweight algorithm proposed in this paper,the image in the ampoule bottle surface defect test set is used for testing.The results show that the average accuracy of the lightweight detection algorithm designed in this paper in the test set is 89.3%,and the model size is one third of the size before compression,so that the algorithm can be deployed to lightweight devices later.(3)Set up a data acquisition platform for ampoule,select the appropriate industrial camera and lens to complete the data acquisition,mark the defects in the collected image,and establish the surface defect detection data set of ampoule according to the VOC format for the training of the model designed in this paper.Deploy the lightweight network model proposed in this paper to the Jetson TX2 edge computing module,optimize and accelerate the model through Tensor RT,and design comparative experiments to compare the reasoning speed and detection accuracy of different platform algorithms.Design a human-computer interaction interface using Py QT5,connect to a database to save detection data,and complete the software design of the system. |