Academic Journal of Science and Technology ISSN: 2771-3032 | Vol. 12, No. 2, 2024 26 Classification of Tobacco Defects based on Vgg16 Shujie Liu * Jinan Cigarette Factory, China Tobacco Shandong Industrial Co., Ltd., Jinan, 250101, China * Corresponding author Email: alotove.liu@hotmail.com Abstract: In the existing cigarette packet defect detection using simple image processing methods, the defect detection capability is limited and the corresponding defects cannot be counted. This paper addresses this problem and proposes a vgg16- based defect classification method for cigarette packets, which can effectively detect and count the defects of cigarette packets. Experiments have proved that the detection accuracy can reach 100% under ideal conditions. Keywords: Deep Learning; Vgg16; Defect Classification. 1. Introduction China is a major tobacco country, and cigarettes are the most important in the tobacco industry Important products In the production process of tobacco, it is inevitable that due to various factors Various factors lead to defects in the appearance of cigarette packs Remove from the production line The defect of cigarette packaging is a key step for cigarette factories to improve the quality of cigarettes Suddenly At present, the high-speed cigarette box production line has reached 200 units per second The speed of support is no longer sufficient for traditional manual inspection Application Calculation Computer vision technology can automatically and quickly inspect the appearance defects of cigarette packs Testing and classification can improve the quality and efficiency of cigarette production. With the development of digital image processing technology, cigarette appearance defect detection is becoming more and more intelligent. However, the existing defect detection tools used to deal with HOG [9] and other methods are relatively simple, in the package colour is not obvious is not able to better complete the detection task and the lack of corresponding statistical methods. This paper focuses on the study of defect detection methods based on vgg16 [10], in order to improve the detection ability at the same time, increase the defect statistics function, convenient data statistics, to provide quality assurance. With the development of deep learning, AlexNet [1], VGG16 [2], ResNet [3] and other networks have been attempted to be used in many detection and classification problems There have been a lot of applied research in automatic product quality testing, such as bamboo strips, textiles, steel strips, etc Gao Qinquan et al. [4] applied it to The improvement of the CenterNet network has classified 10 surface defects of bamboo strips, with an average detection accuracy (mean Average Precision, mAP) of 76.9% Liu Yangyang et al. [5] classified nearly 20 types of defects in fabrics and proposed a detection method based on improved Faster RCNN, MAP reached 63.4% Ding Guanxiong et al. [6] increased the receptive field by adding dilated convolutional layers to the AlexNet network, achieving an average accuracy and average recall of 85% for fabric defect classification Kou Xupeng et al. [7] achieved an mAP of 67.7% on the GC10- DET steel strip defect dataset, which is 4.9% higher than the original model Xu et al. [8] applied the improved YOLOv3 to detect surface defects on steel plates, and the accuracy on the test set improved by 23.3% compared to the original YOLOv3. This article improves the VGG16 network to make it more adaptable. A feature based on the appearance defect image of cigarette packs and cigarettes is proposed. 2. VGG16 Classification Method based on Transfer Learning 2.1. Introduction of VGG16 VGG16 has a total of 16 layers, 13 convolutional layers, and 3 fully connected layers. After two convolutions with 64 convolution kernels in the first round, it uses one pooling, and after two convolutions with 128 convolution kernels in the second round, it uses pooling; After 3 more convolutions with 256 kernels, pooling is used, followed by two more convolutions with 512 kernels, then pooling, and finally three fully connected convolutions. The 3x3 convolutional kernel shown in orange in the figure, the maximum pooling size of the 2x2 convolutional kernel is orange, the maximum pooling size of the 2x2 convolutional layer is orange, and the three fully connected layers shown in purple in the figure. The deeper the number of convolutional layers in the VGG15 network, the wider the feature map, which can better extract image features and has a good effect on classification problems, and has received a lot of attention. Figure 1. VGG16 network structure The VGG network is widely used in computer vision tasks such as image classification, object detection, and semantic segmentation. The simplicity and ease of implementation of its network structure make VGG one of the classic models in the field of deep learning. Despite the simplicity of the structure of VGG, the number of weights included is large, amounting to a staggering 139,357,544 parameters. These parameters include convolutional kernel weights and fully connected layer weights. For example, for the first convolutional layer, since the number of channels in the input graph is 3, the network 27 must learn convolutional kernels of size 3x3 and number of channels 3. There are 64 such convolutional kernels, resulting in a total of 1728 parameters. The number of weight parameters for the fully connected layer is calculated as: number of nodes in the previous layer x number of nodes in this layer number of nodes in the previous layer x number of nodes in this layer. Therefore, the parameters of the fully connected layer are 4096000 respectively. With such a large number of parameters, VGG16 can be expected to have a high fitting ability; however, at the same time, the disadvantages are also obvious: i.e., the training time is too long, and it is difficult to tune the parameters. The storage capacity required is large and unfavorable for deployment. For example, the size of the file storing the VGG16 weight values is more than 500 MB, which is not conducive to installing into an embedded system. 2.2. Network Training In this paper, we use the Anaconda3 Python integrated environment for Windows platform to perform migration learning using the VGG16 pre-trained model in PyTorch to reduce the learning time and computational overhead. The network was trained with batch size set to 8, learning rate set to 0.00002, and the network was optimised using Adam optimiser. Meanwhile, the data is increased by random cropping, flipping, and adding noise during training to improve the network performance. 2.3. Training Results and Analysis During the training process of the network, the loss drops and variety classification accuracy in the testing phase of the network were counted and the results are shown in Figure 2.2. Figure 2. VGG16 test losses and accuracy rates From the figure, it can be found that after the completion of the ninth round of training, the model works the best, with a test accuracy of 100% and a test loss reduced to a minimum of 0.014. The confusion matrix of the test results [11] is shown in Figure 2.3. Figure 3. VGG16 test confusion matrix 3. Summary Through the study of deep learning based tobacco brand recognition method, it is determined to use VGG16 classification method based on migration learning, and the experimental results show that the method has high accuracy and practicality for fast tobacco brand name classification. References [1] Krizhevsky A, Sutskever I, Hinton G E. Imagenet classification with deep convolutional neural networks [J]. Advances in Neural Information Processing Systems, 2012, 25: 1 097-1 105. [2] Simonyan K, Zisserman A. Very deep convolutional networks for large-scale image recognition[J]. arXiv: 1409. 1556, 2014. [3] He K, Zhang X, Ren S, et al. Deep residual learning for image recognition[C]//Proceedings of the IEEE Conference onComp uter Vision and Pattern Recognition, Las Vegas, NV, USA, 2016: 770-778. [4] Gao Q Q, Huang B C, Liu W Z, et al. Detection method of ba mboo strip surface defects based on improved CenterNet [J]. Computer Application, 2020, 31(12): 1-8. [5] Liu Y Y. Research on cloth defect detection method based on deep learning[D]. Harbin : Harbin Institute of Technology, 2020. [6] Ding G X. Research on the algorithm for classifi-cation of fabric defects [D]. Shanghai: Shanghai Normal University, 2020. [7] Kou X P, Liu S J, Ma Z R. Steel strip defect detection method based on Faster-RCNN[J]. China Metallurgy, 2021, 31(4): 77-83. [8] Xu Q, Zhu H J, Fan H H, et al. Research on improved YOLOv3 network in steel plate surface defect detectio n[J]. Computer Engineering and Applications, 2020, 56(16): 265-272. [9] Dalal N, Triggs B .Histograms of Oriented Gradients for Human Detection[C]//IEEE Computer Society Conference on Computer Vision & Pattern Recognition.IEEE, 2005.DOI: 10.1109/ CVPR.2005.177. [10] Simonyan K, Zisserman A .Very Deep Convolutional Networks for Large-Scale Image Recognition[J].Computer Science, 2014.DOI:10.48550/arXiv.1409.1556. [11] Ting K M .Confusion Matrix[J].Springer US, 2017.DOI:10. 1007/ 978-1-4899-7687-1_50.