A package defect detection method based on a graph neural network

By constructing the PDIGCN algorithm model for cigarette packaging defect detection based on graph neural networks, the problem of insufficient intelligence in defect detection before sealing finished cigarette cartons was solved, achieving efficient and accurate identification of cigarette defects and improving the automation level and detection accuracy of the packaging production line.

CN117197102BActive Publication Date: 2025-11-18NANJING INST OF TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311208520.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-19
Publication Date
2025-11-18
Estimated Expiration
2043-09-19

AI Technical Summary

Technical Problem

Existing technologies lack sufficient intelligence and accuracy in detecting defects before sealing finished cigarette cartons, making it difficult to effectively identify defects such as inverted or flipped cigarette packs, mixed brands, and insufficient quantity.

Method used

A graph neural network-based method for detecting cigarette packaging defects is adopted. The PDIGCN algorithm model for detecting cigarette packaging defects is constructed and trained. Defects in cigarette pack images are identified through object detection and graph classification modules. Feature fusion is performed by combining graph convolutional layers and fully connected layers to output the detection results.

Benefits of technology

It significantly improves the automation level and inspection efficiency of packaging production lines, has the ability to resist geometric deformation, takes into account both qualitative and quantitative defect detection, and has high accuracy and strong robustness.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117197102B_ABST
    Figure CN117197102B_ABST
Patent Text Reader

Abstract

The application discloses a kind of based on graph neural network's packing defect detection method, including collecting the cigarette image before finished piece cigarette cartoning, constructs and trains based on graph neural network's cigarette packing defect detection algorithm model PDIGCN, output detection result P, applies the model of well-trained, and the cigarette in the finished piece box in cigarette packing assembly line is carried out defect detection;The method designed in the application realizes the intelligent detection of cigarette finished piece cartoning before cigarette inversion, turnover, brand mixture, quantity is not enough and the like defect, improves the intelligent degree of packing assembly line, improves cigarette packing system accuracy and reliability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of computer vision, deep learning, and defect detection, and specifically to a packaging defect detection method based on graph neural networks. Background Technology

[0002] Packaging defect detection is of great significance to industrial production. Effective automated packaging defect detection technology can ensure product quality, reduce customer complaints and recall costs, improve production efficiency and reduce costs, and enhance a company's market competitiveness. As a consumer product, the packaging quality of cigarettes is crucial to its market competitiveness and consumer experience. Therefore, efficient and accurate intelligent detection of cigarette packaging defects is of great importance.

[0003] Cigarette production involves different stages of packaging. To address various defects at each stage of the packaging process, industry and academia have proposed numerous detection methods. Existing technologies include: using adhesive dot detection sensors to detect adhesive defects in packaging; using image recognition-based detection systems to identify defects such as skewing, folding, and missing seals for cigarette pack seals; using image analysis-based inkjet printing integrity detection devices to detect invisible inkjet printing defects; and employing methods such as pose estimation and corner detection to improve detection accuracy for cigarette pack packaging defects, or using deep learning technology to extract color image features of cigarette boxes to identify information such as the shape and sealing of the four sides, thus rejecting substandard cigarette boxes.

[0004] This invention targets the inspection stage of finished cigarette boxes before sealing, aiming to detect defects such as insufficient quantity of cigarette packs, inversion, flipping, and mixing of different types of cigarettes. Currently, intelligent inspection methods for this stage are rare, and the efficiency and accuracy of traditional methods need improvement. Therefore, designing a defect detection method for the pre-sealing inspection stage is urgent and of practical significance. Summary of the Invention

[0005] The purpose of this invention is to provide a packaging defect detection method based on graph neural networks, which can intelligently detect defects such as inverted or flipped cigarette cartons, mixed brands, and insufficient quantity before sealing finished cigarette boxes, thereby improving the intelligence level of the packaging production line and enhancing the accuracy and reliability of the cigarette packaging system.

