Disclosure of Invention
Aiming at the problems of multiple parameters, complex network structure, large calculation amount, timely extension and the like in the existing defect detection method, the invention provides a method and a system for detecting the defects of a flat-plate shell based on Lie-Mean. The method has the advantages of few parameters, strong comprehensiveness, good calculation performance and the like, no additional GPU is needed to be purchased, the cost is reduced, the time delay of the detection method is small, the accuracy is high, and the detection method can be applied to detection of products of actual production lines.
The invention aims to overcome the defects of the prior art and provides a method for detecting the defects of a flat-plate shell based on Lie-Mean.
The purpose of the invention can be realized by the following technical scheme: a method for detecting defects of a flat plate shell based on Lie-Mean comprises the following steps:
step 1, acquiring a flat shell image and carrying out image preprocessing;
step 2, manually marking the preprocessed image, marking the flat shell product with defects, giving the category of the defects to obtain a data sample set;
step 3, mapping the obtained data sample set to a plum cluster manifold space, and calculating and obtaining the average value in the plum cluster of each flat shell product category;
step 4, carrying out image preprocessing on the shell image of the flat plate to be detected, and mapping the image into a plum cluster manifold space to obtain a test sample;
and 5, calculating the geodesic distance from the test sample to the mean value in each class of the plum group obtained in the step 3, and judging the class to which the mean value in the plum group with the shortest geodesic distance belongs as the class of the test sample.
Further, the image preprocessing refers to the image size setting, and in the present invention, all the flat panel housing images are set to 256 × 256 (width × height, unit: pixel).
Furthermore, the types detected by the invention are scratches, cracks, color errors, shapes and sizes, and 5 types are counted.
Further, the specific step of mapping the data sample set to the lie group manifold space is as follows:
xij=exp(Mij) Wherein M isijIndicating that the jth sample data sample, x, in the ith category was previously markedijThe j-th lie group sample in the i-th category in the lie group space is represented, and the total number is 5.
Further, the specific implementation manner of calculating the mean value in the plum cluster of each flat shell product category is as follows:
inputting:
x
ijrepresenting the j 'th sample, n, in the i' th class distributed over the lie group manifold space
iThe number of training samples in the ith classification is shown, and c classes are total.
Step 31: let i equal to 1, k equal to 0, and m equal to xil;
Step 32: performing inner loop operations, computing
μ ═ exp (Δ μ), k ═ k +1, exit the loop when | | Δ μ | > epsilon and k < Max _ Iters are satisfied;
step 33: performing an external loop to calculate μiD, when i is not more than c, the loop is withdrawn;
and (3) outputting: mu.siI 1, 2.. c, i.e. the mean value within each sorted group of plums.
Wherein G represents the lie group manifold space, k represents the number of cycles, the value of k is smaller than the maximum iteration number Max _ Iters, m is used for storing an intermediate value, tau represents the step length, epsilon represents a preset threshold value, and other symbols are consistent with the meaning of the previous expression. Because the algorithm only adopts local convergence by adopting a gradient descent method, the found mean value mu in the lie group which is not necessarily the global optimum is foundiThe ideal practical effect can be obtained by modifying the initial estimate epsilon and the step length tau. The choice of τ is related to the manifold structure of lie groups, and τ ═ 1 is appropriate for spherical manifolds, and when the manifold structure of lie groups is a vector space, the gradient decrease of τ ═ 1 is equivalent to linear averaging. For the general lie group, according to the characteristics of the gradient descent method, when the value of tau is too large, the extreme point may be crossed, and when the value is too small, the convergence speed is too slow. In the present invention, Max _ Iters is set to 300, τ is set to 3, ∈ is set to 0.00000006, and c is set to 5.
Further, the geodesic distance from the sample to the mean value in each class of lie groups is calculated as follows:
wherein i
*Indicating the final class of the test sample,
the mean-within-lie group, representing the ith category, is indexed, and x represents the test sample.
The invention also provides a system for detecting the defects of the flat shell based on the Lie-Mean, which comprises the following modules:
the preprocessing module is used for acquiring a flat shell image and preprocessing the image;
the data sample set acquisition module is used for manually marking the preprocessed image, marking the flat shell product with defects, and giving the types of the defects to obtain a data sample set;
the Mean value calculation module in the Lie group is used for mapping the obtained data sample set to the Lie-Mean manifold space and calculating the Mean value in the Lie group of each flat shell product category;
the test sample acquisition module is used for carrying out image preprocessing on the shell image of the flat plate to be detected and mapping the image into a Lie-Mean manifold space to obtain a test sample;
and the class judgment module is used for calculating the geodesic distance from the test sample to the mean value in each class of the plum group obtained in the mean value calculation module in the plum group, and judging the class to which the mean value in the plum group with the shortest geodesic distance belongs as the class of the test sample.
Furthermore, the specific implementation manner of mapping the data sample set to the lie cluster manifold space in the data sample set obtaining module is as follows,
xij=exp(Mij) Wherein M isijIndicating that the jth sample data sample, x, in the ith category was previously markedijRepresenting the jth lie sample in the ith class in the lie space.
Furthermore, the specific implementation manner of calculating and obtaining the mean value in the plum cluster of each flat shell product category in the data sample set acquisition module is as follows,
input device
x
ijRepresenting the j 'th sample, n, in the i' th class distributed over the lie group manifold space
iRepresenting the number of training samples in the ith classification, wherein the training samples have c classes;
step 31, let i equal to 1, k equal to 0, and m equal to xil;
Step 32, executing internal loop operation, calculating
μ ═ exp (Δ μ), k ═ k +1, exit the loop when | | Δ μ | > epsilon and k < Max _ Iters are satisfied;
step 33, execute the outer loop, calculate μiD, when i is not more than c, the loop is withdrawn;
output muiI 1, 2.. c, i.e. the mean value within each sorted group of plums;
wherein k represents the number of cycles, the value of k should be less than the maximum number of iterations Max _ Iters, m is used for storing an intermediate value, τ represents the step length, and ε represents a preset threshold.
Further, the specific implementation manner of the category determination module is as follows,
wherein i
*Indicates the class of the test sample or samples,
the mean-within-lie group, representing the ith category, is indexed, and x represents the test sample.
The invention has the beneficial effects that the invention adopts the method and the system for detecting the defects of the flat shell based on the Lie-Mean, and has the following beneficial effects:
(1) the mean value in the plum group adopted by the invention is more essential to represent the commonality of a class of things, if an unknown sample is closer to the mean value in the plum group of a certain class than other classes, the unknown sample is considered to belong to the class most probably;
(2) the Lie-Mean adopted by the invention has better interpretability and comprehensiveness than a deep learning neural network model, and overcomes the defect of poor interpretability and comprehensiveness of the prior art;
(3) the method has the advantages of less calculation parameters, excellent calculation performance and small time delay, improves the classification accuracy while ensuring good working efficiency, does not need additional GPU hardware, does not increase the cost, and makes practical production and application possible.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. The detailed description of the embodiments of the present invention generally described and illustrated in the figures herein is not intended to limit the scope of the invention, which is claimed, but is merely representative of selected embodiments of the invention.
It should be noted that: like reference symbols in the following drawings indicate like items, and thus, once an item is defined in one drawing, it need not be further defined and explained in subsequent drawings.
As shown in fig. 1, a method for detecting defects of a flat panel housing based on Lie-Mean includes the following steps:
step 1, acquiring a flat shell image and carrying out image preprocessing;
step 2, manually marking the preprocessed image, marking the flat shell product with defects, giving the category of the defects to obtain a data sample set;
step 3, mapping the obtained data sample set to a plum cluster manifold space, and calculating to obtain an average value in the plum cluster of each flat shell product category;
step 4, carrying out image preprocessing on the shell image of the flat plate to be detected, and mapping the image into a plum cluster manifold space to obtain a test sample;
and 5, calculating the geodesic distance from the test sample to the mean value in each class of the plum group obtained in the step 3, and judging the class to which the mean value in the plum group with the shortest geodesic distance belongs as the class of the test sample.
In the invention, all the images of the flat shell to be detected are set to be 256 × 256 (width × height, unit: pixel).
The detection types comprise scratches, cracks, color errors, shapes and sizes, and the total number is 5;
the specific steps of mapping the data sample set to the lie cluster manifold space are as follows:
xij=exp(Mij) Wherein M isijIndicating that the jth sample data sample, x, in the ith category was previously markedijThe j-th lie group sample in the i-th category in the lie group space is represented, and the total number is 5.
Further, the difference between the inner and outer mean values of the lie group is shown in FIG. 2, where x is shown in FIG. 2(1)1,x2,xr1,xr2Respectively refers to different lie group sample points on the lie group manifold space, d (mu, x) represents the distance between the mean value mu in the lie group and the lie group sample point on the manifold space, and is the geodesic distance on the manifold space, namely the curve length, and the obtained mean value in the lie group is also positioned on the manifold space; FIG. 2(2) shows the Euclidean distance | | | μ -xr2The average, i.e., the outer mean, obtained by | | is not located on the manifold space.
Further, the calculation of the mean value in the plum cluster of each product category of the flat shell is specifically based on the following algorithm:
input device
x
ijRepresenting the j-th sample, n, in the i-th class distributed over the lie group stream planet space
iThe number of training samples in the ith classification is shown, and c classes are total.
Step 31, let i equal to 1, k equal to 0, and m equal to xil;
Step 32, executing internal loop operation, calculating
μ ═ exp (Δ μ), k ═ k +1, exit the loop when | | Δ μ | > epsilon and k < Max _ Iters are satisfied;
step 33, execute the outer loop, calculate μiD, when i is not more than c, the loop is withdrawn;
output muiI 1, 2.. c, i.e. the mean value within each sorted group of plums;
wherein k represents the number of cycles, the value of k should be less than the maximum number of iterations Max _ Iters, m is used for storing an intermediate value, τ represents the step length, ε represents a preset threshold, and other symbols are consistent with the previous expression meaning. Because the algorithm only adopts local convergence by adopting a gradient descent method, the found mean value mu in the lie group which is not necessarily the global optimum is foundiThe ideal practical effect can be obtained by modifying the initial estimate epsilon and the step length tau. The choice of τ is related to the manifold structure of lie groups, and τ ═ 1 is appropriate for spherical manifolds, and when the manifold structure of lie groups is a vector space, the gradient decrease of τ ═ 1 is equivalent to linear averaging. For the general lie group, according to the characteristics of the gradient descent method, when the value of tau is too large, the extreme point may be crossed, and when the value is too small, the convergence speed is too slow. In the present invention, Max _ Iters is set to 300, τ is set to 3, ∈ is set to 0.00000006, and c is set to 5.
And calculating the geodesic distance from the sample to the mean value in each class of the plum group for the test sample, and judging the class as the class to which the mean value in the shortest plum group belongs.
Further, the above-mentioned discrimination calculationThe method comprises the following steps:
wherein i
*Indicates the category determined to be the last,
the mean value within the lie group representing the ith category is indexed, and x represents the sample to be tested.
The embodiment of the invention also provides a system for detecting the defects of the flat shell based on the Lie-Mean, which comprises the following modules:
the preprocessing module is used for acquiring a flat shell image and preprocessing the image;
the data sample set acquisition module is used for manually marking the preprocessed image, marking the flat shell product with defects, and giving the types of the defects to obtain a data sample set;
the Mean value calculation module in the Lie group is used for mapping the obtained data sample set to the Lie-Mean manifold space and calculating the Mean value in the Lie group of each flat shell product category;
the test sample acquisition module is used for carrying out image preprocessing on the shell image of the flat plate to be detected and mapping the image into a Lie-Mean manifold space to obtain a test sample;
and the class judgment module is used for calculating the geodesic distance from the test sample to the mean value in each class of the plum group obtained in the mean value calculation module in the plum group, and judging the class to which the mean value in the plum group with the shortest geodesic distance belongs as the class of the test sample.
Furthermore, the specific implementation manner of mapping the data sample set to the lie cluster manifold space in the data sample set obtaining module is as follows,
xij=exp(Mij) Wherein M isijIndicating that the jth sample data sample, x, in the ith category was previously markedijRepresenting the jth lie sample in the ith class in the lie space.
Furthermore, the specific implementation manner of calculating and obtaining the mean value in the plum cluster of each flat shell product category in the data sample set acquisition module is as follows,
input device
x
ijRepresenting the j 'th sample, n, in the i' th class distributed over the lie group manifold space
iRepresenting the number of training samples in the ith classification, wherein the training samples have c classes;
step 31, let i equal to 1, k equal to 0, and m equal to xil;
Step 32, executing internal loop operation, calculating
μ ═ exp (Δ μ), k ═ k +1, exit the loop when | | Δ μ | > epsilon and k < Max _ Iters are satisfied;
step 33, execute the outer loop, calculate μiD, when i is not more than c, the loop is withdrawn;
output muiI 1, 2.. c, i.e. the mean value within each sorted group of plums;
wherein k represents the number of cycles, the value of k should be less than the maximum number of iterations Max _ Iters, m is used for storing an intermediate value, τ represents the step length, and ε represents a preset threshold.
Further, the specific implementation manner of the category determination module is as follows,
wherein i
*Indicates the class of the test sample or samples,
the mean-within-lie group, representing the ith category, is indexed, and x represents the test sample.
The specific implementation of each module corresponds to each step, and the invention is not described.
The test is carried out according to the method and the system, the test result is shown in fig. 3, fig. 3 is an image output by defect detection, and finally, the type of the defect is judged to be a scratch.
Table 1 compares the operating efficiency of the inventive process with other processes. As can be seen from the table, the operation efficiency of the invention is obviously higher than that of the traditional detection method, so that the system can be applied to actual production.
TABLE 1 comparison of the operating efficiency of the process of the invention with other processes
Table 2 compares the accuracy of the inventive method with other methods. As can be seen from the table, the accuracy of the invention is significantly higher than that of the traditional detection method, and the system can maintain good efficiency and has high accuracy.
TABLE 2 comparison of the accuracy of the method of the invention with other methods
Product classification
|
The method has the advantages of high accuracy
|
The traditional method (as SVM) accuracy%
|
Scratch mark
|
99.89
|
97.99
|
Fracture of
|
100
|
98.99
|
Color error
|
98.99
|
96.87
|
Shape of
|
100
|
99.62
|
Size and breadth
|
99.86
|
98.23 |
The above description is only a part of the embodiments of the present invention, and is not intended to limit the present invention, and it will be apparent to those skilled in the art that various modifications can be made in the present invention. Any changes, equivalent substitutions or improvements made within the spirit and principle of the present invention should be included within the scope of the present invention. Note that like reference numerals and letters denote like items in the following drawings. Thus, once an item is defined in one drawing, it need not be further defined and explained in subsequent drawings.