A text recognition model training method, text recognition method and device

By performing secondary training and update of the convolutional recurrent neural network model and reducing loss function, the missed detection and inefficiency in shape-near word detection are solved, and more efficient shape-near word recognition is achieved.

CN114596570BActive Publication Date: 2025-04-25BEIJING UNISOUND INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210224776.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-07
Publication Date
2025-04-25
Estimated Expiration
2042-03-07

AI Technical Summary

Technical Problem

The prior art has problems of missed detection and inefficiency in the detection of shape-close characters, and the word library of shape-close characters is frequently updated, so full coverage cannot be achieved.

Method used

The convolutional recurrent neural network model is quadraticly trained by text image samples, and the model parameters are updated with the loss function of the two trainings to form a pre-trained model for identifying the morphological characters.

Benefits of technology

By expanding the inter-category distance and reducing the intra-category distance, the network can better distinguish fractal characters, improve the recognition efficiency of morphological characters, and avoid the dependence of manual detection and morphological characters thesaurus.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114596570B_ABST
    Figure CN114596570B_ABST
Patent Text Reader

Abstract

The present application discloses a training method, a text recognition method and a device for a text recognition model. The method includes: obtaining text image samples; training a convolutional recurrent neural network model using the text image samples to obtain a trained convolutional recurrent neural network model, and determining the trained convolutional recurrent neural network model as a pre-training model; iteratively training the pre-training model using the text image samples to obtain an initial training result output by the pre-training model in each iterative training, and determining the training result that meets the preset requirements in the initial training result as the target training result; calculating the target loss function based on the target training result, and updating the pre-training model using the target loss function until a text recognition model is obtained. The training method of the present application can better expand the distance between classes and reduce the distance within classes; it can enable the network to better distinguish similar characters, and improve the recognition efficiency of similar characters.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and in particular to a text recognition model training method, a text recognition method and a device. Background Art

[0002] Similar characters refer to Chinese characters that are similar in glyph structure. Similar characters appear in groups. Single Chinese characters are not similar characters. They can only be called similar characters when compared with other Chinese characters and the characters of both sides are similar in glyph structure. The judgment of similar characters is subjective in a certain degree of emotion. Affected by various factors, the results of subjective judgments of different people may not be consistent. At present, the acquisition of similar characters mainly relies on different staff to detect or adopts a preset similar character word library to detect. In the process of realizing the present invention, the inventor finds that when using artificial detection of similar characters, the situation of missing detection of similar characters will occur, and the artificial detection efficiency is low. And the resources in the similar character word library need to be updated regularly, and full coverage of similar characters cannot be achieved. Summary of the invention

[0003] In order to solve the above technical problems or at least partially solve the above technical problems, the present application provides a text recognition model training method, a text recognition method and a device.

[0004] According to one aspect of an embodiment of the present application, a method for training a text recognition model is provided, comprising:

[0005] Acquire a text image sample, wherein the text image sample includes at least two characters whose similarity is greater than a preset threshold;

[0006] Using the text image samples to train a convolutional recurrent neural network model to obtain a trained convolutional recurrent neural network model, and determining the trained convolutional recurrent neural network model as a pre-trained model;

[0007] Iteratively training the pre-trained model using the text image samples to obtain initial training results output by the pre-trained model in each iterative training, and determining the training results that meet preset requirements in the initial training results as target training results;

[0008] A target loss function is calculated based on the target training result, and the pre-training model is updated using the target loss function until a text recognition model is obtained.

[0009] Furthermore, the method of training a convolutional recurrent neural network model using the text image samples to obtain a trained convolutional recurrent neural network model includes:

[0010] Acquire label information corresponding to the text image sample, wherein the label information includes: a sample of the number of characters corresponding to the characters whose similarity is greater than a preset threshold in the text image sample, and a sample of text features of the characters whose similarity is greater than a preset threshold;

[0011] The convolutional recurrent neural network model is trained using the text image samples and the label information so that the convolutional recurrent neural network model learns text feature samples of texts whose similarity is greater than a preset threshold, thereby obtaining a trained convolutional recurrent neural network model.

[0012] Furthermore, the iterative training of the pre-trained model using the text image samples to obtain an initial training result output by the pre-trained model in each iterative training includes:

[0013] Inputting the text image sample into the pre-trained model, so that the pre-trained model predicts the text in the text image sample whose similarity is greater than a preset threshold, and the number of texts corresponding to the text, based on the image features of the text image sample;

[0014] The number of characters is determined as the initial training result.

[0015] Furthermore, determining the training results that meet the preset requirements in the initial training results as the target training results includes:

[0016] A training result in which the number of characters in the initial training result matches the sample number of characters carried in the label information is determined as the target training result.

[0017] Further, the calculating the target loss function based on the target training result includes:

[0018] Obtaining the number of target characters carried in the target training result, and determining target text features corresponding to the number of target characters from the text image samples;

[0019] Calculating a first loss function between the target text feature and the text feature sample;

[0020] Obtaining a second loss function, wherein the second loss function is obtained when training a convolutional recurrent neural network model using the text image sample and the label information;

[0021] Obtaining a weight value corresponding to the first loss function, calculating a product of the first loss function and the weight value, and determining the product as a third loss function;

[0022] Calculate the sum of the second loss function and the third loss function, and determine the sum as the target loss function.

[0023] According to another aspect of the embodiment of the present application, a text recognition method is also provided, using the above-mentioned text recognition model, including:

[0024] Acquire a target image to be recognized, wherein the target image includes a plurality of characters;

[0025] Obtain a pre-trained text recognition model, wherein the text recognition model is trained based on text image samples and a convolutional recurrent neural network model;

[0026] The target image is input into the text recognition model so that the text recognition model extracts image features of the target image and text features from the image features, and based on the text features, determines the text in the target image whose similarity is greater than a preset threshold and the number of texts corresponding to the text.

[0027] According to another aspect of the embodiment of the present application, there is also provided a training device for a text recognition model, comprising:

[0028] An acquisition module, used for acquiring a text image sample, wherein the text image sample includes at least two characters whose similarity is greater than a preset threshold;

[0029] A training module, used to train a convolutional recurrent neural network model using the text image samples to obtain a trained convolutional recurrent neural network model, and determine the trained convolutional recurrent neural network model as a pre-trained model;

[0030] A processing module, configured to iteratively train the pre-trained model using the text image samples, obtain an initial training result output by the pre-trained model in each iterative training, and determine a training result that meets a preset requirement in the initial training results as a target training result;

[0031] An updating module is used to calculate a loss function based on the target training result, and to update the pre-training model using the loss function until a text recognition model is obtained.

[0032] According to another aspect of the embodiment of the present application, there is also provided a text recognition device, including:

[0033] A first acquisition module is used to acquire a target image to be recognized, wherein the target image includes a plurality of characters;

[0034] A second acquisition module is used to acquire a pre-trained text recognition model, wherein the text recognition model is trained based on text image samples and a convolutional recurrent neural network model;

[0035] The recognition module is used to input the target image into the text recognition model so that the text recognition model extracts the image features of the target image and extracts the text features from the image features, and determines the text in the target image whose similarity is greater than a preset threshold and the number of texts corresponding to the texts based on the text features.

[0036] According to another aspect of an embodiment of the present application, a storage medium is further provided, which includes a stored program, and the above steps are executed when the program is run.

[0037] According to another aspect of an embodiment of the present application, there is also provided an electronic device, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; wherein: the memory is used to store computer programs; and the processor is used to execute the steps in the above method by running the program stored in the memory.

[0038] The embodiment of the present application also provides a computer program product including instructions, which, when executed on a computer, enables the computer to execute the steps in the above method.

[0039] The above technical solution provided by the embodiment of the present application has the following advantages over the prior art: the embodiment of the present application uses text image samples to perform secondary training on the convolutional recurrent neural network model, and updates the model parameters in combination with the loss function of the two trainings, which can better expand the distance between classes and reduce the distance within classes; it can enable the network to better distinguish similar characters, and no longer requires manual detection and detection methods of similar character vocabulary, thereby improving the recognition efficiency of similar characters. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0041] 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, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0042] Figure 1 A flowchart of a method for training a text recognition model provided in an embodiment of the present application;

