Text recognition network training method, device, computer equipment and storage medium
By obtaining the sample images of correct and easily confused text annotation information, calculating the loss value and training the text recognition network, the problem of low recognition accuracy of easily confused text in the prior art is solved, improving the recognition accuracy and simplifying the annotation process.
Patent Information
- Application Number
- CN202110997813.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-27
- Publication Date
- 2024-12-13
- Estimated Expiration
- 2041-08-27
AI Technical Summary
The existing text recognition network has low recognition accuracy for confusing texts during training, especially the high confusion rate between letters and numbers, resulting in insufficient recognition accuracy.
By obtaining sample images with correct and confusing text annotation information, compute the corresponding loss values, and train the text recognition network based on these loss values, use the pre-trained second text recognition network to generate confusing text annotation information to improve the network Identification ability.
The text recognition network's ability to recognize confusing texts is improved, the overall recognition accuracy is improved, the annotation process is simplified and the training process is accelerated.
Smart Images

Figure CN113705568B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of neural network technology, and in particular to a text recognition network training method, device, computer equipment and storage medium. Background Art
[0002] In the related art, when training the first text recognition network, generally, annotation information is added to the sample image with text, and the annotation information is used to represent the text content in the sample image. Then, the sample image is input into the first text recognition network, and then the first text recognition network is trained based on the output and annotation information of the first text recognition network.
[0003] However, since some characters are too similar, such as the letter "O" and the number "0", the first character recognition network trained based on this method has low recognition accuracy for these easily confused characters. Summary of the invention
[0004] The embodiments of the present disclosure at least provide a text recognition network training method, apparatus, computer equipment and storage medium.
[0005] In a first aspect, an embodiment of the present disclosure provides a text recognition network training method, comprising:
[0006] Acquire a sample image set with text, wherein the sample image set includes a first sample image corresponding to correct text annotation information and confusing text annotation information;
[0007] Determining predicted text content corresponding to the first sample image based on a first text recognition network to be trained;
[0008] Based on the correct text annotation information and the predicted text content, determining a first loss value when the correct text annotation information is used as the supervisory information; and based on the easily confused text annotation information and the predicted text content, determining a second loss value when the easily confused text annotation information is used as the supervisory information;
[0009] Based on the first loss value and the second loss value, the first text recognition network to be trained is trained.
[0010] Through the above method, the correct text annotation information and the easily confused text annotation information of the first sample image are respectively used as supervision data, and the first loss value and the second loss value in the training process are calculated. Then, based on the first loss value and the second loss value, the first character recognition network is trained. In this way, since the first sample image used by the first character recognition network in the training process is added with easily confused text annotation information, the first character recognition network can improve its recognition ability for easily confused text, that is, this training method improves the network accuracy of the first character recognition network.
[0011] In a possible implementation manner, the method further includes determining a first sample image in the sample image set and confusable text annotation information corresponding to the first sample image according to the following method:
[0012] Inputting a target sample image in the sample image set into a pre-trained second text recognition network to determine the predicted text content corresponding to the target sample image; wherein the second text recognition network is trained based on sample images in the sample image set and correct text annotation information corresponding to the sample images;
[0013] When it is detected based on the correct text annotation information of the target sample image that erroneous text content exists in the predicted text content corresponding to the target sample image, the target sample image is used as the first sample image, and the predicted text content of the target sample image is used as the confusing text annotation information of the first sample image.
[0014] In this way, by determining the first sample image and the easily confused text annotation information through the second text recognition network, the efficiency and accuracy of the first sample image annotation can be improved, and manual annotation of the first sample image can be avoided.
[0015] In a possible implementation, the first text recognition network to be trained is a pre-trained second text recognition network, and the second text recognition network is used to generate confusable text annotation information of the first sample image.
[0016] Directly training the second text recognition network based on the first sample image on the basis of the already trained second text recognition network can improve the training speed of the network.
[0017] In a possible implementation manner, when the first text recognition network to be trained is an untrained initial network, the sample image set further includes a second sample image corresponding to a correct text annotation.
[0018] The data volume of the first sample image in the sample image set is relatively small. When the first text recognition network to be trained is an untrained initial network, the network accuracy of the trained first text recognition network can be improved by training the first text recognition network based on the first sample image and the second sample image.
[0019] In a possible implementation, the training of the first text recognition network to be trained based on the first loss value and the second loss value includes:
[0020] Determine a first target loss value of the first sample image based on the first loss value and the second loss value of the first sample image; and use the first loss value corresponding to the second sample image as the second target loss value of the second sample image;
[0021] Determine a target loss value in this training process based on the first target loss value and the second target loss value;
[0022] Based on the target loss value, the first text recognition network to be trained is trained.
[0023] In a possible implementation manner, determining a first target loss value of the first sample image based on the first loss value and the second loss value of the first sample image includes:
[0024] Determining a contrast loss value based on a first loss value and a second loss value of the first sample image; the contrast loss value is used to indicate the ability of the first text recognition network to recognize easily confused text;
[0025] The first target loss value is determined based on the first loss value of the first sample image and the contrast loss value.
[0026] In a possible implementation manner, determining the contrast loss value based on the first loss value and the second loss value of the first sample image includes:
[0027] The difference between the first loss value and the second loss value of the first sample image is used as the contrast loss value.
[0028] In a second aspect, the present disclosure also provides a text recognition network training device, including:
[0029] An acquisition module, used for acquiring a sample image set with text, wherein the sample image set includes a first sample image corresponding to correct text annotation information and confusing text annotation information;
[0030] A first determination module, configured to determine predicted text content corresponding to the first sample image based on a first text recognition network to be trained;
[0031] A second determination module is used to determine a first loss value when the correct text annotation information is used as the supervision information based on the correct text annotation information and the predicted text content; and to determine a second loss value when the easily confused text annotation information is used as the supervision information based on the easily confused text annotation information and the predicted text content;
[0032] A training module is used to train the first text recognition network to be trained based on the first loss value and the second loss value.
[0033] In a possible implementation manner, the acquisition module is further configured to determine the first sample image in the sample image set and the easily-confusing text annotation information corresponding to the first sample image according to the following method:
[0034] Inputting a target sample image in the sample image set into a pre-trained second text recognition network to determine the predicted text content corresponding to the target sample image; wherein the second text recognition network is trained based on sample images in the sample image set and correct text annotation information corresponding to the sample images;
[0035] When it is detected based on the correct text annotation information of the target sample image that erroneous text content exists in the predicted text content corresponding to the target sample image, the target sample image is used as the first sample image, and the predicted text content of the target sample image is used as the confusing text annotation information of the first sample image.
[0036] In a possible implementation manner, the first character recognition network to be trained is the second character recognition network.
[0037] In a possible implementation manner, when the first text recognition network to be trained is an untrained initial network, the sample image set further includes second sample images corresponding only to correct text annotations.
[0038] In a possible implementation manner, the training module, when training the first text recognition network to be trained based on the first loss value and the second loss value, is used to:
[0039] Determine a first target loss value of the first sample image based on the first loss value and the second loss value of the first sample image; and use the first loss value corresponding to the second sample image as the second target loss value of the second sample image;
[0040] Determine a target loss value in this training process based on the first target loss value and the second target loss value;
[0041] Based on the target loss value, the first text recognition network to be trained is trained.
[0042] In a possible implementation manner, when determining the first target loss value of the first sample image based on the first loss value and the second loss value of the first sample image, the training module is configured to:
[0043] Determining a contrast loss value based on a first loss value and a second loss value of the first sample image; the contrast loss value is used to indicate the ability of the first text recognition network to recognize easily confused text;
[0044] The first target loss value is determined based on the first loss value of the first sample image and the contrast loss value.
[0045] In a possible implementation, when determining the contrast loss value based on the first loss value and the second loss value of the first sample image, the training module is used to:
[0046] The difference between the first loss value and the second loss value of the first sample image is used as the contrast loss value.
[0047] In a third aspect, an embodiment of the present disclosure further provides a computer device, comprising: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the computer device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the steps of the above-mentioned first aspect, or any possible implementation of the first aspect are performed.
[0048] In a fourth aspect, an embodiment of the present disclosure further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned first aspect or any possible implementation of the first aspect are executed.
[0049] For a description of the effects of the above-mentioned text recognition network training device, computer equipment, and computer-readable storage medium, please refer to the description of the above-mentioned text recognition network training method, which will not be repeated here.
[0050] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following is a brief introduction to the drawings required for use in the embodiments. The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and are used together with the specification to illustrate the technical solutions of the present disclosure. It should be understood that the following drawings only illustrate certain embodiments of the present disclosure and should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can also be obtained based on these drawings without creative work.
[0052] Figure 1 A flowchart of a text recognition network training method provided by an embodiment of the present disclosure is shown;
[0053] Figure 2 A flowchart of a method for determining a first sample image and easily-confusing text annotation information of the first sample image in a text recognition network training method provided by an embodiment of the present disclosure is shown;
[0054] Figure 3 A schematic diagram of the structure of a text recognition network training device provided by an embodiment of the present disclosure is shown;
[0055] Figure 4 A schematic diagram of the structure of a computer device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0056] In order to make the purpose, technical scheme and advantages of the embodiments of the present disclosure clearer, the technical scheme in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all of the embodiments. The components of the embodiments of the present disclosure generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure provided in the drawings is not intended to limit the scope of the present disclosure for protection, but merely represents the selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present disclosure.
[0057] Research has found that in traditional implementations, since there is no separate training for the neural network's ability to recognize easily confused texts, the trained neural network has weak recognition capabilities for easily confused texts and low recognition accuracy.
[0058] Based on this, the present disclosure provides a text recognition network training method, apparatus, computer equipment and storage medium, which respectively use the correct text annotation information and the easily confused text annotation information of the first sample image as supervision data, calculate the first loss value and the second loss value in the training process, and then train the first text recognition network based on the first loss value and the second loss value. In this way, since the first sample image used by the first text recognition network in the training process has the easily confused text annotation information added, the first text recognition network can improve its recognition ability for easily confused text, that is, this training method improves the network accuracy of the first text recognition network.
[0059] The defects existing in the above traditional solutions are the results obtained by the inventors after practice and careful research. Therefore, the discovery process of the above problems and the solutions proposed by the present disclosure for the above problems below should be the contributions made by the inventors to the present disclosure during the disclosure process.
[0060] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0061] To facilitate understanding of this embodiment, a text recognition network training method disclosed in the embodiment of the present disclosure is first introduced in detail. The executor of the text recognition network training method provided in the embodiment of the present disclosure is generally a computer device with certain computing capabilities, and the computer device includes, for example: a terminal device or a server or other processing device.
[0062] See also Figure 1 FIG. 1 is a flowchart of a text recognition network training method provided by an embodiment of the present disclosure, wherein the method includes steps 101 to 104, wherein:
[0063] Step 101: Acquire a sample image set with text, wherein the sample image set includes a first sample image corresponding to correct text annotation information and confusing text annotation information.
[0064] Step 102: Determine the predicted text content corresponding to the first sample image based on the first text recognition network to be trained.
[0065] Step 103: Based on the correct text annotation information and the predicted text content, determine a first loss value when the correct text annotation information is used as the supervisory information; and based on the confusable text annotation information and the predicted text content, determine a second loss value when the confusable text annotation information is used as the supervisory information.
[0066] Step 104: Train the first text recognition network to be trained based on the first loss value and the second loss value.
[0067] The following is a detailed description of the above steps.
[0068] For step 101,
[0069] Here, the correct text annotation information is used to indicate the correct text in the first sample image, and the easily confused text annotation information is used to indicate the easily confused text corresponding to at least part of the correct text in the first sample image.
[0070] For example, if the text in the first sample image is "hello", the correct text annotation information corresponding to the first sample image may be "hello", and the confusing text corresponding to the letter "o" is the number "0", then the confusing text annotation information corresponding to the first sample image may be "hell0". It can be seen that the confusing text annotation information includes some correct text and another part of confusing text corresponding to the correct text.
[0071] In a possible implementation, the correct text annotation information and the confusing text annotation information corresponding to the first sample image may be pre-annotated. For example, after acquiring the sample image set, the confusing text annotation information corresponding to the first sample image may be determined based on the correct text annotation information of the first sample image.
[0072] Specifically, when determining the first sample image in the sample image set and the easily confusing text annotation information corresponding to the first sample image, the following may be referred to: Figure 2 The method shown includes the following steps:
[0073] Step 201: Input the target sample image in the sample image set into a pre-trained second text recognition network to determine the predicted text content corresponding to the target sample image; wherein the second text recognition network is trained based on the sample images in the sample image set and the correct text annotation information corresponding to the sample images.
[0074] Here, the second text recognition network may be a pre-trained network. Specifically, the target sample image may be input into the second text recognition network to be trained to obtain the predicted text content corresponding to the second text recognition network, and then the loss value in this training process is determined based on the predicted text content and the correct text annotation information, and the second text recognition network is trained based on the loss value. The sample images used in the process of training the second text recognition network may be images in the sample image set.
[0075] Step 202: When it is detected based on the correct text annotation information of the target sample image that erroneous text content exists in the predicted text content corresponding to the target sample image, the target sample image is used as the first sample image, and the predicted text content of the target sample image is used as the confusing text annotation information of the first sample image.
[0076] Although the second text recognition network is well trained, its recognition accuracy cannot reach 100%, so missed recognition or wrong recognition may occur. The presence of wrong text content in the predicted text content can be understood as incorrectly recognizing some characters in the sample image as other characters, such as recognizing the letter "o" as the number "0" and the letter "l" as the number "1".
[0077] In a possible implementation, when the same target sample image is input into the second text recognition network, multiple different results may be obtained, for example, the letter "l" may be recognized as the number "1" or the letter "I". Therefore, there may be multiple easily confused text annotation information corresponding to the sample image, and different easily confused text annotation information may be added to the same sample image and used as different first sample images to participate in the training of the neural network.
[0078] Exemplarily, the confusing texts corresponding to sample image 1 may include three: a, b, and c. Then, correct text annotation information and confusing text annotation information a may be added to sample image 1 as a first sample image, correct text annotation information and confusing text annotation information b may be added to sample image 1 as a first sample image, and correct text annotation information and confusing text annotation information c may be added to sample image 1 as a first sample image, thereby obtaining three first sample images based on sample image 1.
[0079] For step 102,
[0080] Here, the first character recognition network to be trained may refer to the pre-trained second character recognition network described in step 101. Since the second character recognition network has been preliminarily trained, when training the first character recognition network to be trained (i.e., the pre-trained second character recognition network described above), in order to improve the network training efficiency, only the first sample image described in step 101 may be used to train the first character recognition network. Alternatively, the first character recognition network to be trained may refer to an untrained initial network.
[0081] In a possible implementation, the sample image set also includes a second sample image corresponding to correct text annotation information, wherein the second sample image may also carry other annotation information. In order to ensure the network accuracy of the trained first text recognition network, the first sample image and the second sample image can be used simultaneously to train the first text recognition network.
[0082] In the case where the first text recognition network to be trained is an untrained initial network, since the sample data amount of the first sample image is small, the network accuracy may be insufficient if the initial network is trained only by the first sample image. Therefore, the initial network can be trained based on the first sample image and the second sample image at the same time.
[0083] In other words, if the initial network is trained only based on the first sample image, since the first sample image only contains easily confused text, the trained first text recognition network has a stronger recognition ability for easily confused text and a weaker recognition ability for non-easy confused text. Therefore, in order to improve the recognition ability for non-easy confused text, the initial network can be trained based on the first sample image and the second sample image at the same time.
[0084] When the first text recognition network to be trained is trained based on the first sample image and the second sample image at the same time, multiple first sample images and / or second sample images can be used as a group of sample images (a batch), and the sample images in the group of sample images are input into the first text recognition network to be trained in sequence to determine the corresponding predicted text content.
[0085] For step 103,
[0086] In a possible implementation, the first loss value and the second loss value may be the same type of loss, for example, both may be cross entropy loss or connectionist temporal classification (CTC) loss. The specific calculation method of the first loss value and the second loss value will not be described in detail here.
[0087] Here, if the correct text annotation information is used as the supervisory information, the first loss value can be used to characterize the probability that the first text recognition network recognizes the text in the sample image as the text content corresponding to the correct text annotation information, and the larger the first loss value, the lower the probability; if the confusing text annotation information is used as the supervisory information, the second loss value can be used to characterize the probability that the first text recognition network recognizes the text in the sample image as the text content corresponding to the confusing text annotation information, and the larger the second loss value, the lower the probability.
[0088] For step 104,
[0089] If only the first sample image is used when training the first text recognition network to be trained, then when training the first text recognition network based on the first loss value and the second loss value, a contrast loss value can be first calculated based on the first loss value and the second loss value, and the contrast loss value is used to represent the ability of the first text recognition network to recognize easily confused text; then, based on the first loss value and the contrast loss value, a target loss value in this training process is determined, and the first text recognition network is trained based on the target loss value.
[0090] Specifically, for each first sample image, the target loss value corresponding to the first sample image can be determined based on the first loss value and the contrast loss value of the first sample image, and then based on the target loss values corresponding to each first sample image in this training process, the average loss value is calculated, and the average loss value is used as the target loss value in this training process.
[0091] Exemplarily, the target loss value corresponding to the first sample image may be calculated by the following formula:
[0092] L total =L gt +λL conmpare
[0093] Among them, L total represents the target loss value, L gt represents the first loss value, L conmpare represents the contrast loss value, and λ is a pre-set weight hyperparameter.
[0094] Here, λ can be understood as a balancing coefficient, that is, a coefficient set to balance the influence of the first loss value and the comparison loss value on the target loss value.
[0095] The purpose of training the neural network in the end is to reduce the target loss value, which can be further understood as reducing the first loss value and the contrast loss value. The contrast loss value can refer to the difference between the first loss value and the second loss value. The meaning of reducing the contrast loss can be understood as minimizing the first loss value while maximizing the second loss value. The minimizing the first loss value can be understood as making it more likely that the prediction result of the first text recognition network is consistent with the text content corresponding to the correct text annotation information. The maximizing the second loss value can be understood as making it less likely that the prediction result of the first text recognition network is consistent with the text content corresponding to the confusing text annotation information.
[0096] If the first sample image and the second sample image are used when training the first text recognition network to be trained, then based on the first loss value and the second loss value, when training the first text recognition network, the first target loss value of the first sample image can be determined based on the first loss value and the second loss value of the first sample image; and the first loss value corresponding to the second sample image is used as the second target loss value of the second sample image; and then based on the first target loss value and the second target loss value, the target loss value of this training process is determined; and then based on the target loss value, the first text recognition network is trained.
[0097] Here, the first target loss value may refer to the target loss value described in the above formula, that is, the first target loss value is calculated by calculating the contrast loss value and then substituting the first loss value and the contrast loss value into the above formula.
[0098] Since the second sample image does not have confusing text annotation information, it can be considered that the contrast loss value of the second sample image is 0.
[0099] When determining the target loss value of this training process based on the first target loss value and the second target loss value, the average value of the target loss values corresponding to the sample images used in the training process can be used as the target loss value of this training process.
[0100] In the text recognition network training method provided by the embodiment of the present disclosure, the correct text annotation information and the easily confused text annotation information of the first sample image are respectively used as supervision data, and the first loss value and the second loss value in the training process are calculated. Then, based on the first loss value and the second loss value, the first text recognition network is trained. In this way, since the easily confused text annotation information is added to the first sample image used by the first text recognition network in the training process, the first text recognition network can improve its recognition ability for easily confused text, that is, this training method improves the network accuracy of the first text recognition network.
[0101] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.
[0102] Based on the same inventive concept, the embodiment of the present disclosure also provides a text recognition network training device corresponding to the text recognition network training method. Since the principle of solving the problem by the device in the embodiment of the present disclosure is similar to the above-mentioned text recognition network training method in the embodiment of the present disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.
[0103] Reference Figure 3 , which is a schematic diagram of the architecture of a text recognition network training device provided by an embodiment of the present disclosure, the device includes: an acquisition module 301, a first determination module 302, a second determination module 303, and a training module 304; wherein,
[0104] An acquisition module 301 is used to acquire a sample image set with text, wherein the sample image set includes a first sample image corresponding to correct text annotation information and confusing text annotation information;
[0105] A first determination module 302, configured to determine the predicted text content corresponding to the first sample image based on a first text recognition network to be trained;
[0106] A second determination module 303 is used to determine a first loss value when the correct text annotation information is used as the supervision information based on the correct text annotation information and the predicted text content; and to determine a second loss value when the easily confused text annotation information is used as the supervision information based on the easily confused text annotation information and the predicted text content;
[0107] The training module 304 is used to train the first text recognition network to be trained based on the first loss value and the second loss value.
[0108] In a possible implementation manner, the acquisition module 301 is further configured to determine the first sample image in the sample image set and the easily-confusing text annotation information corresponding to the first sample image according to the following method:
[0109] Inputting a target sample image in the sample image set into a pre-trained second text recognition network to determine the predicted text content corresponding to the target sample image; wherein the second text recognition network is trained based on sample images in the sample image set and correct text annotation information corresponding to the sample images;
[0110] When it is detected based on the correct text annotation information of the target sample image that erroneous text content exists in the predicted text content corresponding to the target sample image, the target sample image is used as the first sample image, and the predicted text content of the target sample image is used as the confusing text annotation information of the first sample image.
[0111] In a possible implementation, the first text recognition network to be trained is a pre-trained second text recognition network, and the second text recognition network is used to generate confusable text annotation information of the first sample image.
[0112] In a possible implementation manner, when the first text recognition network to be trained is an untrained initial network, the sample image set further includes a second sample image corresponding to a correct text annotation.
[0113] In a possible implementation manner, the training module 304, when training the first text recognition network to be trained based on the first loss value and the second loss value, is configured to:
[0114] Determine a first target loss value of the first sample image based on the first loss value and the second loss value of the first sample image; and use the first loss value corresponding to the second sample image as the second target loss value of the second sample image;
[0115] Determine a target loss value in this training process based on the first target loss value and the second target loss value;
[0116] Based on the target loss value, the first text recognition network to be trained is trained.
[0117] In a possible implementation manner, when determining the first target loss value of the first sample image based on the first loss value and the second loss value of the first sample image, the training module 304 is configured to:
[0118] Determining a contrast loss value based on a first loss value and a second loss value of the first sample image; the contrast loss value is used to indicate the ability of the first text recognition network to recognize easily confused text;
[0119] The first target loss value is determined based on the first loss value of the first sample image and the contrast loss value.
[0120] In a possible implementation, the training module 304, when determining the contrast loss value based on the first loss value and the second loss value of the first sample image, is configured to:
[0121] The difference between the first loss value and the second loss value of the first sample image is used as the contrast loss value.
[0122] For descriptions of the processing flow of each module in the device and the interaction flow between each module, reference may be made to the relevant descriptions in the above method embodiment, which will not be described in detail here.
[0123] Based on the same technical concept, the embodiment of the present disclosure also provides a computer device. Figure 4As shown, it is a schematic diagram of the structure of a computer device 400 provided in an embodiment of the present disclosure, including a processor 401, a memory 402, and a bus 403. Among them, the memory 402 is used to store execution instructions, including a memory 4021 and an external memory 4022; the memory 4021 here is also called an internal memory, which is used to temporarily store the operation data in the processor 401, and the data exchanged with the external memory 4022 such as a hard disk. The processor 401 exchanges data with the external memory 4022 through the memory 4021. When the computer device 400 is running, the processor 401 communicates with the memory 402 through the bus 403, so that the processor 401 executes the following instructions:
[0124] Acquire a sample image set with text, wherein the sample image set includes a first sample image corresponding to correct text annotation information and confusing text annotation information;
[0125] Determining predicted text content corresponding to the first sample image based on a first text recognition network to be trained;
[0126] Based on the correct text annotation information and the predicted text content, determining a first loss value when the correct text annotation information is used as the supervisory information; and based on the easily confused text annotation information and the predicted text content, determining a second loss value when the easily confused text annotation information is used as the supervisory information;
[0127] Based on the first loss value and the second loss value, the first text recognition network to be trained is trained.
[0128] In a possible implementation manner, in the instructions executed by the processor 401, the method further includes determining the first sample image in the sample image set and the easily confusing text annotation information corresponding to the first sample image according to the following method:
[0129] Inputting a sample image in the sample image set into a pre-trained second text recognition network to determine the predicted text content corresponding to the sample image; wherein the second text recognition network is trained based on the sample image and the correct text annotation information corresponding to the sample image;
[0130] When it is detected based on the correct text annotation information of any sample image that erroneous text content exists in the predicted text content corresponding to the sample image, the sample image is used as the first sample image, and the predicted text content of the sample image is used as the confusing text annotation information of the sample image.
[0131] In a possible implementation, in the instructions executed by the processor 401, the first text recognition network to be trained is a pre-trained second text recognition network, and the second text recognition network is used to generate confusable text annotation information of the first sample image.
[0132] In a possible implementation, in the instructions executed by the processor 401, when the first text recognition network to be trained is an untrained initial network, the sample image set also includes a second sample image corresponding to a correct text annotation.
[0133] In a possible implementation manner, in the instructions executed by the processor 401, the step of training the first text recognition network to be trained based on the first loss value and the second loss value includes:
[0134] Determine a first target loss value of the first sample image based on the first loss value and the second loss value of the first sample image; and use the first loss value corresponding to the second sample image as the second target loss value of the second sample image;
[0135] Determine a target loss value in this training process based on the first target loss value and the second target loss value;
[0136] Based on the target loss value, the first text recognition network to be trained is trained.
[0137] In a possible implementation manner, in the instruction executed by the processor 401, determining the first target loss value of the first sample image based on the first loss value and the second loss value of the first sample image includes:
[0138] Determining a contrast loss value based on a first loss value and a second loss value of the first sample image; the contrast loss value is used to indicate the ability of the first text recognition network to recognize easily confused text;
[0139] The first target loss value is determined based on the first loss value of the first sample image and the contrast loss value.
[0140] In a possible implementation manner, in the instruction executed by the processor 401, determining the contrast loss value based on the first loss value and the second loss value of the first sample image includes:
[0141] The difference between the first loss value and the second loss value of the first sample image is used as the contrast loss value.
[0142] The present disclosure also provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the steps of the text recognition network training method described in the above method embodiment are executed. The storage medium can be a volatile or non-volatile computer-readable storage medium.
[0143] The present disclosure also provides a computer program product that carries a program code. The program code includes instructions that can be used to execute the steps of the text recognition network training method described in the above method embodiment. For details, please refer to the above method embodiment, which will not be repeated here.
[0144] The computer program product may be implemented in hardware, software or a combination thereof. In one optional embodiment, the computer program product is implemented as a computer storage medium. In another optional embodiment, the computer program product is implemented as a software product, such as a software development kit (SDK).
[0145] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. In the several embodiments provided in the present disclosure, it should be understood that the disclosed system, device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the device or unit can be electrical, mechanical or other forms.
[0146] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0147] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0148] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0149] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present disclosure, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.
Claims
1. A text recognition network training method, It is characterized in that include: Acquire a sample image set with text, wherein the sample image set includes a first sample image corresponding to correct text annotation information and confusing text annotation information; Determining predicted text content corresponding to the first sample image based on a first text recognition network to be trained; Based on the correct text annotation information and the predicted text content, determining a first loss value when the correct text annotation information is used as the supervisory information; and based on the easily confused text annotation information and the predicted text content, determining a second loss value when the easily confused text annotation information is used as the supervisory information; Based on the first loss value and the second loss value, training the first text recognition network to be trained; The step of training the first text recognition network to be trained based on the first loss value and the second loss value includes: Determine the difference between the first loss value and the second loss value as a contrast loss value; wherein the contrast loss value is used to indicate the ability of the first text recognition network to recognize easily confusing text; Determine a target loss value corresponding to each first sample image based on the first loss value and the contrast loss value of each first sample image; Based on the target loss values corresponding to the first sample images, an average loss value is determined, and the average loss value is used as the target loss value in this training process; The first text recognition network to be trained is trained based on the target loss value in this training process.
2. The method according to claim 1, It is characterized in that The method further includes determining a first sample image in the sample image set and confusable text annotation information corresponding to the first sample image according to the following method: Inputting a target sample image in the sample image set into a pre-trained second text recognition network to determine the predicted text content corresponding to the target sample image; wherein the second text recognition network is trained based on sample images in the sample image set and correct text annotation information corresponding to the sample images; When it is detected based on the correct text annotation information of the target sample image that erroneous text content exists in the predicted text content corresponding to the target sample image, the target sample image is used as the first sample image, and the predicted text content of the target sample image is used as the confusing text annotation information of the first sample image.
3. The method according to claim 1 or 2, It is characterized in that The first text recognition network to be trained is a pre-trained second text recognition network, and the second text recognition network is used to generate easily confusing text annotation information of the first sample image.
4. The method according to any one of claims 1 to 3, It is characterized in that In the case that the first text recognition network to be trained is an untrained initial network, the sample image set also includes a second sample image corresponding to a correct text annotation.
5. The method according to claim 4, It is characterized in that The step of training the first text recognition network to be trained based on the first loss value and the second loss value includes: Determine a first target loss value of the first sample image based on the first loss value and the second loss value of the first sample image; and use the first loss value corresponding to the second sample image as the second target loss value of the second sample image; Determine a target loss value in this training process based on the first target loss value and the second target loss value; Based on the target loss value, the first text recognition network to be trained is trained.
6. The method according to claim 5, It is characterized in that The determining a first target loss value of the first sample image based on the first loss value and the second loss value of the first sample image includes: Determining a contrast loss value based on a first loss value and a second loss value of the first sample image; the contrast loss value is used to indicate the ability of the first text recognition network to recognize easily confused text; The first target loss value is determined based on the first loss value of the first sample image and the contrast loss value.
7. The method according to claim 6, It is characterized in that The determining of the contrast loss value based on the first loss value and the second loss value of the first sample image includes: The difference between the first loss value and the second loss value of the first sample image is used as the contrast loss value.
8. A text recognition network training device, It is characterized in that include: An acquisition module, used for acquiring a sample image set with text, wherein the sample image set includes a first sample image corresponding to correct text annotation information and confusing text annotation information; A first determination module, configured to determine predicted text content corresponding to the first sample image based on a first text recognition network to be trained; A second determination module is used to determine a first loss value when the correct text annotation information is used as the supervision information based on the correct text annotation information and the predicted text content; and to determine a second loss value when the easily confused text annotation information is used as the supervision information based on the easily confused text annotation information and the predicted text content; A training module, used for training the first text recognition network to be trained based on the first loss value and the second loss value; Wherein, the training module is specifically used for: Determine the difference between the first loss value and the second loss value as a contrast loss value; wherein the contrast loss value is used to indicate the ability of the first text recognition network to recognize easily confusing text; Determine a target loss value corresponding to each first sample image based on the first loss value and the contrast loss value of each first sample image; Based on the target loss values corresponding to the first sample images, an average loss value is determined, and the average loss value is used as the target loss value in this training process; The first text recognition network to be trained is trained based on the target loss value in this training process.
9. A computer device, It is characterized in that include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the computer device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the steps of the text recognition network training method as described in any one of claims 1 to 7 are performed.
10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the text recognition network training method as described in any one of claims 1 to 7 are executed.
