CN113627556B - Method and device for realizing image classification, electronic equipment and storage medium - Google Patents
Method and device for realizing image classification, electronic equipment and storage medium Download PDFInfo
- Publication number
- CN113627556B CN113627556B CN202110950080.7A CN202110950080A CN113627556B CN 113627556 B CN113627556 B CN 113627556B CN 202110950080 A CN202110950080 A CN 202110950080A CN 113627556 B CN113627556 B CN 113627556B
- Authority
- CN
- China
- Prior art keywords
- classified
- vector
- image
- training
- class
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 45
- 239000013598 vector Substances 0.000 claims abstract description 290
- 238000013145 classification model Methods 0.000 claims abstract description 105
- 238000012549 training Methods 0.000 claims description 104
- 230000006870 function Effects 0.000 claims description 48
- 238000012795 verification Methods 0.000 claims description 25
- 239000011159 matrix material Substances 0.000 claims description 21
- 238000004590 computer program Methods 0.000 claims description 7
- 238000004422 calculation algorithm Methods 0.000 claims description 6
- 238000012545 processing Methods 0.000 claims description 6
- 238000005457 optimization Methods 0.000 claims description 5
- 230000003190 augmentative effect Effects 0.000 claims description 4
- 238000004364 calculation method Methods 0.000 claims description 4
- 238000002372 labelling Methods 0.000 claims description 4
- 238000013527 convolutional neural network Methods 0.000 claims description 3
- 230000004083 survival effect Effects 0.000 claims 1
- 230000000694 effects Effects 0.000 abstract description 6
- 238000010586 diagram Methods 0.000 description 4
- 238000007635 classification algorithm Methods 0.000 description 3
- 230000003287 optical effect Effects 0.000 description 3
- NAWXUBYGYWOOIX-SFHVURJKSA-N (2s)-2-[[4-[2-(2,4-diaminoquinazolin-6-yl)ethyl]benzoyl]amino]-4-methylidenepentanedioic acid Chemical compound C1=CC2=NC(N)=NC(N)=C2C=C1CCC1=CC=C(C(=O)N[C@@H](CC(=C)C(O)=O)C(O)=O)C=C1 NAWXUBYGYWOOIX-SFHVURJKSA-N 0.000 description 2
- 238000013528 artificial neural network Methods 0.000 description 2
- 239000013307 optical fiber Substances 0.000 description 2
- 230000000644 propagated effect Effects 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 238000003709 image segmentation Methods 0.000 description 1
- 238000010801 machine learning Methods 0.000 description 1
- 238000010295 mobile communication Methods 0.000 description 1
- 230000008707 rearrangement Effects 0.000 description 1
- 230000000306 recurrent effect Effects 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 239000007787 solid Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F18/00—Pattern recognition
- G06F18/20—Analysing
- G06F18/24—Classification techniques
- G06F18/241—Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F18/00—Pattern recognition
- G06F18/20—Analysing
- G06F18/21—Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
- G06F18/214—Generating training patterns; Bootstrap methods, e.g. bagging or boosting
Landscapes
- Engineering & Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Theoretical Computer Science (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Bioinformatics & Cheminformatics (AREA)
- Bioinformatics & Computational Biology (AREA)
- Artificial Intelligence (AREA)
- Evolutionary Biology (AREA)
- Evolutionary Computation (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Life Sciences & Earth Sciences (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
- Image Analysis (AREA)
Abstract
The embodiment of the invention discloses a method and a device for realizing image classification, electronic equipment and a storage medium. Wherein, the method comprises the following steps: acquiring a feature vector of an image to be classified as the feature vector to be classified; inputting the feature vector to be classified into an image classification model, calculating a sparse representation vector of the feature vector to be classified based on an objective function of the image classification model, and determining the category of the image to be classified according to the sparse representation vector; wherein the objective function includes a regular sparse representation term and a setting class representation term. According to the embodiment of the invention, the problem of low image feature representation capability of the image classification model in the face of complex images is solved through the method, and the effect of high classification accuracy of the image classification model is realized.
Description
Technical Field
The embodiment of the invention relates to the technical field of image processing, in particular to a method and a device for realizing image classification, electronic equipment and a storage medium.
Background
With the advent of the big data age, more and more people began studying image classification algorithms. In recent years, researchers have proposed a number of image classification algorithms, for example, image classification by machine learning models.
In the related art, for example, there are an image classification method based on a support vector, an image classification method based on a collaborative representation, an image classification algorithm based on a non-negative representation, and the like, when these methods face a complex image, the image feature representation capability of the image classification model is low, resulting in poor classification performance of the image classification model.
Disclosure of Invention
The embodiment of the invention provides a method and a device for realizing image classification, electronic equipment and a storage medium, which are used for improving the classification performance of an image classification model.
In a first aspect, an embodiment of the present invention provides an implementation method for image classification, including:
acquiring a feature vector of an image to be classified as the feature vector to be classified;
inputting the feature vector to be classified into an image classification model, calculating a sparse representation vector of the feature vector to be classified based on an objective function of the image classification model, and determining the category of the image to be classified according to the sparse representation vector;
the objective function comprises a conventional sparse representation item and a setting class representation item, wherein the conventional sparse representation item is used for determining reconstruction errors between the feature vector to be classified and training feature vectors of all training samples of the image classification model, and the setting class representation item is used for determining the sum of the reconstruction errors between the feature vector to be classified and the training feature vectors of the training samples of each setting class.
In a second aspect, an embodiment of the present invention further provides an apparatus for implementing image classification, including:
the image feature vector acquisition module is used for acquiring feature vectors of the images to be classified as the feature vectors to be classified;
the image category determination module is used for inputting the feature vector to be classified into an image classification model, calculating a sparse representation vector of the feature vector to be classified based on an objective function of the image classification model, and determining the category of the image to be classified according to the sparse representation vector;
the objective function comprises a conventional sparse representation item and a setting class representation item, wherein the conventional sparse representation item is used for determining reconstruction errors between the feature vector to be classified and training feature vectors of all training samples of the image classification model, and the setting class representation item is used for determining the sum of the reconstruction errors between the feature vector to be classified and the training feature vectors of the training samples of each setting class.
In a third aspect, an embodiment of the present invention further provides an electronic device, where the electronic device includes:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, the one or more programs cause the one or more processors to implement a method for image classification as any one of the embodiments of the present invention.
In a fourth aspect, the embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the computer program implements the method for implementing image classification according to any one of the embodiments of the present invention.
The method for realizing image classification provided by the embodiment of the invention comprises the steps of inputting a feature vector to be classified into an image classification model, calculating a sparse representation vector of the feature vector to be classified based on an objective function comprising a conventional sparse representation item and a setting class representation item in the image classification model, and determining the class of an image to be classified according to the sparse representation vector. The problem of low image feature representation capability of the image classification model when the complex image is faced is solved, and the effect of high classification accuracy of the image classification model is achieved.
Drawings
Fig. 1 is a flowchart of an implementation method for image classification according to an embodiment of the present invention;
fig. 2 is a flowchart of an implementation method for image classification according to a second embodiment of the present invention;
fig. 3 is a schematic structural diagram of an apparatus for implementing image classification according to a third embodiment of the present invention;
fig. 4 is a schematic structural diagram of an electronic device according to a fourth embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures.
Example one
Fig. 1 is a flowchart of an implementation method for image classification according to an embodiment of the present invention, where this embodiment is applicable to a case where an image classification model obtained by objective function optimization classifies an image, and the method may be implemented by an implementation apparatus for image classification, and the apparatus may be implemented in a software and/or hardware manner. The apparatus can be configured in a server, and the method specifically includes:
and S110, acquiring a feature vector of the image to be classified as the feature vector to be classified.
In the above operation, specifically, the image to be classified may be an image stored locally by the electronic device, or may also be an image acquired in real time by the electronic device. Electronic devices may include, but are not limited to, cell phones, tablets, computers, smart cameras, and servers. The image to be classified may also be an image in an experimental database commonly used by those skilled in the art, such as a face recognition database, a handwritten number recognition database, and the like, the face recognition database may be an Extended YaleB database and a CMU PIE database, and the handwritten number recognition database may be an MNIST database and a USPS database. The number of images to be classified may be one or more. The size of the image to be classified is not limited and may be 224 × 224.
Optionally, the obtaining the feature vector of the image to be classified includes: for the image to be classified, converting a pixel matrix into a one-dimensional vector as the characteristic vector to be classified; or processing the image to be classified by adopting a convolutional neural network, and outputting the feature vector to be classified from a full connection layer. The image to be classified can be processed by using a mechanism including but not limited to a recurrent neural network and attention, and a feature vector to be classified is output. The image to be classified is converted into the vector or the characteristic vector of the image to be classified is obtained by processing the image to be classified by adopting a neural network method, so that the computer can be helped to identify and process, and remove redundant information by extracting important information, and the classification performance of the image classification model is helped to be improved.
S120, inputting the feature vector to be classified into an image classification model, calculating a sparse representation vector of the feature vector to be classified based on an objective function of the image classification model, and determining the category of the image to be classified according to the sparse representation vector.
The objective function comprises a conventional sparse representation item and a setting class representation item, wherein the conventional sparse representation item is used for determining reconstruction errors between the feature vector to be classified and training feature vectors of all training samples of the image classification model, and the setting class representation item is used for determining the sum of the reconstruction errors between the feature vector to be classified and the training feature vectors of the training samples of each setting class.
Wherein, the image classification model can be a sparse representation model or a mixed sparse representation model. The sparse representation model is used for carrying out sparse representation on the feature vectors to be classified by using all known classes of training feature vectors and predicting that the images to be classified belong to the class with the minimum reconstruction error. The mixed sparse representation model is used for sparsely representing the feature vectors to be classified by utilizing the training feature vectors of all known classes, sparsely representing the feature vectors to be classified by utilizing the training feature vectors in all the classes respectively, and predicting that the images to be classified belong to the class with the minimum reconstruction error. In the above operation, specifically, the sparse representation is also called sparse coding, and the training feature vectors of the training samples are linearly combined to represent the samples to be classified. Where the sparsity of the linear representation coefficients can be obtained using 1-norm minimization. Wherein the reconstruction error may be a 2-norm squared error or a mean squared error between the image classification model output and the original input.
Optionally, the formula of the objective function is as follows:
wherein y is a feature vector to be classified, and y belongs to R D×1 R represents a matrix, and D represents the characteristic dimension of the characteristic vector to be classified; can be a set of training feature vectors for all classes X belongs to R D×N N denotes the total number of training samples, X = [) 1 ,X 2 ,...,X C ]Consists of class C training feature vectors, C representing the number of classes of the training samples, wherein,a column-wise mosaic matrix of training eigenvectors belonging to class i, i being the class number, n i Representing the number of training samples of the ith class; s = [ S ] 1 ,S 2 ,...,S C ] T A sparse representation vector which represents the feature vector to be classified by adopting each type of training feature vector; wherein it is present>Column-wise splicing matrix X of ith class training feature vector for representing feature vector to be classified i The sparse representation vector of the run; />Is a conventional sparse representation item; />For each n in the feature vector to be classified and class C i The sum of the reconstruction errors of the training feature vectors; alpha is a sparse adjustment parameter for adjusting the sparsity of the sparse representation vector, and beta is a participation parameter for adjusting the setting class representation; />Is the square of the 2-norm of the vector, | | |. The luminance 1 Is the vector 1-norm.
In the above operation, the dimension is specifically the number of feature vectors in the image, and the dimension is not limited and may be 768, 1024, and 4096. The training sample image before the training sample is converted into the training feature vector may be an image stored locally by the electronic device, or an image acquired in real time by the electronic device. Electronic devices may include, but are not limited to, cell phones, tablets, computers, smart cameras, and servers. The training sample image may also be an experimental database commonly used by those skilled in the art, such as a face recognition database, such as an Extended YaleB database and a CMU PIE database, and a handwritten digit recognition database, such as an MNIST numberDatabases and USPS databases. The size of the training sample image is not limited and may be 224 x 224.X is the training characteristic vector of the training sample, N is N training samples in total, N can be 25 and 100, N is not limited, X is the training characteristic vector of C categories in total, C can be 5 and 10, the number of categories C is not limited, each category comprises N i The number of training samples contained in each category can be the same or different, n i May be 5 and 10, for n i And are not intended to be limiting. Wherein s is a sparse representation vector represented by each class of training feature vector for the feature vector to be classified, the sparse representation vectors totally comprise C classes, and the ith class of sparse representation vector is a column-wise splicing matrix X of the ith class of training feature vector for the feature to be classified i The sparse representation of the vector is performed such that,for the reconstruction errors of the feature vector to be classified and N training feature vectors of C classes,and expressing the sample y to be classified by linearly combining the feature vectors of N training samples in X, wherein the sparsity of linear representation coefficients of the feature vectors of all the training samples, namely the sparsity of sparse representation vectors, is obtained by using 1-norm minimization. />Each is represented by n in class C i The feature vectors of the training samples are linearly combined to represent the feature vector y to be classified so as to correct the defect that the feature vectors of N training samples in X are used for fitting the feature vector to be classified, and the accuracy of sparse representation of the feature vector to be classified by the similar training feature vector is enhanced. The target function not only comprises the reconstruction errors of the feature vector to be classified and N training feature vectors of C classes, but also comprises the feature vector to be classified and each N of the C classes i The sum of reconstruction errors of training samples, i.e. the objective function comprehensively takes into account the global features and the setting class of the imageThe characteristics realize accurate representation of the image and ensure the robustness and the discriminability of the target function at the same time.
Optionally, before inputting the feature vector to be classified into an image classification model, the method further includes: inputting the verification feature vectors of a plurality of verification samples into an image classification model to output a classification result; comparing the output classification result with the labeling classification result of the verification sample to determine the classification recognition rate of the image classification model; and adjusting the sparse adjustment parameters according to the classification recognition rate.
In the above operation, specifically, before the feature vector to be classified is input into the image classification model, the output classification result of the image classification model is compared with the labeled classification result of the verification sample by using the verification sample to determine the classification recognition rate of the image classification model, and the values of α and β can be adjusted according to the classification recognition rate to improve the classification recognition rate of the image classification model. The images in the verification sample can be images stored locally by the electronic device, images acquired by the electronic device in real time, or common experimental databases of those skilled in the art, and the images are classified by human or machine. The labeling classification result is a classification result labeled on the verification sample image to be classified, and can be classified into landscapes, people, arabic numbers and the like. The number of the verification samples is one or more, when the number of the verification samples is multiple, the image classification models are respectively input, the image classification models output the classification recognition rates of all the verification samples, the average classification recognition rate is calculated, and the average classification recognition rate is used as the final classification recognition rate of the image classification models.
In the above operation, specifically, α and β are parameters to be adjusted, a range of α and β is a numerical value between 0 and 1, α and β may be set as empirical values, β may be fixed first, an optimal value of α may be adjusted, a value of α may be fixed first, an optimal value of β may be adjusted second, α and β may be adjusted to corresponding optimal values at the same time, for example, a first round may fix β to 0.1 for the first time, and α may be set to 0.1 for the first time, then a verification sample is input into the image classification model and a classification result is output, the output classification result is compared with a labeled classification result of the verification sample to determine a classification recognition rate of the image classification model, a first round may adjust α to 0.2 for the second time, the verification sample is still input into the image classification model and a classification result is output, the output classification result is compared with a labeled classification result of the verification sample to determine a classification recognition rate of the image classification model, the first round compares the output classification result with a first round recognition rate of the first round, and compares the maximum classification rate with a second round to obtain a maximum classification rate, and a first round compares the maximum classification rate of the image classification model. And then, the second round can fix beta to 0.2 for the first time, alpha can be set to 0.1, the verification sample is still input into the image classification model, the classification result is output, the output classification result is compared with the labeled classification result of the verification sample, the classification recognition rate of the image classification model is determined, the maximum classification recognition rate of the image classification model is compared with the classification recognition rate of the first round, the next comparison is carried out, the second round can adjust alpha to 0.2, the verification sample is still input into the image classification model, the classification result is output, the output classification result is compared with the labeled classification result of the verification sample, the classification recognition rate of the image classification model is determined, the maximum classification recognition rate of the image classification model obtained in the last time is compared, the maximum classification recognition rate of the image classification model is used for the next comparison, and the like, until alpha is adjusted to 1, and the alpha value which enables the classification rate of the image classification model to be maximum in the first round and the second round is obtained. And the analogy is carried out until the beta is adjusted to be 1, and the values of alpha and beta which enable the classification recognition rate of the image classification model to be maximum in all the rounds are obtained.
According to the technical scheme provided by the embodiment of the invention, the characteristic vector to be classified is input into an image classification model, the sparse representation vector of the characteristic vector to be classified is calculated based on the target function comprising a conventional sparse representation item and a setting class representation item in the image classification model, and the class of the image to be classified is determined according to the sparse representation vector. The problem of low image feature representation capability of the image classification model when the complex image is faced is solved, and the effect of high classification accuracy of the image classification model is achieved.
Example two
Fig. 2 is a flowchart of an implementation method for image classification according to a second embodiment of the present invention, where on the basis of the foregoing embodiments, optionally, the step of inputting the feature vector to be classified into an image classification model, calculating a sparse representation vector of the feature vector to be classified based on an objective function of the image classification model, and determining the category of the image to be classified according to the sparse representation vector includes: inputting the feature vector to be classified into an image classification model, calculating a sparse representation vector of the feature vector to be classified based on a target function of the image classification model by using an Alternating Direction Method of Multipliers (ADMM), and determining the category of the image to be classified according to the sparse representation vector.
As shown in fig. 2, the method of the embodiment may specifically include:
s210, obtaining a feature vector of the image to be classified as the feature vector to be classified.
S220, inputting the feature vectors to be classified into an image classification model, calculating sparse representation vectors of the feature vectors to be classified based on a target function of the image classification model by utilizing an alternating direction multiplier algorithm, and determining the category of the image to be classified according to the sparse representation vectors.
In the above operation, specifically, after the values of α and β are determined by the verification sample, the feature vector to be classified may be input into an image classification model, a sparse representation vector of the feature vector to be classified is calculated based on an objective function of the image classification model by using an alternating direction multiplier algorithm, and the category of the image to be classified is determined according to the sparse representation vector. The alternating direction multiplier method is a computer framework for solving a separable convex optimization problem, wherein the convex optimization problem is a problem with a global optimal solution in a defined domain.
Optionally, calculating a sparse representation vector of the feature vector to be classified based on an objective function of the image classification model includes:
the objective function of the image classification model is expressed as formula (1):
convert equation (1) to:
for the formula (3), the method is optimized by adopting an alternating direction multiplier method, and 2 alpha s calculation is performed 1 Let s be z, the optimization problem of equation (3) above is converted into:
s.t.s=z
converting the formula (4) into an augmented Lagrangian function, and marking the function as a formula (5):
wherein δ is an augmented lagrange multiplier, ρ is a penalty parameter, and equation (5) is simplified and irrelevant terms are ignored to obtain equation (6):
wherein trace { } represents the sum of elements on a diagonal of a calculation matrix, and I is an identity matrix;
the variables z and delta are fixed, iterated on s according to equation (7),
computing to determine a closed solution s of s t+1 Comprises the following steps:
where t is the number of iterations, t =0,1,2 0 、z 0 And delta 0 The initial vector is a zero vector;
the variables s and δ are fixed, and the iteration is performed on z according to equation (9):
computing to determine a closed solution for z as z t+1 :
Fixing variables s and z, updating lagrange multiplier delta:
δ t+1 =δ t +ρ(s t+1 -z t+1 ) (11)
s t+1 and the sparse representation vector is used as the characteristic vector to be classified.
Iterating the calculation steps of s, z and delta until meeting the convergence condition of the image classification model or the iteration times exceeds a preset threshold, wherein the convergence condition can be that | | s is met simultaneously t -z t || 2 ≤tol、||s t+1 -s t || 2 Less than or equal to tol and | z t+1 -z t || 2 Tol ≦ wherein tol > 0 is a small tolerance value, to find the optimal image representation vectorFor example, the feature vector y to be classified and the set X of all class training feature vectors are input into the image classification model, and s in the formula of the objective function of the image classification model is set 0 、z 0 And delta 0 The initial vector is a zero vector, and when t =0, s can be calculated according to formula (8) first 1 Then s is 1 And delta 0 By substituting the formula (10), z can be calculated 1 Finally, s is 1 And z 1 Substituting equation (11) can calculate delta 1 The first iteration is completed and s is obtained 1 、z 1 And delta 1 . Will z 1 And delta 1 Substituting equation (8) can calculate s 2 Then s is 2 And delta 1 By substituting the formula (10), z can be calculated 2 Finally, s is 2 And z 2 Substituting equation (11) can calculate delta 2 The second iteration process is completed and s is obtained 2 、z 2 And delta 2 . And (4) sequentially iterating and updating s, z and delta until the convergence condition of the image classification model is met or the iteration times exceed a preset threshold value, and stopping iteration, namely calculating the optimal sparse representation vector(s) based on the characteristic vector to be classified>
At this point, calculating the sparse representation vector s of the feature vector to be classified based on the objective function of the image classification model, and calculating the optimal solution by using the ADMM algorithm and representing the optimal solution asNamely, the image representation vector with the optimal training feature vector for the feature vector to be classified is obtained. Image segmentation using alternating direction multiplier methodThe solution of the objective function of the class model achieves the effects of high solving speed and good convergence. Next, the reconstruction errors of the feature vectors to be classified and each class of training feature vectors can be calculated respectively, and the formula is:
wherein, the values of i are 1,2, 3, \ 8230, C and C are the number of classes of training samples. Wherein,column-wise splicing matrix X of ith class training feature vector for representing feature vector to be classified i The optimal sparse representation vector is performed, and i represents the class number.
After the reconstruction errors of the feature vectors to be classified and each class of training feature vectors are calculated, the reconstruction errors of the feature vectors to be classified and each class of training feature vectors are compared, the class corresponding to the training feature vector with the minimum reconstruction error is the class of the feature vectors to be classified, and the formula is as follows:
according to the technical scheme, after the feature vectors to be classified are input into an image classification model, sparse representation vectors of the feature vectors to be classified are calculated based on an objective function of the image classification model by using an alternating direction multiplier algorithm, and the categories of the images to be classified are determined according to the sparse representation vectors, namely, the sparse representation vectors of the feature vectors to be classified are subjected to an alternating solving mode, so that problems are continuously decomposed and then are gradually solved, and the problems are solved. The problem that the objective function of the image classification model is difficult to solve is solved, and the effects of improving the classification speed and the classification accuracy of the image classification model are achieved.
EXAMPLE III
Fig. 3 is a schematic structural diagram of an implementation apparatus for image classification according to a third embodiment of the present invention, where the implementation apparatus for image classification according to the third embodiment of the present invention may be implemented by software and/or hardware, and may be configured in a server to implement an implementation method for image classification according to the third embodiment of the present invention. As shown in fig. 3, the apparatus may specifically include: an image feature vector acquisition module 310 and an image class determination module 320.
The image feature vector acquiring module 310 is configured to acquire a feature vector of an image to be classified as a feature vector to be classified;
an image category determining module 320, configured to input the feature vector to be classified into an image classification model, calculate a sparse representation vector of the feature vector to be classified based on an objective function of the image classification model, and determine a category of the image to be classified according to the sparse representation vector;
the objective function comprises a conventional sparse representation item and a setting class representation item, wherein the conventional sparse representation item is used for determining reconstruction errors between the feature vector to be classified and training feature vectors of all training samples of the image classification model, and the setting class representation item is used for determining the sum of the reconstruction errors between the feature vector to be classified and the training feature vectors of the training samples of each setting class.
According to the technical scheme, the feature vectors to be classified are input into an image classification model, sparse representation vectors of the feature vectors to be classified are calculated based on an objective function comprising a conventional sparse representation item and a setting class representation item in the image classification model, and the classes of the images to be classified are determined according to the sparse representation vectors. The problem of low image feature representation capability of the image classification model when the complex image is faced is solved, and the effect of high classification accuracy of the image classification model is achieved.
In the above apparatus, optionally, the setting-class representation item has a sparsity adjustment parameter, and the sparsity adjustment parameter is determined by a classification recognition rate of the image classification model.
In the above apparatus, optionally, the apparatus further includes a parameter adjusting module, configured to input the verification feature vectors of the multiple verification samples into the image classification model before inputting the feature vectors to be classified into the image classification model, so as to output a classification result; comparing the output classification result with the labeling classification result of the verification sample to determine the classification recognition rate of the image classification model; and adjusting the sparse adjustment parameters according to the classification recognition rate.
In the above apparatus, optionally, the image feature vector obtaining module 310 is specifically configured to obtain a feature vector of an image to be classified, and includes: for the image to be classified, converting a pixel matrix into a one-dimensional vector as the characteristic vector to be classified; or processing the image to be classified by adopting a convolutional neural network, and outputting the feature vector to be classified from a full connection layer.
In the above apparatus, optionally, the formula of the objective function is as follows:
wherein: y is a feature vector to be classified, y belongs to R D×1 R represents a matrix, and D represents the characteristic dimension of the characteristic vector to be classified; x is a set of training feature vectors of all categories, and X belongs to R D×N N denotes the total number of training samples, X = [) 1 ,X 2 ,...,X C ]Consists of class C training feature vectors, C representing the number of classes of the training samples, wherein,a column-wise mosaic matrix of training eigenvectors belonging to class i, i being the class number, n i Representing the number of training samples of the ith class; s = [ S ] 1 ,S 2 ,...,S C ] T A sparse representation vector which represents the feature vector to be classified by adopting each type of training feature vector; wherein it is present>A column-wise splicing matrix X of the ith class of training feature vectors for representing the features to be classified i The sparse representation vector of the run; />Is a conventional sparse representation item; />For each n in the feature vector to be classified and class C i The sum of the reconstruction errors of the training feature vectors of the training samples; alpha is a sparse adjustment parameter for adjusting the sparsity of the sparse representation vector, and beta is a participation parameter for adjusting the setting class representation; />Is the square of the 2-norm of the vector, | | |. The luminance 1 Is the vector 1-norm.
In the above apparatus, optionally, the image category determining module 320 is specifically configured to input the feature vector to be classified into an image classification model, calculate a sparse representation vector of the feature vector to be classified based on an objective function of the image classification model, and determining the category of the image to be classified according to the sparse representation vector includes: inputting the feature vector to be classified into an image classification model, calculating a sparse representation vector of the feature vector to be classified based on a target function of the image classification model by utilizing an alternating direction multiplier algorithm, and determining the category of the image to be classified according to the sparse representation vector.
The device for realizing image classification can execute the method for realizing image classification provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method.
Example four
Fig. 4 is a schematic structural diagram of an electronic device according to a fourth embodiment of the present invention, and as shown in fig. 4, the electronic device according to the fourth embodiment of the present invention includes: a processor 410, a memory 420, an input device 430, and an output device 440; the number of the processors 410 in the electronic device may be one or more, and one processor 410 is taken as an example in fig. 4; the processor 410, the memory 420, the input device 430 and the output device 440 in the electronic apparatus may be connected by a bus or other means, and the bus connection is exemplified in fig. 4.
The memory 420 in the electronic device is used as a computer-readable storage medium for storing software programs, computer-executable programs, and modules, such as program instructions/modules corresponding to an updating method of index data in a search engine according to an embodiment of the present invention. The processor 410 executes various functional applications of the device and data processing by executing software programs, instructions, and modules stored in the memory 420.
The memory 420 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required for at least one function; the storage data area may store data created according to the use of the terminal, and the like. Further, the memory 420 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device. In some examples, the memory 420 can further include memory located remotely from the processor 410, which can be connected to the devices over a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The input device 430 may be used to receive input numeric or character information and to generate signal inputs relating to user settings and function controls of the apparatus. The output device 440 may include a display device such as a display screen.
EXAMPLE five
The fifth embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the method for implementing image classification provided in all the embodiments of the present invention of the present application, where the method includes: acquiring a feature vector of an image to be classified as the feature vector to be classified; inputting the feature vector to be classified into an image classification model, calculating a sparse representation vector of the feature vector to be classified based on an objective function of the image classification model, and determining the category of the image to be classified according to the sparse representation vector; wherein the objective function comprises a regular sparse representation term and a setting class representation term, the regular sparse representation term is used for determining reconstruction errors between the feature vector to be classified and feature vectors of all training samples of the image classification model, and the setting class representation term is used for determining the sum of the reconstruction errors between the feature vector to be classified and the training feature vectors of the training samples of each setting class.
Computer storage media for embodiments of the invention may employ any combination of one or more computer-readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for embodiments of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims (9)
1. An implementation method for image classification is characterized by comprising the following steps:
acquiring a feature vector of an image to be classified as the feature vector to be classified;
inputting the feature vector to be classified into an image classification model, calculating a sparse representation vector of the feature vector to be classified based on an objective function of the image classification model, and determining the category of the image to be classified according to the sparse representation vector;
wherein the objective function comprises a conventional sparse representation term and a setting class representation term, the conventional sparse representation term is used for determining reconstruction errors between the feature vector to be classified and feature vectors of all training samples of the image classification model, and the setting class representation term is used for determining the sum of the reconstruction errors between the feature vector to be classified and the training feature vectors of the training samples of each setting class;
the formula of the objective function is as follows:
wherein:
y is a feature vector to be classified, y belongs to R D×1 R represents a matrix, and D represents the characteristic dimension of the characteristic vector to be classified;
x is a set of training feature vectors of all categories, and X belongs to R D×N N denotes the total number of training samples, X = [) 1 ,X 2 ,...,X C ]Consists of class C training feature vectors, C representing the number of classes of training feature vectors of the training samples, wherein,a column-wise mosaic matrix of training eigenvectors for training samples belonging to the ith class, i being the class number, n i Representing the number of training samples of the ith class;
s=[S 1 ,S 2 ,...,S C ] T sparse representation vectors which are represented by adopting each type of training feature vectors are adopted for the feature vectors to be classified; wherein,a column-wise splicing matrix X of the ith class of training feature vectors for representing the features to be classified i The sparse representation vector of the run;
for each n in the feature vector to be classified and class C i The sum of reconstruction errors of training feature vectors of the training samples;
alpha is a sparse adjustment parameter for adjusting the sparsity of the sparse representation vector, and beta is a participation parameter for adjusting the setting class representation;
the determining the category of the image to be classified according to the sparse representation vector comprises:
respectively calculating reconstruction errors of the feature vectors to be classified and each class of training feature vectors based on the sparse representation vectors to obtain a plurality of corresponding reconstruction error values;
and determining the class corresponding to the training feature vector corresponding to the minimum reconstruction error value in the reconstruction error values as the class of the image to be classified.
2. The method of claim 1, wherein the profile representation has a sparsity adjustment parameter determined by a classification recognition rate of the image classification model.
3. The method according to claim 2, wherein before inputting the feature vector to be classified into an image classification model, further comprising:
inputting the verification feature vectors of a plurality of verification samples into an image classification model to output a classification result;
comparing the output classification result with the labeling classification result of the verification sample to determine the classification recognition rate of the image classification model;
and adjusting the sparse adjustment parameters according to the classification recognition rate.
4. The method of claim 1, wherein obtaining the feature vector of the image to be classified comprises:
for the image to be classified, converting a pixel matrix into a one-dimensional vector as the characteristic vector to be classified; or
And processing the image to be classified by adopting a convolutional neural network, and outputting the feature vector to be classified from a full connection layer.
5. The method of claim 1, wherein the feature vector to be classified is input into an image classification model, a sparse representation vector of the feature vector to be classified is calculated based on an objective function of the image classification model, and determining the class of the image to be classified according to the sparse representation vector comprises:
inputting the feature vector to be classified into an image classification model, calculating a sparse representation vector of the feature vector to be classified based on a target function of the image classification model by utilizing an alternating direction multiplier algorithm, and determining the category of the image to be classified according to the sparse representation vector.
6. The method of claim 5, wherein computing the sparse representation vector of the feature vector to be classified based on the objective function of the image classification model comprises:
the objective function of the image classification model is expressed as formula (1):
convert equation (1) to:
for the formula (3), the method is optimized by adopting an alternating direction multiplier method, and 2 alpha s survival is performed 1 Let s be z, the optimization problem of equation (3) above is converted into:
converting the formula (4) into an augmented Lagrangian function, and marking the function as a formula (5):
wherein δ is an augmented lagrange multiplier, ρ is a penalty parameter, and equation (5) is simplified and irrelevant terms are ignored to obtain equation (6):
wherein trace { } represents the sum of elements on a diagonal of a calculation matrix, and I is an identity matrix;
the variables z and delta are fixed, iterated on s according to equation (7),
computing to determine a closed solution s of s t+1 Comprises the following steps:
where t is the number of iterations, t =0,1,2 0 、z 0 And delta 0 The initial vector is a zero vector;
fixing the variables s and δ, iterating z according to equation (9):
computing to determine a closed solution for z as z t+1 :
Fixing variables s and z, updating lagrange multiplier delta:
δ t+1 =δ t +ρ(s t+1 -z t+1 ) (11)
s t+1 and the sparse representation vector is used as the characteristic vector to be classified.
7. An apparatus for implementing image classification, comprising:
the image feature vector acquisition module is used for acquiring feature vectors of the images to be classified as the feature vectors to be classified;
the image category determination module is used for inputting the feature vector to be classified into an image classification model, calculating a sparse representation vector of the feature vector to be classified based on an objective function of the image classification model, and determining the category of the image to be classified according to the sparse representation vector;
the target function comprises a conventional sparse representation item and a setting class representation item, wherein the conventional sparse representation item is used for determining reconstruction errors between the feature vector to be classified and training feature vectors of all training samples of the image classification model, and the setting class representation item is used for determining the sum of the reconstruction errors between the feature vector to be classified and the training feature vectors of the training samples of each setting class;
the formula of the objective function is as follows:
wherein: y is a feature vector to be classified, y belongs to R D×1 R represents a matrix, and D represents the characteristic dimension of the characteristic vector to be classified; x is a set of training feature vectors of all categories, and X belongs to R D×N N denotes the total number of training samples, X = [) 1 ,X 2 ,...,X C ]Consists of class C training feature vectors, C representing the number of classes of the training samples, wherein,a column-wise mosaic matrix of training eigenvectors belonging to class i, i being the class number, n i Representing the number of training samples of the ith class; s = [ S ] 1 ,S 2 ,...,S C ] T A sparse representation vector which represents the feature vector to be classified by adopting each type of training feature vector; wherein,a column-wise splicing matrix X of ith training feature vectors for representing the features to be classified i The sparse representation vector of the run;is a conventional sparse representation item;for each n in the feature vector to be classified and class C i The sum of the reconstruction errors of the training feature vectors of the training samples; alpha is a sparse adjustment parameter for adjusting the sparsity of the sparse representation vector, and beta is a participation parameter for adjusting the setting class representation;is the square of the 2-norm of the vector, | | |. The luminance 1 Vector 1-norm;
the image category determination module is further used for respectively calculating reconstruction errors of the feature vectors to be classified and each training feature vector based on the sparse representation vector to obtain a plurality of corresponding reconstruction error values;
and determining the class corresponding to the training feature vector corresponding to the minimum reconstruction error value in the plurality of reconstruction error values as the class of the image to be classified.
8. An electronic device, characterized in that the electronic device comprises:
one or more processors;
a memory for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement an implementation method for image classification as claimed in any one of claims 1-6.
9. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out a method of carrying out image classification according to any one of claims 1 to 6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110950080.7A CN113627556B (en) | 2021-08-18 | 2021-08-18 | Method and device for realizing image classification, electronic equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110950080.7A CN113627556B (en) | 2021-08-18 | 2021-08-18 | Method and device for realizing image classification, electronic equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113627556A CN113627556A (en) | 2021-11-09 |
CN113627556B true CN113627556B (en) | 2023-03-24 |
Family
ID=78386422
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110950080.7A Active CN113627556B (en) | 2021-08-18 | 2021-08-18 | Method and device for realizing image classification, electronic equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113627556B (en) |
Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112085112A (en) * | 2020-09-14 | 2020-12-15 | 苏州大学 | Image category detection method, system, electronic equipment and storage medium |
Family Cites Families (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106778863A (en) * | 2016-12-12 | 2017-05-31 | 武汉科技大学 | The warehouse kinds of goods recognition methods of dictionary learning is differentiated based on Fisher |
CN106845551B (en) * | 2017-01-24 | 2020-08-11 | 湘潭大学 | Tissue pathology image identification method |
CN106960225B (en) * | 2017-03-31 | 2020-01-31 | 哈尔滨理工大学 | sparse image classification method based on low-rank supervision |
CN108564107A (en) * | 2018-03-21 | 2018-09-21 | 温州大学苍南研究院 | The sample class classifying method of semi-supervised dictionary learning based on atom Laplce's figure regularization |
-
2021
- 2021-08-18 CN CN202110950080.7A patent/CN113627556B/en active Active
Patent Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112085112A (en) * | 2020-09-14 | 2020-12-15 | 苏州大学 | Image category detection method, system, electronic equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN113627556A (en) | 2021-11-09 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
KR102478000B1 (en) | Image processing methods, training methods, devices, devices, media and programs | |
EP3940591A1 (en) | Image generating method, neural network compression method, and related apparatus and device | |
CN106570464B (en) | Face recognition method and device for rapidly processing face shielding | |
CN111340738B (en) | Image rain removing method based on multi-scale progressive fusion | |
CN111428557A (en) | Method and device for automatically checking handwritten signature based on neural network model | |
CN111476138B (en) | Construction method, identification method and related equipment for building drawing component identification model | |
CN108460749B (en) | Rapid fusion method of hyperspectral and multispectral images | |
CN110781970B (en) | Classifier generation method, device, equipment and storage medium | |
WO2023179099A1 (en) | Image detection method and apparatus, and device and readable storage medium | |
CN108171261A (en) | Adaptive semi-supervision image classification method, device, equipment and the medium of robust | |
CN112883231B (en) | Short video popularity prediction method, system, electronic equipment and storage medium | |
CN111008726A (en) | Class image conversion method in power load prediction | |
Lyu et al. | A GPU‐free real‐time object detection method for apron surveillance video based on quantized MobileNet‐SSD | |
Xia et al. | Combination of multi‐scale and residual learning in deep CNN for image denoising | |
US20210286544A1 (en) | Economic long short-term memory for recurrent neural networks | |
CN113409307A (en) | Image denoising method, device and medium based on heterogeneous noise characteristics | |
CN117060401A (en) | New energy power prediction method, device, equipment and computer readable storage medium | |
CN117407875A (en) | Malicious code classification method and system and electronic equipment | |
CN110288002B (en) | Image classification method based on sparse orthogonal neural network | |
CN113627556B (en) | Method and device for realizing image classification, electronic equipment and storage medium | |
CN116503314A (en) | Quality inspection system and method for door manufacturing | |
CN115331081A (en) | Image target detection method and device | |
CN114065913A (en) | Model quantization method and device and terminal equipment | |
CN114463646A (en) | Remote sensing scene classification method based on multi-head self-attention convolution neural network | |
CN111967580B (en) | Low-bit neural network training method and system based on feature migration |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |