A text recognition method and recognition device based on lightweight neural network

By enhancing and preprocessing the initially recognized image and using a lightweight text recognition model for inference, the problems of slow text recognition speed and low accuracy in the prior art are solved, and efficient and accurate text recognition effect is achieved.

CN113963151BActive Publication Date: 2025-02-28肖礼全
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111389797.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-19
Publication Date
2025-02-28
Estimated Expiration
2041-11-19

AI Technical Summary

Technical Problem

In the prior art, the speed of recognizing images with text is slower, and the accuracy of image recognition in the dictionary pen environment is low.

Method used

The text recognition method based on lightweight neural network is adopted to enhance and preprocess the initial image to be identified, and the appropriate image to be identified is obtained, and the lightweight text recognition model is used for inference, obtain the word index vector, and finally match it with the dictionary library to obtain the text recognition results.

Benefits of technology

The speed and accuracy of text recognition are improved, the parameters and calculation amount of lightweight text recognition model are reduced, and the inference speed and stability of the model are enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113963151B_ABST
    Figure CN113963151B_ABST
Patent Text Reader

Abstract

The present invention discloses a text recognition method and a recognition device based on a lightweight neural network, which can have the characteristics of high recognition speed and high recognition accuracy. The method comprises: obtaining an initial image to be recognized input by a dictionary pen, and performing image enhancement on the initial image to be recognized to obtain a first image to be recognized; the image to be recognized contains text; preprocessing the first image to be recognized to obtain a second image to be recognized; obtaining a trained lightweight text recognition model, the lightweight text recognition model is used to recognize text in the image; inputting the second image to be recognized into the lightweight text recognition model for inference, and obtaining a word index vector corresponding to the second image to be recognized; matching the word index vector with the text in the dictionary library to obtain a text recognition result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence and image recognition technology, and in particular to a text recognition method and a recognition device based on a lightweight neural network. Background Art

[0002] In the existing text recognition scheme, images with text are generally processed uniformly for model training, and then the text is recognized based on the trained model. However, the structure of the model is mainly composed of ordinary convolution and activation functions, and its recognition speed is slow, and the image recognition accuracy of the dictionary pen environment is low. Summary of the invention

[0003] Based on this, the purpose of the present invention is to solve the problems in the prior art of slow recognition of images with text and low accuracy of image recognition in a dictionary pen environment, and to provide a text recognition method and recognition device based on a lightweight neural network with the characteristics of high recognition speed and high recognition accuracy.

[0004] In a first aspect, an embodiment of the present invention provides a text recognition method based on a lightweight neural network, comprising:

[0005] Acquire an initial image to be recognized input by a dictionary pen, and perform image enhancement on the initial image to be recognized to obtain a first image to be recognized; the image to be recognized contains text;

[0006] Preprocessing the first image to be recognized to obtain a second image to be recognized;

[0007] Obtaining a trained lightweight text recognition model, where the lightweight text recognition model is used to recognize text in an image;

[0008] Inputting the second image to be recognized into the lightweight text recognition model for inference to obtain a word index vector corresponding to the second image to be recognized;

[0009] The word index vector is matched with the characters in the dictionary library to obtain the character recognition result.

[0010] In an embodiment of the present invention, by performing image enhancement on the initial image to be recognized, the contrast and brightness of the image can be effectively enhanced. By using a trained lightweight text recognition model to infer the second image to be recognized, the reasoning speed and stability of the recognized text can be improved, thereby improving the recognition speed and accuracy of the recognized text.

[0011] In a possible design, performing image enhancement processing on the initial image to be recognized to obtain a first image to be recognized includes:

[0012] Adaptively adjust the contrast and image brightness of the initial image to be recognized to obtain the first image to be recognized.

[0013] In a possible design, preprocessing the first image to be recognized to obtain a second image to be recognized includes:

[0014] After normalizing and resizing the first image to be recognized, the second image to be recognized is obtained; the size of the second image to be recognized is consistent with the size of the input image of the lightweight text recognition model.

[0015] In a possible design, the structure of the lightweight text recognition model includes: a lightweight convolution block, a residual block and an activation block;

[0016] Inputting the second image to be recognized into the lightweight text recognition model for inference to obtain a word index vector corresponding to the second image to be recognized, including:

[0017] Inputting the second image to be recognized into the lightweight text recognition model, and performing spatial separation convolution and depth separation convolution calculation on the second image to be recognized by the lightweight convolution block to obtain a first feature image;

[0018] activating the first feature image by using the activation function through the activation block to obtain the activated first feature image;

[0019] The second image to be recognized and the activated first feature image are added through the residual block to obtain a word index vector corresponding to the second image to be recognized.

[0020] In one possible design, the lightweight convolution block includes a spatially separable convolution block and a depth-separable convolution block;

[0021] After performing spatial separation convolution and depth separation convolution on the second image to be recognized by the light convolution block, a first feature image is obtained, including:

[0022] Performing spatial separation convolution calculation on the second image to be identified and the first convolution kernel by means of group convolution through the spatially separable convolution block to obtain a second feature image;

[0023] The second feature image is subjected to depth-separable convolution calculation with a plurality of second convolution kernels through the depth-separable convolution block to obtain the first feature image.

[0024] In a possible design, the spatially separable convolution block performs spatially separated convolution calculation on the second image to be identified and the first convolution kernel in a group convolution manner to obtain a second feature image, including:

[0025] The spatially separable convolution block performs convolution calculations on a plurality of features in the second image to be identified and a plurality of convolution features of the first convolution kernel in a one-to-one correspondence to obtain a plurality of first output features, and the plurality of first output features constitute the second feature image.

[0026] In a possible design, performing depth separation convolution calculation on the second feature image and a plurality of second convolution kernels through the depth separable convolution block to obtain the first feature image includes:

[0027] The second feature image is convolved with multiple second convolution kernels one by one through the depth-wise separable convolution block to obtain multiple second output features, and the multiple second output features constitute the first feature image.

[0028] Compared with the prior art, the technical solution provided by the embodiment of the present invention can effectively reduce the number of parameters and calculation amount of the lightweight text recognition model, and can optimize the various features of the second image to be recognized, thereby improving the reasoning speed and stability of the lightweight text recognition model, and can improve the recognition speed and accuracy of the lightweight text recognition model in recognizing text.

[0029] In a second aspect, an embodiment of the present invention further provides an identification device, including:

[0030] A processing unit is used to obtain an initial image to be recognized input by a dictionary pen, and perform image enhancement on the initial image to be recognized to obtain a first image to be recognized; the image to be recognized contains text; and pre-process the first image to be recognized to obtain a second image to be recognized;

[0031] The recognition unit is used to obtain a trained lightweight text recognition model, where the lightweight text recognition model is used to recognize text in an image; input the second image to be recognized into the lightweight text recognition model for inference to obtain a word index vector corresponding to the second image to be recognized; and match the word index vector with text in a dictionary library to obtain a text recognition result.

[0032] In a possible design, the processing unit is specifically used for:

[0033] Adaptively adjust the contrast and image brightness of the initial image to be recognized to obtain the first image to be recognized.

[0034] In a possible design, the processing unit is specifically used for:

[0035] After normalizing and resizing the first image to be recognized, the second image to be recognized is obtained; the size of the second image to be recognized is consistent with the size of the input image of the lightweight text recognition model.

[0036] In a possible design, the structure of the lightweight text recognition model includes: a lightweight convolution block, a residual block and an activation block; the recognition unit is specifically used for:

[0037] Inputting the second image to be recognized into the lightweight text recognition model, and performing spatial separation convolution and depth separation convolution calculation on the second image to be recognized by the lightweight convolution block to obtain a first feature image;

[0038] activating the first feature image by using the activation function through the activation block to obtain the activated first feature image;

[0039] The second image to be recognized and the activated first feature image are added through the residual block to obtain a word index vector corresponding to the second image to be recognized.

[0040] In a possible design, the lightweight convolution block includes a spatially separable convolution block and a depth-separable convolution block; and the identification unit is specifically used to:

[0041] Performing spatial separation convolution calculation on the second image to be identified and the first convolution kernel by means of group convolution through the spatially separable convolution block to obtain a second feature image;

[0042] The second feature image is subjected to depth-separable convolution calculation with a plurality of second convolution kernels through the depth-separable convolution block to obtain the first feature image.

[0043] In a possible design, the identification unit is specifically used for:

[0044] The spatially separable convolution block performs convolution calculations on a plurality of features in the second image to be identified and a plurality of convolution features of the first convolution kernel in a one-to-one correspondence to obtain a plurality of first output features, and the plurality of first output features constitute the second feature image.

[0045] In a possible design, the identification unit is specifically used for:

[0046] The second feature image is convolved with multiple second convolution kernels one by one through the depth-wise separable convolution block to obtain multiple second output features, and the multiple second output features constitute the first feature image.

[0047] In a third aspect, an embodiment of the present invention further provides an identification device, the identification device comprising: at least one memory and at least one processor;

[0048] The at least one memory is used to store one or more programs;

[0049] When the one or more programs are executed by the at least one processor, the method involved in any possible design of the first aspect described above is implemented.

[0050] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores at least one program; when the at least one program is executed by a processor, the method involved in any possible design of the first aspect above is implemented.

[0051] The beneficial technical effects of the second to fourth aspects can refer to the beneficial technical effects of the first aspect mentioned above, and will not be repeated here.

[0052] For better understanding and implementation, the present invention is described in detail below with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] Figure 1 A flowchart of a text recognition method based on a lightweight neural network provided by an embodiment of the present invention;

[0054] Figure 2 A schematic diagram of a recognition device provided by an embodiment of the present invention adaptively adjusting the contrast and image brightness of an initial image to be recognized to obtain a first image to be recognized;

[0055] Figure 3 A schematic diagram of a process of executing step S104 by an identification device provided in an embodiment of the present invention;

[0056] Figure 4 A schematic diagram of a recognition device provided by an embodiment of the present invention, in which a second feature image is obtained by performing spatial separation convolution calculation on a second image to be recognized and a first convolution kernel through a spatially separable convolution block;

[0057] Figure 5 A schematic diagram of a recognition device provided by an embodiment of the present invention, in which a first feature image is obtained by performing depth separation convolution calculation on a second feature image and a plurality of second convolution kernels through a depth separable convolution block;

[0058] Figure 6 A schematic diagram of the structure of an identification device provided by an embodiment of the present invention;

[0059] Figure 7 A schematic diagram of the structure of another identification device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0060] The directional terms such as up, down, left, right, front, back, front, back, top, bottom, etc. mentioned or may be mentioned in this specification are defined relative to their structure and are relative concepts. Therefore, they may change accordingly according to their different locations and different usage conditions. Therefore, these or other directional terms should not be interpreted as restrictive terms.

[0061] The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of embodiments consistent with some aspects of the present disclosure.

[0062] The terms used in this disclosure are only for the purpose of describing specific embodiments and are not intended to limit the disclosure. The singular forms of "a", "the" and "the" used in this disclosure are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.

[0063] Unless otherwise specified, ordinal numbers such as "first" and "second" in the embodiments of the present invention are used to distinguish multiple objects and are not used to limit the order, timing, priority or importance of the multiple objects.

[0064] The shapes and sizes of various components in the drawings do not reflect the true scale, and are intended only to illustrate the implementations described in the following exemplary embodiments.

[0065] Please refer to Figure 1 The figure is a flow chart of a method for character recognition based on a lightweight neural network provided by an embodiment of the present invention. The method can be applied to a recognition device, which can be a dictionary pen, or a device that interacts with a dictionary pen, which is not limited by the embodiment of the present invention. Figure 1 As shown, the method may include:

[0066] S101, obtaining an initial image to be recognized input by a dictionary pen, and performing image enhancement on the initial image to be recognized to obtain a first image to be recognized.

[0067] In some embodiments, the image to be recognized may include text. For example, the dictionary pen may scan text in a book, a display board, etc. to obtain an image to be recognized that includes the corresponding text.

[0068] In some embodiments, the recognition device may adaptively adjust the contrast and image brightness of the initial image to be recognized to obtain the first image to be recognized.

[0069] For example, taking books as an example, the diversity of book materials, background brightness, and uneven image quality may affect the contrast of the initial image to be recognized obtained by the dictionary pen scanning the text, thereby affecting the accuracy of text recognition. In the embodiment of the present invention, by adaptively adjusting the contrast and image brightness of the initial image to be recognized, the accuracy and generalization of text recognition by the recognition device can be improved. For example, Figure 2 As shown, the maximum pixel value and the minimum pixel value in the initial image to be identified can be counted to obtain the pixel value range of the initial image to be identified, and then the pixel value range of the initial image to be identified is mapped to the 0-255 pixel grayscale value range to obtain the first image to be identified, thereby effectively enhancing the image contrast and image brightness.

[0070] S102: pre-process the first image to be recognized to obtain a second image to be recognized.