[0006] To achieve the above functions, this invention designs a packaging defect detection method based on graph neural networks, which performs the following steps S1-S3: constructing and training a graph neural network-based cigarette packaging defect detection algorithm model PDIGCN, and applying the trained model to complete the defect detection of cigarette cartons in the finished product box on the cigarette packaging production line.

[0007] Step S1: For the cigarette packaging production line, set up detection points in the stage after the cigarette cartons are packed and before the finished product is sealed. Use an industrial camera to take an overhead picture of the cigarette cartons inside the finished product box and collect the cigarette cartons image I before the finished product is sealed.

[0008] Step S2: Construct a cigarette packaging defect detection algorithm model PDIGCN based on graph neural network to detect defects in each pack of cigarettes in image I. The model includes a target detection algorithm module and a graph classification module. Taking the cigarette image I collected in step S1 as input, the target detection algorithm module identifies the end face targets of each pack of cigarettes in image I. The graph classification module further infers whether there are defects in the end face targets of each pack of cigarettes, classifies the defects, and outputs the detection result P, where the detection result P is whether the pack of cigarettes is normal or defective, and the specific type of defect.

[0009] The cigarette packaging defect detection algorithm model PDIGCN is trained until the preset convergence condition is met, and the trained cigarette packaging defect detection algorithm model PDIGCN is obtained.

[0010] Step S3: Apply the trained cigarette packaging defect detection algorithm model PDIGCN to detect defects in the cartons of cigarettes in the finished product boxes on the cigarette packaging production line, store and display the detection result P, and send a command to the sorting system. Store the detection result P for the information system to query and display it on the LCD screen for human-computer interaction. The command sent to the sorting system only includes normal and abnormal.

[0011] Beneficial effects: Compared with the prior art, the advantages of the present invention include:

[0012] This invention designs a packaging defect detection method based on graph neural networks. Targeting the defect problem of finished cigarette cartons before sealing, it proposes an intelligent detection method that significantly improves the automation level and efficiency of the production line. Combining artificial intelligence technology and graph computing theory, it proposes a novel defect detection method with advantages such as resistance to geometric deformation, consideration of both qualitative and quantitative defects, high accuracy, and strong robustness. Attached Figure Description

[0013] Figure 1 This is a flowchart of a packaging defect detection method based on a graph neural network according to an embodiment of the present invention;

[0014] Figure 2 This is a basic framework diagram of the PDIGCN algorithm model for detecting defects in cigarette packaging provided in an embodiment of the present invention;

[0015] Figure 3 This is an example diagram of the cropping result of the input cigarette image provided in an embodiment of the present invention;

[0016] Figure 4This is an example diagram of target detection on the end face of a cigarette pack according to an embodiment of the present invention;

[0017] Figure 5 This is a flowchart of the processing of the composition module BG provided according to an embodiment of the present invention;

[0018] Figure 6 This is a flowchart of the processing of the graphical representation module GP provided according to an embodiment of the present invention;

[0019] Figure 7 This is a flowchart of the graph classification module GC provided according to an embodiment of the present invention;

[0020] Figure 8 This is a flowchart illustrating the training process of the PDIGCN algorithm model for detecting defects in cigarette packaging, provided in an embodiment of the present invention. Detailed Implementation

[0021] The present invention will be further described below with reference to the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present invention, and should not be used to limit the scope of protection of the present invention.

[0022] This invention provides a packaging defect detection method based on graph neural networks. This method relies on packaging production lines and sorting systems, and refers to... Figure 1 Perform the following steps S1-S3 to construct and train the PDIGCN graph neural network-based cigarette packaging defect detection algorithm model, and apply the trained model to complete the defect detection of cigarette cartons in the finished product box on the cigarette packaging production line:

[0023] Step S1: For the cigarette packaging production line, set up detection points in the stage after the cigarette cartons are packed and before the finished product is sealed. Use an industrial camera to take an overhead picture of the cigarette cartons inside the finished product box and collect the cigarette cartons image I before the finished product is sealed.