[0043] Figure 2 A flowchart of a text recognition method provided in an embodiment of the present application;

[0044] Figure 3A block diagram of a text recognition model training device provided in an embodiment of the present application;

[0045] Figure 4 A block diagram of a text recognition device provided by another embodiment of the present application;

[0046] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0047] In order to make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. The schematic embodiments of the present application and their descriptions are used to explain the present application and do not constitute improper limitations on the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.

[0048] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another similar entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0049] The embodiments of the present application provide a training method for a text recognition model, a text recognition method and a device. The method provided in the embodiments of the present invention can be applied to any required electronic device, for example, it can be an electronic device such as a server or a terminal, which is not specifically limited here. For the convenience of description, it is referred to as an electronic device in the following.

[0050] According to one aspect of the embodiments of the present application, a method embodiment of training a text recognition model is provided. Figure 1 A flowchart of a method for training a text recognition model provided in an embodiment of the present application, such as Figure 1 As shown, the method includes:

[0051] Step S11: Obtain a text image sample, where the text image sample includes at least two texts with a similarity greater than a preset threshold.

[0052] The method provided by the embodiments of this application is applied to an image processing device, which can be a device such as a smart phone or a computer. The image processing device can receive a text image sample uploaded by a user. The text image sample includes at least two texts with a similarity greater than a preset threshold, that is, similar-shaped characters. For example: 诞, 蜒, 掩, 淹, 俺, 彦, 谚, 秧, 映, 殃, 扬, 杨, 汤, 场, 肠, 袄, 沃, 跃, 妖, 饶, 绕, 浇, 挠.

[0053] Step S12: Use the text image sample to train a convolutional recurrent neural network model to obtain a trained convolutional recurrent neural network model, and determine the trained convolutional recurrent neural network model as a pre-trained model.

[0054] In the embodiments of this application, using the text image sample to train a convolutional recurrent neural network model to obtain a trained convolutional recurrent neural network model includes the following steps A1 - A2:

[0055] Step A1: Obtain the label information corresponding to the text image sample, where the label information includes: the text quantity sample corresponding to the text with a similarity greater than the preset threshold in the text image sample, and the text feature sample of the text with a similarity greater than the preset threshold.

[0056] In the embodiments of this application, after obtaining the text image sample, the image processing device can use a detection model to detect the text features in the text image sample, and then calculate the similarity between each text feature. Determine the text features with a similarity greater than the preset threshold as text feature samples, then label the text feature samples, and perform associated labeling on the texts corresponding to the text feature samples to obtain the text quantity sample corresponding to the text.

[0057] As an example, the associated similar-shaped characters included in the text image sample are: 诞—蜒, 掩—淹—俺, 彦—谚, 秧—映—殃. The text quantity sample of the similar-shaped characters is 10.

[0058] Step A2: Use the text image sample and the label information to train the convolutional recurrent neural network model, so that the convolutional recurrent neural network model learns the text feature samples of the texts with a similarity greater than the preset threshold to obtain a trained convolutional recurrent neural network model.

[0059] In the embodiments of this application, input the text image sample and the label information into the convolutional recurrent neural network model. The convolutional recurrent neural network model learns the text feature samples with an associated relationship in the text image sample to obtain a trained convolutional recurrent neural network model.

[0060] Specifically, the text image samples and label information are input into the convolutional recurrent neural network model so that the convolutional recurrent neural network model learns the text feature samples with associated relationships in the text image samples, and outputs the training results, and then calculates the loss function (CTC_Loss) based on the training results and the true results. The model parameters of the convolutional recurrent neural network model are updated according to the loss function, and the training is repeated until the loss function falls into the target range. The target range can be a range pre-set by the staff. When the loss function falls into the target range, it means that the convolutional recurrent neural network model has achieved the training effect. At this time, the trained convolutional recurrent neural network model is determined as a pre-trained model.

[0061] It should be noted that the embodiment of the present application uses a convolutional recurrent neural network model (Convolutional Recurrent Neural Network, abbreviation: CRNN), which includes a CNN feature extraction layer and a BLSTM sequence feature extraction layer, and can perform end-to-end joint training. It uses BLSTM and CTC components to learn the contextual relationship in the text image, thereby effectively improving the accuracy of text recognition and making the model more robust. During the prediction process, the front end uses a standard CNN network to extract the features of the text image, uses BLSTM to fuse the feature vectors to extract the contextual features of the character sequence, and then obtains the probability distribution of each column feature, and finally predicts the text sequence through the transcription layer (CTC rule).

[0062] Step S13, iteratively training the pre-trained model using text image samples to obtain initial training results output by the pre-trained model in each iterative training, and determining the training results that meet preset requirements in the initial training results as target training results.

[0063] In the embodiment of the present application, the pre-trained model is iteratively trained using text image samples to obtain the initial training results output by the pre-trained model in each iterative training, including the following steps B1-B2:

[0064] Step B1, inputting the text image samples into the pre-trained model, so that the pre-trained model predicts the text in the text image samples whose similarity is greater than a preset threshold, and the number of texts corresponding to the texts based on the image features of the text image samples.

[0065] Step B2, determining the number of characters as the initial training result.

[0066] In an embodiment of the present application, a training result in the initial training result that meets preset requirements is determined as a target training result, including: a training result in which the number of characters in the initial training result matches a sample of the number of characters carried in the label information is determined as the target training result.

[0067] It should be noted that the embodiment of the present application uses text image samples and label information to train the convolutional recurrent neural network model once, and determines the trained convolutional recurrent neural network model as a pre-training model, the purpose of which is to enable the convolutional recurrent neural network model to preliminarily identify similar characters. Then the embodiment of the present application reuses the text image sample to input into the pre-training model, so that the pre-training model predicts similar characters, and determines the prediction result output by the pre-training model as the initial training result, wherein the initial training result includes: the similar characters (i.e., characters with a similarity greater than a preset threshold) detected by the pre-training model from the text image sample, and the number of characters corresponding to the similar characters. It can be understood that the pre-training model will also output its position information in the image when detecting similar characters, and then the number of characters can be counted based on the position information.

[0068] Step S14, calculating the target loss function based on the target training result, and using the target loss function to update the pre-training model until a text recognition model is obtained.

[0069] In an embodiment of the present application, the target loss function is calculated based on the target training result, including the following steps C1-C5:

[0070] Step C1, obtaining the target text quantity carried in the target training result, and determining the target text features corresponding to the target text quantity from the text image samples.

[0071] Step C2, calculating a first loss function between the target text feature and the text feature sample.

[0072] Step C3, obtaining a second loss function, wherein the second loss function is obtained when training a convolutional recurrent neural network model using text image samples and label information.

[0073] Step C4, obtaining a weight value corresponding to the first loss function, calculating the product of the first loss function and the weight value, and determining the product as the third loss function.

[0074] Step C5, calculating the sum of the second loss function and the third loss function, and determining the sum as the target loss function.

[0075] In an embodiment of the present application, the first loss function is ArcFace Loss, which is calculated by the target text feature and the text feature sample. Then, ArcFace Loss is multiplied by its corresponding weight value to obtain a product, and then the product is added to the second loss function (i.e., CTC_Loss) to obtain the final target loss function, and then the model parameters of the pre-trained model are updated using the final target loss function, and the updated pre-trained model is used for repeated training until the pre-trained model meets the training requirements, and it is determined as a text recognition model. By combining ArcFace Loss and CTC_Loss to update the model parameters, the embodiment of the present application can better expand the distance between classes and reduce the distance within classes.

[0076] The embodiment of the present application uses text image samples to perform secondary training on the convolutional recurrent neural network model, and updates the model parameters in combination with the loss functions of the two trainings, which can better expand the distance between classes and reduce the distance within classes; it can enable the network to better distinguish similar characters, and no longer requires manual detection and detection methods of similar character vocabulary, thereby improving the recognition efficiency of similar characters.

[0077] Figure 2 A flowchart of a text recognition method provided in an embodiment of the present application is shown in FIG. Figure 2 As shown, the method includes:

[0078] Step S21, obtaining a target image to be recognized, wherein the target image includes a plurality of characters.

