A text recognition method, device, computer equipment, storage medium and product

By training the neural network model to identify the text area information in the image, the problem of OCR being unable to identify text categories is solved, the accurate recognition and classification of image text is achieved, and the recognition efficiency and accuracy are improved.

CN117727037BActive Publication Date: 2024-10-22SHUXING TECH (BEIJING) CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202311301253.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-10-09
Publication Date
2024-10-22
Estimated Expiration
2043-10-09

AI Technical Summary

Technical Problem

Existing OCR text recognition technology cannot effectively identify text categories in images, resulting in a lack of specific classification information when identifying text information in images, affecting the accuracy of scene recognition, scene recognition, and product content recognition.

Method used

By obtaining a sample image data set, extracting text area information and inputting it into a preset neural network model for training, a text recognition model is generated to identify text and text categories in images, and a convolutional neural network model is used to combine recurrent layers and bidirectional depth The learning module extracts text feature information.

Benefits of technology

It achieves accurate recognition and classification of text in images, improves the accuracy and efficiency of text recognition, and can identify different categories of text information in different scenarios, reducing unnecessary recognition workload and improving user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117727037B_ABST
    Figure CN117727037B_ABST
Patent Text Reader

Abstract

The embodiments of the present application disclose a text recognition method, apparatus, computer equipment, storage medium and product, the method comprising: obtaining a sample image data set, the sample image data set comprising a plurality of sample images, each sample image comprising text information and a text category label added for each text information; obtaining one or more text area images in each sample image, and obtaining area information of each text area image in the corresponding sample image, the area information comprising position information and / or size information; inputting each text area image, each area information and each text category label into a preset neural network model for training to obtain a text recognition model; obtaining an image to be processed, and inputting the image to be processed into the text recognition model to obtain the text and text category of the image to be processed, which can effectively identify the text and text category in the image and improve the accuracy of text recognition.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image recognition technology, and in particular to a text recognition method, device, computer equipment, storage medium and product. Background Art

[0002] With the development of computer technology, the application of image recognition is becoming more and more extensive. For example, most images such as note pictures, video screenshots, advertising pictures, and product pictures contain text. These text recognitions have a great auxiliary effect on scene recognition, scene recognition, product content recognition, search recommendation, etc. At present, the main method for text recognition in images is to recognize the text information in the image through optical character recognition (OCR). However, although OCR text recognition can recognize the text information in the image, it does not know the specific text category of the recognized text information. For example, OCR recognizes two texts from an image, namely: 622***5541, Guangdong City***, and does not know that the first text represents the bank card number and the second text represents the household registration address. Therefore, it is very important to recognize text in images more effectively. Summary of the invention

[0003] The embodiments of the present application provide a text recognition method, apparatus, computer equipment, storage medium and product, which can effectively recognize text and text categories in an image and improve the accuracy of text recognition.

[0004] In a first aspect, an embodiment of the present application provides a text recognition method, comprising:

[0005] Acquire a sample image data set, wherein the sample image data set includes a plurality of sample images, each of which includes text information and a text category label added to each text information;

[0006] Acquire one or more text area images in each of the sample images, and acquire area information of each of the one or more text area images in the corresponding sample images, wherein the area information includes position information and / or size information;

[0007] Inputting each of the text area images, the area information of each of the text area images in the corresponding sample images, and the text category label of each text information corresponding to each of the sample images into a preset neural network model for training to obtain a text recognition model;

[0008] An image to be processed is acquired, and the image to be processed is input into the text recognition model to obtain text information of the image to be processed, wherein the text information includes text and text category.

[0009] In a second aspect, an embodiment of the present application provides a text recognition device, including:

[0010] A first acquisition unit is used to acquire a sample image data set, where the sample image data set includes a plurality of sample images, each of which includes text information and a text category label added to each text information;

[0011] a second acquisition unit, configured to acquire one or more text region images from each of the sample images, and acquire region information of each of the one or more text region images in each corresponding sample image, wherein the region information includes position information and / or size information;

[0012] A training unit, used for inputting the text area images, the area information of the text area images in the corresponding sample images, and the text category label of each text information corresponding to the sample images into a preset neural network model for training to obtain a text recognition model;

[0013] The recognition unit is used to obtain the image to be processed, and input the image to be processed into the text recognition model to obtain text information of the image to be processed, wherein the text information includes text and text category.

[0014] In a third aspect, an embodiment of the present application provides a computer device, comprising: a processor and a memory, wherein the processor is used to execute the method described in the first aspect above.

[0015] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, in which program instructions are stored, and when the program instructions are executed, the method described in the first aspect above is implemented.

[0016] In a fifth aspect, an embodiment of the present application discloses a computer program product or a computer program, which includes program instructions, and when the program instructions are executed by a processor, the method described in the first aspect is implemented.

[0017] The embodiment of the present application can obtain a sample image data set, which includes multiple sample images, each sample image includes text information and a text category label added for each text information; obtain one or more text area images in each sample image, and obtain the area information of each text area image in the corresponding sample image, and the area information includes position information and / or size information; input each text area image, the area information of each text area image in the corresponding sample image, and the text category label of each text information corresponding to each sample image into a preset neural network model for training to obtain a text recognition model; input the image to be processed into the text recognition model to obtain the text and text category of the image to be processed. In this way, the text and text category in the image can be effectively identified, which helps to improve the accuracy of text recognition. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0019] Figure 1 It is a flowchart of a text recognition method provided in an embodiment of the present application;

[0020] Figure 2 is a schematic diagram of a text area image provided in an embodiment of the present application;

[0021] Figure 3 It is a structural schematic diagram of a convolutional neural network model provided in an embodiment of the present application;