[0024] Step S2: Construct a cigarette packaging defect detection algorithm model PDIGCN based on graph neural network to detect defects in each pack of cigarettes in image I. The model includes a target detection algorithm module and a graph classification module. Taking the cigarette image I collected in step S1 as input, the target detection algorithm module identifies the end face targets of each pack of cigarettes in image I. The graph classification module further infers whether there are defects in the end face targets of each pack of cigarettes, classifies the defects, and outputs the detection result P. The detection result P includes one or more of the following: normal, insufficient quantity, brand mixing, end face flipping, and inverted upper and lower end faces of the pack of cigarettes.

[0025] The basic framework of the PDIGCN algorithm model for detecting defects in cigarette packaging is referenced. Figure 2The following steps are performed: S201 Preprocessing the cigarette image I; S202 Identifying the target on the end face of the cigarette pack; and S203-S205 Inferring whether there are defects in the cigarette pack within the finished product box, classifying the defects, and outputting the detection result P.

[0026] Step S201: Based on the target detection module's requirements for input image resolution, crop and downsample the cigarette image I to obtain the cigarette image I. in For example, the YOLOv5 object detection network supports an image resolution of 640×640. The initial resolution of the cigarette image I is 2592×2048. The preprocessing function is to crop the edges and downsample the cigarette image I to obtain a resolution suitable for the object detection module. In practical applications, the viewing angle, shooting distance, and triggering timing of the industrial camera are adjusted to ensure that the acquisition scene is relatively fixed. Edges of a fixed number of pixels are cropped to highlight the area inside the box. The cropping result of the cigarette image I is referenced. Figure 3 Then, downsampling is used to adapt the input image resolution set by the object detection network.

[0027] Step S202: The target detection algorithm module detects the cigarette image I based on the target detection algorithm. in The target is obtained by analyzing the end face of the cigarette pack. The target detection algorithm module is based on classic deep learning networks such as Yolov5 and Yolov7. In specific implementation, the category of the cigarette pack end face target depends on the product category and series on a production line. Most cigarette packs have different patterns on the two ends, and whether the end faces are aligned is also a condition for the finished product to be qualified. Therefore, the number of categories of cigarette pack end face targets is approximately four times the product of the product category and series. In this embodiment, there are 40 categories of cigarette pack end face targets. Figure 4 An example of target detection on the end face of cigarette packs is given, and the target detection box, category, and confidence score of cigarette packs are presented visually.

[0028] Step S203: Refer to Figure 5 Construct a graph module BG, input the target result tensor TO, and output the graph G.<V,E> And its adjacency matrix A; the function of the graph construction module BG is to parse the target result tensor TO of the target detection algorithm and construct the graph structure.

[0029] The constructed graph module BG takes the target result tensor TO as input and obtains graph G =<V,E> The specific steps for obtaining and adjacency matrix A are as follows:

[0030] Step 2031: Decompose the target information of the cigarette end face from the target result tensor TO, including: the coordinates of the center point of the detection box (x i ,y i ), the width and height values ​​of the detection box (w i,h i ), Confidence CF of the detection box i The classification vector C of the target at the end of the cigarette pack. i , where i represents the sequence number of the target on the end face of the cigarette; for example, the center point coordinates of the first detection box of a sample are (67,68), the width and height values ​​are (100,55), the confidence level is 0.86, and the classification C1 is a one-hot vector of length 40;