[0079] The text recognition method provided in the embodiment of the present application is applied to an image processing device, which may be a smart phone, a computer or other device. The target image may be an image uploaded by a user to the image processing device, or an image captured by an image acquisition device, or an image captured from the Internet by the image processing device. There are multiple characters to be recognized in the target image.

[0080] Step S22, obtaining a pre-trained text recognition model, wherein the text recognition model is trained based on text image samples and a convolutional recurrent neural network model.

[0081] In an embodiment of the present application, the training process of the text recognition model is as follows: obtaining a text image sample, wherein the text image sample includes at least two characters whose similarity is greater than a preset threshold; using the text image sample to train a convolutional recurrent neural network model to obtain a trained convolutional recurrent neural network model, and determining the trained convolutional recurrent neural network model as a pre-trained model; using the text image sample to iteratively train the pre-trained model to obtain an initial training result output by the pre-trained model in each iterative training, and determining the training result in the initial training result that meets the preset requirements as the target training result; calculating a target loss function based on the target training result, and using the target loss function to update the pre-trained model until a text recognition model is obtained.

[0082] Step S23, input the target image into the text recognition model so that the text recognition model extracts the image features of the target image, and extracts the text features from the image features, and determines the text in the target image whose similarity is greater than a preset threshold based on the text features, and the number of texts corresponding to the texts.

[0083] In an embodiment of the present application, the target image is input into a text recognition model, the text recognition model extracts image features of the target image, then extracts text features from the image features, and calculates the similarity between the text features, extracts text whose similarity is greater than a preset threshold (i.e., similar characters), and determines the number of characters corresponding to the similar characters.

[0084] Figure 3 This is a block diagram of a text recognition model training device provided in an embodiment of the present application. The device can be implemented as part or all of an electronic device through software, hardware, or a combination of both. Figure 3 As shown, the device comprises:

[0085] An acquisition module 31 is used to acquire a text image sample, wherein the text image sample includes at least two characters whose similarity is greater than a preset threshold;

[0086] A training module 32 is used to train the convolutional recurrent neural network model using the text image samples to obtain a trained convolutional recurrent neural network model, and determine the trained convolutional recurrent neural network model as a pre-trained model;

[0087] The processing module 33 is used to iteratively train the pre-trained model using the text image samples, obtain the initial training results output by the pre-trained model in each iterative training, and determine the training results that meet the preset requirements in the initial training results as the target training results;

[0088] The updating module 34 is used to calculate the loss function based on the target training result, and use the loss function to update the pre-training model until a text recognition model is obtained.

[0089] In an embodiment of the present application, the training module 32 is used to obtain label information corresponding to the text image samples, wherein the label information includes: a text quantity sample corresponding to the text whose similarity is greater than a preset threshold in the text image samples, and a text feature sample of the text whose similarity is greater than the preset threshold; and train the convolutional recurrent neural network model using the text image samples and the label information so that the convolutional recurrent neural network model learns the text feature samples of the text whose similarity is greater than the preset threshold, thereby obtaining a trained convolutional recurrent neural network model.

[0090] In an embodiment of the present application, the processing module 33 is used to input the text image sample into the pre-trained model so that the pre-trained model predicts the text in the text image sample whose similarity is greater than a preset threshold and the number of texts corresponding to the text based on the image features of the text image sample; and determines the number of texts as the initial training result.

[0091] In the embodiment of the present application, the processing module 33 is used to determine the training result in which the number of characters in the initial training result matches the sample of the number of characters carried in the label information as the target training result.

[0092] In an embodiment of the present application, an update module is used to obtain the target number of characters carried in the target training result, and determine the target text features corresponding to the target number of characters from the text image samples; calculate the first loss function between the target text features and the text feature samples; obtain the second loss function, wherein the second loss function is obtained when training the convolutional recurrent neural network model using the text image samples and label information; obtain the weight value corresponding to the first loss function, calculate the product of the first loss function and the weight value, and determine the product as the third loss function; calculate the sum of the second loss function and the third loss function, and determine the sum as the target loss function.

[0093] The embodiment of the present application uses text image samples to perform secondary training on the convolutional recurrent neural network model, and updates the model parameters in combination with the loss functions of the two trainings, which can better expand the distance between classes and reduce the distance within classes; it can enable the network to better distinguish similar characters, and no longer requires manual detection and detection methods of similar character vocabulary, thereby improving the recognition efficiency of similar characters.

