An object defect detection method, system, device and medium
Through feature extraction model and subspace clustering model with group sparse constraints, the problem of the optimal dimensional reduction projection matrix and data distribution in spoon defect detection is solved, and the accurate detection of spoon defects is achieved.
Patent Information
- Application Number
- CN202310117531.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-15
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2043-02-15
AI Technical Summary
In the prior art In spoon defect detection, traditional subspace clustering methods cannot effectively solve the problem of the optimal dimensional reduction projection matrix and data distribution of spoon images, resulting in poor detection of spoon defects.
A feature extraction model is used to combine a subspace clustering model with group sparse constraints. By iteratively solving the objective function, the model parameters with the smallest cluster loss are determined, the distance between the image feature set and the cluster center is calculated, and defect detection is realized.
Accurate detection of spoon defects is achieved, detection interference is avoided, and detection effect is improved.
Smart Images

Figure CN116152194B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence, and particularly to an object defect detection method, system, device and medium. Background Art
[0002] Defect detection is a very important application in computer vision technology. In recent years, deep learning has achieved very good results in feature encoding, and more and more scholars and engineers have begun to introduce deep learning algorithms into the field of defect detection. In the field of industrial spoons, since there are various types of spoon defects, it is difficult to collect complete defect samples. In this case, traditional supervised machine learning methods that rely on defect label data are difficult to effectively encode defect features and cannot adapt to the application scenario of industrial spoon defect detection.
[0003] For the problem of detecting spoon defects without positive samples, using traditional subspace clustering methods to achieve unsupervised clustering is a common means, such as methods like LDAKM and DEC. However, these methods mainly have two problems:
[0004] 1. These methods adopt a separate optimization method for dimensionality reduction and clustering. In this case, for a certain spoon image, its optimal dimensionality reduction projection matrix may not be able to obtain the optimal clustering result, thereby affecting the spoon defect detection effect.
[0005] 2. These methods use a fixed l2 norm or l 2,1 norm to calculate the loss function. The l2 norm assigns larger weights to data with large distances, and it is sensitive to outliers. On the contrary, the l 2,1 norm will assign higher weights to data in high-density regions and easily ignore the contribution of data in sparse regions to model optimization. Since the types of defects in spoon images are uncertain and their data distributions are not fixed, it is difficult for these methods to achieve good clustering results. Therefore, if the subspace clustering algorithm cannot effectively solve the above two problems, it will seriously affect the spoon defect detection effect. Summary of the Invention
[0006] The purpose of the present invention is to provide an object defect detection method, system, device and medium, which can achieve accurate defect detection through computer vision that combines a deep neural network and a clustering algorithm.
[0007] To achieve the above purpose, the present invention provides the following solutions:
[0008] An object defect detection method, the method includes:
[0009] Obtain a target image set; the target image set includes: images of each target object within the detection area;
[0010] Extract the features of the target image set using a feature extraction model to obtain an image feature set; the feature extraction model is established using machine learning methods;
[0011] Construct a subspace clustering model with group sparse constraints; the subspace clustering model includes: a sparse constraint model and a clustering model;
[0012] Determine the objective function and constraints of the subspace clustering model; the constraint is: the group sparse constraint matrix is constrained in a row-by-row manner; the objective function is constructed with the goal of minimizing the clustering loss; the clustering loss is the within-class adaptive paradigm error of the subspace clustering model;
[0013] Solve the objective function according to the constraints in an iterative manner to obtain the optimal parameter values of the subspace clustering model; the optimal parameter values are the values of the model parameters of the subspace clustering model corresponding to the minimum clustering loss; the model parameters include: the projection matrix of subspace clustering, the clustering index matrix, and the clustering center matrix;
[0014] Determine the cluster centers of the subspace clustering model according to the optimal parameter values;
[0015] Calculate the distances between the image feature set and the cluster centers to obtain the defect detection classification results of each target object in the target image set; the defect detection classification results include: defective and non-defective.
[0016] Optionally, the objective function is:
[0017]
[0018] B = [B1, B2]
[0019] where B is the group sparse constraint matrix; F is the clustering index matrix; G is the clustering center matrix; A is an orthogonal matrix; T is the transpose transformation; I is the identity matrix; A T is the transpose transformation of matrix A; X is the image feature set; B1 is the projection matrix of sparse constraints; ||·|| σ is the adaptive paradigm; ||B|| 2,1 is the l 2,1 norm of the group sparse constraint matrix; σ is the adaptive factor; λ, α, β, and γ are all user-specified hyperparameters used to adjust the importance of each module; B2 is the projection matrix of subspace clustering.
[0020] Optionally, the determination method of the feature extraction model is:
[0021] Obtain training data; the training data includes defective sample images and non-defective sample images;
[0022] Divide the training data into a training set and a validation set;
[0023] Construct a shared neural network;
[0024] Input the training set into the shared neural network, and train the parameters in the shared neural network with the goal of minimizing the feature error between the features output by the shared neural network and the features of the training data, to obtain a trained shared neural network;
[0025] Adjust the parameters of the trained shared neural network using the validation set to obtain the feature extraction model.
[0026] An object defect detection system, the system includes:
[0027] A target image set acquisition module for acquiring a target image set; the target image set includes: images of each target object within the detection area;
[0028] A feature extraction module for extracting the features of the target image set using a feature extraction model to obtain an image feature set; the feature extraction model is established using a machine learning method;
[0029] A model construction module for constructing a subspace clustering model with group sparse constraints; the subspace clustering model includes: a sparse constraint model and a clustering model;
[0030] A target function and constraint condition determination module for determining the target function and constraint conditions of the subspace clustering model; the constraint condition is: the group sparse constraint matrix is constrained in a row-by-row manner; the target function is constructed with the goal of minimizing the clustering loss; the clustering loss is the within-class adaptive paradigm error of the subspace clustering model;
[0031] A parameter solving module for solving the target function according to the constraint conditions in an iterative manner to obtain the optimal parameter values of the subspace clustering model; the optimal parameter values are the values of the model parameters of the subspace clustering model corresponding to the minimum clustering loss; the model parameters include: the projection matrix of subspace clustering, the clustering index matrix, and the clustering center matrix;
[0032] A cluster center determination module for determining the cluster centers of the subspace clustering model according to the optimal parameter values;
[0033] A detection and classification module for calculating the distances between the image feature set and the cluster centers to obtain the defect detection and classification results of each target object in the target image set; the defect detection and classification results include: defective and non-defective.
[0034] Optionally, the objective function is:
[0035]
[0036] B = [B1, B2]
[0037] where B is the group sparse constraint matrix; F is the clustering index matrix; G is the clustering center matrix; A is an orthogonal matrix; T is the transpose transformation; I is the identity matrix; A T is the transpose transformation of matrix A; X is the image feature set; B1 is the projection matrix of the sparse constraint; ||·|| σ is the adaptive norm; ||B|| 2,1 is the l 2,1 norm of the group sparse constraint matrix; σ is the adaptive factor; λ, α, β, and γ are all user-specified hyperparameters for adjusting the importance of each module; B2 is the projection matrix of subspace clustering.
[0038] Optionally, the feature extraction model in the feature extraction module specifically includes:
[0039] A training data acquisition sub-module for acquiring training data; the training data includes defective sample images and non-defective sample images;
[0040] A partitioning sub-module for partitioning the training data into a training set and a validation set;
[0041] A shared neural network construction sub-module for constructing a shared neural network;
[0042] A training sub-module for inputting the training set into the shared neural network and training the parameters in the shared neural network with the goal of minimizing the feature error between the features output by the shared neural network and the features of the training data, to obtain a trained shared neural network;
[0043] A feature extraction model determination sub-module for adjusting the parameters of the trained shared neural network using the validation set to obtain the feature extraction model.
[0044] An electronic device includes a memory and a processor, the memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to execute the object defect detection method described in any one of the above.
[0045] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it implements the object defect detection method described in any one of the above.
[0046] According to the specific embodiments provided by the present invention, the following technical effects of the present invention are disclosed:
[0047] An embodiment of the present invention provides an object defect detection method, system, device and medium. The method extracts features of a target image set by using a feature extraction model to obtain an image feature set; constructs a subspace clustering model with group sparse constraints and determines an objective function and constraint conditions; uses an iterative method to solve the objective function according to the constraint conditions to obtain the value of the model parameters when the clustering loss of the subspace clustering model is minimized; after determining the cluster centers of the subspace clustering model according to the model parameters, calculates the distances between the image feature set and the cluster centers to obtain the defect detection classification results of each target object in the target image set. Since the feature extraction model is established by using machine learning methods and the defect detection classification is determined by the subspace clustering model with group sparse constraints; since the present invention combines machine learning methods with computer vision of clustering algorithms, it can avoid detection interference, thereby enabling accurate detection of defects. Description of the Drawings
[0048] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required to be used in the embodiments. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0049] Figure 1 It is a flowchart of the object defect detection method provided by the embodiment of the present invention;
[0050] Figure 2 It is a structural diagram of the object defect detection system provided by the embodiment of the present invention;
[0051] Figure 3 It is a three-dimensional schematic diagram of the structure for obtaining an image of a spoon by using a high-speed image sensor provided by the embodiment of the present invention;
[0052] Figure 4 It is a top view of the structure for obtaining an image of a spoon by using a high-speed image sensor provided by the embodiment of the present invention;
[0053] Figure 5 It is a flowchart of the object defect detection method in practical applications provided by the embodiment of the present invention;
[0054] Figure 6 It is a flowchart of the overall solution provided by the embodiment of the present invention.
[0055] Symbol Description:
[0056] Target image set acquisition module - 1, feature extraction module - 2, model construction module - 3, target function and constraint determination module - 4, parameter solution module - 5, cluster center determination module - 6, detection and classification module - 7. Detailed implementation manners
[0057] The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0058] The purpose of the present invention is to provide an object defect detection method, system, device and medium, which can accurately detect defects by combining machine learning methods and computer vision of clustering algorithms.
[0059] In order to make the above objects, features and advantages of the present invention more obvious and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific implementation manners.
[0060] Embodiment 1
[0061] As Figure 1 shown, the embodiment of the present invention provides an object defect detection method, which includes:
[0062] Step 100: Obtain a target image set; the target image set includes images of each target object in the detection area.
[0063] Step 200: Extract features of the target image set by using a feature extraction model to obtain an image feature set; the feature extraction model is established by using machine learning methods. Among them, the machine learning method can select a deep neural network. Among them, the deep neural network can be trained by constructing a shared neural network, and finally a VGG network is obtained.
[0064] Specifically, the method for determining the feature extraction model is:
[0065] Obtain training data; the training data includes defective sample images and non-defective sample images;
[0066] Divide the training data into a training set and a validation set;
[0067] Construct a shared neural network;
[0068] Input the training set into the shared neural network, and train the parameters in the shared neural network with the goal of minimizing the feature error between the features output by the shared neural network and the features of the training data, to obtain the trained shared neural network;
[0069] Use the validation set to adjust the parameters of the trained shared neural network to obtain the feature extraction model.
[0070] Step 300: Construct a subspace clustering model with group sparse constraints; the subspace clustering model includes: a sparse constraint model and a clustering model.
[0071] Step 400: Determine the objective function and constraints of the subspace clustering model; the constraint is: the group sparse constraint matrix is constrained in a row-by-row manner; the objective function is constructed with the goal of minimizing the clustering loss; the clustering loss is the within-class adaptive norm error of the subspace clustering model.
[0072] Step 500: Use an iterative method to solve the objective function according to the constraints to obtain the optimal parameter values of the subspace clustering model; the optimal parameter values are the values of the model parameters of the subspace clustering model corresponding to the minimum clustering loss; the model parameters include: the projection matrix of subspace clustering, the clustering index matrix, and the clustering center matrix.
[0073] Step 600: Determine the cluster centers of the subspace clustering model according to the optimal parameter values.
[0074] Step 700: Calculate the distances between the image feature set and the cluster centers to obtain the defect detection classification results of each target object in the target image set; the defect detection classification results include: defective and non-defective.
[0075] Specifically, the objective function is:
[0076]
[0077] B = [B1, B2]
[0078] where B is the group sparse constraint matrix; F is the clustering index matrix; G is the clustering center matrix; A is an orthogonal matrix; T is the transpose transformation; I is the identity matrix; A T is the transpose transformation of matrix A; X is the image feature set; B1 is the projection matrix of sparse constraint; ||·|| σ is the adaptive norm; ||B|| 2,1 is the l of the group sparse constraint matrix 2,1The normal form; σ is an adaptive factor; λ, α, β, and γ are all hyperparameters specified by the user for adjusting the importance of each module; B2 is the projection matrix of subspace clustering.
[0079] An iterative method is adopted to solve the objective function according to the constraint conditions, and the values of the model parameters when the clustering loss of the subspace clustering model is minimized are obtained; the model parameters include: the projection matrix of subspace clustering, the clustering index matrix, and the clustering center matrix.
[0080] The subspace clustering model using the model parameters is determined as the classification model.
[0081] In practical applications, taking the defect detection of industrial spoons as an example, the actual operation flowchart of the object defect detection method provided by the present invention is as Figure 5 shown. Through feature selection and subspace clustering of the target image set, then iteratively optimizing the projection matrix through group sparse constraints, and by determining the clustering center matrix G and the clustering index matrix F, the clustering result is finally output.
[0082] The specific operation process can also be as follows:
[0083] The present invention includes a hardware part and a software algorithm part. The hardware part is used to collect images of the spoons to be detected on the production line, and the software algorithm part, based on the images collected by the hardware part, uses deep learning algorithms and subspace clustering algorithms to find defective spoons. Figure 6 It is the overall scheme flowchart. First, training data is obtained; the training data is divided into a training set and a validation set; then feature extraction is performed in the VGG network, and then through the subspace clustering algorithm with group sparse constraints, the distance from the non-defective spoons is compared to obtain the defective spoon clusters, and finally the detection and classification are realized.
[0084] The hardware includes a high-speed image sensor and a host computer. The spoons are fixed on the conveyor belt in a unified manner. The high-speed image sensor is fixedly installed on the conveying equipment of the spoon production line, so that the high-speed image sensor is perpendicular to the conveyor belt and faces the spoons on the conveyor belt. The high-speed image sensor is connected to the host computer. The host computer controls the high-speed image sensor to obtain the syringe images in real time, and then the high-speed image sensor transmits the obtained images to the host computer. The host computer cuts and extracts features from the industrial spoon images in a unified manner, and finally calls the subspace clustering algorithm to cluster the spoon images to determine the spoon defects. The software part mainly clusters the spoon images through the input data to find defective spoons. Figure 3 and Figure 4 is a schematic diagram of the structure for obtaining spoon images using a high-speed image sensor. Among them, in Figure 3 and Figure 4Among them, from left to right, the 1st spoon, the 2nd spoon, the 3rd spoon... the (n - 3)th spoon, the (n - 2)th spoon, the (n - 1)th spoon, and the nth spoon are arranged in sequence.
[0085] (1) By adding self-made defects such as black shadows and material shortages at the possible defect positions of the spoons, L positive sample spoon images are made, and the VGG network in the shared neural network is trained with K negative sample spoon images without added defects. After the training is completed, the VGG network initially encodes the spoon features. However, due to the limited self-made spoon defect training set, there may be more noises in the VGG deep features. At the same time, the types of defects of the spoons to be detected in the real application scenario are unknown, and it is difficult to directly use the VGG network to predict whether the spoons have defects. The present invention will, on the basis of the VGG deep features, utilize the sparse clustering algorithm to mine the distinguishability of different spoon deep features in the subspace.
[0086] For example: The VGG network is trained with 510 spoon data (including L = 144 artificial-made positive samples and K = 366 negative samples), and 90% of them are used for training and 10% for testing. During the training, the network parameters are initialized with the pre-trained parameters on the imagenet dataset, the epoch value is set to j = 50, the batch size is set to 32, the cross entropy loss function and the ADAM optimization algorithm are used, and 324 spoon image data are collected on the real spoon industrial production line for verification and analysis. The VGG network extracts 256-dimensional feature data for each image sample, and on this basis, the clustering method proposed by the present invention is executed to detect defects. At the same time, the effects are compared with two mainstream clustering methods, K-means (KM) and FastAdaptive KM Subspace Clustering (FAKM). Two evaluation metrics are used to measure the effectiveness of different methods: Normalized Mutual Information (NMI) and Accuracy (ACC). Table 1 shows the performance comparison results of various algorithms on the spoon dataset. It can be seen from the results of the table that the method provided by the present invention has obvious advantages in ACC and NMI compared with other comparison methods. The above results fully prove the effectiveness of the method provided by the present invention. Table 1 shows the performance comparison of various algorithms on the spoon dataset.
[0087] Table 1 Performance Comparison of Various Algorithms on the Spoon Dataset
[0088] ACC% NMI% KM 79.74±0.33 55.47±0.26 FAKM 82.12±0.78 61.55±0.47 OURS (This invention) 85.76±0.47 63.32±0.35
[0089] (2) Collect n spoon images of N*M (hereinafter referred to as images) within a certain period of time. Input the images into the VGG network trained in step (1), and take the output of the second fully connected layer as the image depth features. After extracting the depth features, form a dataset X = [x1, x2,..., x n ∈ R n×d , where n is the number of samples and d is the sample feature dimension. The images can be divided into positive samples (images containing defects) and negative samples (images not containing defects), and the number of classes c = 2.
[0090] (3) On the dataset X, construct a subspace learning model based on sparse constraints, that is, a sparse constraint model.
[0091]
[0092] B1 ∈ R d×r ;
[0093] A ∈ R d×r ;
[0094] Among them, B1 is the projection matrix of sparse constraints; d is the sample feature dimension; r is the sample dimension after dimensionality reduction; A is an orthogonal matrix; T is the transpose transformation; I is the identity matrix; A T is the transpose transformation of matrix A; X is the image feature set; ||·|| σ is the adaptive norm; σ is the adaptive factor.
[0095] The definition of the adaptive norm ||·|| σ is as follows:
[0096]
[0097] Among them, σ is the adaptive factor; c i is the i-th row of matrix C; is the square of the l2 norm of c i ; it can be seen that when σ → 0, ||C|| σ can be approximated as the l 2,1 norm of matrix C; when σ → ∞, ||C|| σ can be approximated as the F norm of matrix C.
[0098] (4) On the dataset X, construct a clustering model for spoon images of subspace clustering, that is, a clustering model.
[0099]
[0100] B2 ∈ R d×r ;
[0101] F ∈ R n×c ;
[0102] G ∈ R c×r ;
[0103] Among them, F is the clustering index matrix; G is the clustering center matrix; B2 is the projection matrix for subspace clustering; d is the sample feature dimension; r is the dimension of the sample after dimensionality reduction; n is the number of samples; c is the number of classes.
[0104] (5) On the basis of steps (2) and (3), construct the spoon adaptive subspace clustering objective function with group sparse constraints as follows:
[0105]
[0106] B = [B1, B2]
[0107] Among them, B is the group sparse constraint matrix; F is the clustering index matrix; G is the clustering center matrix; A is an orthogonal matrix; T is the transpose transformation; I is the identity matrix; A T is the transpose transformation of matrix A; X is the image feature set; B1 is the projection matrix with sparse constraints; ||·|| σ is the adaptive norm; ||B|| 2,1 is the l 2,1 norm of the group sparse constraint matrix; σ is the adaptive factor; λ, α, β, and γ are all user-specified hyperparameters used to adjust the importance of each module; B2 is the projection matrix for subspace clustering.
[0108] and and and are used to enhance the generalization ability of the model and prevent overfitting. B = [B1, B2] is the group sparse constraint matrix.
[0109] The l 2,1 norm term of the group sparse joint constraint matrix in the objective function adopts ||B|| 2,1 with a row-wise constraint method, making B have a row-wise sparse property, which is conducive to selecting the most representative image features. When there is noise in B1 and B2, ||B|| 2,1 will combine the results of B1 and B2 and constraint B row-wise, making the unimportant rows in B approach zero, and thus effectively excluding noise interference.
[0110] (6) Solve the objective function
[0111] Since the non-smooth norm is used in the present invention, before optimization, the objective function needs to be transformed, and the original objective function can be rewritten as:
[0112]
[0113]
[0114]
[0115] Among them, B is the group sparse constraint matrix; F is the clustering index matrix; G is the clustering center matrix; A is the orthogonal matrix; T is the transpose transformation; I is the identity matrix; A T is the transpose transformation of matrix A; B1 is the projection matrix of sparse constraint; B2 is the projection matrix of subspace clustering; n is the number of samples; σ is the adaptive factor; i is the i-th row; x i is the feature data of the i-th image; λ, α, β, and γ are hyperparameters specified by the user to adjust the importance of each module; f i is the i-th row of the F matrix.
[0116] (7) The iterative optimization process is as follows:
[0117] Let X ∈ R n×d represent the input data set; t represents the t-th iterative optimization.
[0118] Step 1: Calculate:
[0119]
[0120]
[0121] where S and V are diagonal matrices with s i and v i as the diagonal elements respectively.
[0122]
[0123]
[0124] Step 2: Update:
[0125] B1 t =(αE + X T SX + γD) 木1 X T SXA;
[0126] B2 t =(X T VX + βE + γD) 木1 X T VFG;
[0127] X T XB1 t = UΣJ T ;
[0128] A t = UJ T ;
[0129] B = [B1, B2];
[0130]
[0131] Wherein, E is the identity matrix; X is the image feature set; A is an orthogonal matrix; T is the transpose transformation; B is the group sparse constraint matrix; F is the clustering index matrix; G is the clustering center matrix; B1 is the projection matrix of the sparse constraint; B2 is the projection matrix of subspace clustering; α, β, and γ are hyperparameters specified by the user for adjusting the importance of each module; t is the t-th iterative update; D is the auxiliary diagonal B i is the i-th row of matrix B; U and J are unitary matrices obtained by singular value decomposition of the matrix, Σ is the diagonal matrix obtained by singular value decomposition; d is the sample feature dimension.
[0132] Step 3: Update G t = (F T F) -1 F T XB2.
[0133] Step 4: Update the clustering index matrix F, and assign each data point to the nearest cluster center through the K-means algorithm.
[0134]
[0135] Wherein, F ij is the data of the i-th row and j-th row of the clustering index matrix F; i is the i-th row; j is the j-th row; B is the group sparse constraint matrix; T is the transpose transformation; x i is the feature data of the i-th image; g k is the k-th row of the clustering center matrix G.
[0136] Step 5: Update t = t + 1.
[0137] Step 6: When the values of the objective function calculated twice are less than a certain value, go to Step 7; otherwise, repeat Steps 1 - 6.
[0138] Step 7: Output B2, F, G.
[0139] (8) Distinguish defective spoons:
[0140] Prepare some normal (non-defective) spoon samples and extract their feature data using the VGG network. Take the average of the feature data of the normal spoon samples to obtain the feature vector data u. Compare the Euclidean distances between the centers of the two clusters in the clustering center matrix G and u. The closer distance d n is the non-defective cluster, and the farther distance d p is the defective cluster, thereby locating the defective spoons.
[0141] (9) Other issues:
[0142] When facing extreme cases in the test samples, such as all spoons being defective or non - defective, calculate the distance between the two types of cluster centers after the algorithm runs. If the distance is less than a certain value ε, merge the two types into one type, and use the method in step (8) to determine whether this type is defective or not.
[0143] Embodiment 2
[0144] As Figure 2 shown, the embodiment of the present invention provides an object defect detection system, which includes: a target image set acquisition module 1, a feature extraction module 2, a model construction module 3, a target function and constraint determination module 4, a parameter solving module 5, a cluster center determination module 6, and a detection and classification module 7.
[0145] The target image set acquisition module 1 is used to acquire a target image set; the target image set includes: images of each target object within the detection area.
[0146] The feature extraction module 2 is used to extract the features of the target image set by using a feature extraction model to obtain an image feature set; the feature extraction model is established by using machine learning methods.
[0147] Specifically, the feature extraction model in the feature extraction module 2 specifically includes: a training data acquisition sub - module, a division sub - module, a shared neural network construction sub - module, a training sub - module, and a feature extraction model determination sub - module.
[0148] The training data acquisition sub - module is used to acquire training data; the training data includes defective sample images and non - defective sample images.
[0149] The division sub - module is used to divide the training data into a training set and a validation set.
[0150] The shared neural network construction sub - module is used to construct a shared neural network.
[0151] The training sub - module is used to input the training set into the shared neural network, and with the goal of minimizing the feature error between the features output by the shared neural network and the features of the training data, train the parameters in the shared neural network to obtain a trained shared neural network.
[0152] The feature extraction model determination sub - module is used to adjust the parameters of the trained shared neural network by using the validation set to obtain the feature extraction model.
[0153] The model construction module 3 is used to construct a subspace clustering model with group sparse constraints; the subspace clustering model includes: a sparse constraint model and a clustering model.
[0154] The objective function and constraint determination module 4 is used to determine the objective function and constraints of the subspace clustering model; the constraint is that the group sparse constraint matrix is constrained in a row-by-row manner; the objective function is constructed with the goal of minimizing the clustering loss; the clustering loss is the intra-class adaptive paradigm error of the subspace clustering model.
[0155] The parameter solving module 5 is used to iteratively solve the objective function according to the constraints to obtain the optimal parameter values of the subspace clustering model; the optimal parameter values are the values of the model parameters of the subspace clustering model corresponding to the minimum clustering loss; the model parameters include: the projection matrix of subspace clustering, the clustering index matrix, and the clustering center matrix.
[0156] The cluster center determination module 6 is used to determine the cluster center of the subspace clustering model according to the optimal parameter values.
[0157] The detection and classification module 7 is used to calculate the distance between the image feature set and the cluster center to obtain the defect detection and classification results of each target object in the target image set; the defect detection and classification results include: defective and non-defective.
[0158] Specifically, the objective function is:
[0159]
[0160] B = [B1, B2]
[0161] where B is the group sparse constraint matrix; F is the clustering index matrix; G is the clustering center matrix; A is an orthogonal matrix; T is the transpose transformation; I is the identity matrix; A T is the transpose transformation of matrix A; X is the image feature set; B1 is the projection matrix of sparse constraint; ||·|| σ is the adaptive paradigm; ||B|| 2,1 is the l 2,1 norm of the group sparse constraint matrix; σ is the adaptive factor; λ, α, β, and γ are hyperparameters specified by the user for adjusting the importance of each module; B2 is the projection matrix of subspace clustering.
[0162] The solving sub-module is used to iteratively solve the objective function according to the constraints to obtain the values of the model parameters of the subspace clustering model when the clustering loss is minimized; the model parameters include: the projection matrix of subspace clustering, the clustering index matrix, and the clustering center matrix.
[0163] The classification model determination sub-module is used to determine the subspace clustering model using the model parameters as the classification model.
[0164] Example 3
[0165] An embodiment of the present invention provides an electronic device, including a memory and a processor. The memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to execute the object defect detection method in Embodiment 1.
[0166] As an optional implementation manner, an embodiment of the present invention further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the object defect detection method in Embodiment 1 is implemented.
[0167] The beneficial effects of the present invention are as follows: This solution introduces the VGG network to encode the spoon image features, and finds the optimal clustering result of the spoon by constructing a group sparse constraint matrix. At the same time, an adaptive paradigm is introduced to flexibly handle different data distributions in practical applications, and its learning effect is better than that of traditional learning solutions.
[0168] In this specification, each embodiment is described in a progressive manner. The key point of each embodiment is to illustrate the differences from other embodiments. The same or similar parts among the embodiments can be referred to each other. For the system disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple, and the relevant parts can be referred to the description of the method part.
[0169] Specific examples are used in this article to elaborate on the principle and implementation manner of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for those of ordinary skill in the art, according to the idea of the present invention, there will be changes in the specific implementation manner and application scope. In summary, the content of this specification should not be construed as a limitation to the present invention.
Claims
1. A method for detecting object defects, characterized in that, The method includes: Obtaining a target image set; the target image set includes images of each target object within a detection region; Extracting features of the target image set using a feature extraction model to obtain an image feature set; the feature extraction model is established using a machine learning method; Constructing a subspace clustering model with group sparse constraints; the subspace clustering model includes a sparse constraint model and a clustering model; Determining the objective function and constraint conditions of the subspace clustering model; the constraint condition is to perform row-wise constraint on the group sparse constraint matrix; the objective function is constructed with the goal of minimizing the clustering loss; the clustering loss is the within-class adaptive norm error of the subspace clustering model; Using an iterative method to solve the objective function according to the constraint conditions to obtain the optimal parameter values of the subspace clustering model; the optimal parameter values are the values of the model parameters of the subspace clustering model corresponding to the minimum clustering loss; the model parameters include the projection matrix, clustering index matrix, and clustering center matrix of subspace clustering; Determining the cluster centers of the subspace clustering model according to the optimal parameter values; Calculating the distances between the image feature set and the cluster centers to obtain the defect detection classification results of each target object in the target image set; the defect detection classification results include defective and non-defective.
2. The object defect detection method according to claim 1, wherein, The objective function is: B = [B1, B2] Among them, B is the group sparse constraint matrix; F is the clustering index matrix; G is the clustering center matrix; A is the orthogonal matrix; T is the transpose transformation; I is the identity matrix; A T is the transpose transformation of matrix A; X is the image feature set; B1 is the projection matrix of the sparse constraint; ||·|| σ is the adaptive norm; ||B|| 2,1 is the l 2,1 norm of the group sparse constraint matrix; σ is the adaptive factor; λ, α, β, and γ are all hyperparameters; B2 is the projection matrix of subspace clustering.
3. The object defect detection method according to claim 1, characterized in that, The method for determining the feature extraction model is: Obtaining training data; the training data includes defective sample images and non-defective sample images; Dividing the training data into a training set and a validation set; Constructing a shared neural network; Inputting the training set into the shared neural network, and training the parameters in the shared neural network with the goal of minimizing the feature error between the features output by the shared neural network and the features of the training data to obtain a trained shared neural network; Adjusting the parameters of the trained shared neural network using the validation set to obtain the feature extraction model.
4. An object defect detection system, characterized in that, The system includes: A target image set acquisition module for obtaining a target image set; the target image set includes images of each target object within a detection region; A feature extraction module for extracting features of the target image set using a feature extraction model to obtain an image feature set; the feature extraction model is established using a machine learning method; A model construction module for constructing a subspace clustering model with group sparse constraints; the subspace clustering model includes a sparse constraint model and a clustering model; An objective function and constraint condition determination module for determining the objective function and constraint conditions of the subspace clustering model; the constraint condition is to perform row-wise constraint on the group sparse constraint matrix; the objective function is constructed with the goal of minimizing the clustering loss; the clustering loss is the within-class adaptive norm error of the subspace clustering model; A parameter solving module, which is used to solve the objective function according to the constraint conditions in an iterative manner to obtain the optimal parameter values of the subspace clustering model; the optimal parameter values are the values of the model parameters of the subspace clustering model corresponding to the minimum clustering loss; the model parameters include: the projection matrix of subspace clustering, the clustering index matrix, and the cluster center matrix; A cluster center determination module, which is used to determine the cluster centers of the subspace clustering model according to the optimal parameter values; A detection and classification module, which is used to calculate the distances between the image feature set and the cluster centers to obtain the defect detection and classification results of each target object in the target image set; the defect detection and classification results include: defective and non-defective.
5. The object defect detection system according to claim 4, characterized in that, The objective function is: B = [B1, B2] Among them, B is the group sparse constraint matrix; F is the clustering index matrix; G is the clustering center matrix; A is an orthogonal matrix; T is the transpose transformation; I is the identity matrix; A T is the transpose transformation of matrix A; X is the image feature set; B1 is the projection matrix of sparse constraint; ||·|| σ is the adaptive norm; ||B|| 2,1 is the l 2,1 norm of the group sparse constraint matrix; σ is the adaptive factor; λ, α, β, and γ are all hyperparameters; B2 is the projection matrix of subspace clustering.
6. The object defect detection system according to claim 4, characterized in that, The feature extraction model in the feature extraction module specifically includes: A training data acquisition sub-module, which is used to acquire training data; the training data includes defective sample images and non-defective sample images; A division sub-module, which is used to divide the training data into a training set and a validation set; A shared neural network construction sub-module, which is used to construct a shared neural network; A training sub-module, which is used to input the training set into the shared neural network and train the parameters in the shared neural network with the goal of minimizing the feature error between the features output by the shared neural network and the features of the training data to obtain a trained shared neural network; A feature extraction model determination sub-module, which is used to adjust the parameters of the trained shared neural network by using the validation set to obtain the feature extraction model.
7. An electronic device, characterized in that, It includes a memory and a processor. The memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to execute the object defect detection method according to any one of claims 1 to 3.
8. A computer-readable storage medium, characterized in that, It stores a computer program, and when the computer program is executed by the processor, it implements the object defect detection method according to any one of claims 1 to 3.
Citation Information
Patent Citations
Hyperspectral image feature recognition method, device and equipment and storage medium
CN112070008A
Clustering method based on group sparse optimization
CN112508049A