[0031] Step 2032: Based on the decomposed target information of the cigarette end face, construct the vertex set V = {v1, v2, ..., v} of graph G. i ,…,v nv}, where nv represents the number of vertices; specifically, the i-th smoke trail target corresponds to the i-th vertex v. i And the classification vector C of the target detection box on the end face of the cigarette pack. i As vertex v i The embedding vector, the coordinates of the center point of the detection box (x i ,y i ) and detection box width and height values ​​(w i ,h i Also serves as vertex v i The attributes; in the embodiment, most samples resolved to nv=25 vertices, while some samples with insufficient number of cigarettes had 23 or 24 vertices;

[0032] Step 2033: Calculate the minimum x-coordinate of the center point of each detection box. min Maximum x-coordinate max Minimum value of the ordinate y min , the maximum value of the ordinate y max According to the finished product box capacity specifications (n) set by the production line. row ×n col ), calculate the average spacing d between the longitudinal and transverse coordinates of the center points of the cigarette end face detection frame. yavg and d xavg d yavg =(y max -y min ) / n row ,d xavg =(x max -x min ) / n col , where n row and n col These represent the number of rows and columns of cigarette packs in the finished product box, respectively. In this embodiment, the capacity specification of the finished cigarette packs set in the production line is 5×5. In the actual packing process, there are cases where the cigarette packs are not neatly arranged. Therefore, the position information of all detection frames is collected and the average value is calculated as a reference to improve the robustness of the algorithm.

[0033] Step 2034: Construct each vertex v i NS domain set i Traverse the vertex set V and select a vertex v that satisfies one of the following two conditions. j Add to NS i , where v j ≠v i :

[0034] |x j -x i |≤d xavg / 4, and 3d yavg / 4<|y j -y i |<5d yavg / 4;

[0035] |y j -y i | <d yavg / 4, and 3d xavg / 4<|x j -x i |<5d xavg / 4;

[0036] In the formula, x j and y j Vertex v j The horizontal and vertical coordinates; in actual samples, cigarette packs are not placed neatly. In this embodiment, the upper, lower, left and right vertices of the vertex are set as its neighborhood, and the average interval is used as a reference to set the fault tolerance range.

[0037] Step 2035: Construct the edge set of graph G That is, for each vertex v in the vertex set V i NS sets up its domain i Each vertex in the array is connected to an edge;

[0038] Step 2036: From graph G =<V,E> Generate an adjacency matrix A = {a ij} nv×nv The adjacency matrix A has a scale of nv rows and nv columns, where the rows and columns correspond to vertices v1, v2, ..., v1 respectively. i ,…,v nv The element in the i-th row and j-th column is denoted as a. ij If there exists an edge (v) in the edge set E of graph G. i ,v j ), then a ij Set to 1, otherwise a ij Set to 0; the graph adjacency matrix constructed for a certain sample in the example is:

[0039] Step S204: Refer to Figure 6 Construct a graph representation module GP, take a graph G and an adjacency matrix A as input, and output a graph representation tensor H. (2) The function of the graph representation module GP is to represent the target information of the cigarette end face and its adjacency relationship described in graph G as complex semantic information.

[0040] The graph representation module GP takes a graph G and an adjacency matrix A as input and outputs a graph representation tensor H. (2) The specific steps are as follows:

[0041] Step S2041: Calculate the regularized adjacency matrix from the adjacency matrix A. The specific calculation method is: Let I nv Let be an identity matrix with nv elements on its diagonal; let To and A diagonal matrix of the same dimension, wherein the i-th diagonal element equal The sum of all elements in the i-th row, i.e. in express The element in the i-th row and j-th column; calculate the regularized adjacency matrix.

[0042] Step S2042: Calculate the graph feature matrix X from graph G; the specific calculation method is as follows: determine the dimension of the graph feature matrix X, the number of rows is equal to the number of vertices nv of graph G, and the number of columns is equal to the classification vector C of the target detection box on the end face of the cigarette. i Given the length nc, the dimension of the graph characteristic matrix X is determined to be nv×nc; the i-th vertex v is sequentially... i Embedding vector C i Assign the i-th row to the graph feature matrix X; in the example, the length of the classification vector of the detection box is nc = 40. If the number of vertices in a sample graph is 24, then the dimension of the graph feature matrix X is 24 × 40.

[0043] Step S2043: Process the graph property matrix X and the regularized adjacency matrix of graph G using a graph convolutional layer GL1. The matrix H is obtained by feeding it into the ReLU activation function. (1) The process can be formalized as follows:

[0044]

[0045] H (1) =ReLU(H)

[0046] In the formula, Θ (1) The parameter matrix of the graph convolutional layer GL1 is obtained through network training.