[0094] Figure 4 This is a block diagram of a text recognition device provided in an embodiment of the present application. The device can be implemented as part or all of an electronic device through software, hardware, or a combination of both. Figure 4 As shown, the device comprises:

[0095] A first acquisition module 41 is used to acquire a target image to be recognized, wherein the target image includes a plurality of characters;

[0096] A second acquisition module 42 is used to acquire a pre-trained text recognition model, wherein the text recognition model is obtained by training based on text image samples and a convolutional recurrent neural network model;

[0097] The recognition module 43 is used to input the target image into the text recognition model so that the text recognition model extracts the image features of the target image and extracts the text features from the image features, and determines the text in the target image whose similarity is greater than a preset threshold and the number of texts corresponding to the texts based on the text features.

[0098] The present application also provides an electronic device, such as Figure 5 As shown, the electronic device may include: a processor 1501 , a communication interface 1502 , a memory 1503 and a communication bus 1504 , wherein the processor 1501 , the communication interface 1502 , and the memory 1503 communicate with each other via the communication bus 1504 .

[0099] Memory 1503, used for storing computer programs;

[0100] The processor 1501 is used to implement the steps of the above embodiment when executing the computer program stored in the memory 1503.

[0101] The communication bus mentioned in the above terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0102] The communication interface is used for communication between the above terminal and other devices.

[0103] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0104] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0105] In another embodiment provided in the present application, a computer-readable storage medium is provided, in which instructions are stored. When the computer-readable storage medium is run on a computer, the computer executes the text recognition model method described in any one of the above embodiments.

[0106] In another embodiment provided by the present application, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute the text recognition model method described in any one of the above embodiments.

[0107] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk SolidState Disk), etc.

[0108] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application are included in the protection scope of the present application.

[0109] The above description is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest range consistent with the principles and novel features applied for herein.

Claims

1. A method for training a text recognition model, characterized in that: include: Acquire a text image sample, wherein the text image sample includes at least two characters whose similarity is greater than a preset threshold; Using the text image samples to train a convolutional recurrent neural network model to obtain a trained convolutional recurrent neural network model, including: obtaining label information corresponding to the text image samples, wherein the label information includes: a sample of the number of characters corresponding to characters whose similarity is greater than a preset threshold in the text image samples, and a sample of text features of characters whose similarity is greater than a preset threshold, and using the text image samples and the label information to train a convolutional recurrent neural network model so that the convolutional recurrent neural network model learns the sample of text features of characters whose similarity is greater than the preset threshold, thereby obtaining a trained convolutional recurrent neural network model; and determining the trained convolutional recurrent neural network model as a pre-training model; Iteratively training the pre-trained model using the text image samples to obtain initial training results output by the pre-trained model in each iterative training, and determining the training results that meet preset requirements in the initial training results as target training results, including: inputting the text image samples into the pre-trained model so that the pre-trained model predicts the text in the text image samples whose similarity is greater than a preset threshold and the number of texts corresponding to the texts based on the image features of the text image samples, determining the number of texts as the initial training result, and determining the training result in which the number of texts in the initial training result matches the sample of the number of texts carried in the label information as the target training result; A target loss function is calculated based on the target training result, and the pre-training model is updated using the target loss function until a text recognition model is obtained.

2. The method according to claim 1, characterized in that The calculating the target loss function based on the target training result includes: Obtaining the number of target characters carried in the target training result, and determining target text features corresponding to the number of target characters from the text image samples; Calculating a first loss function between the target text feature and the text feature sample; Obtaining a second loss function, wherein the second loss function is obtained when training a convolutional recurrent neural network model using the text image sample and the label information; Obtaining a weight value corresponding to the first loss function, calculating a product of the first loss function and the weight value, and determining the product as a third loss function; Calculate the sum of the second loss function and the third loss function, and determine the sum as the target loss function.