[0022] Figure 4 is a schematic diagram of text recognition provided by an embodiment of the present application;

[0023] Figure 5 is a flowchart of another text recognition method provided in an embodiment of the present application;

[0024] Figure 6 is a schematic diagram of a model training based on regional information provided in an embodiment of the present application;

[0025] Figure 7 It is a schematic diagram of a structure for determining the value of a loss function;

[0026] Figure 8 It is a flowchart of another text recognition method provided in an embodiment of the present application;

[0027] Fig. 9is a structural schematic diagram of a text recognition device provided in an embodiment of the present application;

[0028] Fig.10 It is a structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0029] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0030] This application proposes a text recognition method, which can be applied to various scenarios of recognizing text from images (such as note pictures, video screenshots, advertising pictures, product pictures, etc.). By recognizing text from images, it plays an auxiliary role in scenario recognition, scene recognition, product content recognition, search recommendation, etc.

[0031] The present application obtains a sample image data set, which includes multiple sample images, each of which includes text information and a text category label added for each text information; obtains one or more text area images in each sample image, and obtains area information of each text area image in the corresponding sample image, wherein the area information includes position information and / or size information; inputs each text area image, the area information of each text area image in the corresponding sample image, and the text category label of each text information corresponding to each sample image into a preset neural network model for training to obtain a text recognition model; inputs the image to be processed into the text recognition model to obtain the text and text category of the image to be processed. In this way, the text and text category in the image can be effectively identified, which helps to improve the accuracy of text recognition.

[0032] The text recognition method provided in the embodiments of the present application can be applied to a text recognition device, which can be set in a computer device. In some embodiments, the computer device can include but is not limited to smart phones, tablet computers, laptop computers, desktop computers, in-vehicle smart terminals, smart watches and other smart terminal devices.

[0033] The text recognition method provided in the embodiment of the present application is schematically described below with reference to the accompanying drawings.

[0034] For details, please see Figure 1 , Figure 1It is a flowchart of a text recognition method provided in an embodiment of the present application. The text recognition method in the embodiment of the present application can be executed by a text recognition device, wherein the text recognition device can be set in a computer device.

[0035] S101: Acquire a sample image dataset, where the sample image dataset includes a plurality of sample images, each of which includes text information and a text category label added to each of the text information.

[0036] In an embodiment of the present application, a computer device may obtain a sample image data set, the sample image data set including a plurality of sample images, each sample image including text information and a text category label added to each text information. In some embodiments, the text category label may include but is not limited to any one or more of characters such as words, numbers, letters, etc., and the text category label is used to indicate the category of the text information in the corresponding sample image, for example, category one of the text category label includes bank name, signboard name, name, etc.

[0037] S102: Acquire one or more text region images in each sample image, and acquire region information of each text region image in the one or more text region images in the corresponding sample image, where the region information includes position information and / or size information.

[0038] In an embodiment of the present application, a computer device can obtain one or more text area images in each sample image, and obtain area information of each text area image in the one or more text area images in the corresponding sample images, and the area information may include position information and / or size information, wherein the position information may include but is not limited to coordinate information, longitude and latitude information, etc., and the size information may include but is not limited to one or more information such as length, width, height, and area.

[0039] In one embodiment, the area information includes position information. When a computer device obtains the area information of each text area image in one or more text area images in a corresponding sample image, it can obtain the coordinate information of each text area image in the corresponding sample image; and determine the position information of each text area image in the corresponding sample image based on the coordinate information of each text area image in the corresponding sample image.

[0040] In one embodiment, when a computer device obtains a sample image including multiple text area images, it can obtain the coordinate information of each text area image in the multiple text area images in the sample image, and the length, width, height, and area of ​​the text area image.

[0041] In some embodiments, the coordinate information includes vertex coordinate information of each text area image in each corresponding sample image, and the vertex coordinate information is determined according to a coordinate system established with the geometric center of the image area of ​​each text area image as the origin. In some embodiments, the vertex coordinate information may include the upper left vertex coordinate information and the lower right vertex coordinate information of the image area where each text area image is located in the coordinate system, wherein the upper left vertex coordinate and the lower right vertex coordinate are determined with the origin of the coordinate system as the midpoint (i.e., the reference point), i.e., the upper left vertex coordinate is in the area between the positive X coordinate and the positive Y coordinate, and the lower right vertex coordinate is in the area between the negative X coordinate and the positive Y coordinate, wherein the upper left vertex coordinate information includes the X coordinate and the Y coordinate of the upper left vertex, and the lower right vertex coordinate information includes the X coordinate and the Y coordinate of the lower right vertex. For example, the text area image is a regular rectangular text area, and the rectangular text area is formed and cropped by the upper left point (x1, y1) and the lower right point (x2, y2).

[0042] In some embodiments, the vertex coordinate information may include the upper left vertex coordinate information, lower left vertex coordinate information, upper right vertex coordinate information and lower right vertex coordinate information of the image area where each text area image is located in the coordinate system. Figure 2 Take this as an example to illustrate: Figure 2 is a schematic diagram of a text area image provided by an embodiment of the present application, such as Figure 2 As shown, the vertex coordinate information is determined based on a coordinate system established with the geometric center 22 of the image area 21 of the text area image as the origin, and the vertex coordinate information includes upper left vertex coordinate information 231, lower left vertex coordinate information 232, upper right vertex coordinate information 233 and lower right vertex coordinate information 234.

[0043] In one embodiment, the area information includes size information. When the computer device obtains the area information of the text area image in each sample image corresponding to each sample image, it can determine the image height and image width of each text area image in the corresponding sample image; determine the area of ​​each text area image according to the image height and image width; and determine the image height, image width and area of ​​each text area image as the size information of each text area image in the corresponding sample image.

[0044] In one implementation, when determining the area of ​​each text region image according to the image height and image width, the computer device may calculate the product of the image height and image width of each text region image, and determine the product of the image height and image width of each text region image as the area of ​​each corresponding text region image. Figure 2For example, assume that the computer device determines that the image height of the text region image 20 in the corresponding sample image is h and the image width is w; and determines the area of ​​the text region image 20 as h*w according to the image height h and the image width w.

[0045] In one embodiment, the area information includes position information and size information. When the computer device obtains the area information of the text area image in each sample image in the corresponding sample image, it can obtain the coordinate information of each text area image in the corresponding sample image; determine the position information of each text area image according to the coordinate information of each text area image in the corresponding sample image, determine the image height and image width of each text area image in the corresponding sample image; determine the area of ​​each text area image according to the image height and image width; determine the image height, image width and area of ​​each text area image as the size information of each text area image in the corresponding sample image. In this way, the embodiment of the present application helps to more accurately identify the area where the text information in the sample image is located.

[0046] In one embodiment, before acquiring one or more text area images in each sample image, the computer device may acquire target scene information and select one or more text area images from each sample image according to the target scene. In some embodiments, the target scene information may be information of any customized scene pre-entered by the user, including but not limited to scenes such as data recognition and data query, such as a scene of user address query, a scene of bank category query, a scene of commodity category recognition, etc.

[0047] In one embodiment, when a computer device selects one or more text area images from each sample image according to a target scene, it can determine data information associated with the target scene according to the target scene, and select one or more text area images corresponding to the data information associated with the target scene from each sample image.

[0048] For example, assuming that the target scene is a user address query scene, the computing device can determine the user information and address information associated with the user address query scene based on the user address query scene, and select one or more text area images corresponding to the user information and address information from each sample image.

[0049] For another example, assuming that the target scenario is a bank category query scenario, the computing device can determine information such as the bank logo and bank name based on the bank category query scenario, and select one or more text area images associated with the bank logo, bank name and other information from each sample image.

[0050] For another example, assuming that the target scene is a scene of product category recognition, the computing device can determine information such as the product name, product shape, product color, etc. based on the scene of product category recognition, and select one or more text area images corresponding to the product name, product shape, product color, etc. from each sample image.

[0051] The embodiment of the present application selects one or more text area images corresponding to the target scene from the sample image in combination with the target scene, so that the text area image corresponding to the target scene can be identified from the sample image more quickly and accurately, which helps to train a text recognition model that can recognize the text information required in different scenarios, thereby improving the accuracy and efficiency of the text recognition model.

[0052] S103: Input each text area image, the area information of each text area image in the corresponding sample image, and the text category label of each text information corresponding to each sample image into a preset neural network model for training to obtain a text recognition model.

[0053] In the embodiment of the present application, the computer device can input each text area image, the area information of each text area image in the corresponding sample image, and the text category label of each text information corresponding to each sample image into a preset neural network model for training to obtain a text recognition model. In some embodiments, the preset neural network model may include but is not limited to a convolutional neural network model (Convolutional Recurrent Neural Network, CRNN), etc. Further, the recognition process of the convolutional neural network model is as follows: Figure 3 As shown, Figure 3 is a structural diagram of a convolutional neural network model provided in an embodiment of the present application, such as Figure 3 As shown, the convolutional neural network model includes a convolution layer 31, a recursive layer 32 and an output layer 33 (i.e., a recognition layer). The image 34 to be recognized including the text state is input into the convolution layer 31 to obtain a convolution feature map 311, and the convolution feature map 311 is further input into the recursive layer 32 to obtain a feature vector 321 (i.e., a feature sequence). The feature vector 321 is input into a bidirectional long short-term memory network (LSTM, Long Short-Term Memory) module 322 of bidirectional deep learning in the recursive layer 32, and the output data of the LSTM of the bidirectional deep learning is input into the output layer 33 to recognize and obtain the text 331 "state" in the image 34 to be recognized.

[0054] In one embodiment, when a computer device inputs each text area image, the area information of each text area image in the corresponding sample image, and the text category label of each text information corresponding to each sample image into a preset neural network model for training to obtain a text recognition model, it can extract text image feature information from each text area image; extract regional feature information from the regional information of each text area image; determine the text category label of each text area image according to the text category label of each text information corresponding to each sample image; and input the extracted text image feature information, regional feature information, and text category label of each text area image into a preset neural network model for training to obtain the text recognition model.

[0055] In one embodiment, when a computer inputs each text area image, the area information of each text area image in the corresponding sample image, and the text category label of each text information corresponding to each sample image into a preset neural network model for training to obtain a text recognition model, it can obtain target scene information and extract scene feature information from the target scene information; further extract text image feature information from each text area image; extract region feature information from the region information of each text area image; determine the text category label of each text area image according to the text category label of each text information corresponding to each sample image; input the extracted scene feature information, each text image feature information, each region feature information, and the text category label of each text area image into a preset neural network model for training to obtain the text recognition model.

[0056] By introducing scene information to train the text recognition model, the text information in different scenes can be accurately and efficiently recognized through the text recognition model.

[0057] S104: Acquire an image to be processed, and input the image to be processed into the text recognition model to obtain text information of the image to be processed, where the text information includes text and text category.

[0058] In an embodiment of the present application, a computer device may acquire an image to be processed, and input the image to be processed into the text recognition model to obtain text information of the image to be processed, where the text information includes text and text category.

[0059] In one embodiment, a computer device can obtain a text area image and area information of the text area image in an image to be processed, where the area information of the text area image in the image to be processed may include location information and / or size information of the text area, and input the text area image and area information of the text area image of the image to be processed into the text recognition model to obtain the text and text category of the image to be processed.

[0060] Specifically Figure 4 For example, Figure 4 is a schematic diagram of text recognition provided by an embodiment of the present application, such as Figure 4 As shown, it is assumed that the area information 42 of the text area image is obtained from the image to be processed 41, and the image to be processed 41 and the text area information 42 of the text area image of the image to be processed 41 are input into the text recognition model 43, and the text 44 of the image to be processed such as "Qianmen Dashilan Main Store" and the text category 45 of the text 44 such as "shop sign" are recognized.

[0061] The embodiments of the present application help to select corresponding text according to text categories in different recognition scenarios by identifying text and text categories in the image to be processed, so that users can quickly and accurately obtain corresponding text in different recognition scenarios.

[0062] In one embodiment, after the text recognition model identifies the text and text category of the image to be processed, the computer device can generate prompt information based on the text and text category of the image to be processed. The prompt information is used to indicate each text and the text category corresponding to each text, so that users can view it more conveniently and quickly, thereby improving the user experience.

[0063] In one embodiment, the computer device can obtain the target scene information corresponding to the image to be processed, and input the target scene information corresponding to the image to be processed and the image to be processed into the text recognition model to obtain the text and text category of the image to be processed in the target scene.

[0064] In one embodiment, when the computer device inputs the target scene information corresponding to the image to be processed and the image to be processed into the text recognition model, it can determine one or more text area images corresponding to the target scene information corresponding to the image to be processed from the image to be processed based on the target scene information corresponding to the image to be processed, and obtain the area information (i.e., position information and / or size information) of each text area image in the image to be processed, and further input each text area image and the area information of each text area image in the image to be processed into the text recognition model to identify the text and text category required by the image to be processed in the target scene.

[0065] by Figure 4For example, assuming that the target scene information corresponding to the image to be processed is a store name, the computer device can determine a text area image 41 corresponding to the store name corresponding to the image to be processed from the image to be processed, and obtain the area information 42 of the text area image 41 in the image to be processed, and further input the text area image 41 and the area information 42 of the text area image 41 in the image to be processed into the text recognition model 43, and identify the text 44 "Qianmen Dashilan Headquarters" and the text category 45 "Store Sign" required by the image to be processed in the store name recognition scenario.

[0066] The embodiment of the present application recognizes the image to be processed by introducing a text recognition model obtained by scene information training, which can realize the recognition of different categories of text in the same image to be processed in different scenes, avoid recognizing text information that is not needed in a certain scene, reduce the recognition workload, and improve the efficiency and accuracy of text recognition.

[0067] In one embodiment, after the computer device identifies the text and text category of the image to be processed in the target scene through a text recognition model, the computer device can generate prompt information based on the text and text category of the image to be processed in the target scene. The prompt information is used to indicate the various texts of the image to be processed in the target scene and the text category corresponding to each text, so that users can view it more conveniently and quickly, thereby improving the user experience.

[0068] The embodiment of the present application can obtain a sample image data set, which includes multiple sample images, each sample image includes text information and a text category label added for each text information; obtain one or more text area images in each sample image, and obtain the area information of each text area image in the corresponding sample image, the area information includes position information and / or size information; input each text area image, each area information and each text category label into a preset neural network model for training to obtain a text recognition model; obtain an image to be processed, and input the image to be processed into the text recognition model to obtain the text and text category of the image to be processed, which can effectively identify the text and text category in the image and improve the accuracy of text recognition.

[0069] For details, please see Figure 5 , Figure 5 1 is a flowchart of another text recognition method provided by an embodiment of the present application. The text recognition method of the embodiment of the present application can be performed by a text recognition device, wherein the text recognition device is set in a computer device, wherein the specific explanation of the computer device is as described above. Specifically, the method of the embodiment of the present application includes the following steps.

[0070] S501: Acquire a sample image data set, where the sample image data set includes a plurality of sample images, each of which includes text information and a text category label added to each of the text information.

[0071] S502: Obtain one or more text region images in each sample image, and obtain region information of each text region image in the one or more text region images in the corresponding sample image, where the region information includes position information and / or size information.

[0072] S503: extracting text image feature information from each text region image, and extracting region feature information from region information of each text region image.

[0073] In the embodiment of the present application, the computer device can extract text image feature information from each text region image, and extract region feature information from region information of each text region image.

[0074] In one embodiment, when extracting region feature information from region information of each text region image, the computer device may extract position feature information and / or size feature information from the region information of each text region image.

[0075] Furthermore, when extracting the position feature information from the region information of each text region image, the computer device may extract the position feature information from the position information of each text region image.

[0076] Furthermore, when extracting size feature information from the area information of each text area image, the computer device can extract the height feature information from the height information in the size information of each text area image, extract the width feature information from the width information in the size information of each text area image, and extract the area feature information from the area information in the size information of each text area image.

[0077] S504: Input the extracted feature information of each text image, each region feature information and the text category label of each text region image into a preset neural network model for training to obtain the text recognition model.

[0078] In an embodiment of the present application, the computer device can input the extracted feature information of each text image, each region feature information, and the text category label of each text region image into a preset neural network model for training to obtain the text recognition model.

[0079] In one embodiment, the area information includes position information and size information; the computer device can extract position feature information and size feature information from the area information of each text area image, and input the extracted text image feature information, position feature information and size feature information of each text area image as well as the text category label of each text area image into a preset neural network model for training to obtain the text recognition model.

[0080] by Figure 6 Take this as an example to illustrate: Figure 6 is a schematic diagram of a model training based on regional information provided in an embodiment of the present application, such as Figure 6 As shown, the position information 61 extracted from the area information of the text area image includes the upper left vertex X coordinate, the upper left vertex Y coordinate, the lower right vertex X coordinate and the lower right vertex Y coordinate, and the size information 62 extracted from the area information of the text area image includes the image width, image height and area (i.e., the area of ​​the image occupied by the text), and the upper left vertex X coordinate, the upper left vertex Y coordinate, the lower right vertex X coordinate and the lower right vertex Y coordinate of each text area image extracted, as well as the image width, image height and area are input into the embedding layer 63 of the preset neural network model for embedding to obtain position feature information (such as a position feature vector) and size feature information (such as a size feature vector), and the position feature information and the size feature information are input into the convolution layer FC64, further convolved with the text image feature information input to the convolution layer, and the text recognition model is obtained by training according to the convolution result.

[0081] In one embodiment, the area information includes location information; the computer device can extract location feature information from the area information of each text area image, and input the extracted text image feature information and location feature information of each text area image and the text category label of each text area image into a preset neural network model for training to obtain the text recognition model.

[0082] In one embodiment, when a computer device inputs the extracted text image feature information and region feature information of each text area image and the text category label of each text area image into a preset neural network model for training to obtain a text recognition model, the obtained text image feature information, region feature information and text category label of each text area image can be input into a preset neural network model for training to obtain sample texts corresponding to each text area image and category information of each sample text; a loss function value is determined according to each sample text, category information of each sample text and text category label of each text area image, and model parameters of the preset neural network model are adjusted according to the loss function value; each text image feature information, each region feature information and text category label of each text area image are input into the neural network model after adjusting the model parameters for retraining, and when the loss function value obtained by retraining is less than the function threshold, it is determined that a text recognition model is obtained.

[0083] In one embodiment, when a computer device determines a loss function value based on each sample text, the category information of each sample text, and the text category label of each text area image, the computer device may compare the category information of each sample text with the text category label corresponding to each text area image; determine the category similarity between the category of each sample text obtained by the neural network model and the corresponding text category label of each text area image based on the comparison result; and determine the loss function value based on the category similarity.

[0084] In one embodiment, when the computer device compares the category information of each sample text with the text category label corresponding to each sample image, and determines the category similarity between the category of each sample text obtained by the neural network model and the text category label corresponding to each sample image according to the comparison result, the computer device may use a preset similarity algorithm to calculate the similarity between the category information of each sample text and the text category label corresponding to each sample image. The preset similarity algorithm may include but is not limited to a cosine similarity algorithm.

[0085] In one embodiment, when determining the loss function value, the computer device includes the loss function value obtained by performing text recognition on the sample image and the structured cross entropy loss function value obtained by the text recognition model, wherein the loss function value obtained by the text recognition includes the loss function value of the temporal classification based on the neural network (Connectionist Temporal Classification, CTC) Loss and the center loss function value CenterLoss for the text similarity, wherein CTCLoss is a Loss calculation method specifically for this scenario that does not require alignment, and CenterLoss uses the distance between the feature and the feature center and Softmax Loss as the loss function. Specifically, Figure 7 As shown, Figure 7 It is a structural diagram for determining the value of the loss function, such as Figure 7 As shown, CTCLoss 711 and CenterLoss 712 are obtained by performing text recognition 71 on a sample image 70, and the cross entropy Loss 721 of the structured 72 is obtained by the text recognition model.

[0086] By introducing the loss function value determined by text recognition into the cross entropy loss function value to determine the loss function value of the training text recognition model, it is helpful to train a better text recognition model and help improve the reliability and accuracy of the trained text recognition model.

[0087] In this way, the embodiment of the present application can train a text recognition model that can recognize text information and the category of text information in an image, which can improve the reliability of the text recognition model and help improve the accuracy and effectiveness of recognizing text from an image.

[0088] The embodiment of the present application can obtain a sample image data set, which includes multiple sample images, each sample image includes text information and a text category label added for each text information; obtain the area information of the text area image in each sample image in the corresponding sample image, and the area information includes position information and / or size information; extract text image feature information from each text area image, and extract area feature information from the area information of each text area image; input the extracted text image feature information and area feature information of each text area image into a preset neural network model for training to obtain the text recognition model; obtain an image to be processed, and input the image to be processed into the text recognition model to obtain text information of the image to be processed, and the text information includes text and text category, which helps to improve the accuracy and effectiveness of text recognition.

[0089] For details, please see Figure 8 , Figure 8It is a flowchart of another text recognition method provided by an embodiment of the present application. The text recognition method of the embodiment of the present application can be performed by a text recognition device, wherein the text recognition device is set in a computer device, wherein the specific explanation of the computer device is as described above. Specifically, the method of the embodiment of the present application includes the following steps.

[0090] S801: Acquire a sample image data set, where the sample image data set includes a plurality of sample images, each of which includes text information and a text category label added to each of the text information.

[0091] S802: Obtain target scene information, and select one or more text area images from each sample image according to the target scene, and obtain area information of each text area image in the one or more text area images in the corresponding sample images, where the area information includes position information and / or size information.

[0092] S803: extracting scene feature information from the target scene information, extracting text image feature information from each text region image, and extracting region feature information from the region information of each text region image.

[0093] In the embodiment of the present application, the computer device can extract scene feature information from the target scene information, extract text image feature information from each text region image, and extract region feature information from region information of each text region image. In some embodiments, the target scene information can be text description information.

[0094] When extracting scene feature information from target scene information, the computer device may extract the scene feature information, namely, text description feature information, from text description information used to describe the target scene information.

[0095] When extracting the region feature information from the region information of each text region image, the computer device may extract the position feature information and / or size feature information from the region information of each text region image.

[0096] Furthermore, when extracting the position feature information from the region information of each text region image, the computer device may extract the position feature information from the position information of each text region image.

[0097] Furthermore, when extracting size feature information from the area information of each text area image, the computer device can extract the height feature information from the height information in the size information of each text area image, extract the width feature information from the width information in the size information of each text area image, and extract the area feature information from the area information in the size information of each text area image.

[0098] S804: Input the extracted scene feature information, feature information of each text image, feature information of each region, and text category labels of each text region image into a preset neural network model for training to obtain the text recognition model.

[0099] In the embodiment of the present application, the computer device can input the extracted scene feature information, each text image feature information, each region feature information and the text category label of each text region image into a preset neural network model for training to obtain the text recognition model. Wherein, each region feature information includes position feature information and / or size feature information.

[0100] In one embodiment, when a computer device inputs the extracted scene feature information, text image feature information and region feature information of each text area image, and text category labels of each text area image into a preset neural network model for training to obtain a text recognition model, the obtained scene feature information, each text image feature information, each region feature information, and text category labels of each text area image can be input into a preset neural network model for training to obtain sample texts corresponding to each text area image in the target scene and category information of each sample text; a loss function value is determined according to each sample text, category information of each sample text, and text category labels of each text area image, and model parameters of the preset neural network model are adjusted according to the loss function value; each text image feature information, each region feature information, and text category labels of each text area image are input into the neural network model after adjusting the model parameters for retraining, and when the loss function value obtained from the retraining is less than the function threshold, it is determined that a text recognition model is obtained.

[0101] The embodiment of the present application introduces the target scene to train the text recognition model, so that the text recognition model can recognize corresponding text information for different scenes, which helps to improve the accuracy and efficiency of text recognition in different scenes.

[0102] See also Fig. 9 , Fig. 9 901 is a schematic diagram of a text recognition device provided in an embodiment of the present application. Specifically, the device is set in a computer device, and the device includes: a first acquisition unit 901, a second acquisition unit 902, a training unit 903 and a recognition unit 904;

[0103] A first acquisition unit 901 is used to acquire a sample image data set, where the sample image data set includes a plurality of sample images, each of which includes text information and a text category label added to each text information;

[0104] A second acquisition unit 902 is used to acquire one or more text area images from each of the sample images, and acquire area information of each of the one or more text area images in the corresponding sample images, wherein the area information includes position information and / or size information;

[0105] A training unit 903 is used to input the text area images, the area information of the text area images in the corresponding sample images, and the text category label of each text information corresponding to the sample images into a preset neural network model for training to obtain a text recognition model;

[0106] The recognition unit 904 is used to obtain the image to be processed, and input the image to be processed into the text recognition model to obtain text information of the image to be processed, where the text information includes text and text category.

[0107] Further, the region information includes position information; when the second acquisition unit 902 acquires the region information of each text region image in the one or more text region images corresponding to each sample image, it is specifically used to:

[0108] Obtaining coordinate information of each text area image in each corresponding sample image;

[0109] According to the coordinate information of each text region image in each corresponding sample image, the position information of each text region image in each corresponding sample image is determined.

[0110] Furthermore, the coordinate information includes vertex coordinate information of each text area image in the corresponding sample image, and the vertex coordinate information is determined based on a coordinate system established with the geometric center of the image area of ​​each text area image as the origin, and the vertex coordinate information includes the upper left vertex coordinate information and the lower right vertex coordinate information of the image area where the each text area image is located in the coordinate system.

[0111] Further, the region information includes size information; when the second acquisition unit 902 acquires the region information of each text region image in the one or more text region images corresponding to each sample image, it is specifically used to:

[0112] Determine the image height and image width of each text area image in each corresponding sample image;

[0113] Determine the area of ​​each text region image according to the image height and the image width;

[0114] The image height, image width and area of ​​each text region image are determined as the size information of each text region image in the corresponding sample image.

[0115] Furthermore, the training unit 903 inputs the text area images, the area information of the text area images in the corresponding sample images, and the text category label of each text information corresponding to the sample images into a preset neural network model for training, and when the text recognition model is obtained, it is specifically used for:

[0116] Extracting text image feature information from each of the text region images;

[0117] Extracting regional feature information from the regional information of each text region image;

[0118] Determining the text category label of each text area image according to the text category label of each text information corresponding to each sample image;

[0119] The extracted feature information of each text image, each region feature information and the text category label of each text region image are input into a preset neural network model for training to obtain the text recognition model.

[0120] Furthermore, the training unit 903 inputs the extracted feature information of each text image, each region feature information and the text category label of each text region image into a preset neural network model for training, and when the text recognition model is obtained, it is specifically used for:

[0121] Inputting the obtained feature information of each text image, the feature information of each region, and the text category label of each text region image into the preset neural network model for training, and obtaining sample text corresponding to each text region image and category information of each sample text;

[0122] Determining a loss function value according to each sample text, category information of each sample text, and text category labels of each text region image, and adjusting model parameters of the preset neural network model according to the loss function value;

[0123] The feature information of each text image, the feature information of each region and the text category label of each text region image are input into the neural network model after adjusting the model parameters for retraining. When the loss function value obtained by retraining is less than the function threshold, it is determined that the text recognition model is obtained.

[0124] Further, when the training unit 903 determines the loss function value according to the sample texts, the category information of the sample texts and the text category labels of the text region images, it is specifically used to:

[0125] Comparing the category information of each sample text with the text category label corresponding to each text region image;

[0126] Determine the category similarity between the category of each sample text obtained by the neural network model and the corresponding text category label of each text region image according to the comparison result;

[0127] The loss function value is determined according to the category similarity.

[0128] The embodiment of the present application can obtain a sample image data set, which includes multiple sample images, each sample image includes text information and a text category label added for each text information; obtain one or more text area images in each sample image, and obtain the area information of each text area image in the corresponding sample image, the area information includes position information and / or size information; input each text area image, each area information and each text category label into a preset neural network model for training to obtain a text recognition model; obtain an image to be processed, and input the image to be processed into the text recognition model to obtain the text and text category of the image to be processed, which can effectively identify the text and text category in the image and improve the accuracy of text recognition.

[0129] See also Fig.10 , Fig.10 1001 is a schematic diagram of a computer device provided in an embodiment of the present application. Specifically, the computer device includes: a memory 1001 and a processor 1002.

[0130] In one embodiment, the computer device further includes a data interface 1003, and the data interface 1003 is used to transfer data information between the computer device and other devices.

[0131] The memory 1001 may include a volatile memory; the memory 1001 may also include a non-volatile memory; the memory 1001 may also include a combination of the above-mentioned types of memories. The processor 1002 may be a central processing unit (CPU). The processor 1002 may further include a hardware chip. The above-mentioned hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD) or a combination thereof. The above-mentioned PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA) or any combination thereof.

[0132] The memory 1001 is used to store programs, and the processor 1002 can call the program stored in the memory 1001 to perform the following steps:

[0133] Acquire a sample image data set, wherein the sample image data set includes a plurality of sample images, each of which includes text information and a text category label added to each text information;

[0134] Acquire one or more text area images in each of the sample images, and acquire area information of each of the one or more text area images in the corresponding sample images, wherein the area information includes position information and / or size information;

[0135] Inputting each of the text area images, the area information of each of the text area images in the corresponding sample images, and the text category label of each text information corresponding to each of the sample images into a preset neural network model for training to obtain a text recognition model;

[0136] An image to be processed is acquired, and the image to be processed is input into the text recognition model to obtain text information of the image to be processed, wherein the text information includes text and text category.

[0137] Further, the region information includes position information; when the processor 1002 obtains the region information of each text region image in the one or more text region images corresponding to each sample image, it is specifically used to:

[0138] Obtaining coordinate information of each text area image in each corresponding sample image;

[0139] According to the coordinate information of each text region image in each corresponding sample image, the position information of each text region image in each corresponding sample image is determined.

[0140] Furthermore, the coordinate information includes vertex coordinate information of each text area image in the corresponding sample image, and the vertex coordinate information is determined based on a coordinate system established with the geometric center of the image area of ​​each text area image as the origin, and the vertex coordinate information includes the upper left vertex coordinate information and the lower right vertex coordinate information of the image area where the each text area image is located in the coordinate system.

[0141] Further, the region information includes size information; when the processor 1002 obtains the region information of each text region image in the one or more text region images corresponding to each sample image, it is specifically used to:

[0142] Determine the image height and image width of each text area image in each corresponding sample image;

[0143] Determine the area of ​​each text region image according to the image height and the image width;

[0144] The image height, image width and area of ​​each text region image are determined as the size information of each text region image in the corresponding sample image.

[0145] Further, the processor 1002 inputs the respective text area images, the area information of the respective text area images in the corresponding respective sample images, and the text category label of each text information corresponding to the respective sample images into a preset neural network model for training, and when obtaining the text recognition model, is specifically used for:

[0146] Extracting text image feature information from each of the text region images;

[0147] Extracting regional feature information from the regional information of each text region image;

[0148] Determining the text category label of each text area image according to the text category label of each text information corresponding to each sample image;

[0149] The extracted feature information of each text image, each region feature information and the text category label of each text region image are input into a preset neural network model for training to obtain the text recognition model.

[0150] Furthermore, the processor 1002 inputs the extracted feature information of each text image, each region feature information and the text category label of each text region image into a preset neural network model for training, and when the text recognition model is obtained, it is specifically used for:

[0151] Inputting the obtained feature information of each text image, the feature information of each region, and the text category label of each text region image into the preset neural network model for training, and obtaining sample text corresponding to each text region image and category information of each sample text;

[0152] Determining a loss function value according to each sample text, category information of each sample text, and text category labels of each text region image, and adjusting model parameters of the preset neural network model according to the loss function value;

[0153] The feature information of each text image, the feature information of each region and the text category label of each text region image are input into the neural network model after adjusting the model parameters for retraining. When the loss function value obtained by retraining is less than the function threshold, it is determined that the text recognition model is obtained.

[0154] Further, when the processor 1002 determines the loss function value according to the sample texts, the category information of the sample texts, and the text category labels of the text region images, it is specifically used to:

[0155] Comparing the category information of each sample text with the text category label corresponding to each text region image;

[0156] Determine the category similarity between the category of each sample text obtained by the neural network model and the corresponding text category label of each text region image according to the comparison result;

[0157] The loss function value is determined according to the category similarity.

[0158] The embodiment of the present application can obtain a sample image data set, which includes multiple sample images, each sample image includes text information and a text category label added for each text information; obtain one or more text area images in each sample image, and obtain the area information of each text area image in the corresponding sample image, the area information includes position information and / or size information; input each text area image, each area information and each text category label into a preset neural network model for training to obtain a text recognition model; obtain an image to be processed, and input the image to be processed into the text recognition model to obtain the text and text category of the image to be processed, which can effectively identify the text and text category in the image and improve the accuracy of text recognition.

[0159] An embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the method described in the embodiment corresponding to the present application, and can also implement the device of the embodiment corresponding to the present application, which will not be described in detail here.

[0160] The computer-readable storage medium may be an internal storage unit of the device described in any of the foregoing embodiments, such as a hard disk or memory of the device. The computer-readable storage medium may also be an external storage device of the device, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the device. Furthermore, the computer-readable storage medium may also include both an internal storage unit of the device and an external storage device. The computer-readable storage medium is used to store the computer program and other programs and data required by the computer device. The computer-readable storage medium may also be used to temporarily store data that has been output or is to be output.

[0161] The embodiments of the present application also provide a computer program product or a computer program, which includes 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 executes the steps performed in the method embodiments provided in the above various implementation modes.

[0162] A person skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.

[0163] The above disclosure is only part of the embodiments of the present application, which certainly cannot be used to limit the scope of rights of the present application. Ordinary technicians in this field can understand that all or part of the processes of implementing the above embodiments and making equivalent changes according to the claims of this application are still within the scope of the present invention.

Claims

1. A text recognition method, It is characterized in that include: Acquire a sample image data set, wherein the sample image data set includes a plurality of sample images, each of which includes text information and a text category label added to each text information; Acquire one or more text area images in each of the sample images, and acquire area information of each of the one or more text area images in the corresponding sample images, wherein the area information includes position information and / or size information; Inputting each of the text area images, the area information of each of the text area images in the corresponding sample images, and the text category label of each text information corresponding to each of the sample images into a preset neural network model for training to obtain a text recognition model; Acquire an image to be processed, and input the image to be processed into the text recognition model to obtain text information of the image to be processed, wherein the text information includes text and text category; The step of inputting the text area images, the area information of the text area images in the corresponding sample images, and the text category label of each text information corresponding to the sample images into a preset neural network model for training to obtain a text recognition model includes: Extracting text image feature information from each of the text region images; Extracting regional feature information from the regional information of each text region image; Determining the text category label of each text area image according to the text category label of each text information corresponding to each sample image; Inputting the obtained feature information of each text image, the feature information of each region, and the text category label of each text region image into the preset neural network model for training, and obtaining sample text corresponding to each text region image and category information of each sample text; The loss function value is determined according to the sample texts, the category information of the sample texts and the text category labels of the text area images, and the model parameters of the preset neural network model are adjusted according to the loss function value to train a text recognition model.

2. The method according to claim 1, It is characterized in that The region information includes position information; the step of obtaining the region information of each text region image in the one or more text region images in the corresponding sample images includes: Obtaining coordinate information of each text area image in each corresponding sample image; According to the coordinate information of each text region image in each corresponding sample image, the position information of each text region image in each corresponding sample image is determined.

3. The method according to claim 2, It is characterized in that The coordinate information includes vertex coordinate information of each text area image in the corresponding sample image, and the vertex coordinate information is determined based on a coordinate system established with the geometric center of the image area of ​​each text area image as the origin. The vertex coordinate information includes the upper left vertex coordinate information and the lower right vertex coordinate information of the image area where the each text area image is located in the coordinate system.

4. The method according to claim 1, It is characterized in that The region information includes size information; the step of obtaining region information of each text region image in the one or more text region images in the corresponding sample images includes: Determine the image height and image width of each text area image in each corresponding sample image; Determine the area of ​​each text region image according to the image height and the image width; The image height, image width and area of ​​each text region image are determined as the size information of each text region image in the corresponding sample image.

5. The method according to claim 1, It is characterized in that The determining of the loss function value according to the sample texts, the category information of the sample texts and the text category labels of the text region images includes: Comparing the category information of each sample text with the text category label corresponding to each text region image; Determine the category similarity between the category of each sample text obtained by the neural network model and the corresponding text category label of each text region image according to the comparison result; The loss function value is determined according to the category similarity.

6. A text recognition device, It is characterized in that include: A first acquisition unit is used to acquire a sample image data set, where the sample image data set includes a plurality of sample images, each of which includes text information and a text category label added to each text information; a second acquisition unit, configured to acquire one or more text region images from each of the sample images, and acquire region information of each of the one or more text region images in each corresponding sample image, wherein the region information includes position information and / or size information; A training unit, used for inputting the text area images, the area information of the text area images in the corresponding sample images, and the text category label of each text information corresponding to the sample images into a preset neural network model for training to obtain a text recognition model; A recognition unit, used for acquiring an image to be processed, and inputting the image to be processed into the text recognition model to obtain text information of the image to be processed, wherein the text information includes text and text category; The training unit inputs the text area images, the area information of the text area images in the corresponding sample images, and the text category label of each text information corresponding to the sample images into a preset neural network model for training, and when obtaining the text recognition model, it is specifically used to extract text image feature information from the text area images; extract regional feature information from the area information of the text area images; determine the text category label of each text area image according to the text category label of each text information corresponding to the sample images; input the obtained text image feature information, the regional feature information, and the text category label of each text area image into the preset neural network model for training, and obtain the sample text corresponding to the text area image and the category information of each sample text; determine the loss function value according to the sample texts, the category information of the sample texts, and the text category label of the text area images, and adjust the model parameters of the preset neural network model according to the loss function value to train and obtain the text recognition model.

7. A computer device, It is characterized in that The method comprises a processor and a memory, wherein the processor and the memory are connected to each other, wherein the memory is used to store a computer program, and the processor is configured to call the computer program to execute the method according to any one of claims 1 to 5.

8. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores program instructions, which, when executed, implement the method according to any one of claims 1 to 5.

9. A computer program product, It is characterized in that The computer program product comprises program instructions, and when the program instructions are executed by a processor, the method according to any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • OCR-based credential recognition method, a device, a computer device and a storage medium

    CN109492643A

  • Image text recognition method and device, computer equipment and computer storage medium

    CN111275038A

  • Image recognition model training method and device, image recognition method and device and electronic equipment

    CN113378833A

  • Identification method and device, computer equipment and storage medium

    CN114299500A

  • Text separation model training method and device, electronic equipment and storage medium

    CN114419641A