CN113627556A - 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 PDF

Info

Publication number
CN113627556A
CN113627556A CN202110950080.7A CN202110950080A CN113627556A CN 113627556 A CN113627556 A CN 113627556A CN 202110950080 A CN202110950080 A CN 202110950080A CN 113627556 A CN113627556 A CN 113627556A
Authority
CN
China
Prior art keywords
classified
vector
image
feature vector
image classification
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.)
Granted
Application number
CN202110950080.7A
Other languages
Chinese (zh)
Other versions
CN113627556B (en
Inventor
罗步升
林志超
黄笑辉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangdong Power Grid Co Ltd
Huizhou Power Supply Bureau of Guangdong Power Grid Co Ltd
Original Assignee
Guangdong Power Grid Co Ltd
Huizhou Power Supply Bureau of Guangdong Power Grid Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Guangdong Power Grid Co Ltd, Huizhou Power Supply Bureau of Guangdong Power Grid Co Ltd filed Critical Guangdong Power Grid Co Ltd
Priority to CN202110950080.7A priority Critical patent/CN113627556B/en
Publication of CN113627556A publication Critical patent/CN113627556A/en
Application granted granted Critical
Publication of CN113627556B publication Critical patent/CN113627556B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/24Classification techniques
    • G06F18/241Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/214Generating 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

Method and device for realizing image classification, electronic equipment and storage medium
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, cause the one or more processors to implement an implementation method of image classification as described in 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.
According to the method for realizing image classification provided by the embodiment of the invention, the feature vector to be classified is input into an image classification model, the sparse representation vector of the feature vector to be classified is calculated based on the target function comprising the conventional sparse representation item and the 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.
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 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 x 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 respectively using the training feature vectors in all the classes, 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:
Figure BDA0003218337780000051
wherein y is a feature vector to be classified, and y belongs to RD×1R 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 RD×NN denotes the total number of training samples, X ═ X1,X2,...,XC]Consists of class C training feature vectors, C representing the number of classes of the training samples, wherein,
Figure BDA0003218337780000052
a column-wise mosaic matrix of training eigenvectors belonging to class i, i being the class number, niRepresenting the number of training samples of the ith class; s ═ S1,S2,...,SC]TA sparse representation vector which represents the feature vector to be classified by adopting each type of training feature vector; wherein the content of the first and second substances,
Figure BDA0003218337780000053
column-wise splicing matrix X of ith class training feature vector for representing feature vector to be classifiediThe sparse representation vector of the run;
Figure BDA0003218337780000054
is a conventional sparse representation item;
Figure BDA0003218337780000055
for each n in the feature vector to be classified and class CiThe sum of the reconstruction errors of the training feature vectors; α is a sparsity adjustment parameter for adjusting sparsity of the sparse representation vector, β isAdjusting the participation parameter represented by the setting class;
Figure BDA0003218337780000056
is the square of the 2-norm of the vector, | | |. the luminance1Is 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 images may also be experimental databases commonly used by those skilled in the art, such as a face recognition database, which may be an Extended YaleB database and a CMU PIE database, and a handwritten digit recognition database, which may be an MNIST database and a USPS database. The size of the training sample image is not limited and may be 224 x 224. X is the training feature vector of the training sample, N is a total of N training samples, N can be 25 and 100, N is not limited, C is a total of C training feature vectors, C can be 5 and 10, the number of classes C is not limited, and each class contains NiThe number of training samples contained in each category can be the same or different, niMay be 5 and 10, for niAnd 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 of C classes are contained in total, and the sparse representation vector of the ith class is a column-wise splicing matrix X of the training feature vector of the ith class for the feature vector to be classifiediThe sparse representation of the vector is performed such that,
Figure BDA0003218337780000061
for the reconstruction errors of the feature vector to be classified and N training feature vectors of C classes,
Figure BDA0003218337780000062
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.
Figure BDA0003218337780000063
Each is represented by n in class CiThe 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 classesiThe sum of reconstruction errors of the training samples, namely the target function comprehensively considers the global features and the setting features of the images, realizes accurate representation of the images, and simultaneously ensures the robustness and the discriminability of the target function.
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 in real time by the electronic device, or an experimental database commonly used by persons 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, α and β are both values 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, β may be fixed to 0.1 for the first round, α may be set to 0.1 for the first round, then the verification sample is input into the image classification model, and 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, α may be adjusted to 0.2 for the first round, the verification sample is still input into the image classification model, and the classification result is output, the output classification result is compared with the labeled classification result of the verification sample, and determining the classification recognition rate of the image classification model, comparing the classification recognition rate with the first classification recognition rate of the first round, using the value with the maximum classification recognition rate for the next comparison, and repeating the steps until alpha is adjusted to 1, and obtaining the alpha value which enables the maximum classification recognition rate of the image classification model in the first round. Then the second round can fix beta to 0.2 for the first time, alpha can be set to 0.1, still input the verification sample into the image classification model and output the classification result, compare the output classification result with the labeled classification result of the verification sample to determine the classification recognition rate of the image classification model and compare the maximum classification recognition rate with the first round image classification model and use the maximum classification recognition rate of the image classification model for the next comparison, the second round can adjust alpha to 0.2, still input the verification sample into the image classification model and output the classification result, compare the output classification result with the labeled classification result of the verification sample to determine the classification recognition rate of the image classification model and compare the maximum classification recognition rate with the image classification model obtained in the last time and use the maximum classification recognition rate of the image classification model for the next comparison, and the analogy is carried out until alpha is adjusted to 1, and the alpha value which enables the classification recognition 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 an objective 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):
Figure BDA0003218337780000101
convert equation (1) to:
Figure BDA0003218337780000102
mixing [ 0... multidot.X ]i,...,0]By using
Figure BDA0003218337780000103
To express, equation (2) is converted into:
Figure BDA0003218337780000104
for the formula (3), the method is optimized by adopting an alternating direction multiplier method, and 2 alpha s survival is performed1Let s be z, convert the optimization problem of equation (3) above to:
Figure BDA0003218337780000105
s.t.s=z
converting the formula (4) into an augmented Lagrangian function, and marking the function as a formula (5):
Figure BDA0003218337780000106
wherein δ is an augmented lagrange multiplier, ρ is a penalty parameter, and equation (5) is simplified and an irrelevant term is ignored to obtain equation (6):
Figure BDA0003218337780000107
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),
Figure BDA0003218337780000111
computing to determine a closed solution s of st+1Comprises the following steps:
Figure BDA0003218337780000112
where t is the number of iterations, t is 0,1,20、z0And delta0The initial vector is a zero vector;
the variables s and δ are fixed, and the iteration is performed on z according to equation (9):
Figure BDA0003218337780000113
computing to determine a closed solution for z as zt+1
Figure BDA0003218337780000114
Fixing variables s and z, updating lagrange multiplier delta:
δt+1=δt+ρ(st+1-zt+1) (11)
st+1and 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 simultaneouslyt-zt||2≤tol、||st+1-st||2Less than or equal to tol and | zt+1-zt||2Tol ≦ wherein tol > 0 is a small tolerance value, to find the optimal image representation vector
Figure BDA0003218337780000115
For 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 set0、z0And delta0The initial vector is zero vector, and when t is 0, s can be calculated according to formula (8) first1Then s is1And delta0By substituting the formula (10), z can be calculated1Finally, s is1And z1Substituting equation (11) can calculate delta1The first iteration is completed and s is obtained1、z1And delta1. Will z1And delta1Substituting equation (8) can calculate s2Then s is2And delta1By substituting the formula (10), z can be calculated2Finally, s is2And z2Substituting equation (11) can calculate delta2The second iteration process is completed and s is obtained2、z2And delta2. And sequentially iteratively updating s, z and delta until the convergence condition of the image classification model is met or the iteration frequency exceeds a preset threshold value, and stopping iteration, namely calculating the optimal sparse representation vector of the feature vector to be classified
Figure BDA0003218337780000124
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 as
Figure BDA0003218337780000125
Namely, the image representation vector with the optimal training feature vector for the feature vector to be classified is obtained. The solution of the objective function of the image classification model is solved by using the alternative direction multiplier method, so that the effects of high solving speed and good convergence are achieved. Next, the reconstruction error of the feature vector to be classified and each class of training feature vector can be calculated respectively, and the formula is:
Figure BDA0003218337780000121
wherein, the values of i are respectively 1,2, 3 and …, and C is the number of the classes of the training samples. Wherein the content of the first and second substances,
Figure BDA0003218337780000122
column-wise splicing matrix X of ith class training feature vector for representing feature vector to be classifiediThe optimal sparse representation vector is performed, and i represents the class number.
After the reconstruction error of the feature vector to be classified and each class of training feature vector is calculated, the reconstruction error value of the feature vector to be classified and each class of training feature vector are compared, the class corresponding to the training feature vector with the minimum reconstruction error is the class of the feature vector to be classified, and the formula is as follows:
Figure BDA0003218337780000123
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 obtaining module 310 is configured to obtain 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:
Figure BDA0003218337780000141
wherein: y is a feature vector to be classified, y belongs to RD×1R 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 RD×NN denotes the total number of training samples, X ═ X1,X2,...,XC]Consists of class C training feature vectors, C representing the number of classes of the training samples, wherein,
Figure BDA0003218337780000142
a column-wise mosaic matrix of training eigenvectors belonging to class i, i being the class number, niRepresenting the number of training samples of the ith class; s ═ S1,S2,...,SC]TA sparse representation vector which represents the feature vector to be classified by adopting each type of training feature vector; wherein the content of the first and second substances,
Figure BDA0003218337780000143
a column-wise splicing matrix X of the ith class of training feature vectors for representing the features to be classifiediThe sparse representation vector of the run;
Figure BDA0003218337780000144
is a conventional sparse representation item;
Figure BDA0003218337780000145
for each n in the feature vector to be classified and class CiThe 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;
Figure BDA0003218337780000151
is the square of the 2-norm of the vector, | | |. the luminance1Is 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 image classification implementation device can execute the image classification implementation method 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, memory 420 may further include memory located remotely from processor 410, which may be connected to devices through 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 entered numeric or character information and to generate signal inputs relating to user settings and function control 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; 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 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.
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 many 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 (10)

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;
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 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.
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 according to any of claims 1-4, wherein the objective function is formulated as follows:
Figure FDA0003218337770000021
wherein:
y is a feature vector to be classified, y belongs to RD×1R 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 RD×NN denotes the total number of training samples, X ═ X1,X2,...,XC]Consists of class C training feature vectors, C representing the number of classes of training feature vectors of the training samples, wherein,
Figure FDA0003218337770000022
a column-wise mosaic matrix of training eigenvectors for training samples belonging to the ith class, i being the class number, niNumber of training samples representing the ith class;
s=[S1,S2,...,SC]TA sparse representation vector which represents the feature vector to be classified by adopting each type of training feature vector; wherein the content of the first and second substances,
Figure FDA0003218337770000023
a column-wise splicing matrix X of the ith class of training feature vectors for representing the features to be classifiediThe sparse representation vector of the run;
Figure FDA0003218337770000024
is a conventional sparse representation item;
Figure FDA0003218337770000025
for each n in the feature vector to be classified and class CiThe 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;
Figure FDA0003218337770000026
is the square of the 2-norm of the vector, | | |. the luminance1Is the vector 1-norm.
6. The method of claim 5, 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.
7. The method of claim 6, 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):
Figure FDA0003218337770000031
convert equation (1) to:
Figure FDA0003218337770000032
mixing [ 0... multidot.X ]i,...,0]By using
Figure FDA0003218337770000033
To express, equation (2) is converted into:
Figure FDA0003218337770000034
for the formula (3), the method is optimized by adopting an alternating direction multiplier method, and 2 alpha s survival is performed1Let s be z, convert the optimization problem of equation (3) above to:
Figure FDA0003218337770000035
converting the formula (4) into an augmented Lagrangian function, and marking the function as a formula (5):
Figure FDA0003218337770000036
wherein δ is an augmented lagrange multiplier, ρ is a penalty parameter, and equation (5) is simplified and an irrelevant term is ignored to obtain equation (6):
Figure FDA0003218337770000041
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),
Figure FDA0003218337770000042
computing to determine a closed solution s of st+1Comprises the following steps:
Figure FDA0003218337770000043
where t is the number of iterations, t is 0,1,20、z0And delta0The initial vector is a zero vector;
the variables s and δ are fixed, and the iteration is performed on z according to equation (9):
Figure FDA0003218337770000044
computing to determine a closed solution for z as zt+1
Figure FDA0003218337770000045
Fixing variables s and z, updating lagrange multiplier delta:
δt+1=δt+ρ(st+1-zt+1) (11)
st+1as a sparse representation of the feature vector to be classifiedAnd (5) vector quantity.
8. 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 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.
9. An electronic device, characterized in that the electronic device comprises:
one or more processors;
a storage device 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-7.
10. 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 7.
CN202110950080.7A 2021-08-18 2021-08-18 Method and device for realizing image classification, electronic equipment and storage medium Active CN113627556B (en)

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 true CN113627556A (en) 2021-11-09
CN113627556B 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 (5)

