CN113591983A - Image recognition method and device - Google Patents

Image recognition method and device Download PDF

Info

Publication number
CN113591983A
CN113591983A CN202110871626.XA CN202110871626A CN113591983A CN 113591983 A CN113591983 A CN 113591983A CN 202110871626 A CN202110871626 A CN 202110871626A CN 113591983 A CN113591983 A CN 113591983A
Authority
CN
China
Prior art keywords
characteristic value
target
characteristic
eigenvalue
matrix
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
CN202110871626.XA
Other languages
Chinese (zh)
Other versions
CN113591983B (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.)
Gemdale Corp
Original Assignee
Gemdale Corp
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 Gemdale Corp filed Critical Gemdale Corp
Priority to CN202110871626.XA priority Critical patent/CN113591983B/en
Publication of CN113591983A publication Critical patent/CN113591983A/en
Application granted granted Critical
Publication of CN113591983B publication Critical patent/CN113591983B/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/22Matching criteria, e.g. proximity measures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/23Clustering techniques
    • G06F18/232Non-hierarchical techniques
    • G06F18/2321Non-hierarchical techniques using statistics or function optimisation, e.g. modelling of probability density functions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology

Landscapes

  • Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Artificial Intelligence (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Evolutionary Computation (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Evolutionary Biology (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Computational Linguistics (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Health & Medical Sciences (AREA)
  • General Health & Medical Sciences (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Probability & Statistics with Applications (AREA)
  • Image Analysis (AREA)

Abstract

The application provides an image recognition method and device. The method comprises the following steps: acquiring a characteristic matrix of an image to be identified; selecting a characteristic value from the characteristic matrix as a target characteristic value, selecting a column characteristic value and a row characteristic value corresponding to the target characteristic value, and encoding the target characteristic value based on the target characteristic value, the column characteristic value and the row characteristic value; reselecting an eigenvalue from the eigenvalues of the characteristic matrix which are not selected as target eigenvalues, reselecting column eigenvalues and row eigenvalues corresponding to the target eigenvalues, and encoding the reselected target eigenvalues based on the reselected target eigenvalues and the reselected column eigenvalues and row eigenvalues corresponding to the target eigenvalues until the eigenvalues in the characteristic matrix are all used as target eigenvalues to encode, thereby obtaining an encoded characteristic matrix; and inputting the coded feature matrix into an image recognition model to recognize the image to be recognized.

Description

Image recognition method and device
Technical Field
The present disclosure relates to the field of image recognition, and in particular, to an image recognition method and apparatus.
Background
In the prior art, when an image is identified, the image to be identified is usually compared with a plurality of pre-stored images, the pre-stored image most similar to the image to be identified is determined, and the image to be identified is identified through pre-stored information corresponding to the pre-stored image.
However, since the pre-stored image is limited, the difference between the pre-stored image most similar to the image to be recognized and the image to be recognized may be large, resulting in inaccurate recognition.
Disclosure of Invention
The application aims to provide an image identification method and device, which can solve the problem of inaccurate image identification.
According to an aspect of an embodiment of the present application, there is provided an image recognition method including: acquiring a characteristic matrix of an image to be identified; selecting a characteristic value from the characteristic matrix as a target characteristic value a, selecting a characteristic value which is positioned in the same column with the target characteristic value and has a first set distance from the target characteristic value as a column characteristic value b, selecting a characteristic value which is positioned in the same row with the target characteristic value and has a second set distance from the target characteristic value as a row characteristic value c, and substituting the target characteristic value a, the column characteristic value b and the row characteristic value c into a formula
Figure BDA0003189034110000011
Encoding the target characteristic value to obtain an encoded target characteristic value a 1; reselecting an eigenvalue from the eigenvalues of the characteristic matrix which are not selected as the target eigenvalue, reselecting a column eigenvalue and a row eigenvalue corresponding to the target eigenvalue, substituting the reselected target eigenvalue, the reselected column eigenvalue and the reselected row eigenvalue corresponding to the target eigenvalue into a formula to encode the reselected target eigenvalue until the eigenvalues in the characteristic matrix are all used as the target eigenvalue to encode, and obtaining an encoded characteristic matrix; inputting the coded feature matrixAnd entering the image recognition model to recognize the image to be recognized.
According to an aspect of an embodiment of the present application, there is provided an image recognition apparatus including: the acquisition module is configured to acquire a feature matrix of the image to be identified; the selecting module is configured to select a characteristic value from the characteristic matrix as a target characteristic value a, select a characteristic value which is positioned in the same column with the target characteristic value and has a first set distance from the target characteristic value as a column characteristic value b, and select a characteristic value which is positioned in the same row with the target characteristic value and has a second set distance from the target characteristic value as a row characteristic value c; an encoding module configured to bring the target feature values a, the column feature values b, and the row feature values c into a formula
Figure BDA0003189034110000021
Encoding the target characteristic value to obtain an encoded target characteristic value a1, reselecting a characteristic value from the characteristic values of the characteristic matrix which are not selected as the target characteristic value, reselecting a column characteristic value and a row characteristic value corresponding to the target characteristic value, substituting the reselected target characteristic value, the reselected column characteristic value and the reselected row characteristic value corresponding to the target characteristic value into a formula, and encoding the reselected target characteristic value until the characteristic values in the characteristic matrix are all used as the target characteristic value to be encoded to obtain an encoded characteristic matrix; and the identification module is configured to input the coded feature matrix into an image identification model so as to identify the image to be identified.
In an embodiment of the present application, based on the foregoing solution, the column eigenvalue is an eigenvalue of the eigenvalue matrix that is located in the same column as the target eigenvalue, is located on the right side of the target eigenvalue, and is adjacent to the target eigenvalue; the row eigenvalue is an eigenvalue of the same row in the eigenvalue matrix as the target eigenvalue, below the target eigenvalue, and adjacent to the target eigenvalue.
In an embodiment of the application, based on the foregoing solution, before the target feature value a, the column feature value b, and the row feature value c are substituted into a formula, the selecting module is configured to: if the column characteristic value is null, determining the column characteristic value as 1; and if the line characteristic value is null, determining the line characteristic value as 1.
In an embodiment of the application, based on the foregoing scheme, before inputting the encoded feature matrix into an image recognition model, the recognition module is configured to: acquiring weights of hidden layers in a pre-trained neural network model; and if the weight of the hidden layer is smaller than the weight threshold, removing the hidden layer to obtain the image recognition model.
In an embodiment of the application, based on the foregoing solution, after removing the hidden layer, the identification module is configured to: acquiring a weight index of the neural network model, wherein the weight index is formed by combining the hidden layer weights according to the sequence of the hidden layers in the neural network model; and deleting the hidden layer weight corresponding to the removed hidden layer from the weight index to obtain the weight index after the hidden layer is removed.
In an embodiment of the application, based on the foregoing scheme, before inputting the encoded feature matrix into an image recognition model, the recognition module is configured to: acquiring a weight matrix corresponding to the weight of each hidden layer in a pre-trained neural network model; clustering the weight matrix corresponding to each hidden layer weight to obtain a clustered weight matrix corresponding to each hidden layer weight; and updating each hidden layer based on the clustered weight matrix corresponding to the weight of each hidden layer to obtain the image recognition model.
In an embodiment of the present application, based on the foregoing solution, the identification module is configured to: acquiring the number of input neurons/the number of output neurons of the hidden layer; clustering the characteristic values in the weight matrix corresponding to the hidden layer to obtain a plurality of characteristic clusters; selecting the same number of feature clusters as the number of input neurons/the number of output neurons in the plurality of feature clusters; averaging the characteristic values in the same characteristic cluster, and taking the average value as a clustering characteristic value; and determining a clustered weight matrix corresponding to the hidden layer weight based on the clustering characteristic value.
In an embodiment of the present application, based on the foregoing solution, the identification module is configured to: acquiring a gradient matrix of the hidden layer corresponding to the weight matrix; summing gradients corresponding to characteristic values in the same characteristic cluster to obtain a clustering gradient; summing the clustering characteristic values and the clustering gradients corresponding to the clustering characteristic values to obtain a summation result; and combining the summation results to obtain a clustered weight matrix corresponding to the hidden layer weight.
In an embodiment of the present application, based on the foregoing solution, the identification module is configured to: randomly selecting a plurality of preparation central points in the characteristic values; re-determining a plurality of actual center points among the feature values based on distances between the feature values other than the feature values as the preliminary center points and the preliminary center points; calculating the distance between the characteristic value except the actual central point and the actual central point to obtain a calculation result; and determining the characteristic value which belongs to the same cluster with the actual central point based on the calculation result to obtain the characteristic cluster corresponding to the actual central point.
According to an aspect of embodiments of the present application, there is provided a computer-readable program medium storing computer program instructions which, when executed by a computer, cause the computer to perform the method of any one of the above.
According to an aspect of an embodiment of the present application, there is provided an electronic device including: a processor; a memory having computer readable instructions stored thereon which, when executed by the processor, implement the method of any of the above.
According to an aspect of embodiments herein, there is provided a computer program product or computer program comprising computer instructions stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions to cause the computer device to perform the methods provided in the various alternative embodiments described above.
The technical scheme provided by the embodiment of the application can have the following beneficial effects:
in the technical scheme provided by some embodiments of the application, a feature matrix of an image to be identified is obtained; selecting a characteristic value from the characteristic matrix as a target characteristic value a, selecting a characteristic value which is positioned in the same row with the target characteristic value and has a first set distance from the target characteristic value as a row characteristic value b, and selecting a characteristic value which is positioned in the same row with the target characteristic value and has a second set distance from the target characteristic value as a row characteristic value c; substituting the target eigenvalue a, the column eigenvalue b and the row eigenvalue c into a formula
Figure BDA0003189034110000041
The target characteristic value is encoded to obtain an encoded target characteristic value a1, the formula characteristic values are required to be not 0, a1 approaches to 0 when abc is less than 1 after formula derivation, and a1 approaches to infinity when abc is greater than 1 after formula derivation, so that a larger characteristic value can be amplified through encoding to weaken a smaller characteristic value, and the encoded target characteristic value a1 can better embody the main characteristics of the image to be recognized; reselecting a characteristic value from the characteristic values of the characteristic matrix which are not selected as target characteristic values, reselecting column characteristic values and row characteristic values corresponding to the target characteristic values, substituting the reselected target characteristic values, the reselected column characteristic values and the reselected row characteristic values corresponding to the target characteristic values into a formula to encode the reselected target characteristic values until the characteristic values in the characteristic matrix are all used as the target characteristic values to encode, so as to obtain an encoded characteristic matrix, wherein the encoded characteristic matrix is composed of characteristic values capable of embodying the main characteristics of the image to be recognized, and the encoded characteristic matrix can embody the main characteristics of the image to be recognized; inputting the coded feature matrix into an image recognition model,the image to be recognized is recognized based on the main characteristics of the image to be recognized, and the image can be recognized more accurately.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the application.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and together with the description, serve to explain the principles of the application.
FIG. 1 shows a schematic diagram of an exemplary system architecture to which aspects of embodiments of the present application may be applied;
FIG. 2 schematically shows a flow diagram of an image recognition method according to an embodiment of the present application;
FIG. 3 schematically shows a block diagram of an image recognition apparatus according to an embodiment of the present application;
FIG. 4 is a hardware diagram illustrating an electronic device according to an example embodiment.
Detailed Description
Example embodiments will now be described more fully with reference to the accompanying drawings. Example embodiments may, however, be embodied in many different forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the concept of example embodiments to those skilled in the art.
Furthermore, the described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of embodiments of the application. One skilled in the relevant art will recognize, however, that the subject matter of the present application can be practiced without one or more of the specific details, or with other methods, components, devices, steps, and so forth. In other instances, well-known methods, devices, implementations, or operations have not been shown or described in detail to avoid obscuring aspects of the application.
The block diagrams shown in the figures are functional entities only and do not necessarily correspond to physically separate entities. I.e. these functional entities may be implemented in the form of software, or in one or more hardware modules or integrated circuits, or in different networks and/or processor means and/or microcontroller means.
The flow charts shown in the drawings are merely illustrative and do not necessarily include all of the contents and operations/steps, nor do they necessarily have to be performed in the order described. For example, some operations/steps may be decomposed, and some operations/steps may be combined or partially combined, so that the actual execution sequence may be changed according to the actual situation.
Fig. 1 shows a schematic diagram of an exemplary system architecture 100 to which the technical solutions of the embodiments of the present application can be applied.
As shown in fig. 1, system architecture 100 may include clients 101, network 102, and server 103. Network 102 serves as a medium for providing communication links between clients 101 and servers 103. Network 102 may include various types of connections, such as wired communication links, wireless communication links, and so forth, which are not limiting in this application.
It should be understood that the number of clients 101, networks 102, and servers 103 in fig. 1 is merely illustrative. There may be any number of clients 101, networks 102, and servers 103, as desired for implementation. For example, the server 103 may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server providing basic cloud computing services such as a cloud service, a cloud database, cloud computing, a cloud function, cloud storage, a Network service, cloud communication, a middleware service, a domain name service, a security service, a Content Delivery Network (CDN), a big data and artificial intelligence platform, and the like. The client 101 may be, but is not limited to, a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart speaker, a smart watch, and the like.
In one embodiment of the present application, the server 103 obtains a feature matrix of an image to be recognized; in the feature matrixSelecting a characteristic value as a target characteristic value a, selecting a characteristic value which is positioned in the same row with the target characteristic value and has a first set distance with the target characteristic value as a row characteristic value b, and selecting a characteristic value which is positioned in the same row with the target characteristic value and has a second set distance with the target characteristic value as a row characteristic value c; substituting the target eigenvalue a, the column eigenvalue b and the row eigenvalue c into a formula
Figure BDA0003189034110000061
The target characteristic value is encoded to obtain an encoded target characteristic value a1, the formula characteristic values are required to be not 0, a1 approaches to 0 when abc is less than 1 after formula derivation, and a1 approaches to infinity when abc is greater than 1 after formula derivation, so that a larger characteristic value can be amplified through encoding to weaken a smaller characteristic value, and the encoded target characteristic value a1 can better embody the main characteristics of the image to be recognized; reselecting a characteristic value from the characteristic values of the characteristic matrix which are not selected as target characteristic values, reselecting column characteristic values and row characteristic values corresponding to the target characteristic values, substituting the reselected target characteristic values, the reselected column characteristic values and the reselected row characteristic values corresponding to the target characteristic values into a formula to encode the reselected target characteristic values until the characteristic values in the characteristic matrix are all used as the target characteristic values to encode, so as to obtain an encoded characteristic matrix, wherein the encoded characteristic matrix is composed of characteristic values capable of embodying the main characteristics of the image to be recognized, and the encoded characteristic matrix can embody the main characteristics of the image to be recognized; and inputting the coded feature matrix into an image recognition model to realize recognition of the image to be recognized based on the main features of the image to be recognized, so that the image can be recognized more accurately.
It should be noted that the image recognition method provided in the embodiment of the present application is generally executed by the server 103, and accordingly, the image recognition apparatus is generally disposed in the server 103. However, in other embodiments of the present application, the client 101 may also have a similar function as the server 103, so as to execute the image recognition method provided by the embodiments of the present application.
The implementation details of the technical solution of the embodiment of the present application are set forth in detail below:
fig. 2 schematically shows a flowchart of an image recognition method according to an embodiment of the present application, where an execution subject of the image recognition method may be a server, such as the server 103 shown in fig. 1.
Referring to fig. 2, the image recognition method at least includes steps S210 to S230, which are described in detail as follows:
in step S210, a feature matrix of the image to be recognized is acquired.
In an embodiment of the application, an image to be recognized may be obtained, and feature extraction may be performed on the image to be recognized to obtain a feature matrix of the image to be recognized.
In step S220, a feature value is selected from the feature matrix as a target feature value a, a feature value in the same row as the target feature value and having a first set distance from the target feature value is selected as a row feature value b, a feature value in the same row as the target feature value and having a second set distance from the target feature value is selected as a row feature value c, and the target feature value a, the row feature value b, and the row feature value c are substituted into a formula
Figure BDA0003189034110000062
The target characteristic value is encoded to obtain an encoded target characteristic value a 1.
In one embodiment of the present application, the column eigenvalue may be an eigenvalue of the eigenvalue matrix that is located in the same column as the target eigenvalue, is located on the right side of the target eigenvalue, and is adjacent to the target eigenvalue; the row eigenvalue is an eigenvalue in the same row as the target eigenvalue in the eigenvalue matrix, below the target eigenvalue, and adjacent to the target eigenvalue, that is, the first set distance may be equal to the second set distance equal to 1, and the first set distance and the second set distance may be other values, which is not limited herein.
In one embodiment of the present application, if the column eigenvalue is null, the column eigenvalue may be determined to be 1; if the row eigenvalue is null, the row eigenvalue may be determined to be 1.
In step S230, one eigenvalue is reselected from the eigenvalues of the feature matrix that are not selected as target eigenvalues, and column eigenvalues and row eigenvalues corresponding to the target eigenvalues are reselected, and the reselected target eigenvalues, the reselected column eigenvalues and row eigenvalues corresponding to the target eigenvalues are substituted into a formula to encode the reselected target eigenvalues until all eigenvalues in the feature matrix are encoded as target eigenvalues, thereby obtaining an encoded feature matrix.
In step S240, the encoded feature matrix is input into an image recognition model to recognize an image to be recognized.
In an embodiment of the present application, before inputting the encoded feature matrix into the image recognition model, weights of hidden layers in the pre-trained neural network model may be obtained; and if the weight of the hidden layer is smaller than the weight threshold, removing the hidden layer to obtain an image recognition model, so that the obtained image recognition model is simpler and faster in recognition.
In one embodiment of the present application, after removing the hidden layer, a weight index of the neural network model may be obtained, the weight index being formed by combining the hidden layer weights in the order of the hidden layer in the neural network model; and deleting the hidden layer weight corresponding to the removed hidden layer from the weight index to obtain the weight index with the hidden layer removed, so that the obtained weight index with the hidden layer removed has fewer digits to occupy less memory of the server.
In an embodiment of the present application, a weight matrix corresponding to the weight of each hidden layer in a pre-trained neural network model may be obtained; clustering the weight matrix corresponding to each hidden layer weight to obtain a clustered weight matrix corresponding to each hidden layer weight; and updating each hidden layer based on the clustered weight matrix corresponding to the weight of each hidden layer to obtain an image recognition model, so as to compress the weight of each hidden layer and lighten the obtained image recognition model.
In one embodiment of the present application, the number of input neurons/the number of output neurons of the hidden layer may be acquired; clustering the characteristic values in the weight matrix corresponding to the hidden layer to obtain a plurality of characteristic clusters; selecting the feature clusters with the same number as the number of input neurons/the number of output neurons from the plurality of feature clusters; averaging the characteristic values in the same characteristic cluster, and taking the average value as a clustering characteristic value; and determining a clustered weight matrix corresponding to the hidden layer weight based on the clustering characteristic value.
In an embodiment of the present application, a gradient matrix of the hidden layer corresponding to the weight matrix may be obtained; summing gradients corresponding to characteristic values in the same characteristic cluster to obtain a clustering gradient; summing the clustering characteristic values and the clustering gradients of the corresponding clustering characteristic values to obtain a summation result; and combining the summation results to obtain a clustered weight matrix corresponding to the hidden layer weight.
In one embodiment of the present application, a plurality of preliminary center points may be randomly selected among the feature values; re-determining a plurality of actual center points among the feature values based on distances between the feature values other than the feature values as the preliminary center points and the preliminary center points; calculating the distance between the characteristic value except the actual central point and the actual central point to obtain a calculation result; and determining the characteristic value which belongs to the same cluster with the actual central point based on the calculation result to obtain the characteristic cluster corresponding to the actual central point.
In an embodiment of the present application, a weight matrix corresponding to the weight of each hidden layer in the neural network after the hidden layer is removed may be obtained; clustering the weight matrix corresponding to each hidden layer weight to obtain a clustered weight matrix corresponding to each hidden layer weight; and updating each hidden layer based on the clustered weight matrix corresponding to the weight of each hidden layer to obtain an image recognition model, so as to compress the weight of each hidden layer and lighten the obtained image recognition model.
In the embodiment of fig. 2, the feature matrix of the image to be recognized is obtained; selecting a characteristic value from the characteristic matrix as a target characteristic value a, and selecting a characteristic value which is in the same column with the target characteristic value and is in the same line with the target characteristic valueThe distance between the values is a characteristic value of a first set distance, the characteristic value is used as a column characteristic value b, and a characteristic value which is positioned in the same row with the target characteristic value and has a second set distance with the target characteristic value is selected as a row characteristic value c; substituting the target eigenvalue a, the column eigenvalue b and the row eigenvalue c into a formula
Figure BDA0003189034110000081
Figure BDA0003189034110000082
The target characteristic value is encoded to obtain an encoded target characteristic value a1, the formula characteristic values are required to be not 0, a1 approaches to 0 when abc is less than 1 after formula derivation, and a1 approaches to infinity when abc is greater than 1 after formula derivation, so that a larger characteristic value can be amplified through encoding to weaken a smaller characteristic value, and the encoded target characteristic value a1 can better embody the main characteristics of the image to be recognized; reselecting a characteristic value from the characteristic values of the characteristic matrix which are not selected as target characteristic values, reselecting column characteristic values and row characteristic values corresponding to the target characteristic values, substituting the reselected target characteristic values, the reselected column characteristic values and the reselected row characteristic values corresponding to the target characteristic values into a formula to encode the reselected target characteristic values until the characteristic values in the characteristic matrix are all used as the target characteristic values to encode, so as to obtain an encoded characteristic matrix, wherein the encoded characteristic matrix is composed of characteristic values capable of embodying the main characteristics of the image to be recognized, and the encoded characteristic matrix can embody the main characteristics of the image to be recognized; and inputting the coded feature matrix into an image recognition model to realize recognition of the image to be recognized based on the main features of the image to be recognized, so that the image can be recognized more accurately.
In an embodiment of the application, the image recognition method can be applied to a Computer Aided Design (CAD) examination, so that the speed of the CAD examination can be greatly increased, mutual conflict and visual communication between building components in the CAD image can be pre-judged in advance, and the cooperation capability between project workers is improved.
Embodiments of the apparatus of the present application are described below, which may be used to perform the image recognition methods in the above-described embodiments of the present application. For details that are not disclosed in the embodiments of the apparatus of the present application, please refer to the embodiments of the image recognition method described above in the present application.
Fig. 3 schematically shows a block diagram of an image recognition apparatus according to an embodiment of the present application.
Referring to fig. 3, an image recognition apparatus 300 according to an embodiment of the present application includes an obtaining module 301, a selecting module 302, an encoding module 303, and a recognition module 304.
According to an aspect of the embodiment of the present application, based on the foregoing scheme, the obtaining module 301 is configured to obtain a feature matrix of an image to be identified; the selecting module 302 is configured to select a feature value in the feature matrix as a target feature value a, select a feature value located in the same column as the target feature value and having a first set distance from the target feature value as a column feature value b, and select a feature value located in the same row as the target feature value and having a second set distance from the target feature value as a row feature value c; the encoding module 303 is configured to bring the target feature value a, the column feature value b and the row feature value c into a formula
Figure BDA0003189034110000091
Coding the target characteristic value to obtain a coded target characteristic value a1, reselecting a characteristic value from the characteristic values of the characteristic matrix which are not selected as the target characteristic value, reselecting a column characteristic value and a row characteristic value corresponding to the target characteristic value, substituting the reselected target characteristic value, the reselected column characteristic value and the reselected row characteristic value corresponding to the target characteristic value into a formula to code the reselected target characteristic value until the characteristic values in the characteristic matrix are all used as the target characteristic value to be coded to obtain a coded characteristic matrix; the recognition module 304 is configured to input the encoded feature matrix into an image recognition model to recognize an image to be recognized.
In an embodiment of the present application, based on the foregoing scheme, the column eigenvalue is an eigenvalue of the eigenvalue matrix that is located in the same column as the target eigenvalue, is located on the right side of the target eigenvalue, and is adjacent to the target eigenvalue; the row eigenvalue is an eigenvalue in the same row as the target eigenvalue in the eigenvalue matrix, below the target eigenvalue, and adjacent to the target eigenvalue.
In an embodiment of the present application, based on the foregoing solution, before the target feature value a, the column feature value b, and the row feature value c are substituted into the formula, the selecting 302 module is configured to: if the column characteristic value is null, determining the column characteristic value as 1; if the row eigenvalue is null, the row eigenvalue is determined to be 1.
In an embodiment of the present application, based on the foregoing scheme, before inputting the encoded feature matrix into the image recognition model, the recognition module 304 is configured to: acquiring weights of hidden layers in a pre-trained neural network model; and if the weight of the hidden layer is smaller than the weight threshold value, removing the hidden layer to obtain the image recognition model.
In an embodiment of the present application, based on the foregoing solution, after removing the hidden layer, the identifying module 304 is configured to: acquiring a weight index of the neural network model, wherein the weight index is formed by combining hidden layer weights according to the sequence of hidden layers in the neural network model; and deleting the hidden layer weight corresponding to the removed hidden layer from the weight index to obtain the weight index with the hidden layer removed.
In an embodiment of the present application, based on the foregoing scheme, before inputting the encoded feature matrix into the image recognition model, the recognition module 304 is configured to: acquiring a weight matrix corresponding to the weight of each hidden layer in a pre-trained neural network model; clustering the weight matrix corresponding to each hidden layer weight to obtain a clustered weight matrix corresponding to each hidden layer weight; and updating each hidden layer based on the clustered weight matrix corresponding to the weight of each hidden layer to obtain an image recognition model.
In an embodiment of the present application, based on the foregoing solution, the identifying module 304 is configured to: acquiring the number of input neurons/the number of output neurons of the hidden layer; clustering the characteristic values in the weight matrix corresponding to the hidden layer to obtain a plurality of characteristic clusters; selecting the feature clusters with the same number as the number of input neurons/the number of output neurons from the plurality of feature clusters; averaging the characteristic values in the same characteristic cluster, and taking the average value as a clustering characteristic value; and determining a clustered weight matrix corresponding to the hidden layer weight based on the clustering characteristic value.
In an embodiment of the present application, based on the foregoing solution, the identifying module 304 is configured to: acquiring a gradient matrix of the hidden layer corresponding to the weight matrix; summing gradients corresponding to characteristic values in the same characteristic cluster to obtain a clustering gradient; summing the clustering characteristic values and the clustering gradients of the corresponding clustering characteristic values to obtain a summation result; and combining the summation results to obtain a clustered weight matrix corresponding to the hidden layer weight.
In an embodiment of the present application, based on the foregoing solution, the identifying module 304 is configured to: randomly selecting a plurality of preparation central points from the characteristic values; re-determining a plurality of actual center points among the feature values based on distances between the feature values other than the feature values as the preliminary center points and the preliminary center points; calculating the distance between the characteristic value except the actual central point and the actual central point to obtain a calculation result; and determining the characteristic value which belongs to the same cluster with the actual central point based on the calculation result to obtain the characteristic cluster corresponding to the actual central point.
As will be appreciated by one skilled in the art, aspects of the present application may be embodied as a system, method or program product. Accordingly, various aspects of the present application may be embodied in the form of: an entirely hardware embodiment, an entirely software embodiment (including firmware, microcode, etc.) or an embodiment combining hardware and software aspects that may all generally be referred to herein as a "circuit," module "or" system.
An electronic device 40 according to this embodiment of the present application is described below with reference to fig. 4. The electronic device 40 shown in fig. 4 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present application.
As shown in fig. 4, electronic device 40 is embodied in the form of a general purpose computing device. The components of electronic device 40 may include, but are not limited to: the at least one processing unit 41, the at least one memory unit 42, a bus 43 connecting different system components (including the memory unit 42 and the processing unit 41), and a display unit 44.
Wherein the storage unit stores program code executable by the processing unit 41 to cause the processing unit 41 to perform the steps according to various exemplary embodiments of the present application described in the section "example methods" above in this specification.
The storage unit 42 may include readable media in the form of volatile memory units, such as a random access memory unit (RAM)421 and/or a cache memory unit 422, and may further include a read only memory unit (ROM) 423.
The storage unit 42 may also include a program/utility 424 having a set (at least one) of program modules 425, such program modules 425 including, but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which, or some combination thereof, may comprise an implementation of a network environment.
Bus 43 may be one or more of any of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
The electronic device 40 may also communicate with one or more external devices (e.g., keyboard, pointing device, bluetooth device, etc.), with one or more devices that enable a user to interact with the electronic device 40, and/or with any devices (e.g., router, modem, etc.) that enable the electronic device 40 to communicate with one or more other computing devices. Such communication may be through an input/output (I/O) interface 45. Also, the electronic device 40 may communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network, such as the Internet) via the network adapter 46. As shown, the network adapter 46 communicates with other modules of the electronic device 40 via the bus 43. It should be understood that although not shown in the figures, other hardware and/or software modules may be used in conjunction with electronic device 40, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, among others.
Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein may be implemented by software, or by software in combination with necessary hardware. Therefore, the technical solution according to the embodiments of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a usb disk, a removable hard disk, etc.) or on a network, and includes several instructions to make a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) execute the method according to the embodiments of the present application.
There is also provided, in accordance with an embodiment of the present application, a computer-readable storage medium having stored thereon a program product capable of implementing the above-described method of the present specification. In some possible embodiments, various aspects of the present application may also be implemented in the form of a program product comprising program code for causing a terminal device to perform the steps according to various exemplary embodiments of the present application described in the "exemplary methods" section above of this specification, when the program product is run on the terminal device.
According to one embodiment of the present application, a program product for implementing the above method may employ a portable compact disc read only memory (CD-ROM) and include program code, and may be run on a terminal device, such as a personal computer. However, the program product of the present application is not limited thereto, and in this document, a 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.
The program product may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. A 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 readable storage medium include: an electrical connection having one or more wires, a portable disk, 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.
A computer readable signal medium may include a propagated data signal with 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 readable signal medium may also be any readable medium that is not a 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 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.
Program code for carrying out operations of the present application may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, 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 computing device, partly on the user's device, as a stand-alone software package, partly on the user's computing device and partly on a remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computing device (e.g., through the internet using an internet service provider).
Furthermore, the above-described figures are merely schematic illustrations of processes involved in methods according to exemplary embodiments of the present application, and are not intended to be limiting. It will be readily understood that the processes shown in the above figures are not intended to indicate or limit the chronological order of the processes. In addition, it is also readily understood that these processes may be performed synchronously or asynchronously, e.g., in multiple modules.
It will be understood that the present application is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the application is limited only by the appended claims.

Claims (10)

1. An image recognition method, comprising:
acquiring a characteristic matrix of an image to be identified;
selecting a characteristic value from the characteristic matrix as a target characteristic value a, selecting a characteristic value which is positioned in the same column with the target characteristic value and has a first set distance from the target characteristic value as a column characteristic value b, selecting a characteristic value which is positioned in the same row with the target characteristic value and has a second set distance from the target characteristic value as a row characteristic value c, and substituting the target characteristic value a, the column characteristic value b and the row characteristic value c into a formula
Figure FDA0003189034100000011
Encoding the target characteristic value to obtain an encoded target characteristic value a 1;
reselecting an eigenvalue from the eigenvalues of the characteristic matrix which are not selected as the target eigenvalue, reselecting a column eigenvalue and a row eigenvalue corresponding to the target eigenvalue, substituting the reselected target eigenvalue, the reselected column eigenvalue and the reselected row eigenvalue corresponding to the target eigenvalue into a formula to encode the reselected target eigenvalue until the eigenvalues in the characteristic matrix are all used as the target eigenvalue to encode, and obtaining an encoded characteristic matrix;
and inputting the coded feature matrix into an image recognition model so as to recognize the image to be recognized.
2. The image recognition method according to claim 1,
the column eigenvalue is an eigenvalue which is positioned in the same column as the target eigenvalue, positioned on the right side of the target eigenvalue and adjacent to the target eigenvalue in the eigenvalue matrix;
the row eigenvalue is an eigenvalue of the same row in the eigenvalue matrix as the target eigenvalue, below the target eigenvalue, and adjacent to the target eigenvalue.
3. The image recognition method according to claim 1, wherein before the target feature value a, the column feature value b, and the row feature value c are substituted into a formula, the method comprises:
if the column characteristic value is null, determining the column characteristic value as 1;
and if the line characteristic value is null, determining the line characteristic value as 1.
4. The image recognition method of claim 1, wherein before inputting the encoded feature matrix into an image recognition model, the method comprises:
acquiring weights of hidden layers in a pre-trained neural network model;
and if the weight of the hidden layer is smaller than the weight threshold, removing the hidden layer to obtain the image recognition model.
5. The image recognition method of claim 4, wherein after removing the hidden layer, the method comprises:
acquiring a weight index of the neural network model, wherein the weight index is formed by combining the hidden layer weights according to the sequence of the hidden layers in the neural network model;
and deleting the hidden layer weight corresponding to the removed hidden layer from the weight index to obtain the weight index after the hidden layer is removed.
6. The image recognition method of claim 1, wherein before inputting the encoded feature matrix into an image recognition model, the method comprises:
acquiring a weight matrix corresponding to the weight of each hidden layer in a pre-trained neural network model;
clustering the weight matrix corresponding to each hidden layer weight to obtain a clustered weight matrix corresponding to each hidden layer weight;
and updating each hidden layer based on the clustered weight matrix corresponding to the weight of each hidden layer to obtain the image recognition model.
7. The image recognition method according to claim 6, wherein the clustering the weight matrix corresponding to each hidden layer weight to obtain a clustered weight matrix corresponding to each hidden layer weight comprises:
acquiring the number of input neurons/the number of output neurons of the hidden layer;
clustering the characteristic values in the weight matrix corresponding to the hidden layer to obtain a plurality of characteristic clusters;
selecting the same number of feature clusters as the number of input neurons/the number of output neurons in the plurality of feature clusters;
averaging the characteristic values in the same characteristic cluster, and taking the average value as a clustering characteristic value;
and determining a clustered weight matrix corresponding to the hidden layer weight based on the clustering characteristic value.
8. The image recognition method of claim 7, wherein the determining the clustered weight matrix corresponding to the hidden layer weight based on the class feature value comprises:
acquiring a gradient matrix of the hidden layer corresponding to the weight matrix;
summing gradients corresponding to characteristic values in the same characteristic cluster to obtain a clustering gradient;
summing the clustering characteristic values and the clustering gradients corresponding to the clustering characteristic values to obtain a summation result;
and combining the summation results to obtain a clustered weight matrix corresponding to the hidden layer weight.
9. The image recognition method according to claim 7, wherein the clustering the feature values in the weight matrix corresponding to the hidden layer to obtain a plurality of feature clusters comprises:
randomly selecting a plurality of preparation central points in the characteristic values;
re-determining a plurality of actual center points among the feature values based on distances between the feature values other than the feature values as the preliminary center points and the preliminary center points;
calculating the distance between the characteristic value except the actual central point and the actual central point to obtain a calculation result;
and determining the characteristic value which belongs to the same cluster with the actual central point based on the calculation result to obtain the characteristic cluster corresponding to the actual central point.
10. An image recognition apparatus, comprising:
the acquisition module is configured to acquire a feature matrix of the image to be identified;
the selecting module is configured to select a characteristic value from the characteristic matrix as a target characteristic value a, select a characteristic value which is positioned in the same column with the target characteristic value and has a first set distance from the target characteristic value as a column characteristic value b, and select a characteristic value which is positioned in the same row with the target characteristic value and has a second set distance from the target characteristic value as a row characteristic value c;
an encoding module configured to bring the target feature values a, the column feature values b, and the row feature values c into a formula
Figure FDA0003189034100000031
Encoding the target characteristic value to obtain an encoded target characteristic value a1, reselecting a characteristic value from the characteristic values of the characteristic matrix which are not selected as the target characteristic value, reselecting a column characteristic value and a row characteristic value corresponding to the target characteristic value, substituting the reselected target characteristic value, the reselected column characteristic value and the reselected row characteristic value corresponding to the target characteristic value into a formula, and encoding the reselected target characteristic value until the characteristic values in the characteristic matrix are all used as the target characteristic value to be encoded to obtain an encoded characteristic matrix;
and the identification module is configured to input the coded feature matrix into an image identification model so as to identify the image to be identified.
CN202110871626.XA 2021-07-30 2021-07-30 Image recognition method and device Active CN113591983B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110871626.XA CN113591983B (en) 2021-07-30 2021-07-30 Image recognition method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110871626.XA CN113591983B (en) 2021-07-30 2021-07-30 Image recognition method and device

Publications (2)

Publication Number Publication Date
CN113591983A true CN113591983A (en) 2021-11-02
CN113591983B CN113591983B (en) 2024-03-19

Family

ID=78252680

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110871626.XA Active CN113591983B (en) 2021-07-30 2021-07-30 Image recognition method and device

Country Status (1)

Country Link
CN (1) CN113591983B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109325875A (en) * 2018-08-31 2019-02-12 合肥工业大学 Implicit group based on the hidden feature of online social user finds method
CN109862365A (en) * 2019-01-30 2019-06-07 西安万像电子科技有限公司 Image processing method and device
CN110070085A (en) * 2019-04-30 2019-07-30 北京百度网讯科技有限公司 Licence plate recognition method and device
CN111310787A (en) * 2020-01-15 2020-06-19 江苏大学 Brain function network multi-core fuzzy clustering method based on stacked encoder
CN111783787A (en) * 2020-07-10 2020-10-16 上海淇毓信息科技有限公司 Method and device for identifying image characters and electronic equipment
WO2020232905A1 (en) * 2019-05-20 2020-11-26 平安科技(深圳)有限公司 Superobject information-based remote sensing image target extraction method, device, electronic apparatus, and medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109325875A (en) * 2018-08-31 2019-02-12 合肥工业大学 Implicit group based on the hidden feature of online social user finds method
CN109862365A (en) * 2019-01-30 2019-06-07 西安万像电子科技有限公司 Image processing method and device
CN110070085A (en) * 2019-04-30 2019-07-30 北京百度网讯科技有限公司 Licence plate recognition method and device
WO2020232905A1 (en) * 2019-05-20 2020-11-26 平安科技(深圳)有限公司 Superobject information-based remote sensing image target extraction method, device, electronic apparatus, and medium
CN111310787A (en) * 2020-01-15 2020-06-19 江苏大学 Brain function network multi-core fuzzy clustering method based on stacked encoder
CN111783787A (en) * 2020-07-10 2020-10-16 上海淇毓信息科技有限公司 Method and device for identifying image characters and electronic equipment

Also Published As

Publication number Publication date
CN113591983B (en) 2024-03-19

Similar Documents

Publication Publication Date Title
WO2022105117A1 (en) Method and device for image quality assessment, computer device, and storage medium
CN111612038B (en) Abnormal user detection method and device, storage medium and electronic equipment
CN111612041A (en) Abnormal user identification method and device, storage medium and electronic equipment
CN113742483A (en) Document classification method and device, electronic equipment and storage medium
CN110941978B (en) Face clustering method and device for unidentified personnel and storage medium
CN113094509B (en) Text information extraction method, system, device and medium
CN114494784A (en) Deep learning model training method, image processing method and object recognition method
CN113657289A (en) Training method and device of threshold estimation model and electronic equipment
CN111612037A (en) Abnormal user detection method, device, medium and electronic equipment
US20230096921A1 (en) Image recognition method and apparatus, electronic device and readable storage medium
JP2023062150A (en) Character recognition model training, character recognition method, apparatus, equipment, and medium
CN115034315A (en) Business processing method and device based on artificial intelligence, computer equipment and medium
CN111709473A (en) Object feature clustering method and device
CN116703659A (en) Data processing method and device applied to engineering consultation and electronic equipment
CN110348581B (en) User feature optimizing method, device, medium and electronic equipment in user feature group
CN113591983B (en) Image recognition method and device
CN113591987B (en) Image recognition method, device, electronic equipment and medium
CN115116080A (en) Table analysis method and device, electronic equipment and storage medium
CN114897099A (en) User classification method and device based on passenger group deviation smooth optimization and electronic equipment
CN114443864A (en) Cross-modal data matching method and device and computer program product
CN114639143A (en) Portrait filing method, equipment and storage medium based on artificial intelligence
CN113420699A (en) Face matching method and device and electronic equipment
CN113255824A (en) Method and device for training classification model and data classification
CN113535885B (en) Age prediction method and device based on user nickname and electronic equipment
CN116721315B (en) Living body detection model training method, living body detection model training device, medium and electronic equipment

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