[0047] Step S2044: Process matrix H using a graph convolutional layer GL2. (1) and regularized adjacency matrix The output graph representation matrix H is obtained after the ReLU activation function. (2) The process can be formalized as follows:

[0048]

[0049] In the formula, Θ (2) The parameter matrix of the graph convolutional layer GL2 is obtained through network training.

[0050] Step S205: Refer to Figure 7 Construct a graph classification module GC, with the input graph representation tensor H. (2) The output detection result P is the graph classification module GC, which classifies cigarette packaging defects based on a graph representation matrix.

[0051] Construct a graph classification module GC, with the input graph representation tensor H. (2) The specific steps for outputting the detection result P are as follows:

[0052] Step S2051: Normalize the graph representation matrix H (2) And flatten: If the number of detected cigarette end faces is less than or equal to the finished product box capacity specification, i.e., nv≤(n row ×n col Then the graph representation matrix H (2) The number of rows is expanded to (n row ×n col ), and fill with 0; otherwise, maintain the graph representation matrix H. (2) The dimensions remain unchanged; for example, in the embodiment, the finished product capacity specification is (5×5), but only 24 cigarette end face targets are detected from a certain sample. Therefore, it is necessary to change the graphical representation matrix H. (2) Expand to 25 rows, that is, add a row of all zeros. Then, flatten the processed graph representation matrix into (n row ×n col A column vector H of (×nc) elements (flat) In this embodiment, it can be a column vector with 1000 elements;

[0053] Step S2052: Input column vector H (flat) Feature fusion is performed sequentially using fully connected layers FC1 and FC2: the number of input features for fully connected layer FC1 is (n row ×n col ×nc), the number of output features is (n row ×n col The activation function is ReLU; the number of input features for the fully connected layer FC2 is (n row ×ncol The output feature count is 10, and the activation function is ReLU. In the example, the feature vector with 1000 elements is fused into 25 vectors by FC1 and then fused into 10 vectors by FC2.

[0054] Step S2053: Generate the detection result P of packaging defects: Use the fully connected layer FC3 to convert the 10 features of the fully connected layer FC2 into 5 features, and then use the Sigmoid activation function to output the detection result P.

[0055] Reference Figure 8 The cigarette packaging defect detection algorithm model PDIGCN is trained until the preset convergence condition is met, and the trained cigarette packaging defect detection algorithm model PDIGCN is obtained.

[0056] The steps for training the PDIGCN cigarette packaging defect detection algorithm model in step S2 are as follows:

[0057] Step S211: Construct a cigarette pack image dataset: To ensure a relative balance between positive and negative samples, set up normal cigarette pack image samples and various types of defective cigarette pack image samples (insufficient quantity, brand mixing, flipped end faces, inverted top and bottom end faces, etc.), containing various series of cigarette packs from the same brand, and overhead images of finished products before sealing, totaling 10,000 images. The number of normal cigarette pack image samples and various types of defective cigarette pack image samples are equal, and within the defect samples, the number of different types of defective cigarette pack image samples is also equal. Next, use an open-source image annotation tool (e.g., LabelImg) to annotate each cigarette pack image in the dataset with one type of label. This first type of label is a set of target classifications for the cigarette pack's end face, including combinations of brand category and top and bottom end face categories and orientations. Assign a second type of label to each cigarette pack image in the dataset; this second type of label refers to the defect classification of the entire cigarette pack image. Depending on the actual samples, one image can be labeled with multiple classifications.

[0058] Step S212: Shuffle the cigarette image dataset and divide it into training set, test set and validation set in a ratio of 8:1:1;

[0059] Step S213: Use a class of labels to supervise the training of the target detection algorithm module of the cigarette packaging defect detection algorithm model PDIGCN, and save the optimal parameter file after verification testing;

[0060] This step involves training the object detection algorithm module on the dataset described in step S211. In this embodiment, a simplified version of the YOLOv5 object detection network is used. First, the data configuration file is modified. Combining this with self-built data, the number of classes is changed to 40, and the class names are set to a combination of brand name, top and bottom faces, and face direction. Then, the model configuration file is modified, mainly changing the number of classes to 40, while leaving the anchor boxes unchanged. Finally, using the publicly available YOLOv5 parameter file as initial parameters, the algorithm is trained and tested on the self-built dataset, and the optimal parameter file is saved.

[0061] Step S214: Load and freeze the parameters of the target detection module, train the graph classification module of the cigarette packaging defect detection algorithm model PDIGCN using binary label supervision, and save the optimal parameter file of the entire cigarette packaging defect detection algorithm model PDIGCN after verification test;

[0062] In this embodiment, the trained YOLOv5s parameter file is loaded into the target detection module of the PDIGCN cigarette packaging defect detection algorithm model and frozen. The parameters of other modules of the PDIGCN cigarette packaging defect detection algorithm model are randomly initialized. Then, the training is supervised by the binary labels of the dataset, and the loss function is cross-entropy.

[0063] Step S3: Apply the trained cigarette packaging defect detection algorithm model PDIGCN to detect defects in the cartons of cigarettes in the finished product boxes on the cigarette packaging production line, store and display the detection result P, and send a command to the sorting system. Store the detection result P for the information system to query and display it on the LCD screen for human-computer interaction. The command sent to the sorting system only includes normal and abnormal.

[0064] To verify the effectiveness of the defect detection method based on graph neural networks in this invention, an experimental comparison was also conducted with a classification network that treats the entire box as the target detection object. The method disclosed in this invention significantly outperforms the latter scheme in terms of accuracy, recall, and F-score.

[0065] The embodiments of the present invention have been described in detail above with reference to the accompanying drawings. However, the present invention is not limited to the above embodiments. Within the scope of knowledge possessed by those skilled in the art, various changes can be made without departing from the spirit of the present invention.

Claims

1. A packaging defect detection method based on graph neural networks, characterized in that, Perform the following steps S1-S3 to construct and train the PDIGCN cigarette packaging defect detection algorithm model based on graph neural network, and apply the trained model to complete the defect detection of cigarette cartons in the finished product box on the cigarette packaging production line: Step S1: For the cigarette packaging production line, set up detection points in the stage after the cigarette cartons are packed and before the finished product is sealed. Use an industrial camera to take an overhead picture of the cigarette cartons inside the finished product box and collect the cigarette cartons image I before the finished product is sealed. Step S2: Construct a cigarette packaging defect detection algorithm model PDIGCN based on graph neural networks to detect defects in each pack of cigarettes in image I. This model includes a target detection algorithm module and a graph classification module. Taking image I of the cigarette pack collected in step S1 as input, the target detection algorithm module identifies the end face targets of each pack of cigarettes in image I and obtains the target result tensor TO; construct a graph construction module BG, input the target result tensor TO, and output graph G =<V,E> and its adjacency matrix A; the specific steps are as follows: Step 2031: Decompose the target information of the cigarette end face from the target result tensor TO, including: the coordinates of the center point of the detection box (x i ,y i ), the width and height values ​​of the detection box (w i ,h i ), Confidence CF of the detection box i The classification vector C of the target at the end of the cigarette pack. i , where i represents the serial number of the target at the end of the cigarette pack; Step 2032: Based on the decomposed target information of the cigarette end face, construct the vertex set V = {v1, v2, ..., v} of graph G. i ,…,v nv }, where nv represents the number of vertices; specifically, the i-th smoke trail target corresponds to the i-th vertex v. i And the classification vector C of the target detection box on the end face of the cigarette pack. i As vertex v i The embedding vector, the coordinates of the center point of the detection box (x i ,y i ) and detection box width and height values ​​(w i ,h i Also serves as vertex v i Attributes; Step 2033: Calculate the minimum x-coordinate of the center point of each detection box. min Maximum x-coordinate max Minimum value of the ordinate y min , the maximum value of the ordinate y max According to the finished product box capacity specifications (n) set by the production line. row ×n col ), calculate the average spacing d between the longitudinal and transverse coordinates of the center points of the cigarette end face detection frame. yavg and d xavg d yavg =(y max -y min ) / n row ,d xavg =(x max -x min ) / n col , where n row and n col These represent the number of rows and columns of cigarette packs in the finished product box, respectively. Step 2034: Construct each vertex v i NS domain set i Traverse the vertex set V and select a vertex v that satisfies one of the following two conditions. j Add to NS i , where v j ≠v i : |x j -x i |≤d xavg / 4, and 3d yavg / 4 < |y j -y i |<5d yavg / 4; |y j -y i |<d yavg / 4, and 3d xavg / 4 < |x j -x i |<5d xavg / 4; In the formula, x j and y j Vertex v j x-coordinate and y-coordinate; Step 2035: Construct the edge set of graph G That is, for each vertex v in the vertex set V i NS sets up its domain i Each vertex in the array is connected to an edge; Step 2036: From graph G =<V,E> Generate an adjacency matrix A = {a ij } nv×nv The adjacency matrix A has a scale of nv rows and nv columns, where the rows and columns correspond to vertices v1, v2, ..., v1 respectively. i ,…,v nv The element in the i-th row and j-th column is denoted as a. ij If there exists an edge (v) in the edge set E of graph G. i ,v j ), then a ij Set to 1, otherwise a ij Set to 0; The graph classification module further infers whether there are defects in the target end face of each cigarette pack, classifies the defects, and outputs the detection result P, where the detection result P is whether the cigarette pack is normal or defective, and the specific type of defect; The cigarette packaging defect detection algorithm model PDIGCN is trained until the preset convergence condition is met, and the trained cigarette packaging defect detection algorithm model PDIGCN is obtained. Step S3: Apply the trained cigarette packaging defect detection algorithm model PDIGCN to detect defects in the cartons of cigarettes in the finished product boxes on the cigarette packaging production line, store and display the detection result P, and send a command to the sorting system. Store the detection result P for the information system to query and display it on the LCD screen for human-computer interaction. The command sent to the sorting system only includes normal and abnormal.

2. The packaging defect detection method based on graph neural networks according to claim 1, characterized in that, The test result P includes normal, insufficient quantity, mixed brands, flipped end face, and inverted top and bottom ends of the cigarette pack.

3. The packaging defect detection method based on graph neural networks according to claim 1, characterized in that, In step S2, the following steps are performed: S201 Preprocessing the cigarette image I; the target detection algorithm module performs the following steps: S202 Identifying targets on the end face of the cigarette pack; and the image classification module performs the following steps: S203-S205 Inferring whether there are defects in the cigarette packs within the finished product box, classifying the defects, and outputting the detection result P. Step S201: Crop and downsample the cigarette image I to obtain the cigarette image I. in ; Step S202: The target detection algorithm module detects the cigarette image I based on the target detection algorithm. in The target is the end face of the cigarette pack, and the target result tensor TO is obtained. Step S203: Construct the graph construction module BG, input the target result tensor TO, and output the graph G =<V,E> and its adjacency matrix A; Step S204: Construct the graph representation module GP, taking the graph G and adjacency matrix A as inputs, and outputting the graph representation tensor H. (2) ; Step S205: Construct the graph classification module GC, with the input graph representation tensor H. (2) Output the detection result P.

4. The packaging defect detection method based on graph neural networks according to claim 3, characterized in that, In step S204, the graph representation module GP is constructed, taking the graph G and adjacency matrix A as inputs and outputting the graph representation tensor H. (2) The specific steps are as follows: Step S2041: Calculate the regularized adjacency matrix from the adjacency matrix A. The specific calculation method is: Let I nv Let be an identity matrix with nv elements on its diagonal; let To and A diagonal matrix of the same dimension, wherein the i-th diagonal element equal The sum of all elements in the i-th row, i.e. in express The element in the i-th row and j-th column; Calculate the regularized adjacency matrix Step S2042: Calculate the graph feature matrix X from graph G; the specific calculation method is as follows: determine the dimension of the graph feature matrix X, the number of rows is equal to the number of vertices nv of graph G, and the number of columns is equal to the classification vector C of the target detection box on the end face of the cigarette. i Given the length nc, the dimension of the graph characteristic matrix X is determined to be nv×nc; the i-th vertex v is sequentially... i Embedding vector C i Assign the i-th row of the graph characteristic matrix X; Step S2043: Process the graph property matrix X and the regularized adjacency matrix of graph G using a graph convolutional layer GL1. The matrix H is obtained by feeding it into the ReLU activation function. (1) The process can be formalized as follows: A (1) =ReLU(H) In the formula, Θ (1) This represents the parameter matrix of the graph convolutional layer GL1; Step S2044: Process matrix H using a graph convolutional layer GL2. (1) and regularized adjacency matrix The output graph representation matrix H is obtained after the ReLU activation function. (2) The process can be formalized as follows: In the formula, Θ (2) This represents the parameter matrix of the graph convolutional layer GL2.

5. The packaging defect detection method based on graph neural networks according to claim 3, characterized in that, In step S205, the graph classification module GC is constructed, and the input graph representation tensor H is used. (2) The specific steps for outputting the detection result P are as follows: Step S2051: Normalize the graph representation matrix H (2) And flatten: If the number of detected cigarette end faces is less than or equal to the finished product box capacity specification, i.e., nv≤(n row ×n col Then the graph representation matrix H (2) The number of rows is expanded to (n row ×n col ), and fill with 0; otherwise, maintain the graph representation matrix H. (2) The result remains unchanged; then, the processed graph representation matrix is ​​flattened into (n) row ×n col A column vector H of (×nc) elements (flat) ; Step S2052: Input column vector H (flat) Feature fusion is performed sequentially using fully connected layers FC1 and FC2: the number of input features for fully connected layer FC1 is (n row ×n col ×nc), the number of output features is (n row ×n col The activation function is ReLU; the number of input features for the fully connected layer FC2 is (n row ×n col The number of output features is 10, and the activation function is ReLU; Step S2053: Generate the detection result P of packaging defects: Use the fully connected layer FC3 to convert the 10 features of the fully connected layer FC2 into 5 features, and then use the Sigmoid activation function to output the detection result P.

6. The packaging defect detection method based on graph neural networks according to claim 1, characterized in that, One or more of the detection results P correspond to the target on the end face of the cigarette pack.

7. The packaging defect detection method based on graph neural networks according to claim 1, characterized in that, The steps for training the PDIGCN cigarette packaging defect detection algorithm model in step S2 are as follows: Step S211: Construct a cigarette pack image dataset: The cigarette pack image dataset consists of a preset number of cigarette pack images, which include normal cigarette pack image samples and various types of defective cigarette pack image samples; wherein, the number of normal cigarette pack image samples and defective cigarette pack image samples are the same, and the number of various types of defective cigarette pack image samples is also the same in the defective cigarette pack image samples. Each cigarette image in the cigarette image dataset is labeled with a first-class label, which is a set of target classifications for the cigarette end face, including a combination of brand category and upper and lower end face categories and orientations; each cigarette image in the cigarette image dataset is assigned a second-class label, which refers to the defect classification of the entire cigarette image. Step S212: Shuffle the cigarette image dataset and divide it into training set, test set and validation set in a ratio of 8:1:1; Step S213: Use a class of labels to supervise the training of the target detection algorithm module of the cigarette packaging defect detection algorithm model PDIGCN, and save the optimal parameter file after verification testing; Step S214: Load and freeze the parameters of the target detection module, train the graph classification module of the cigarette packaging defect detection algorithm model PDIGCN using binary label supervision, and save the optimal parameter file of the entire cigarette packaging defect detection algorithm model PDIGCN after verification testing.

Citation Information

Patent Citations

  • Cigarette box carton lacking and card mixing detection system and method based on artificial intelligence

    CN113362305A

  • Image defect detection method

    CN114820445A