CN113591983B - Image recognition method and device - Google Patents

Image recognition method and device Download PDF

Info

Publication number
CN113591983B
CN113591983B CN202110871626.XA CN202110871626A CN113591983B CN 113591983 B CN113591983 B CN 113591983B CN 202110871626 A CN202110871626 A CN 202110871626A CN 113591983 B CN113591983 B CN 113591983B
Authority
CN
China
Prior art keywords
characteristic value
target
weight
characteristic
hidden layer
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110871626.XA
Other languages
Chinese (zh)
Other versions
CN113591983A (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

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)
  • Biophysics (AREA)
  • Health & Medical Sciences (AREA)
  • Biomedical Technology (AREA)
  • Probability & Statistics with Applications (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Image Analysis (AREA)

Abstract

The application provides an image recognition method and device. The method comprises the following steps: acquiring a feature 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; re-selecting a characteristic value from characteristic values which are not selected as target characteristic values, re-selecting column characteristic values and row characteristic values corresponding to the target characteristic values, and encoding the re-selected target characteristic values based on the re-selected target characteristic values, the re-selected column characteristic values and row characteristic values corresponding to the 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; 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 generally 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 recognition method and device which can solve the problem of inaccurate image recognition.
According to one aspect of an embodiment of the present application,there is provided an image recognition method including: acquiring a feature 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 with 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 with the target characteristic value as a row characteristic value c, and bringing the target characteristic value a, the column characteristic value b and the row characteristic value c into a formula The target characteristic value is encoded to obtain an encoded target characteristic value a1; re-selecting a characteristic value from the characteristic values which are not selected as the target characteristic values, re-selecting column characteristic values and row characteristic values corresponding to the target characteristic values, and bringing the re-selected target characteristic values, the re-selected column characteristic values and the re-selected row characteristic values corresponding to the target characteristic values into a formula to code the re-selected target characteristic values until the characteristic values in the characteristic matrix are all used as the target characteristic values to code, so as to obtain a coded characteristic matrix; and inputting the coded feature matrix into an 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 selection module is configured to select one characteristic value from the characteristic matrix as a target characteristic value a, select 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 select 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; an encoding module configured to bring the target feature value a, the column feature value b, and the row feature value c into a formula In the method, the target characteristic value is coded to obtain a coded target characteristic value a1, one characteristic value is selected again from characteristic values which are not selected as the target characteristic value in the characteristic matrix to serve as the target characteristic value, the column characteristic value and the row characteristic value which correspond to the target characteristic value are selected again, the selected target characteristic value, the selected column characteristic value and the row characteristic value which correspond to the target characteristic value are taken into a formula again, and the target characteristic value is coded again until the characteristic values in the characteristic matrix are all used as the target characteristic value to be coded, and a coded characteristic matrix is obtained; 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 one embodiment of the present application, based on the foregoing solution, the column eigenvalue is an eigenvalue located in the same column as the target eigenvalue in the eigenvalue matrix, located on the right side of the target eigenvalue and adjacent to the target eigenvalue; the row eigenvalues are eigenvalues in the eigenvalue matrix located in the same row as the target eigenvalue, located below the target eigenvalue and adjacent to the target eigenvalue.
In one embodiment of the present application, based on the foregoing scheme, before bringing the target eigenvalue a, the column eigenvalue b, and the row eigenvalue c into a formula, the selecting module is configured to: if the column feature value is null, determining the column feature value as 1; and if the row characteristic value is null, determining the row characteristic value as 1.
In one embodiment of the present application, based on the foregoing, before inputting the encoded feature matrix into an image recognition model, the recognition module is configured to: acquiring weights of all hidden layers in a pre-trained neural network model; and if the weight of the hidden layer is smaller than a weight threshold, removing the hidden layer to obtain the image recognition model.
In one embodiment of the present 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 weights of the hidden layers 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 one embodiment of the present application, based on the foregoing, before inputting the encoded feature matrix into an image recognition model, the recognition module is configured to: acquiring a weight matrix corresponding to each hidden layer weight in the pre-trained neural network model; clustering the weight matrixes corresponding to the weights of the hidden layers to obtain clustered weight matrixes corresponding to the weights of the hidden layers; and updating each hidden layer based on the clustered weight matrix corresponding to each hidden layer weight to obtain the image recognition model.
In one embodiment of the present application, based on the foregoing scheme, the identification module is configured to: acquiring the number of input neurons/the number of output neurons of the hidden layer; clustering eigenvalues in a weight matrix corresponding to the hidden layer to obtain a plurality of eigenvectors; selecting the same number of feature clusters 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 one embodiment of the present application, based on the foregoing scheme, the identification module is configured to: acquiring a gradient matrix of the hidden layer corresponding to the weight matrix; summing gradients corresponding to the feature values in the same feature cluster to obtain a cluster gradient; summing the cluster characteristic values and the cluster gradients corresponding to the cluster 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, based on the foregoing scheme, the identification module is configured to: randomly selecting a plurality of preparation center points from the characteristic values; re-determining a plurality of actual center points in the feature values based on distances between the feature values other than as the preliminary center points and the preliminary center points; calculating the distance between the characteristic value except the actual center point and the actual center point to obtain a calculation result; and determining the characteristic value belonging to the same cluster with the actual center point based on the calculation result to obtain a characteristic cluster corresponding to the actual center 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 stored thereon computer readable instructions which, when executed by the processor, implement a method as claimed in any one of the preceding claims.
According to an aspect of embodiments of the present application, 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, so that the computer device performs the methods provided in the various alternative embodiments described above.
The technical scheme provided by the embodiment of the application can comprise the following beneficial effects:
in some embodiments of the present application, a feature matrix of an image to be identified is obtained; selecting one characteristic value from the characteristic matrix as a target characteristic value a, selecting the 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 the 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 A row feature value c; bringing the target eigenvalue a, the column eigenvalue b, and the row eigenvalue c into a formulaIn the method, the target characteristic value a1 after encoding is obtained, the characteristic value of the formula is required to be non-0, a1 approaches 0 when abc is smaller than 1 after the formula is derived, and a1 approaches infinity when abc is larger than 1 after the formula is derived, so that the larger characteristic value can be amplified through encoding, the smaller characteristic value is weakened, and the main characteristic of the image to be identified can be reflected by the encoded target characteristic value a 1; re-selecting a characteristic value from characteristic values which are not selected as target characteristic values as the target characteristic value, re-selecting a column characteristic value and a row characteristic value corresponding to the target characteristic value, bringing the re-selected target characteristic value, the re-selected column characteristic value and the re-selected row characteristic value corresponding to the target characteristic value into a formula, and coding the re-selected target characteristic value until the characteristic values in the characteristic matrix are all used as the target characteristic value, so as to obtain a coded characteristic matrix, wherein the coded characteristic matrix consists of characteristic values capable of showing main characteristics of an image to be identified, and the coded characteristic matrix also can show main characteristics of the image to be identified; the coded feature matrix is input into an image recognition model to realize recognition of the image to be recognized based on main features of the image to be recognized, so that 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 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 the technical solutions of embodiments of the present application may be applied;
FIG. 2 schematically illustrates a flow chart of an image recognition method according to one embodiment of the present application;
FIG. 3 schematically illustrates a block diagram of an image recognition device according to one embodiment of the present application;
fig. 4 is a hardware diagram of an electronic device, according to an example embodiment.
Detailed Description
Example embodiments will now be described more fully with reference to the accompanying drawings. However, the exemplary embodiments may be embodied in many 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 the 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 present application. One skilled in the relevant art will recognize, however, that the aspects of the application can be practiced without one or more of the specific details, or with other methods, components, devices, steps, etc. In other instances, well-known methods, devices, implementations, or operations are not shown or described in detail to avoid obscuring aspects of the application.
The block diagrams depicted in the figures are merely functional entities and do not necessarily correspond to physically separate entities. That is, the functional entities may be implemented in software, or in one or more hardware modules or integrated circuits, or in different networks and/or processor devices and/or microcontroller devices.
The flow diagrams depicted in the figures are exemplary only, and do not necessarily include all of the elements and operations/steps, nor must they 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 order of actual execution may be changed according to actual situations.
Fig. 1 shows a schematic diagram of an exemplary system architecture 100 to which the technical solutions of the embodiments of the present application may be applied.
As shown in fig. 1, a system architecture 100 may include a client 101, a network 102, and a server 103. Network 102 is the medium used to provide communication links between clients 101 and servers 103. The network 102 may include various connection types, such as wired communication links, wireless communication links, and the like, as the present application is not limited herein.
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 may be a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, a content delivery network (Content Delivery Network, CDN), and basic cloud computing services such as big data and an artificial intelligence platform. 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, etc.
In one embodiment of the present application, the server 103 obtains the feature matrix of the 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 with the target characteristic value as a column 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; bringing the target eigenvalue a, the column eigenvalue b, and the row eigenvalue c into a formula In the method, the target characteristic value is encoded to obtain an encoded target characteristic value a1, the characteristic value of the formula is required to be non-0, a1 approaches 0 when abc is smaller than 1 after the formula is derived and a1 approaches infinity when abc is larger than 1 after the formula is derived, so that the target characteristic value a1 can be amplified through encodingThe large characteristic value weakens the smaller characteristic value, so that the coded target characteristic value a1 can more embody the main characteristic of the image to be identified; re-selecting a characteristic value from characteristic values which are not selected as target characteristic values as the target characteristic value, re-selecting a column characteristic value and a row characteristic value corresponding to the target characteristic value, bringing the re-selected target characteristic value, the re-selected column characteristic value and the re-selected row characteristic value corresponding to the target characteristic value into a formula, and coding the re-selected target characteristic value until the characteristic values in the characteristic matrix are all used as the target characteristic value, so as to obtain a coded characteristic matrix, wherein the coded characteristic matrix consists of characteristic values capable of showing main characteristics of an image to be identified, and the coded characteristic matrix also can show main characteristics of the image to be identified; the coded feature matrix is input into an image recognition model to realize recognition of the image to be recognized based on 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 device is generally disposed in the server 103. However, in other embodiments of the present application, the client 101 may also have a similar function to the server 103, so as to perform the image recognition method provided in the embodiments of the present application.
The implementation details of the technical solutions of the embodiments of the present application are described in detail below:
fig. 2 schematically illustrates a flowchart of an image recognition method according to an embodiment of the present application, and the execution subject of the image recognition method may be a server, such as the server 103 illustrated in fig. 1.
Referring to fig. 2, the image recognition method at least includes steps S210 to S230, and is described in detail as follows:
in step S210, a feature matrix of an image to be identified is acquired.
In one embodiment of the present application, an image to be identified may be acquired, and feature extraction may be performed on the image to be identified to acquire a feature matrix of the image to be identified.
In step S220, one feature value is selected from the feature matrix as a target feature value a, a feature value which is in the same row as the target feature value and has a first set distance from the target feature value is selected as a row feature value b, a feature value which is in the same row as the target feature value and has 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 brought into the formula In order to encode the target feature value, the encoded target feature value a1 is obtained.
In one embodiment of the present application, the column eigenvalue may be an eigenvalue located in the same column as, right of, and adjacent to the target eigenvalue in the eigenvalue matrix; the line feature value is a feature value that is located in the same line as the target feature value in the feature matrix, is located below the target feature value, and is adjacent to the target feature value, that is, the first set distance may be equal to the second set distance and equal to 1, and the first set distance and the second set distance may be other values, which are not limited herein.
In one embodiment of the present application, if the column feature value is null, the column feature value may be determined to be 1; if the line eigenvalue is empty, the line eigenvalue may be determined to be 1.
In step S230, a feature value is re-selected as a target feature value from the feature values of the feature matrix, which are not selected as the target feature values, the column feature values and the row feature values corresponding to the target feature values are re-selected, and the re-selected target feature values, the re-selected column feature values and the re-selected row feature values corresponding to the target feature values are brought into the formula, so as to encode the re-selected target feature values until the feature values in the feature matrix are all used as the target feature values for encoding, thereby obtaining the 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 one embodiment of the present application, before inputting the encoded feature matrix into the image recognition model, each hidden layer weight in the pre-trained neural network model may be obtained; 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, where the weight index is formed by combining weights of the hidden layer according to 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 after the hidden layer is removed, so that the number of the obtained weight index bits after the hidden layer is removed is smaller, and the memory of the server is occupied.
In one embodiment of the present application, a weight matrix corresponding to each hidden layer weight in the pre-trained neural network model may be obtained; clustering the weight matrixes corresponding to the weights of the hidden layers to obtain clustered weight matrixes corresponding to the weights of the hidden layers; based on the clustered weight matrix corresponding to the weights of the hidden layers, updating the hidden layers to obtain an image recognition model, and compressing the weights of the hidden layers to 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 obtained; clustering eigenvalues in a weight matrix corresponding to the hidden layer to obtain a plurality of eigenvectors; selecting the same number of feature clusters 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 one embodiment of the present application, a gradient matrix of the hidden layer corresponding to the weight matrix may be obtained; summing gradients corresponding to the feature values in the same feature cluster to obtain a cluster 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 selected randomly among the feature values; re-determining a plurality of actual center points among the feature values based on the distance between the feature values other than as the preliminary center point and the preliminary center point; calculating the distance between the characteristic value except for serving as an actual center point and the actual center point to obtain a calculation result; and determining the characteristic value belonging to the same cluster with the actual center point based on the calculation result to obtain the characteristic cluster corresponding to the actual center point.
In one embodiment of the present application, a weight matrix corresponding to each hidden layer weight in the neural network after the hidden layer is removed may be obtained; clustering the weight matrixes corresponding to the weights of the hidden layers to obtain clustered weight matrixes corresponding to the weights of the hidden layers; based on the clustered weight matrix corresponding to the weights of the hidden layers, updating the hidden layers to obtain an image recognition model, and compressing the weights of the hidden layers to lighten the obtained image recognition model.
In the embodiment of fig. 2, the feature matrix of the 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 column with the target characteristic value and has a first set distance with the target characteristic value as a column 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; bringing the target eigenvalue a, the column eigenvalue b, and the row eigenvalue c into a formula In order to encode the target characteristic value to obtain an encoded target characteristic value a1, wherein the characteristic value of the formula is required to be non-0, a1 approaches 0 when abc is smaller than 1 after the derivation of the formula, and a1 approaches infinity when abc is larger than 1 after the derivation, thus The larger characteristic value can be amplified through encoding, and the smaller characteristic value is weakened, so that the encoded target characteristic value a1 can more embody the main characteristic of the image to be identified; re-selecting a characteristic value from characteristic values which are not selected as target characteristic values as the target characteristic value, re-selecting a column characteristic value and a row characteristic value corresponding to the target characteristic value, bringing the re-selected target characteristic value, the re-selected column characteristic value and the re-selected row characteristic value corresponding to the target characteristic value into a formula, and coding the re-selected target characteristic value until the characteristic values in the characteristic matrix are all used as the target characteristic value, so as to obtain a coded characteristic matrix, wherein the coded characteristic matrix consists of characteristic values capable of showing main characteristics of an image to be identified, and the coded characteristic matrix also can show main characteristics of the image to be identified; the coded feature matrix is input into an image recognition model to realize recognition of the image to be recognized based on main features of the image to be recognized, so that the image can be recognized more accurately.
In one embodiment of the application, the image recognition method can be applied to the computer aided design (Computer Aided Design, CAD) drawing, so that the speed of CAD drawing can be greatly improved, mutual conflict and visual communication between building components in the CAD image can be pre-judged in advance, and the collaboration capability between project staff is improved.
The following describes an embodiment of an apparatus of the present application, which may be used to perform the image recognition method in the above-described embodiment of the present application. For details not disclosed in the embodiments of the apparatus of the present application, please refer to the embodiments of the image recognition method described in the present application.
Fig. 3 schematically shows a block diagram of an image recognition device 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 acquisition module 301, a selection module 302, an encoding module 303, and a recognition module 304.
According to an aspect of the embodiments of the present application, based on the foregoing, the obtaining module 301 is configured to obtain a feature moment of an image to be identifiedAn array; the selecting module 302 is configured to select one feature value from the feature matrix as a target feature value a, select a feature value which is in the same column as the target feature value and has a first set distance from the target feature value as a column feature value b, and select a feature value which is in the same row as the target feature value and has 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 eigenvalue a, the column eigenvalue b, and the row eigenvalue c into a formula In the method, a target characteristic value a1 after coding is obtained, one characteristic value is reselected as a target characteristic value in characteristic values which are not selected as the target characteristic value in the characteristic matrix, a column characteristic value and a row characteristic value which correspond to the target characteristic value are reselected, the reselected target characteristic value, the reselected column characteristic value and the reselected row characteristic value which correspond to the target characteristic value are brought into a formula, and coding is carried out on the reselected target characteristic value until the characteristic values in the characteristic matrix are all used as the target characteristic value for coding, so that a coded characteristic matrix is obtained; 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 one embodiment of the present application, based on the foregoing scheme, the column eigenvalue is an eigenvalue located in the same column as the target eigenvalue in the eigenvalue matrix, located on the right side of the target eigenvalue and adjacent to the target eigenvalue; the row eigenvalues are eigenvalues in the eigenvalue matrix located in the same row as the target eigenvalue, located below the target eigenvalue and adjacent to the target eigenvalue.
In one embodiment of the present application, based on the foregoing scheme, before bringing the target eigenvalue a, the column eigenvalue b, and the row eigenvalue c 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 line characteristic value is null, the line characteristic value is determined to be 1.
In one embodiment of the present application, based on the foregoing, prior to inputting the encoded feature matrix into the image recognition model, the recognition module 304 is configured to: acquiring weights of all 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 one embodiment of the present application, based on the foregoing scheme, after removing the hidden layer, the identification module 304 is configured to: acquiring a weight index of the neural network model, wherein the weight index is formed by combining weights of the hidden layers 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 one embodiment of the present application, based on the foregoing, prior to inputting the encoded feature matrix into the image recognition model, the recognition module 304 is configured to: acquiring a weight matrix corresponding to each hidden layer weight in the pre-trained neural network model; clustering the weight matrixes corresponding to the weights of the hidden layers to obtain clustered weight matrixes corresponding to the weights of the hidden layers; updating each hidden layer based on the clustered weight matrix corresponding to each hidden layer weight to obtain an image recognition model.
In one embodiment of the present application, based on the foregoing scheme, the identification module 304 is configured to: acquiring the number of input neurons/the number of output neurons of the hidden layer; clustering eigenvalues in a weight matrix corresponding to the hidden layer to obtain a plurality of eigenvectors; selecting the same number of feature clusters 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 one embodiment of the present application, based on the foregoing scheme, the identification module 304 is configured to: acquiring a gradient matrix corresponding to the hidden layer and a weight matrix; summing gradients corresponding to the feature values in the same feature cluster to obtain a cluster 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, based on the foregoing scheme, the identification module 304 is configured to: randomly selecting a plurality of preparation center points from the characteristic values; re-determining a plurality of actual center points among the feature values based on the distance between the feature values other than as the preliminary center point and the preliminary center point; calculating the distance between the characteristic value except for serving as an actual center point and the actual center point to obtain a calculation result; and determining the characteristic value belonging to the same cluster with the actual center point based on the calculation result to obtain the characteristic cluster corresponding to the actual center point.
Those skilled in the art will appreciate that the various aspects of the present application may be implemented as a system, method, or program product. Accordingly, aspects of the present application may be embodied in the following forms, namely: an entirely hardware embodiment, an entirely software embodiment (including firmware, micro-code, etc.) or an embodiment combining hardware and software aspects may 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 be construed as limiting the functionality and scope of use of the embodiments herein.
As shown in fig. 4, the electronic device 40 is in the form of a general purpose computing device. 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 the different system components (including the memory unit 42 and the processing unit 41), a display unit 44.
Wherein the storage unit stores program code that is executable by the processing unit 41 such that the processing unit 41 performs steps according to various exemplary embodiments of the present application described in the above-mentioned "example methods" section of the present specification.
The memory unit 42 may include readable media in the form of volatile memory units, such as Random Access Memory (RAM) 421 and/or cache memory 422, and may further include Read Only Memory (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 or some combination of which may include an implementation of a network environment.
The bus 43 may be one or more 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.
Electronic device 40 may also communicate with one or more external devices (e.g., keyboard, pointing device, bluetooth device, etc.), one or more devices that enable a user to interact with electronic device 40, and/or any device (e.g., router, modem, etc.) that enables 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, electronic device 40 may communicate with one or more networks such as a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network, such as the Internet, through network adapter 46. As shown, the network adapter 46 communicates with other modules of the electronic device 40 over the bus 43. It should be appreciated that although not shown, other hardware and/or software modules may be used in connection with electronic device 40, including, but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, data backup storage systems, and the like.
From the above description of embodiments, those skilled in the art will readily appreciate that the example embodiments described herein may be implemented in software, or may be implemented in software in combination with the necessary hardware. Thus, the technical solution according to the embodiments of the present application may be embodied in the form of a software product, which may be stored in a non-volatile storage medium (may be a CD-ROM, a usb disk, a mobile hard disk, etc.) or on a network, and includes several instructions to cause a computing device (may be a personal computer, a server, a terminal device, or a network device, etc.) to perform the method according to the embodiments of the present application.
According to an embodiment of the present application, there is also provided a computer readable storage medium having stored thereon a program product capable of implementing the method described above in the present specification. In some possible implementations, the 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 carry out the steps according to the various exemplary embodiments of the present application as described in the "exemplary methods" section 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 comprise 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. The readable storage medium can be, for example, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples (a non-exhaustive list) of the readable storage medium would include the following: an electrical connection having one or more wires, a portable disk, a hard disk, random Access Memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
The computer readable signal medium may include a data signal propagated in baseband or as part of a carrier wave with readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. 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, partly on a remote computing device, or entirely on the remote computing device or server. In the case of remote computing devices, 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., connected via the Internet using an Internet service provider).
Furthermore, the above-described figures are only illustrative of the processes involved in the method according to exemplary embodiments of the present application, and are not intended to be limiting. It will be readily appreciated that the processes shown in the above figures do not indicate or limit the temporal order of these processes. In addition, it is also readily understood that these processes may be performed synchronously or asynchronously, for example, among a plurality of modules.
It is to be understood that the present application is not limited to the precise construction set forth above and shown in the drawings, and that various modifications and changes may be effected therein without departing from the scope thereof. The scope of the application is limited only by the appended claims.

Claims (7)

1. An image recognition method, comprising:
acquiring a feature 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 with 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 with the target characteristic value as a row characteristic value c, and bringing the target characteristic value a, the column characteristic value b and the row characteristic value c into a formula The target characteristic value is encoded to obtain an encoded target characteristic value a1;
re-selecting a characteristic value from the characteristic values which are not selected as the target characteristic values, re-selecting column characteristic values and row characteristic values corresponding to the target characteristic values, and bringing the re-selected target characteristic values, the re-selected column characteristic values and the re-selected row characteristic values corresponding to the target characteristic values into a formula to code the re-selected target characteristic values until the characteristic values in the characteristic matrix are all used as the target characteristic values to code, so as to obtain a coded characteristic matrix;
acquiring weights of all hidden layers in a pre-trained neural network model;
if the weight of the hidden layer is smaller than a weight threshold, removing the hidden layer;
acquiring a weight index of the neural network model, wherein the weight index is formed by combining weights of the hidden layers according to the sequence of the hidden layers in the neural network model;
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 so as to generate a neural network model after the hidden layer is removed;
Acquiring a weight matrix corresponding to each hidden layer weight in the pre-trained neural network model;
clustering the weight matrixes corresponding to the weights of the hidden layers to obtain clustered weight matrixes corresponding to the weights of the hidden layers;
updating each hidden layer in the neural network model after removing the hidden layer based on the clustered weight matrix corresponding to each hidden layer weight to obtain an image recognition model;
and inputting the coded feature matrix into the image recognition model to recognize the image to be recognized.
2. The method for recognizing an image according to claim 1, wherein,
the column eigenvalues are eigenvalues which are positioned in the same column as the target eigenvalues in the eigenvalue matrix, positioned on the right side of the target eigenvalues and adjacent to the target eigenvalues;
the row eigenvalues are eigenvalues in the eigenvalue matrix located in the same row as the target eigenvalue, located below the target eigenvalue and adjacent to the target eigenvalue.
3. The image recognition method according to claim 1, wherein before bringing the target eigenvalue a, column eigenvalue b, and row eigenvalue c into a formula, the method comprises:
If the column feature value is null, determining the column feature value as 1;
and if the row characteristic value is null, determining the row characteristic value as 1.
4. The image recognition method according to claim 1, wherein the clustering the weight matrix corresponding to the weight of each hidden layer to obtain the clustered weight matrix corresponding to the weight of each hidden layer includes:
acquiring the number of input neurons/the number of output neurons of the hidden layer;
clustering eigenvalues in a weight matrix corresponding to the hidden layer to obtain a plurality of eigenvectors;
selecting the same number of feature clusters 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.
5. The method of image recognition according to claim 4, wherein determining the clustered weight matrix corresponding to the hidden layer weight based on the clustered feature values comprises:
acquiring a gradient matrix of the hidden layer corresponding to the weight matrix;
Summing gradients corresponding to the feature values in the same feature cluster to obtain a cluster gradient;
summing the cluster characteristic values and the cluster gradients corresponding to the cluster characteristic values to obtain a summation result;
and combining the summation results to obtain a clustered weight matrix corresponding to the hidden layer weight.
6. The method for identifying an image according to claim 4, wherein clustering the eigenvalues in the weight matrix corresponding to the hidden layer to obtain a plurality of feature clusters includes:
randomly selecting a plurality of preparation center points from the characteristic values;
re-determining a plurality of actual center points in the feature values based on distances between the feature values other than as the preliminary center points and the preliminary center points;
calculating the distance between the characteristic value except the actual center point and the actual center point to obtain a calculation result;
and determining the characteristic value belonging to the same cluster with the actual center point based on the calculation result to obtain a characteristic cluster corresponding to the actual center point.
7. An image recognition apparatus, comprising:
the acquisition module is configured to acquire a feature matrix of the image to be identified;
The selection module is configured to select one characteristic value from the characteristic matrix as a target characteristic value a, select 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 select 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;
an encoding module configured to bring the target feature value a, the column feature value b, and the row feature value c into a formulaIn the method, the target characteristic value is coded to obtain a coded target characteristic value a1, one characteristic value is selected again from characteristic values which are not selected as the target characteristic value in the characteristic matrix to serve as the target characteristic value, the column characteristic value and the row characteristic value which correspond to the target characteristic value are selected again, the selected target characteristic value, the selected column characteristic value and the row characteristic value which correspond to the target characteristic value are taken into a formula again, and the target characteristic value is coded again until the characteristic values in the characteristic matrix are all used as the target characteristic value to be coded, and a coded characteristic matrix is obtained;
The identification module is configured to acquire weights of all hidden layers in the pre-trained neural network model; if the weight of the hidden layer is smaller than a weight threshold, removing the hidden layer; acquiring a weight index of the neural network model, wherein the weight index is formed by combining weights of the hidden layers according to the sequence of the hidden layers in the neural network model; 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 so as to generate a neural network model after the hidden layer is removed; acquiring a weight matrix corresponding to each hidden layer weight in the pre-trained neural network model; clustering the weight matrixes corresponding to the weights of the hidden layers to obtain clustered weight matrixes corresponding to the weights of the hidden layers; updating each hidden layer in the neural network model after removing the hidden layer based on the clustered weight matrix corresponding to each hidden layer weight to obtain an image recognition model; and inputting the coded feature matrix into the image recognition model to recognize the image to be recognized.
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 CN113591983A (en) 2021-11-02
CN113591983B true 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
CN113591983A (en) 2021-11-02

Similar Documents

Publication Publication Date Title
WO2022105117A1 (en) Method and device for image quality assessment, computer device, and storage medium
CN111368551B (en) Method and device for determining event main body
CN110489423B (en) Information extraction method and device, storage medium and electronic equipment
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
CN116978011B (en) Image semantic communication method and system for intelligent target recognition
CN113407850A (en) Method and device for determining and acquiring virtual image and electronic equipment
JP2023062150A (en) Character recognition model training, character recognition method, apparatus, equipment, and medium
CN115796310A (en) Information recommendation method, information recommendation device, information recommendation model training device, information recommendation equipment and storage medium
CN115496970A (en) Training method of image task model, image recognition method and related device
CN114817612A (en) Method and related device for calculating multi-modal data matching degree and training calculation model
CN111539287A (en) Method and device for training face image generation model
CN114120454A (en) Training method and device of living body detection model, electronic equipment and storage medium
CN116127925B (en) Text data enhancement method and device based on destruction processing of text
CN112307243B (en) Method and apparatus for retrieving images
CN113591983B (en) Image recognition method and device
CN111767421A (en) Method, device, electronic equipment and computer readable medium for retrieving image
CN116703659A (en) Data processing method and device applied to engineering consultation and electronic equipment
CN113591987B (en) Image recognition method, device, electronic equipment and medium
CN114419327B (en) Image detection method and training method and device of image detection model
CN114707638A (en) Model training method, model training device, object recognition method, object recognition device, object recognition medium and product
CN115116080A (en) Table analysis method and device, electronic equipment and storage medium
CN114238611A (en) Method, apparatus, device and storage medium for outputting information
CN113255824A (en) Method and device for training classification model and data classification
CN107609645B (en) Method and apparatus for training convolutional neural network

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