3. A method for character recognition, using the character recognition model according to any one of claims 1 to 2, characterized in that: include: Acquire a target image to be recognized, wherein the target image includes a plurality of characters; Obtain a pre-trained text recognition model, wherein the text recognition model is trained based on text image samples and a convolutional recurrent neural network model; The target image is input into the text recognition model so that the text recognition model extracts image features of the target image and text features from the image features, and based on the text features, determines the text in the target image whose similarity is greater than a preset threshold and the number of texts corresponding to the text.

4. A training device for a text recognition model, characterized in that: include: An acquisition module, used for acquiring a text image sample, wherein the text image sample includes at least two characters whose similarity is greater than a preset threshold; A training module, used to train a convolutional recurrent neural network model using the text image samples to obtain a trained convolutional recurrent neural network model, including: obtaining label information corresponding to the text image samples, wherein the label information includes: a sample of the number of characters corresponding to characters whose similarity is greater than a preset threshold in the text image samples, and a sample of text features of characters whose similarity is greater than a preset threshold, and training a convolutional recurrent neural network model using the text image samples and the label information so that the convolutional recurrent neural network model learns the sample of text features of characters whose similarity is greater than the preset threshold, thereby obtaining a trained convolutional recurrent neural network model; and determining the trained convolutional recurrent neural network model as a pre-training model; A processing module, used to iteratively train the pre-trained model using the text image samples, obtain the initial training results output by the pre-trained model in each iterative training, and determine the training results that meet the preset requirements in the initial training results as the target training results, including: inputting the text image samples into the pre-trained model so that the pre-trained model predicts the text in the text image samples whose similarity is greater than a preset threshold and the number of texts corresponding to the texts based on the image features of the text image samples, determining the number of texts as the initial training result, and determining the training result in which the number of texts in the initial training result matches the sample of the number of texts carried in the label information as the target training result; An updating module is used to calculate a loss function based on the target training result, and to update the pre-training model using the loss function until a text recognition model is obtained.

5. A text recognition device, characterized in that: include: A first acquisition module is used to acquire a target image to be recognized, wherein the target image includes a plurality of characters; The second acquisition module acquires a pre-trained text recognition model, including: acquiring a text image sample, wherein the text image sample includes at least two characters whose similarity is greater than a preset threshold; Using the text image samples to train a convolutional recurrent neural network model to obtain a trained convolutional recurrent neural network model, including: obtaining label information corresponding to the text image samples, wherein the label information includes: a sample of the number of characters corresponding to characters whose similarity is greater than a preset threshold in the text image samples, and a sample of text features of characters whose similarity is greater than a preset threshold, and using the text image samples and the label information to train a convolutional recurrent neural network model so that the convolutional recurrent neural network model learns the sample of text features of characters whose similarity is greater than the preset threshold, thereby obtaining a trained convolutional recurrent neural network model; and determining the trained convolutional recurrent neural network model as a pre-training model; Iteratively training the pre-trained model using the text image samples to obtain initial training results output by the pre-trained model in each iterative training, and determining the training results that meet preset requirements in the initial training results as target training results, including: inputting the text image samples into the pre-trained model so that the pre-trained model predicts the text in the text image samples whose similarity is greater than a preset threshold and the number of texts corresponding to the texts based on the image features of the text image samples, determining the number of texts as the initial training result, and determining the training result in which the number of texts in the initial training result matches the sample of the number of texts carried in the label information as the target training result; Calculating a target loss function based on the target training result, and using the target loss function to update the pre-trained model until a text recognition model is obtained, wherein the text recognition model is obtained based on text image samples and a convolutional recurrent neural network model training; The recognition module is used to input the target image into the text recognition model so that the text recognition model extracts the image features of the target image and extracts the text features from the image features, and determines the text in the target image whose similarity is greater than a preset threshold and the number of texts corresponding to the texts based on the text features.

6. A storage medium, characterized in that: The storage medium includes a stored program, wherein the program executes the method steps of any one of claims 1 to 3 when executed.

7. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; wherein: Memory, used to store computer programs; A processor, configured to execute the method steps of any one of claims 1 to 3 by running a program stored in a memory.

Citation Information

Patent Citations

  • Model training method, character recognition method and device, electronic equipment and computer readable medium

    CN109902678A

  • Character recognition model training method and device

    CN113947773A