Method and system for visually detecting glass container by using AI (Artificial Intelligence)
The glass container is detected through AI visual detection method, and confidence prediction is predicted using multiple grids and bounding boxes, which solves the problems of low efficiency and insufficient accuracy of the existing detection methods, and achieves more efficient and accurate detection effects.
Patent Information
- Application Number
- CN202411279723.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-12
- Publication Date
- 2024-11-01
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing glass container detection methods have problems such as low efficiency, high cost and insufficient accuracy, which leads to excessive missed detection rates or over-test rates, which cannot meet customers' high requirements for glass container detection.
Using AI visual detection method, the images of glass containers are collected for preprocessing and normalization, divided into multiple grids and used multiple bounding boxes to predict confidence, and the model is trained to improve detection accuracy and speed.
It improves the accuracy and speed of glass container inspection, provides more detailed and accurate defect information, adapts to various bottle shapes and sizes, narrows the detection gap, and speeds up the detection efficiency.
Smart Images

Figure CN118887202A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of glass container detection technology, and in particular to a method and system for detecting glass containers using AI vision. Background Art
[0002] With the continuous development of glass container production technology, the production technology of my country's daily glass industry has become more mature, and the gap with international advanced technology has been narrowing. However, with the continuous development of production technology, customers now have higher and higher requirements for glass container testing.
[0003] However, the quality inspection of glass is still based on traditional manual light inspection, which has many disadvantages such as low efficiency and high cost, seriously affecting the demand for large-scale production. In recent years, with the rapid development of related theories such as artificial intelligence and machine learning, non-destructive testing technology based on machine vision has been increasingly used in the inspection of various industrial products, gradually replacing the process of manual inspection, expanding social productivity, and creating good social benefits. At present, many domestic testing equipment manufacturers have developed defect detection algorithms for glass, but this defect detection method has problems such as insufficient accuracy and too high missed detection rate or over-detection rate. Summary of the invention
[0004] In view of the above-mentioned defects, the purpose of the present invention is to provide a method and system for inspecting glass containers using AI vision, so as to improve the accuracy and speed of glass container inspection.
[0005] To achieve this purpose, the present invention adopts the following technical solution: a method for inspecting glass containers using AI vision, comprising the following steps:
[0006] Step S1: Collect pictures of glass containers with defects as pictures used for training the model;
[0007] Step S2: preprocess and normalize the image to generate a data set file;
[0008] Step S3: Set model parameters and create a training model;
[0009] Step S4: Divide the data set file into a training set and a test set in proportion, input the training set into the training model to train the model, and use the test set to test the accuracy of the trained model;
[0010] Step S5: obtaining a training model with an accuracy higher than a threshold as a detection model, and performing defect detection on the image of the glass container to be detected by using the detection model;
[0011] The specific steps of step S5 are as follows:
[0012] Obtain a bottle photo of the glass container to be inspected as the photo to be inspected;
[0013] Divide the photo to be detected into S*S grids and set the number of bounding boxes to X;
[0014] Each grid uses X bounding boxes for confidence prediction, where the prediction process calls the detection model;
[0015] The location and category of defects in the glass container are predicted based on the confidence level.
[0016] Preferably, the preprocessing method in step S2 is: adjusting the size of the image, denoising the image, and cleaning the image;
[0017] The normalization method is:
[0018]
[0019] Where x′ represents the normalized data and x represents the original data.
[0020] Preferably, the parameters of the model set in step S3 include period, image size and number of categories.
[0021] Preferably, the training optimization method for the training model in step S4 is as follows:
[0022] Step A1: In the training set, the training data is fed into the model in batches for training, and the selected samples are fed into the model for forward propagation calculation to obtain the prediction result of the sample;
[0023] Step A2: Compare the predicted result of the sample with the true label to obtain the loss function value of this sample;
[0024] Step A3: Calculate the gradient of the training model parameters through the loss function value, and calculate the updated value of the training model parameters according to the gradient;
[0025] Update the parameters of the training model by updating the values;
[0026] Step A4: Use the validation set sample to input the training model and obtain the model performance score of the sample. If the model performance score is greater than the threshold, the training model is output as the detection module. If the model performance score is less than the threshold, it means that the direction is incorrect, so stop training and make adjustments to the network structure or parameters.
[0027] The loss function value calculation is shown as follows:
[0028] L = λ*L1+(1-λ)*L2;
[0029]
[0030] Where L is the loss function value, L1 is the category loss function value, L2 is the position loss function value, λ is the proportional coefficient, pij represents the probability that the i-th sample belongs to the j-th class, y ij is a vector, as follows:
[0031] f(x i ) is the predicted position of the i-th sample, y i is the actual position of the sample, n is the total number of samples processed, and c is the total number of categories;
[0032] The calculation of the model performance score is shown below:
[0033]
[0034] Where Q is the set of defect categories, q represents the qth defect, AveP(q) represents the average accuracy of the qth defect, and TP i Indicates the number of samples predicted as positive samples and actually positive samples in the i-th training, FP i It indicates the number of samples predicted as positive samples but actually negative samples in the i-th training.
[0035] Preferably, the steps of using the test set to test the accuracy of the trained model in step S4 are as follows:
[0036] Input the images of the validation set into the training model in training, obtain the predicted results and actual results of the samples, and obtain the accuracy and recall rate of the training model based on the predicted results and actual results;
[0037] During the training process or after the training is completed, if the accuracy and recall rate both meet the expectations, the training model of this training is retained; if less than, repeat steps S3 to S4;
[0038] The formula for obtaining the accuracy of the training model is as follows:
[0039]
[0040] The recall rate is announced as follows:
[0041]
[0042] Among them, TP is the number of samples predicted to be positive samples and actually are positive samples, FP is the number of samples predicted to be positive samples and actually are negative samples; TN is the number of samples predicted to be negative samples and actually are negative samples;
[0043] FN is the number of samples predicted to be negative samples but actually positive samples.
[0044] Preferably, the confidence degree is obtained in step S5 using the following formula:
[0045] Confidence=Pr(object)*Iou;
[0046] in
[0047] Iou represents the ratio of the intersection and union of the bounding box and the mesh.
[0048] A system for inspecting glass containers using AI vision, using the method for inspecting glass containers using AI vision, comprising: a collection module, a processing module, a setting module, a training module and an application module;
[0049] The acquisition module is used to collect pictures of glass containers with defects as pictures used for training the model;
[0050] The processing module is used to perform preprocessing and normalization processing on the image to generate a data set file;
[0051] The setting module is used to set model parameters and create a training model;
[0052] The training module is used to divide the data set file into a training set, a validation set and a test set in proportion, input the training set into the training model to train the model, use the test set to test the trained model, manually observe whether the test effect meets expectations, and collect statistics to reflect the detection effect, and use the validation set to control the training direction during the training process;
[0053] The application module is used to obtain a model whose accuracy, precision, and recall rate meet expectations and performs well in the test set test as a detection model, and to perform defect detection on the image of the glass container to be detected through the detection model.
[0054] Preferably, the processing module includes a preprocessing module and a normalization module;
[0055] The preprocessing module is used to adjust the size of the image, remove noise from the image, and clean the image;
[0056] The normalization module is used to normalize the preprocessed images.
[0057] Preferably, the training module includes a selection module, a loss value acquisition module, an update module and a scoring module;
[0058] The selection module is used to send the training data into the model in batches for training in the training set, input the selected samples into the model for forward propagation calculation, and obtain the prediction result of the sample;
[0059] The loss value acquisition module is used to compare the predicted result of the sample with the true label to obtain the loss function value of this sample;
[0060] The updating module is used to calculate the gradient of the training model parameters through the loss function value, and calculate the updated value of the training model parameters according to the gradient;
[0061] The scoring module is used to use the validation set sample input into the training model to obtain the model performance score of the sample. If the model performance score is greater than the threshold, the training model is output as the detection module. If the model performance score is less than the threshold, it indicates that the direction is incorrect, the training is stopped, and the network structure or parameter adjustments are made.
[0062] One of the above technical solutions has the following advantages or beneficial effects: In the present invention, the photo of the glass container is first divided into multiple grids to be detected, and multiple bounding boxes are used in each grid for confidence prediction, so that the position of the defect can be more accurately located. Each bounding box can capture the different positions and sizes of the defect, thereby providing more detailed and accurate defect information and increasing the accuracy of detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0063] Figure 1 is a flow chart of an embodiment of the method of the present invention.
[0064] Figure 2 It is a schematic diagram of the structure of an embodiment of the system of the present invention. DETAILED DESCRIPTION
[0065] The embodiments of the present invention are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals represent the same or similar elements or elements having the same or similar functions from beginning to end. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and cannot be understood as limiting the present invention.
[0066] In the description of the embodiments of the present invention, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of the present invention, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0067] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the present invention, unless otherwise specified, the meaning of "plurality" is two or more. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0068] like Figures 1-2 As shown, a method for detecting glass containers using AI vision includes the following steps:
[0069] Step S1: Collect pictures of glass containers with defects as pictures used for training the model;
[0070] Step S2: preprocess and normalize the image to generate a data set file;
[0071] Step S3: Set model parameters and create a training model;
[0072] Step S4: Divide the data set file into a training set, a validation set, and a test set in proportion, input the training set into the training model to train the model, use the test set to test the trained model, manually observe whether the test effect meets expectations, and collect statistics to reflect the detection effect, and use the validation set to control the training direction during the training process;
[0073] Step S5: A model whose accuracy and recall rate meet expectations and performs well in the test set test is obtained as a detection model, and defect detection is performed on the image of the glass container to be detected by using the detection model;
[0074] The specific steps of step S5 are as follows:
[0075] Obtain a bottle photo of the glass container to be inspected as the photo to be inspected;
[0076] Divide the photo to be detected into S*S grids and set the number of bounding boxes to X;
[0077] Each grid uses X bounding boxes for confidence prediction, where the prediction process calls the detection model;
[0078] The location and category of defects in the glass container are predicted based on the confidence level.
[0079] Many domestic inspection equipment manufacturers have developed defect detection algorithms for glass, but the current defect detection methods have the problems of insufficient accuracy and too high missed detection rate or over-detection rate. In order to solve the above problems, the present invention proposes a method for using AI vision to detect glass containers. First, multiple pictures of different defects are obtained as pictures used by the training model, and these pictures are input into the training model for training. The detection model obtained after training can detect the places where defects exist in the glass container. However, directly inputting the pictures of the glass container into the detection model will lead to insufficient detection accuracy, and the above-mentioned problems of too high missed detection rate or over-detection rate are prone to occur. For this reason, in the present invention, the photos of the glass container will be divided into multiple grids to be detected, and multiple bounding boxes are used in each grid for confidence prediction, so that possible defects can be located more accurately. Each bounding box can capture the different positions and sizes of the defects, thereby providing more detailed and accurate defect information and increasing the accuracy of detection.
[0080] In addition, the algorithm uses meshing and bounding boxes to adapt to various bottle shapes and sizes. Whether it is a round, square or other bottle shape, it can be adapted by adjusting the number of grids and the position of the bounding box, thereby narrowing the detection gap of bottles of different shapes and further improving the accuracy and robustness of the algorithm.
[0081] Finally, since multiple grids are set, multiple grids can be input into the detection model at the same time during detection, thereby speeding up the detection efficiency.
[0082] It is worth mentioning that when implementing the technical solution of the present invention, the center point of the bounding box must be within the grid to avoid misidentification. At the same time, when a defect is detected, the center point of the bounding box can be used as the defect coordinate to locate the defect. The length and width of the bounding box are not limited by the grid and can be set according to its own computing power.
[0083] Preferably, the preprocessing method in step S2 is: adjusting the size of the image, denoising the image, and cleaning the image;
[0084] The normalization method is:
[0085]
[0086] Where x′ represents the normalized data and x represents the original data.
[0087] In the present invention, the maximum and minimum standardization is used to normalize the data and map the data to the interval [0,1], so that the value range of the data will not affect the model training, and it is also convenient to compare different features. The maximum and minimum standardization scales the data to the specified interval through linear mapping without changing the original distribution form of the data. This ensures that the relative relationship and distribution characteristics of the data are preserved. In particular, it can play a better role in feature acquisition in the identification of small defects.
[0088] It should be noted that maximum and minimum normalization is sensitive to outliers in the data. If there are outliers in the data, the normalization results may be inaccurate, so it needs to be handled with caution when used.
[0089] Preferably, the parameters of the model set in step S3 include period, image size and number of categories.
[0090] The cycle is the number of training cycles of the training model, which can control the training time and convergence speed of the model. The training cycle is set to avoid the training falling into an infinite loop, which causes the training model to fail to be trained successfully.
[0091] The image size refers to the size of the image input to the target training model. The appropriate image size can provide enough information for the model to accurately detect objects while meeting the computing resource constraints. Larger image sizes may provide more details, but will also increase computational complexity and memory requirements. Smaller image sizes may lose some details, but will reduce the computational burden. By adjusting the image size, you can balance the relationship between accuracy and efficiency.
[0092] Specifically, in one embodiment of the present invention, the image size is set to 224x224 pixels, because in the defect recognition training, the defects of glass containers that are easy to find are relatively small, so there is no need to set a too large image size format. In addition, when the size of the training image is larger than 224x224 pixels, the defective area of the image can be cropped separately to meet the format size of 224x224 pixels. However, after the image is cropped, there may be distortion. Under certain lighting conditions, the distorted pixels are similar to the defects of the glass container. Therefore, after cropping, methods such as bilinear interpolation or bicubic interpolation must be used to reduce the distortion. If some parts of the image are still distorted after using bilinear interpolation or bicubic interpolation, the distorted position can be filled with the color that is the most different from the background color. For example, the background color of a training image is white. When there is still partial distortion after using bilinear interpolation or bicubic interpolation, black is used to fill the distorted part and the image is marked. This is to facilitate the defect recognition training of the training model in the later stage.
[0093] The number of categories refers to the number of different defect categories that the model needs to identify or detect. In defect detection tasks, it is very important to set the number of categories correctly because it directly affects the output and prediction results of the model. If the number of defect categories is set too small, the model may not be able to distinguish different defect categories. If the number of categories is set too large, it may increase the complexity of training and reasoning and cause overfitting problems. Specific users can set the number of defect categories according to the defect categories that often appear in their own glass containers.
[0094] Preferably, the training optimization method for the training model in step S4 is as follows:
[0095] Step A1: In the training set, the training data is fed into the model in batches for training, and the selected samples are fed into the model for forward propagation calculation to obtain the prediction result of the sample;
[0096] Step A2: Compare the predicted result of the sample with the true label to obtain the loss function value of this sample;
[0097] Step A3: Calculate the gradient of the training model parameters through the loss function value, and calculate the updated value of the training model parameters according to the gradient;
[0098] Update the parameters of the training model by updating the values;
[0099] The step of calculating the gradient of the training model parameters through the loss function value can be done through the conventional chain rule, where the gradient of the previous layer is multiplied by the weight matrix of the current layer to obtain the gradient of the current layer. Then the gradient of the current layer is propagated to the previous layer. Since it is an existing algorithm, no further explanation and description will be given here;
[0100] The step of calculating the updated value of the training model parameters according to the gradient can be obtained by multiplying the learning rate of the model by the gradient. The learning rate determines the gradient and step size of the model. The setting of the learning rate will affect the training speed and robustness of the model. The setting of the learning rate is a commercial secret and will not be explained in detail here.
[0101] Update the parameters of the training model by updating the values;
[0102] Step A4: Use the validation set sample to input the training model and obtain the model performance score of the sample. If the model performance score is greater than the threshold, the training model is output as the detection module. If the model performance score is less than the threshold, it means that the direction is incorrect, so stop training and make adjustments to the network structure or parameters.
[0103] The loss function value calculation is shown as follows:
[0104] L = λ*L1+(1-λ)*L2;
[0105]
[0106]
[0107] Where L is the loss function value, L1 is the category loss function value, L2 is the position loss function value, λ is the proportional coefficient, pij represents the probability that the i-th sample belongs to the j-th class, y ij is a vector, as follows:
[0108] f(x i ) is the predicted position of the i-th sample, y i is the actual position of the sample, n is the total number of samples processed, and c is the total number of categories;
[0109] The defect detection task involves two key aspects, namely, accurately classifying the defect category and accurately locating the defect location. By combining the category loss function and the location loss function, the model's recognition of the defect category and accurate prediction of the defect location can be optimized at the same time. In this way, the category and location information of the defect can be comprehensively considered, so that the model can learn the defect characteristics more comprehensively during the training process. The category loss function mainly focuses on the classification accuracy of the target, while the location loss function mainly focuses on the accuracy of the target location. By combining the two, the category and location information of the target can be comprehensively considered, thereby improving the accuracy of target detection. During the training process, the model will update the parameters according to the feedback of the loss function to minimize the overall loss function value, so that the model can better predict the category and location of the target;
[0110] The specific operations of network structure or parameter adjustment are as follows:
[0111] Adjust the dataset annotation method to increase or decrease the types of defects;
[0112] Adjust the training cycle and the ratio of training set, validation set, and test set;
[0113] Adjust the structure of the training network and increase or decrease the number of network layers.
[0114] The calculation of the model performance score is shown below:
[0115]
[0116] Where Q is the set of defect categories, q represents the qth defect, AveP(q) represents the average accuracy of the qth defect, and TP i Indicates the number of samples predicted as positive samples and actually positive samples in the i-th training, FP iIt indicates the number of samples predicted as positive samples but actually negative samples in the i-th training.
[0117] Preferably, the steps of using the test set to test the accuracy of the trained model in step S4 are as follows:
[0118] Input the images of the validation set into the training model in training, obtain the predicted results and actual results of the samples, and obtain the accuracy and recall rate of the training model based on the predicted results and actual results;
[0119] During the training process or after the training is completed, if the accuracy and recall rate both meet the expectations, the training model of this training is retained; if less than, repeat steps S3 to S4;
[0120] The formula for obtaining the accuracy of the training model is as follows:
[0121]
[0122] The recall rate is announced as follows:
[0123]
[0124] Among them, TP is the number of samples predicted to be positive samples and actually are positive samples, FP is the number of samples predicted to be positive samples and actually are negative samples; TN is the number of samples predicted to be negative samples and actually are negative samples;
[0125] FN is the number of samples predicted to be negative samples but actually positive samples.
[0126] Preferably, the confidence degree is obtained in step S5 using the following formula:
[0127] Confidence=Pr(object)*Iou;
[0128] in
[0129] Iou represents the ratio of the intersection and union of the bounding box and the mesh.
[0130] A system for inspecting glass containers using AI vision, using the method for inspecting glass containers using AI vision, comprising: a collection module, a processing module, a setting module, a training module and an application module;
[0131] The acquisition module is used to collect pictures of glass containers with defects as pictures used for training the model;
[0132] The processing module is used to perform preprocessing and normalization processing on the image to generate a data set file;
[0133] The setting module is used to set model parameters and create a training model;
[0134] The training module is used to divide the data set file into a training set, a validation set and a test set in proportion, input the training set into the training model to train the model, use the test set to test the trained model, manually observe whether the test effect meets expectations, and collect statistics to reflect the detection effect, and use the validation set to control the training direction during the training process;
[0135] The application module is used to obtain a model whose accuracy, precision, and recall rate meet expectations and performs well in the test set test as a detection model, and to perform defect detection on the image of the glass container to be detected through the detection model.
[0136] Preferably, the processing module includes a preprocessing module and a normalization module;
[0137] The preprocessing module is used to adjust the size of the image, remove noise from the image, and clean the image;
[0138] The normalization module is used to normalize the preprocessed images.
[0139] Preferably, the training module includes a selection module, a loss value acquisition module, an update module and a scoring module;
[0140] The selection module is used to send the training data into the model in batches for training in the training set, input the selected samples into the model for forward propagation calculation, and obtain the prediction result of the sample;
[0141] The loss value acquisition module is used to compare the predicted result of the sample with the true label to obtain the loss function value of this sample;
[0142] The updating module is used to calculate the gradient of the training model parameters through the loss function value, and calculate the updated value of the training model parameters according to the gradient;
[0143] The scoring module is used to use the validation set sample input into the training model to obtain the model performance score of the sample. If the model performance score is greater than the threshold, the training model is output as the detection module. If the model performance score is less than the threshold, it indicates that the direction is incorrect, the training is stopped, and the network structure or parameter adjustments are made.
[0144] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "illustrative embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0145] Although the embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the claims and their equivalents.
Claims
1. A method for inspecting glass containers using AI vision, characterized in that: The following steps are involved: Step S1: Collect pictures of glass containers with defects as pictures used for training the model; Step S2: preprocess and normalize the image to generate a data set file; Step S3: Set model parameters and create a training model; Step S4: Divide the data set file into a training set and a test set in proportion, input the training set into the training model to train the model, and use the test set to test the accuracy of the trained model; Step S5: obtaining a training model with an accuracy higher than a threshold as a detection model, and performing defect detection on the image of the glass container to be detected by using the detection model; The specific steps of step S5 are as follows: Obtain a bottle photo of the glass container to be inspected as the photo to be inspected; Divide the photo to be detected into S*S grids and set the number of bounding boxes to X; Each grid uses X bounding boxes for confidence prediction, where the prediction process calls the detection model; The location and category of defects in the glass container are predicted based on the confidence level.
2. The method for inspecting glass containers using AI vision according to claim 1, characterized in that: The preprocessing method in step S2 is: adjusting the size of the image, denoising the image, and cleaning the image; The normalization method is: Where x′ represents the normalized data and x represents the original data.
3. The method for inspecting glass containers using AI vision according to claim 1, characterized in that: The parameters of the model set in step S3 include period, image size and number of categories.
4. The method for inspecting glass containers using AI vision according to claim 1, characterized in that: The training optimization method for the training model in step S4 is as follows: Step A1: In the training set, the training data is fed into the model in batches for training, and the selected samples are fed into the model for forward propagation calculation to obtain the prediction result of the sample; Step A2: Compare the predicted result of the sample with the true label to obtain the loss function value of this sample; Step A3: Calculate the gradient of the training model parameters through the loss function value, and calculate the updated value of the training model parameters according to the gradient; Update the parameters of the training model by updating the values; Step A4: Use the validation set sample to input the training model and obtain the model performance score of the sample. If the model performance score is greater than the threshold, the training model is output as the detection module. If the model performance score is less than the threshold, it means that the direction is incorrect, so stop training and make adjustments to the network structure or parameters. The loss function value calculation is shown as follows: L = λ*L1+(1-λ)*L2; Where L is the loss function value, L1 is the category loss function value, L2 is the position loss function value, λ is the proportional coefficient, pij represents the probability that the i-th sample belongs to the j-th class, y ij is a vector, as follows: f(x i ) is the predicted position of the i-th sample, y i is the actual position of the sample, n is the total number of samples processed, and c is the total number of categories; The calculation of the model performance score is shown below: Where Q is the set of defect categories, q represents the qth defect, AveP(q) represents the average accuracy of the qth defect, and TP i Indicates the number of samples predicted as positive samples and actually positive samples in the i-th training, FP i It indicates the number of samples predicted as positive samples but actually negative samples in the i-th training.
5. The method for inspecting glass containers using AI vision according to claim 1, characterized in that: The steps of using the test set to test the accuracy of the trained model in step S4 are as follows: Input the images of the validation set into the training model in training, obtain the predicted results and actual results of the samples, and obtain the accuracy and recall rate of the training model based on the predicted results and actual results; During the training process or after the training is completed, if the accuracy and recall rate both meet the expectations, the training model of this training is retained; if less than, repeat steps S3 to S4; The formula for obtaining the accuracy of the training model is as follows: The recall rate is announced as follows: Among them, TP is the number of samples predicted to be positive samples and actually are positive samples, FP is the number of samples predicted to be positive samples and actually are negative samples; TN is the number of samples predicted to be negative samples and actually are negative samples, and FN is the number of samples predicted to be negative samples and actually are positive samples.
6. The method for inspecting glass containers using AI vision according to claim 1, characterized in that: The formula for obtaining the confidence in step S5 is as follows: Confidence=Pr(object)*Iou; in Iou represents the ratio of the intersection and union of the bounding box and the mesh.
7. A system for inspecting glass containers using AI vision, using the method for inspecting glass containers using AI vision according to any one of claims 1 to 6, characterized in that: include: Acquisition module, processing module, setting module, training module and application module; The acquisition module is used to collect pictures of glass containers with defects as pictures used for training the model; The processing module is used to perform preprocessing and normalization processing on the image to generate a data set file; The setting module is used to set model parameters and create a training model; The training module is used to divide the data set file into a training set and a test set in proportion, input the training set into the training model to train the model, and use the test set to test the accuracy of the trained model; The application module is used to take a training model with an accuracy rate higher than a threshold as a detection model, and perform defect detection on an image of a glass container body to be detected through the detection model.
8. The system for inspecting glass containers using AI vision according to claim 7, characterized in that: The processing module includes a preprocessing module and a normalization module; The preprocessing module is used to adjust the size of the image, remove noise from the image, and clean the image; The normalization module is used to normalize the preprocessed images.
9. The system for inspecting glass containers using AI vision according to claim 7, characterized in that: The training module includes a selection module, a loss value acquisition module, an update module and a scoring module; The selection module is used to send the training data into the model in batches for training in the training set, input the selected samples into the model for forward propagation calculation, and obtain the prediction result of the sample; The loss value acquisition module is used to compare the predicted result of the sample with the true label to obtain the loss function value of this sample; The updating module is used to calculate the gradient of the training model parameters through the loss function value, and calculate the updated value of the training model parameters according to the gradient; The scoring module is used to use the validation set sample input into the training model to obtain the model performance score of the sample. If the model performance score is greater than the threshold, the training model is output as the detection module. If the model performance score is less than the threshold, it indicates that the direction is incorrect, the training is stopped, and the network structure or parameter adjustments are made.
Citation Information
Patent Citations
Surface defect detection method based on improved YOLO V4 algorithm
CN115861170A
Photovoltaic glass corner and surface defect detection method
CN117058081A
Method for detecting defect and method for training model
US20230048386A1