* Cited by examiner, † Cited by third party
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
CN106845551A (en) * 2017-01-24 2017-06-13 湘潭大学 A kind of histopathology image-recognizing method
CN106960225A (en) * 2017-03-31 2017-07-18 哈尔滨理工大学 A kind of sparse image classification method supervised based on low-rank
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
CN112085112A (en) * 2020-09-14 2020-12-15 苏州大学 Image category detection method, system, electronic equipment and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
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
CN106845551A (en) * 2017-01-24 2017-06-13 湘潭大学 A kind of histopathology image-recognizing method
CN106960225A (en) * 2017-03-31 2017-07-18 哈尔滨理工大学 A kind of sparse image classification method supervised based on low-rank
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
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
CN113627556B (en) 2023-03-24

Similar Documents

Publication Publication Date Title
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
CN110866471A (en) Face image quality evaluation method and device, computer readable medium and communication terminal
Chen et al. Image‐denoising algorithm based on improved K‐singular value decomposition and atom optimization
CN108460749B (en) Rapid fusion method of hyperspectral and multispectral images
CN111476138B (en) Construction method, identification method and related equipment for building drawing component identification model
CN111428557A (en) Method and device for automatically checking handwritten signature based on neural network model
WO2022105117A1 (en) Method and device for image quality assessment, computer device, and storage medium
CN112883231B (en) Short video popularity prediction method, system, electronic equipment and storage medium
CN113128478A (en) Model training method, pedestrian analysis method, device, equipment and storage medium
CN110781970A (en) Method, device and equipment for generating classifier and storage medium
CN111598460A (en) Method, device and equipment for monitoring heavy metal content in soil and storage medium
EP4343616A1 (en) Image classification method, model training method, device, storage medium, and computer program
CN115994317A (en) Incomplete multi-view multi-label classification method and system based on depth contrast learning
Yan et al. A hybrid evolutionary algorithm for multiobjective sparse reconstruction
Zhu et al. Semantic image segmentation with shared decomposition convolution and boundary reinforcement structure
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
CN112348001B (en) Training method, recognition method, device, equipment and medium for expression recognition model
US20210286544A1 (en) Economic long short-term memory for recurrent neural networks
CN113409307A (en) Image denoising method, device and medium based on heterogeneous noise characteristics
CN113850298A (en) Image identification method and device and related equipment
CN113627556B (en) Method and device for realizing image classification, electronic equipment and storage medium
CN115376195B (en) Method for training multi-scale network model and face key point detection method

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