[0071] In some embodiments, the recognition device may normalize and resize the first image to be recognized, and obtain a second image to be recognized whose size is consistent with the size of the input image of the lightweight text recognition model, so as to facilitate the subsequent use of the lightweight text recognition model to perform text recognition on the second image to be recognized. For example, the recognition device may normalize the first image to be recognized, obtain the normalized first image to be recognized, and then resize the normalized first image to be recognized to be consistent with the size of the input image of the lightweight text recognition model to obtain the second image to be recognized. Alternatively, the recognition device may resize the first image to be recognized to be consistent with the size of the input image of the lightweight text recognition model, obtain the adjusted first image to be recognized, and then normalize the adjusted first image to be recognized to obtain the second image to be recognized.

[0072] S103: Obtain a trained lightweight text recognition model, where the lightweight text recognition model is used to recognize text in an image.

[0073] In the specific implementation process, before the recognition device executes step S103, the recognition device can first construct a lightweight text recognition model framework. For example, the lightweight text recognition module framework can be constructed using lightweight convolution blocks, residual blocks, and activation blocks. After that, an image containing text obtained by scanning with a dictionary pen after preprocessing (such as binarization, image enhancement, etc.) is obtained. After training the lightweight text recognition model framework, the lightweight text recognition model can be obtained, and the lightweight text recognition model can be stored, such as in a local memory or in the cloud. It can be understood that the structure of the lightweight text recognition model includes: lightweight convolution blocks, residual blocks, and activation blocks, and the lightweight text recognition model can be tuned using images obtained by scanning with a dictionary pen.

[0074] S104: Input the second image to be recognized into the lightweight text recognition model for inference to obtain a word index vector corresponding to the second image to be recognized.

[0075] In some embodiments, in combination Figure 1-3 As shown, during the process of the identification device executing step S104, the following steps may be performed:

[0076] S201. Input a second image to be recognized into a lightweight text recognition model, and perform spatial separation convolution and depth separation convolution calculations on the second image to be recognized through a lightweight convolution block of the lightweight text recognition model to obtain a first feature image.

[0077] In some embodiments, the lightweight convolution block of the lightweight text recognition model may include a spatially separable convolution block and a depthwise separable convolution block.

[0078] In some embodiments, the recognition device may perform spatial separation convolution calculation on the second image to be recognized and the first convolution kernel by means of group convolution through the spatially separable convolution block to obtain the second feature image. For example, the recognition device may convolve multiple features in the second image to be recognized with multiple convolution features of the first convolution kernel one by one through the spatially separable convolution block to obtain multiple first output features, and the multiple first output features constitute the second feature image.

[0079] For example, through the spatially separable convolution block, each feature of the second image to be identified can be mapped to a convolution kernel channel, in which a feature of the second image to be identified and a convolution feature of the first convolution kernel can be used to perform convolution calculation. The calculations between the convolution kernel channels do not interfere with each other. For example, Figure 4 As shown, taking the size of the second image to be identified as 8*8*3 and the first convolution kernel as 3*3*3 as an example, after the second image to be identified and the first convolution kernel are spatially separated and convolved, the size of the second feature image obtained can be 6*6*3. Specifically, after feature a is convolved with convolution feature a, the first output feature a can be obtained, after feature b is convolved with convolution feature b, the first output feature b can be obtained, and after feature c is convolved with convolution feature c, the first output feature c can be obtained.

[0080] Exemplarily, if the size of the second image to be identified is (w+i-1)*(h+j-1)*m, the size of the first convolution kernel is i*j*m, and the size of the second feature image is w*h*m, the calculation formula of the spatially separable convolution block can be represented as follows:

[0081]

[0082] Among them, Output w,h,mRepresented as the second feature image, C i,j,m Represented as the first convolution kernel, Input w+i-1,h+j-1,m It is represented as the second image to be recognized.

[0083] In the embodiment of the present invention, by performing spatial separation convolution calculation on the second image to be identified, each feature of the second image to be identified can be optimized, so that the depth information of the features of the second feature image can be effectively used.

[0084] In some embodiments, the recognition device may perform depth separation convolution calculation on the second feature image and multiple second convolution kernels through the depth separable convolution block to obtain the first feature image. For example, the recognition device may perform convolution calculation on the second feature image and multiple second convolution kernels one by one to obtain multiple second output features, and the multiple second output features constitute the first feature image.

[0085] For example, through the depth-separable convolution block, multiple convolution calculations can be performed on the pixels at the same position of the second feature image, that is, each channel can correspond to a convolution kernel channel, in which the second feature image and a second convolution kernel can be used to perform convolution calculations, and multiple second output features can be obtained. Among them, the pixels of the same feature of the second feature image do not interfere with each other. For example, Figure 5 As shown, taking the second feature image size of 6*6*3, the second convolution kernel of 1*1*3, and the multiple second convolution kernels including 32 second convolution kernels as an example, after the second feature image and the multiple second convolution kernels are subjected to depth separation convolution, the size of the obtained first feature image can be 6*6*32. Specifically, the second feature image can obtain the first second output feature after convolution calculation with the first second convolution kernel, the second feature image can obtain the second second output feature after convolution calculation with the second second convolution kernel, and so on, the second feature image can obtain the 32nd second output feature after convolution calculation with the 32nd second convolution kernel.

[0086] Exemplarily, if the size of the second feature image is (w+i-1)*(h+j-1)*m, the size of the second convolution kernel is i*j*m, the multiple second convolution kernels include n second convolution kernels, and the size of the first feature image is w*h*n, the calculation formula of the spatially separable convolution block can be represented by the following formula (2):

[0087]

[0088] Among them, Output w,h,n Represented as the first feature image, C i,j,m,n Represented as n second convolution kernels, Input w+i-1,h+j-1,m Represented as the second feature image.

[0089] In an embodiment of the present invention, by using lightweight first convolution kernels and second convolution kernels in spatially separable convolution blocks and depth-separable convolution blocks, the number of parameters and the amount of calculation of the lightweight text recognition model can be effectively reduced, and further, the reasoning speed of the lightweight text recognition model can be improved.

[0090] S202, activating the first feature image by using an activation function through an activation block of the lightweight text recognition model to obtain an activated first feature image.

[0091] In the specific implementation process, the activation function may include but is not limited to Sigmoid activation function, Softmax function, tanH function, ReLu function and softplus function. In the embodiment of the present invention, it is not limited to what the activation function is specifically, and it can be set according to actual needs.

[0092] S203 . Add the second image to be recognized and the activated first feature image through the residual block of the lightweight text recognition model to obtain a word index vector corresponding to the second image to be recognized.

[0093] In the specific implementation process, due to the use of lightweight convolution in the lightweight convolution block, there may be a certain degree of loss in the first feature image. In an embodiment of the present invention, by using a residual block, the input image before the input convolution (i.e., the second image to be recognized) and the output image after the convolution (i.e., the first feature image after activation) are added together. This can compensate for the feature loss caused by the lightweight convolution, and further improve the accuracy and stability of the lightweight text recognition model in recognizing text.

[0094] S105: Match the word index vector with the text in the dictionary to obtain a text recognition result.

[0095] In some implementations, the recognition device may pre-store the dictionary library. After obtaining the word index vector, the recognition device may match the word index vector with the text in the dictionary library, determine the text corresponding to the word index vector, and thus obtain the text recognition result of the recognized text.

[0096] From the above description, it can be seen that in the technical solution provided in the embodiment of the present invention, compared with the prior art, the reasoning speed and stability of the lightweight text recognition model in recognizing text can be improved, thereby improving the recognition speed and recognition accuracy of the lightweight text recognition model in recognizing text.

[0097] Based on the same inventive concept, the embodiment of the present invention also provides an identification device, such as Figure 6 As shown, the identification device 300 may include:

[0098] The processing unit 301 is used to obtain an initial image to be recognized input by the dictionary pen, and perform image enhancement on the initial image to be recognized to obtain a first image to be recognized; the image to be recognized contains text; and pre-process the first image to be recognized to obtain a second image to be recognized;

[0099] The recognition unit 302 is used to obtain a trained lightweight text recognition model, which is used to recognize text in an image; input the second image to be recognized into the lightweight text recognition model for inference to obtain a word index vector corresponding to the second image to be recognized; match the word index vector with the text in the dictionary library to obtain a text recognition result.

[0100] In a possible design, the processing unit 301 is specifically configured to:

[0101] Adaptively adjust the contrast and image brightness of the initial image to be recognized to obtain the first image to be recognized.

[0102] In a possible design, the processing unit 301 is specifically configured to:

[0103] After normalizing and resizing the first image to be recognized, the second image to be recognized is obtained; the size of the second image to be recognized is consistent with the size of the input image of the lightweight text recognition model.

[0104] In a possible design, the structure of the lightweight text recognition model includes: a lightweight convolution block, a residual block and an activation block; the recognition unit 302 is specifically used for:

[0105] Inputting the second image to be recognized into the lightweight text recognition model, and performing spatial separation convolution and depth separation convolution calculation on the second image to be recognized by the lightweight convolution block to obtain a first feature image;

[0106] activating the first feature image by using the activation function through the activation block to obtain the activated first feature image;

[0107] The second image to be recognized and the activated first feature image are added through the residual block to obtain a word index vector corresponding to the second image to be recognized.

[0108] In a possible design, the lightweight convolution block includes a spatially separable convolution block and a depth-separable convolution block; and the identification unit 302 is specifically used to:

[0109] Performing spatial separation convolution calculation on the second image to be identified and the first convolution kernel by means of group convolution through the spatially separable convolution block to obtain a second feature image;

[0110] The second feature image is subjected to depth-separable convolution calculation with a plurality of second convolution kernels through the depth-separable convolution block to obtain the first feature image.

[0111] In a possible design, the identification unit 302 is specifically configured to:

[0112] The spatially separable convolution block performs convolution calculations on a plurality of features in the second image to be identified and a plurality of convolution features of the first convolution kernel in a one-to-one correspondence to obtain a plurality of first output features, and the plurality of first output features constitute the second feature image.

[0113] In a possible design, the identification unit 302 is specifically configured to:

[0114] The second feature image is convolved with multiple second convolution kernels one by one through the depth-wise separable convolution block to obtain multiple second output features, and the multiple second output features constitute the first feature image.

[0115] The identification device 300 in the embodiment of the present invention is similar to the above Figure 1 The lightweight neural network-based text recognition method shown is an invention based on the same concept. Through the above detailed description of the lightweight neural network-based text recognition method, those skilled in the art can clearly understand the implementation process of the recognition device 300 in this embodiment, so for the sake of brevity of the specification, it will not be repeated here.

[0116] Based on the same inventive concept, the embodiment of the present invention also provides an identification device, such as Figure 7 As shown, the identification device 400 may include: at least one memory 401 and at least one processor 402. Among them:

[0117] At least one memory 401 is used to store one or more programs.

[0118] When one or more programs are executed by at least one processor 402, the above Figure 1 The text recognition method based on lightweight neural network is shown.

[0119] The identification device 400 may also optionally include a communication interface, and the communication interface is used to communicate with external devices and exchange data.

[0120] It should be noted that the memory 401 may include a high-speed RAM memory, and may also include a nonvolatile memory (nonvolatile memory), such as at least one disk memory.

[0121] In a specific implementation process, if the memory 401, the processor 402 and the communication interface are integrated on a chip, the memory 401, the processor 402 and the communication interface can communicate with each other through an internal interface. If the memory 401, the processor 402 and the communication interface are implemented independently, the memory 401, the processor 402 and the communication interface can be connected to each other through a bus and communicate with each other.

[0122] Based on the same inventive concept, an embodiment of the present invention further provides a computer-readable storage medium, which can store at least one program. When the at least one program is executed by a processor, the above Figure 1 The text recognition method based on lightweight neural network is shown.

[0123] It should be understood that a computer-readable storage medium is any data storage device that can store data or programs, which can then be read by a computer system. Examples of computer-readable storage media include read-only memory, random access memory, CD-ROM, HDD, DVD, magnetic tape, and optical data storage devices, etc.

[0124] The computer readable storage medium can also be distributed over network coupled computer systems so that the computer readable code is stored and executed in a distributed fashion.

[0125] The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, radio frequency (RF), etc., or any suitable combination of the above.

[0126] The above-mentioned embodiments only express several implementation methods of the present invention, and the description is relatively specific and detailed, but it cannot be understood as limiting the scope of the invention patent. It should be pointed out that for ordinary technicians in this field, several modifications and improvements can be made without departing from the concept of the present invention, which all belong to the protection scope of the present invention.

Claims

1. A text recognition method based on a lightweight neural network, characterized in that: include: Acquire an initial image to be recognized input by the dictionary pen, and perform image enhancement on the initial image to be recognized to obtain a first image to be recognized; The image to be recognized contains text; Preprocessing the first image to be recognized to obtain a second image to be recognized; Obtaining a trained lightweight text recognition model, where the lightweight text recognition model is used to recognize text in an image; Inputting the second image to be recognized into the lightweight text recognition model for inference to obtain a word index vector corresponding to the second image to be recognized; Matching the word index vector with the characters in the dictionary to obtain a character recognition result; The structure of the lightweight text recognition model includes: a lightweight convolution block, a residual block and an activation block, and the lightweight convolution block includes a spatially separable convolution block and a depth-separable convolution block; the second image to be recognized is input into the lightweight text recognition model for inference, and a word index vector corresponding to the second image to be recognized is obtained, including: Inputting the second image to be recognized into the lightweight text recognition model, performing spatial separation convolution calculation on the second image to be recognized and the first convolution kernel by means of group convolution through the spatially separable convolution block of the lightweight convolution block, so as to obtain a second feature image; performing depth separation convolution calculation on the second feature image and a plurality of second convolution kernels by means of the depth separable convolution block of the lightweight convolution block, so as to obtain a first feature image; activating the first feature image by using the activation function through the activation block to obtain the activated first feature image; The second image to be recognized and the activated first feature image are added through the residual block to obtain a word index vector corresponding to the second image to be recognized.

2. The method according to claim 1, characterized in that Performing image enhancement processing on the initial image to be identified to obtain a first image to be identified, including: Adaptively adjust the contrast and image brightness of the initial image to be recognized to obtain the first image to be recognized.

3. The method according to claim 1, characterized in that Preprocessing the first image to be recognized to obtain a second image to be recognized includes: After normalizing and resizing the first image to be recognized, the second image to be recognized is obtained; the size of the second image to be recognized is consistent with the size of the input image of the lightweight text recognition model.

4. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: performing spatial separation convolution calculation on the second image to be identified and the first convolution kernel by using the spatially separable convolution block in a group convolution manner to obtain a second feature image, including: The spatially separable convolution block performs convolution calculations on a plurality of features in the second image to be identified and a plurality of convolution features of the first convolution kernel in a one-to-one correspondence to obtain a plurality of first output features, and the plurality of first output features constitute the second feature image.

5. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: performing a depth-separable convolution calculation on the second feature image and a plurality of second convolution kernels through the depth-separable convolution block to obtain the first feature image, including: The second feature image is convolved with multiple second convolution kernels one by one through the depth-wise separable convolution block to obtain multiple second output features, and the multiple second output features constitute the first feature image.

6. An identification device, characterized in that: include: A processing unit, used for acquiring an initial image to be recognized input by the dictionary pen, and performing image enhancement on the initial image to be recognized to obtain a first image to be recognized; The image to be recognized contains text; preprocessing the first image to be recognized to obtain a second image to be recognized; A recognition unit is used to obtain a trained lightweight text recognition model, wherein the lightweight text recognition model is used to recognize text in an image; input the second image to be recognized into the lightweight text recognition model for inference to obtain a word index vector corresponding to the second image to be recognized; match the word index vector with text in a dictionary library to obtain a text recognition result; The structure of the lightweight text recognition model includes: a lightweight convolution block, a residual block and an activation block, and the lightweight convolution block includes a spatially separable convolution block and a depth-separable convolution block; the recognition unit is used to input the second image to be recognized into the lightweight text recognition model for inference, and obtain the word index vector corresponding to the second image to be recognized, specifically for: Inputting the second image to be recognized into the lightweight text recognition model, performing spatial separation convolution calculation on the second image to be recognized and the first convolution kernel by means of group convolution through the spatially separable convolution block of the lightweight convolution block, so as to obtain a second feature image; performing depth separation convolution calculation on the second feature image and a plurality of second convolution kernels by means of the depth separable convolution block of the lightweight convolution block, so as to obtain a first feature image; activating the first feature image by using the activation function through the activation block to obtain the activated first feature image; The second image to be recognized and the activated first feature image are added through the residual block to obtain a word index vector corresponding to the second image to be recognized.

7. An identification device, characterized in that: The identification device includes: at least one memory and at least one processor; The at least one memory is used to store one or more programs; When the one or more programs are executed by the at least one processor, the method according to any one of claims 1 to 5 is implemented.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores at least one program; when the at least one program is executed by a processor, the method according to any one of claims 1 to 5 is executed.

Citation Information

Patent Citations

  • Image character recognition method and system, electronic equipment and storage medium

    CN111832564A

  • Automatic driving direction prediction method based on lightweight neural network

    CN113076815A