Evaluation method and device of optical character recognition model and electronic equipment

By combining text box selection accuracy and edit distance, the performance of the optical character recognition model is evaluated, which solves the problems of single evaluation dimension and strong dependence in the existing technology, and improves the comprehensiveness and accuracy of the evaluation.

CN118537868APending Publication Date: 2024-08-23GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202310156539.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-02-22
Publication Date
2024-08-23

AI Technical Summary

Technical Problem

Existing technology has limitations when evaluating the performance of optical character recognition (OCR) models, especially its strong dependence on text recognition and detection, and its single evaluation dimension, which fails to fully consider factors such as character replacement and text position.

Method used

By combining the text box selection accuracy of the recognized text output by the model and the edit distance between the recognized text and the test text, the performance of the model is evaluated to improve the comprehensiveness and representativeness of the evaluation.

Benefits of technology

A more comprehensive and representative evaluation of OCR model performance is achieved, which can more accurately reflect the model's performance in text recognition and detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118537868A
    Figure CN118537868A
Patent Text Reader

Abstract

The invention discloses an evaluation method and device of an optical character recognition model and electronic equipment. The method comprises the following steps: inputting a test image into a target optical character recognition (OCR) model, and obtaining a recognition text in the test image output by the target OCR model and a textbox position of the recognition text; if the overlap ratio of the textbox position of the test text and the textbox position of the recognition text is greater than an overlap ratio threshold value, calculating an editing distance between a character string of the recognition text and a character string of the test text; the recognition accuracy of the target OCR model is obtained on the basis of the editing distance, then the model is evaluated by combining the text box selection accuracy of the recognition text output by the model and the editing distance between the recognition text and the test text, and the comprehensiveness and representativeness of model evaluation are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image recognition technology, and more specifically, to an evaluation method, device and electronic device for an optical character recognition model. Background Art

[0002] With the development of science and technology, optical character recognition (OCR) technology has been proposed in the field of image recognition technology. Among them, OCR technology can convert printed text in an image into a text format that can be processed by a computer. With the continuous development of big data and deep learning technology, OCR technology has made breakthrough progress, and the use of OCR models has become more and more extensive. Therefore, in related technologies, there are more and more comprehensive requirements for the evaluation of OCR model performance. Summary of the invention

[0003] In view of the above problems, the present application proposes an evaluation method, device, electronic device and storage medium for an optical character recognition model, which can improve the comprehensiveness and representativeness of the model evaluation by combining the text box selection accuracy of the recognized text output by the model and the editing distance between the recognized text and the test text.

[0004] In a first aspect, an embodiment of the present application provides an evaluation method for an optical character recognition model, the method comprising: obtaining a test image set, wherein the test image set comprises a plurality of test images and annotated text corresponding to each of the test images, the annotated text corresponding to each of the test images comprising a test text included in each of the test images and a text box position of the test text; inputting the test image into a target optical character recognition (OCR) model to obtain recognized text in the test image output by the target OCR model, and the text box position of the recognized text; if the degree of overlap between the text box position of the test text and the text box position of the recognized text is greater than a degree of overlap threshold, calculating the edit distance between the character string of the recognized text and the character string of the test text; and obtaining the recognition accuracy of the target OCR model based on the edit distance.

[0005] In the second aspect, the embodiment of the present application provides an evaluation device for an optical character recognition model, the device comprising: a test image set acquisition module, a test image recognition module, an edit distance calculation module, and a recognition accuracy acquisition module. The test image set acquisition module is used to acquire a test image set, wherein the test image set includes multiple test images and annotated texts corresponding to each of the test images, and the annotated texts corresponding to each of the test images include the test text included in each of the test images and the text box position of the test text; the test image recognition module is used to input the test image into a target optical character recognition (OCR) model to obtain the recognized text in the test image output by the target OCR model, and the text box position of the recognized text; the edit distance calculation module is used to calculate the edit distance between the character string of the recognized text and the character string of the test text if the overlap between the text box position of the test text and the text box position of the recognized text is greater than the overlap threshold; the recognition accuracy acquisition module is used to obtain the recognition accuracy of the target OCR model based on the edit distance.

[0006] In a third aspect, an embodiment of the present application provides an electronic device, comprising a memory and a processor, wherein the memory is coupled to the processor, the memory stores instructions, and when the instructions are executed by the processor, the processor executes the above method.

[0007] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which a program code is stored, and the program code can be called by a processor to execute the above method.

[0008] The evaluation method, device, electronic device and storage medium of the optical character recognition model provided in the embodiments of the present application are as follows: obtaining a test image set, wherein the test image set includes multiple test images and annotated text corresponding to each test image, and the annotated text corresponding to each test image includes the test text included in each test image and the text box position of the test text; inputting the test image into a target optical character recognition (OCR) model to obtain the recognized text in the test image output by the target OCR model, and the text box position of the recognized text; if the overlap between the text box position of the test text and the text box position of the recognized text is greater than the overlap threshold, then calculating the edit distance between the character string of the recognized text and the character string of the test text; obtaining the recognition accuracy of the target OCR model based on the edit distance, and then evaluating the model by combining the text box selection accuracy of the recognized text output by the model and the edit distance between the recognized text and the test text, thereby improving the comprehensiveness and representativeness of the model evaluation. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0010] Figure 1 A schematic diagram showing a flow chart of an evaluation method for an optical character recognition model provided by an embodiment of the present application;

[0011] Figure 2 A structural block diagram of an electronic device provided by an embodiment of the present application is shown;

[0012] Figure 3 A schematic diagram of an interface for model evaluation provided by an embodiment of the present application is shown;

[0013] Figure 4 A schematic diagram of text box position matching provided by an embodiment of the present application is shown;

[0014] Figure 5 A schematic diagram of text box position matching provided by an embodiment of the present application is shown;

[0015] Figure 6 A schematic diagram of text box position matching provided by an embodiment of the present application is shown;

[0016] Figure 7 A timing diagram of an optical character recognition model evaluation method provided by an embodiment of the present application is shown;

[0017] Figure 8 A schematic diagram showing a flow chart of an evaluation method for an optical character recognition model provided by an embodiment of the present application;

[0018] Fig. 9 A schematic diagram of text box position matching provided by an embodiment of the present application is shown;

[0019] Fig.10 A schematic diagram of text box position matching provided by an embodiment of the present application is shown;

[0020] Fig.11 A schematic diagram of text box position matching provided by an embodiment of the present application is shown;

[0021] Fig.12 A schematic diagram showing a flow chart of an evaluation method for an optical character recognition model provided by an embodiment of the present application;

[0022] Fig.13 A schematic diagram of an interface for model evaluation provided by an embodiment of the present application is shown;

[0023] Fig.14 A schematic diagram showing a flow chart of an evaluation method for an optical character recognition model provided by an embodiment of the present application;

[0024] Fig.15 A module block diagram of an optical character recognition model evaluation device provided by an embodiment of the present application is shown;

[0025] Fig.16 A block diagram of an electronic device according to an embodiment of the present application for executing an evaluation method of an optical character recognition model according to an embodiment of the present application is shown;

[0026] Fig.17 A storage unit for storing or carrying program codes for implementing an evaluation method for an optical character recognition model according to an embodiment of the present application is shown. DETAILED DESCRIPTION

[0027] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution 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.

[0028] At present, the evaluation of the recognition accuracy of the OCR system usually includes two steps: text detection and text recognition. In the related art, text detection mainly uses the score of the detection box and the annotation box when the overlap (Intersection over Union, IOU) = 0.5 as the threshold as the evaluation index, while text recognition uses character accuracy or field accuracy as the evaluation index. Therefore, in the related art, in the OCR system, since text recognition has a high dependence on the text detection positioning results, there are limitations in the evaluation of the OCR system.

[0029] In addition, the methods for evaluating OCR models in related technologies are mostly targeted at a single specified OCR model, and the performance of the current model is evaluated by calculating the recognition accuracy of the model to recognize the text, without the ability to evaluate multiple OCR models horizontally. Therefore, the methods for calculating the recognition accuracy of the model are mostly based on the single dimension of the number of words in the text, without considering dimensions such as character replacement and text position. Therefore, in related technologies, the methods for evaluating OCR models have the problems of a single evaluation dimension and a single evaluation model.

[0030] In view of the above problems, the inventors have discovered after long-term research and proposed the evaluation method, device, electronic device and storage medium of the optical character recognition model provided in the embodiments of the present application. By combining the text selection accuracy of the recognized text output by the model and the edit distance evaluation model between the recognized text and the test text, the comprehensiveness and representativeness of the model evaluation are improved. Among them, the specific evaluation method of the optical character recognition model is described in detail in the subsequent embodiments.

[0031] See also Figure 1 , Figure 1 The flowchart of the evaluation method of the optical character recognition model provided by an embodiment of the present application is shown. The evaluation method of the optical character recognition model improves the comprehensiveness and representativeness of the model evaluation by combining the text selection accuracy of the recognized text output by the model and the edit distance evaluation model between the recognized text and the test text. In a specific embodiment, the evaluation method of the optical character recognition model can be applied to Fig.15 The optical character recognition model evaluation device 200 and the electronic device 100 ( Fig.16 ). The following will take an electronic device as an example to illustrate the specific process of this embodiment. Of course, it can be understood that the electronic device used in this embodiment may include a smart phone, a tablet computer, a wearable electronic device, etc., which is not limited here. Figure 1 The process shown is described in detail, and the evaluation method of the optical character recognition model may specifically include the following steps:

[0032] Step S110: Acquire a test image set, wherein the test image set includes multiple test images and annotated text corresponding to each of the test images, and the annotated text corresponding to each of the test images includes the test text included in each of the test images and the text box position of the test text.

[0033] In this embodiment, the electronic device can obtain a test image set from an associated cloud or electronic device through wireless communication technology (such as WiFi, Bluetooth, Zigbee, etc.). The test image set can be understood as a data set for evaluating a model; the test image set can include multiple test images and annotated texts corresponding to each test image. The annotated text corresponding to each test image includes the test text included in each test image and the text box position of the test text.

[0034] The test texts included in the multiple test images may correspond to different voice types or the same language type, wherein the language type may include Chinese, English, Japanese, Korean, etc., which are not limited here.

[0035] Among them, each test image and the annotation text corresponding to each test image can be associated with each other by using the same file name. Further, in the process of the electronic device acquiring the test image set, each test image and the annotation text corresponding to each test image can be obtained based on the file name.

[0036] Exemplarily, a user may upload a test image set to a cloud server through a client. When an electronic device needs to obtain the test image set, it may call a software development kit (SDK) or an interface of a corresponding OCR model to obtain the test image set from the cloud server.

[0037] See also Figure 2 , which shows a structural block diagram of an electronic device provided by an embodiment of the present application. Among them, the electronic device may include a data transmission module, an OCR model execution module and a model evaluation module. Among them, the data transmission module can be used to obtain a test image set from an associated cloud or electronic device; it can also receive the recognition result returned by the OCR model execution module and the evaluation result returned by the model evaluation model; it can also display the recognition result and the evaluation result to the user through a user interface (User Interface, UI); it can also receive and store a test image set uploaded by a user.

[0038] Among them, the recognition results returned by the OCR model execution module may include the results of text recognition included in the test image and the detection results of the area of ​​text included in the test image; the evaluation results returned by the model evaluation model may include model evaluation indicators such as the accuracy of the evaluated model, the recall rate of the evaluated model, etc.

[0039] Step S120: inputting the test image into a target optical character recognition (OCR) model, obtaining the recognized text in the test image output by the target OCR model, and the text box position of the recognized text.

[0040] In this embodiment, a plurality of OCR models may be pre-stored in the electronic device, and the electronic device may receive a model determination operation sent by a user, and determine a target OCR model from the plurality of OCR models.

[0041] As an implementable manner, the electronic device may generate and display a model determination interface, wherein the model determination interface includes multiple OCR models. Further, the electronic device may obtain a model determination operation issued by the user based on the model determination interface, and determine a target OCR model from the multiple OCR models based on the model determination operation. The model determination operation issued by the user based on the model determination interface may be a touch operation on a screen included in the electronic device, or may be a press operation on a button included in the electronic device, which is not limited here.

[0042] In some embodiments, the electronic device may receive a first evaluation instruction, wherein the first evaluation instruction may carry an application authentication key (APP_KEY) and a verification key (SECRET_KEY). APP_KEY and SECRET_KEY may be used to authenticate the target OCR model interface call, and accordingly, if the authentication is successful, that is, if APP_KEY and SECRET_KEY match, the target OCR model may be called.

[0043] For example, see Figure 3 , Figure 3 A model evaluation interface generated by an electronic device provided by an embodiment of the present application is shown. The model evaluation interface may include multiple OCR models, such as Baidu, Youdao, Tencent, iFLYTEK, and the American Research Institute. The model evaluation interface may also include an APP_KEY input box for inputting the APP_KEY applied by each algorithm platform, and a SECRET_KEY input box for inputting the SECRET_KEY applied by each algorithm platform.

[0044] In some embodiments, after the electronic device determines the target OCR model, it can call the interface of the target OCR model to obtain a test image from a test image set, and call the target OCR model to recognize the test image, and obtain the recognized text in the test image output by the target OCR model, as well as the text box position of the recognized text.

[0045] Among them, the recognized text in the test image output by the target OCR model is the result of the target OCR model recognizing the text included in the test image; the text box position of the recognized text is the result of the target OCR model detecting the position of the text area corresponding to the recognized text. It can be understood that the text box position of the recognized text can include one or more, that is, the recognized text can include multiple, and the corresponding text box position can also include multiple.

[0046] In some implementations, the electronic device may preprocess the test image and then input the preprocessed test image into the target OCR model. The electronic device preprocessing the test image may include format conversion, definition processing, etc. of the test image.

[0047] Exemplarily, the electronic device can obtain a test image set uploaded by a user from a cloud server, and convert the images in the test image set into a target recognition format (such as base64 format, etc.), and then input the test images converted into base64 format into a target OCR model, call the target OCR model to recognize the text in the input test image, and obtain the recognition result of the target OCR model for the text in the test image.

[0048] In some embodiments, the recognition result of the target OCR model for the text in the test image is in JSON format. Accordingly, when the electronic device obtains the recognized text in the test image output by the target OCR model and the text box position of the recognized text, the recognition result in JSON format output by the target OCR model can be converted into a target result format (such as txt format, etc.), and further extracts the text lines of the recognized text and the coordinates of the area where each line of test text is located (such as left, top, right, bottom), that is, the text box position of the recognized text, and writes the recognized text lines into the text file corresponding to the test image.

[0049] Furthermore, the electronic device may send a text file including the recognized text in the test image output by the target OCR model and the text box position of the recognized text to an associated cloud or electronic device.

[0050] Step S130: If the degree of overlap between the text box position of the test text and the text box position of the recognized text is greater than an overlap threshold, then calculating the edit distance between the character string of the recognized text and the character string of the test text.

[0051] In some embodiments, after the electronic device obtains the text box position of the recognized text corresponding to the test image, it can calculate the overlap between the text box position of the test text of the test image and the text box position of the recognized text of the test image. If the overlap between the text box position of the test text and the text box position of the recognized text is greater than an overlap threshold, the edit distance between the character string of the recognized text and the character string of the test text is calculated.

[0052] The number of text box positions of the test text of the test image may include at least one, and the number of text box positions of the recognized text of the test image may include at least one. The method of calculating the degree of overlap between the text box position of the test text of the test image and the text box position of the recognized text of the test image may be to match the text box position of the test text with the text box position of the recognized text of the test image by one-to-one matching, one-to-many matching, many-to-one matching, etc.

[0053] As an implementable approach, see Figure 4, which shows a schematic diagram of a one-to-one matching of text box positions provided by an embodiment of the present application. Wherein, the solid line portion represents the text box position of the test text, and the dotted line portion represents the text box position of the recognized text. Wherein, if the overlap between the text box position of the test text and the text box position of the recognized text is greater than a first overlap threshold, that is, the text box position of the test text and the text box position of the recognized text can overlap one-to-one, then it is determined that the overlap between the text box position of the test text and the text box position of the recognized text is greater than the overlap threshold, and the electronic device can further calculate the edit distance between the character string of the recognized text and the character string of the test text.

[0054] As another possible implementation, see Figure 5 , which shows a schematic diagram of a one-to-many matching of text box positions provided by an embodiment of the present application. Wherein, the solid line portion represents the text box position of the test text, and the dotted line portion represents the text box position of the recognized text. Wherein, if the overlap threshold of a text box position in the test text and multiple text box positions in the recognized text is greater than the second overlap threshold, that is, the text box position of the test text and the text box position of the recognized text can overlap one-to-many, then it is determined that the overlap of the text box position of the test text and the text box position of the recognized text is greater than the overlap threshold, and the electronic device can further calculate the edit distance between the character string of the recognized text and the character string of the test text.

[0055] As another possible implementation, see Figure 6 , which shows a schematic diagram of a many-to-one matching of text box positions provided by an embodiment of the present application. Wherein, the solid line portion represents the text box position of the test text, and the dotted line portion represents the text box position of the recognized text. Wherein, if the overlap between multiple text box positions in the test text and one text box position in the recognized text is greater than a third overlap threshold, that is, the text box position of the test text and the text box position of the recognized text can overlap many-to-one, then it is determined that the overlap between the text box position of the test text and the text box position of the recognized text is greater than the overlap threshold, and the electronic device can further calculate the edit distance between the character string of the recognized text and the character string of the test text.

[0056] In this embodiment, after the electronic device determines that the overlap between the text box position of the test text and the text box position of the recognition text is greater than the overlap threshold, the edit distance between the character string of the recognition text and the character string of the test text can be calculated. The edit distance is a quantitative measurement of the degree of difference between two character strings (such as English words), and the measurement method calculates how many times it takes to convert one character string into another character string.

[0057] As an implementable method, the electronic device can calculate the edit distance between the string of the recognized text and the string of the test text based on the Levenshtein library in Python, that is, the minimum number of edits required to convert the string of the recognized text into the string of the test text, which may include the number of characters inserted, replaced, or deleted in the string of the recognized text.

[0058] Step S140: obtaining the recognition accuracy of the target OCR model based on the edit distance.

[0059] In this embodiment, after the electronic device obtains the edit distance between the character string of the recognition text and the character string of the test text, it can obtain the recognition accuracy of the target OCR model based on the edit distance.

[0060] The edit distance between the character string of the recognized text and the character string of the test text may include the number of characters required to be replaced to convert the recognized text into the test text, or may include the number of characters required to be inserted to convert the recognized text into the test text. Further, the electronic device may obtain the recognition accuracy of the target OCR model based on the edit distance by substituting the edit distance into the recognition accuracy calculation formula: Get the recognition accuracy of the target OCR model. PRE represents the recognition accuracy, NUM replace Represents the number of characters that need to be replaced to convert the recognized text into the test text, NUM insert Represents the number of characters required to insert to convert the recognized text into the test text, NUM dt Indicates the number of characters in the recognition result text.

[0061] For example, see Figure 7 , Figure 7 A timing diagram of an evaluation method for an optical character recognition model provided in an embodiment of the present application is shown. The electronic device may include a data transmission module, an OCR model execution module, and a model evaluation module. The data transmission module may be used to obtain a test image set stored in an associated cloud server; the associated cloud server may obtain a test image set uploaded by a user through a client. The client serves as a UI display interface and may be used to interact directly with a user. The user may upload a test image set to a cloud server through the client for use in the subsequent call of a target OCR model in the process of evaluating the target OCR model.

[0062] Among them, the OCR model execution module can be understood as an OCR service function, or as an OCR service. The electronic device can use the OCR model execution module to input the test image in the test image set transmitted in the data transmission module as an input parameter of the target OCR model based on the target OCR model online interface or the SDK of the electronic device. Further, the OCR model execution module can call the OCR service of the target OCR model to recognize the test image and obtain a recognition result. Among them, the recognition result may include the recognized text in the test image and the text box position of the recognized text.

[0063] Furthermore, the electronic device can call the model evaluation algorithm through the model evaluation module, and calculate the recognition accuracy and recall rate of the target OCR model recognition text according to the recognition result and the annotated text of the corresponding test image in the test image set. Furthermore, after the execution of the model evaluation module is completed, the recognition accuracy and recall rate of the target OCR model can be returned to the OCR model execution module as the model evaluation result.

[0064] Furthermore, the OCR model execution module can also send the recognition result of the target OCR model on the test image and the recognition accuracy and recall rate of the target OCR model returned by the model evaluation module to the online interface or SDK. Furthermore, the data transmission module can call the preset callback mechanism, pass the recognition result and model evaluation result as parameters to the client, and display the returned data to the client, that is, display the recognition result and model evaluation result to the user.

[0065] An evaluation method for an optical character recognition model provided by an embodiment of the present application comprises obtaining a test image set, wherein the test image set comprises a plurality of test images and annotated text corresponding to each test image, and the annotated text corresponding to each test image comprises the test text included in each test image and the text box position of the test text; inputting the test image into a target optical character recognition (OCR) model to obtain the recognized text in the test image output by the target OCR model, and the text box position of the recognized text; if the overlap between the text box position of the test text and the text box position of the recognized text is greater than an overlap threshold, calculating the edit distance between the character string of the recognized text and the character string of the test text; obtaining the recognition accuracy of the target OCR model based on the edit distance, and then evaluating the model by combining the text box selection accuracy of the recognized text output by the model and the edit distance between the recognized text and the test text, thereby improving the comprehensiveness and representativeness of the model evaluation.

[0066] See also Figure 8 , Figure 8The schematic diagram of the process of evaluating the optical character recognition model provided by an embodiment of the present application is shown. The method is applied to the above electronic device. Figure 8 The process shown is described in detail, and the evaluation method of the optical character recognition model may specifically include the following steps:

[0067] Step S210: Acquire a test image set, wherein the test image set includes multiple test images and annotated text corresponding to each of the test images, and the annotated text corresponding to each of the test images includes the test text included in each of the test images and the text box position of the test text.

[0068] For the specific description of step S210, please refer to the specific description of step S110 above, which will not be repeated here.

[0069] Step S220: input the test image into a target optical character recognition (OCR) model to obtain the recognized text in the test image output by the target OCR model and the text box position of the recognized text.

[0070] In some implementations, after obtaining the test image set, the electronic device may determine the language type of the text included in each test image, and store the test images corresponding to the text in different languages ​​in the corresponding language library.

[0071] As an implementation method, the target OCR model can recognize texts in multiple languages, such as Chinese, English, Japanese, Russian, etc. After the electronic device obtains the test image set, it can input the test image in the test image set into the target OCR model for text detection and recognition.

[0072] As another implementation, the target OCR model can recognize text in one language, such as Chinese / English / Japanese / Russian, etc. Further, when the electronic device needs to evaluate the target OCR model, it can obtain a test image from a language library corresponding to the language that the target OCR model can recognize, and input the test image into the target OCR model for text detection and recognition.

[0073] In some implementations, step S220 may include steps S221 to S223.

[0074] Step S221: Obtain the specified language.

[0075] In some embodiments, the target OCR model can recognize text in multiple languages, and the electronic device can receive a second evaluation instruction sent by the user, and obtain a specified language based on the second evaluation instruction. The second evaluation instruction can carry a specified language. The specified language can be Chinese, English, Latin, etc., which is not limited here.

[0076] In some implementations, the target OCR model can recognize text in one language category, and the electronic device can determine that the target OCR model can recognize one language category as the designated language.

[0077] Step S222: determining a target test image from the test image set based on the specified language.

[0078] In some implementations, after the electronic device obtains the designated language, it can obtain a test image corresponding to the text in the designated language from the test image set as a target test image.

[0079] As an implementable manner, a user may send a test image set to an associated cloud through a client, and further, the associated cloud may classify the images in the test image set based on the language type of the text included in the image, and store them in different language libraries. Further, the electronic device may obtain a test image set classified by language type, and after obtaining a specified language, determine a target test image from the test image set of the corresponding language type.

[0080] As another feasible manner, the electronic device may classify the acquired test image sets according to language types and store them in different language libraries; after obtaining the designated language, the target test image may be determined from the language library corresponding to the designated language.

[0081] Step S223: inputting the target test image into the target OCR model, obtaining the recognized text in the target test image output by the target OCR model, and the text box position of the recognized text.

[0082] In some embodiments, after the electronic device obtains the specified language and determines the target test image, it can input the target test image into a target OCR model to obtain the recognized text in the target test image output by the target OCR model and the text box position of the recognized text.

[0083] As an implementation method, the electronic device can input the specified language and the target test image into the target OCR model, obtain the recognized text in the target test image output by the target OCR model, and the text box position of the recognized text, and use the target OCR model to perform text detection and recognition in the specified language on the target test image according to the specified language, thereby improving the evaluation efficiency of the specified language text recognition of the target OCR model.

[0084] As another implementation, the electronic device may input a specified language and a test image into a target OCR model, obtain the recognized text in the test image output by the target OCR model, and the text box position of the recognized text, and perform text detection and recognition on the test image according to the specified language using the target OCR model.

[0085] It can be understood that after the electronic device obtains the specified language, the target OCR model can detect the text in the target test image in the specified language library; in addition, the specified language and the target test image are input into the target OCR model, and the target OCR model performs text detection and recognition on the target test image according to the specified language, which facilitates the target OCR model to automatically identify the language type of the text in the target test image, thereby improving the rate of text detection and recognition by the target OCR model.

[0086] Step S230: If the degree of overlap between the text box position of the test text and the text box position of the recognized text is greater than an overlap threshold, then calculating the edit distance between the character string of the recognized text and the character string of the test text.

[0087] In some implementations, when the electronic device obtains the test image set, there may be a situation where the annotated text corresponding to the test image fails to be obtained. To ensure that the evaluation method of the optical character recognition model provided in this embodiment is carried out smoothly, the electronic device may determine whether there is an annotated text corresponding to the test image in the electronic device before step S230.

[0088] In some embodiments, in the test image set obtained by the electronic device from the cloud server, the test image and the annotation text corresponding to the test image are named in the same way, based on which the electronic device can detect whether the annotation text corresponding to the test image is obtained according to the naming of the test image. If a text file with the same name is detected, it can be determined that the annotation text corresponding to the test image exists in the electronic device, and it can also be determined that the user has uploaded the annotation text corresponding to the test image.

[0089] Furthermore, after the electronic device obtains the recognized text in the test image output by the target OCR model and the text box position of the recognized text, it can obtain the annotated text corresponding to the test image according to the name of the test image, and calculate the degree of overlap between the text box position of the test text and the text box position of the recognized text; if the degree of overlap between the text box position of the test text and the text box position of the recognized text is greater than the overlap threshold, then the edit distance between the character string of the recognized text and the character string of the test text is calculated.

[0090] In some implementations, the optical character recognition model evaluation method provided in this embodiment may further include steps S231 and S232 before step S230.

[0091] Step S231: Determine the text format of the annotated text corresponding to the test image.

[0092] In some implementations, when the electronic device obtains the test image set, the format of the annotated text corresponding to the test image may be legal. To ensure that the evaluation method of the optical character recognition model provided in this embodiment is carried out smoothly, the electronic device may verify whether the text format of the annotated text corresponding to the test image is legal before step S230.

[0093] The electronic device can determine the annotation text corresponding to the test image according to the name of the test image, and further obtain the text format of the annotation text. The electronic device can detect whether the annotation text includes information such as text content, coordinates of the area where the text is located, and confidence level of the text, and obtain the text format of the annotation text.

[0094] As a possible implementation method, the electronic device can determine whether the text format of the annotated text is legal by regular matching, wherein the correct text format can be the content of the test text contained in the annotated text, the coordinates of the area where the text box of the test text is located, and the confidence of the test text, wherein the confidence can be an optional item. If the annotated text contains the text content and the coordinates of the area where the text box of the test text is located, it is determined that the text format of the annotated text is legal.

[0095] As another possible implementation, after obtaining the coordinates of the text box position of the test text included in the annotated text, the electronic device can calculate the width difference and height difference of the coordinates of two adjacent points, and determine whether the direction of the coordinates of the text box position of the test text meets the standard direction (e.g., clockwise). If it is determined that the direction of the coordinates of the text box position of the test text is clockwise, it is determined that the text format of the annotated text is legal.

[0096] As another possible implementation, the electronic device can calculate the width and height of the text box position of the test text after obtaining the coordinates of the text box position of the test text contained in the annotated text. If the width of the text box position of the test text is greater than a width threshold (e.g., 0), and the height of the text box position of the test text is greater than a height threshold (e.g., 0), then it is determined that the text format of the annotated text is legal.

[0097] As another possible implementation manner, the text format of the annotated text may be legal and may be that the text format of the annotated text includes the test text included in the test image; the coordinate direction of the text box position of the test text satisfies a preset direction; the width of the text box position of the test text is greater than a width threshold; and the height of the text box position of the test text is greater than a height threshold.

[0098] Step S232: If the text format is legal, then the degree of overlap between the text box position of the test text and the text box position of the recognized text is calculated.

[0099] In some embodiments, after the electronic device determines the text format of the annotated text corresponding to the test image, the text format can be verified. If the text format is legal, the degree of overlap between the text box position of the test text and the text box position of the recognized text can be calculated.

[0100] In some implementations, the number of text box positions of the test text is at least one, the number of text box positions of the recognition text is at least one, and step S230 may include steps S233 to S235.

[0101] Step S233: Determine the target text box position of the test text based on at least one text box position of the test text.

[0102] The electronic device may determine the target text box position of the test text based on at least one text box position of the test text; the target text box position of the test text may include one or more text box positions.

[0103] In some implementations, step S233 may include step S2331 or step S2332.

[0104] Step S2331: If the number of the text box position of the test text is one, then one text box position of the test text is determined as the target text box position of the test text.

[0105] In some embodiments, if the number of text box positions for the test text is one, one text box position for the test text is determined as the target text box position for the test text, and the electronic device calculates the degree of overlap between the target text box position of the test text and the text box position of the recognized text.

[0106] Step S2332: If the number of the text box positions of the test text is at least two, at least two text box positions of the test text are combined into a target text box position of the test text.

[0107] In some embodiments, if the number of text box positions of the test text is at least two, at least two text box positions of the test text are combined into a target text box position of the test text, and an electronic device is used to calculate the degree of overlap between the target text box position of the test text and the text box position of the recognized text.

[0108] Step S234: Determine a target text box position of the recognized text based on at least one text box position of the recognized text.

[0109] The electronic device may determine the target text box position of the recognized text based on at least one text box position of the recognized text; the target text box position of the recognized text may include one or more text box positions.

[0110] In some implementations, step S234 may include step S2341 or step S2342.

[0111] Step S2341: If the number of the text box position of the recognized text is one, then one text box position of the recognized text is determined as the target text box position of the recognized text.

[0112] In some embodiments, if the number of text box positions of the recognized text is one, one text box position of the recognized text is determined as the target text box position of the recognized text, and the electronic device calculates the degree of overlap between the target text box position of the recognized text and the text box position of the test text.

[0113] Step S2342: If the number of the text box positions of the recognized text is at least two, at least two text box positions of the recognized text are combined into a target text box position of the recognized text.

[0114] In some embodiments, if the number of text box positions of the recognized text is at least two, at least two text box positions of the recognized text are combined into a target text box position of the recognized text, and an electronic device is used to calculate the degree of overlap between the target text box position of the recognized text and the text box position of the test text.

[0115] Step S235: If the degree of overlap between the target text box position of the test text and the target text box position of the recognized text is greater than the overlap threshold, then calculating the edit distance between the character string of the recognized text and the character string of the test text.

[0116] In some implementations, after the electronic device obtains the target text box position of the test text and the target text box position of the recognized text, it can calculate the degree of overlap between the target text box position of the test text and the target text box position of the recognized text.

[0117] For example, see Fig.10 , which shows a schematic diagram of a target text box position of a test text and a target text box position of a recognition text provided by an embodiment of the present application. Among them, the target text box position A of the test text is a text box position B of the test text, and the target text box position of the recognition text is a text box position of the test text.

[0118] For example, see Fig. 9 , which shows a schematic diagram of a target text box position of a test text and a target text box position of a recognition text provided by an embodiment of the present application. The target text box position of the test text is a text box position B of the test text, and the target text box position of the recognition text is composed of at least two text box positions of the recognition text (A1, A2, A3).

[0119] For example, see Fig.11 , which shows a schematic diagram of a target text box position of a test text and a target text box position of a recognized text provided by an embodiment of the present application. The target text box position of the recognized text is a text box position A of the recognized text, and the target text box position of the test text is composed of at least two text box positions of the test text (B1, B2, B3).

[0120] In this embodiment, after the electronic device obtains the overlap between the target text box position of the test text and the target text box position of the recognized text, the overlap can be compared with the overlap threshold, and according to the comparison result, it is determined whether to calculate the edit distance between the character string of the recognized text and the character string of the test text. Exemplarily, if the overlap between the target text box position of the test text and the target text box position of the recognized text is greater than the overlap threshold, the edit distance between the character string of the recognized text and the character string of the test text is calculated.

[0121] For example, see Fig.12, which shows a flow chart of the evaluation of the optical character recognition model provided by an embodiment of the present application. Among them, after the electronic device obtains the recognized text in the test image output by the target OCR model and the text box position of the recognized text, it can verify whether the text format of the annotated text corresponding to the test image is legal. If it is legal, the text box position of the test text is matched with the text box position of the recognized text, that is, the overlap between the text box position of the test text and the text box position of the recognized text is calculated, and a one-to-one match can be performed. If the match is successful, that is, the overlap between a text box position of the test text and a text box position of the recognized text is greater than the first overlap threshold, the two text boxes and the text string are added to the matching pair, and the edit distance between the matching pairs is calculated in turn, and the accuracy and recall of the target OCR model are calculated based on the edit distance of all matching pairs.

[0122] Among them, if the one-to-one matching fails, the text box position of the test text can be matched with the text box position of the recognized text in a one-to-many manner. If the matching is successful, that is, the overlap between a text box position of the test text and a first text box position composed of multiple text box positions of the recognized text is greater than a second overlap threshold, then the first text box and a text box position of the test text and the corresponding text string are added to the matching pair, and the edit distance between the matching pairs is calculated in turn, and the accuracy and recall of the target OCR model are calculated based on the edit distance of all matching pairs.

[0123] Among them, if the one-to-many matching fails, the text box position of the test text can be matched with the text box position of the recognized text for many-to-one matching. If the matching is successful, that is, the overlap between the second text position composed of multiple text box positions of the test text and a text box position of the recognized text is greater than the third overlap threshold, then the second text box and a text box position of the recognized text and the corresponding text string are added to the matching pair, and the edit distance between the matching pairs is calculated in turn, and the accuracy and recall of the target OCR model are calculated based on the edit distance of all matching pairs.

[0124] It can be understood that in the process of the electronic device obtaining the overlap between the target text box position of the test text and the target text box position of the recognized text, the text box position of the test text and the text box position of the recognized text can be matched in a one-to-one, one-to-many, or many-to-one matching manner. If the match is successful, it can be understood that the overlap between the target text box position of the test text and the target text box position of the recognized text is greater than the overlap threshold. Then, the two or more groups of successfully matched data are formed into a matching pair, and the text strings in the matching pair are compared. The edit distance between the two strings in the matching pair is calculated to calculate the accuracy, recall, and F1 score of the recognition result of the target OCR model based on the edit distance. Among them, the F1 score (F1-Score) is an indicator used in statistics to measure the accuracy of a binary classification model. It takes into account both the accuracy and recall of the classification model. The F1 score can be regarded as a harmonic average of the model accuracy and recall, and its maximum value is 1 and the minimum value is 0.

[0125] In some implementations, step S230 may include steps S236 to S239.

[0126] Step S236: Obtain a first number of characters required to be replaced to convert the character string of the recognition text into the character string of the test text, and determine a first edit distance based on the first number of characters.

[0127] In this embodiment, during the process of calculating the edit distance between the character string of the recognized text and the character string of the test text, the electronic device can obtain the first number of characters required to replace the character string of the recognized text to the character string of the test text, and determine the first edit distance based on the first number of characters. Determining the first edit distance based on the first number of characters may be taking the first number of characters as the first edit distance.

[0128] Step S237: Obtain a second number of characters required to be inserted to convert the character string of the recognition text into the character string of the test text, and determine a second edit distance based on the second number of characters.

[0129] In this embodiment, during the process of calculating the edit distance between the character string of the recognition text and the character string of the test text, the electronic device can obtain the second number of characters required to be inserted to convert the character string of the recognition text into the character string of the test text, and determine the second edit distance based on the second number of characters. Determining the second edit distance based on the second number of characters may be taking the second number of characters as the second edit distance.

[0130] Step S238: Obtain a third number of characters that need to be deleted to convert the character string of the recognition text into the character string of the test text, and determine a third edit distance based on the third number of characters.

[0131] In this embodiment, during the process of calculating the edit distance between the character string of the recognized text and the character string of the test text, the electronic device can obtain the third number of characters required to be deleted to convert the character string of the recognized text into the character string of the test text, and determine the third edit distance based on the third number of characters. Determining the third edit distance based on the third number of characters can be taking the third number of characters as the third edit distance.

[0132] Step S239: Obtaining the edit distance based on the first edit distance, the second edit distance, and the third edit distance.

[0133] In some embodiments, the edit distance between the recognized text string and the test text string can be understood as the minimum number of edits required to convert the recognized text string into the test text string, including the number of characters inserted, replaced, and deleted in the recognized text string.

[0134] Optionally, after obtaining the first edit distance, the second edit distance, and the third edit distance, the electronic device may use the first edit distance, the second edit distance, and the third edit distance as the edit distances between the character string of the recognition text and the character string of the test text.

[0135] Step S240: obtaining the recognition accuracy of the target OCR model based on the edit distance.

[0136] In some embodiments, there are multiple matching pairs in the test image whose text box positions of the test texts overlap with the text box positions of the recognized texts more than a threshold value of overlap. Furthermore, after the electronic device obtains the edit distances of the multiple matching pairs, it can calculate the recognition accuracy of the target OCR model based on the edit distances of the multiple matching pairs.

[0137] In some implementations, step S240 may include steps S241 and S242.

[0138] Step S241: taking the number of characters corresponding to the character string of the recognized text as the fourth number of characters.

[0139] In the process of determining the recognition accuracy of the target OCR model based on the edit distance, the electronic device may use the number of characters corresponding to the character string of the recognized text as the fourth number of characters.

[0140] Step S242: obtain the recognition accuracy of the target OCR model by subtracting the sum of the first edit distance and the second edit distance from one and dividing it by the fourth number of characters.

[0141] Furthermore, the electronic device may obtain the recognition accuracy of the target OCR model by subtracting a quotient obtained by adding the first edit distance and the second edit distance and dividing it by the fourth number of characters.

[0142] Step S250: obtaining the recall rate of the target OCR model based on the edit distance.

[0143] In some implementations, after the electronic device obtains the edit distance between the character string of the recognition text and the character string of the test text, it can obtain the recall rate of the target OCR model based on the edit distance.

[0144] In this embodiment, step S250 may be executed before step S240, may be executed after step S240, or may be executed simultaneously with step S240, which is not limited here.

[0145] In some implementations, step S250 may include steps S251 and S252.

[0146] Step S251: taking the number of characters in the character string of the test text as the fifth number of characters.

[0147] In the process of determining the recognition accuracy of the electronic device based on the edit distance target OCR model, the number of characters in the character string of the test text may be used as the fifth number of characters.

[0148] Step S252: obtain the recall rate of the target OCR model by subtracting the quotient of the sum of the first edit distance and the third edit distance from one and dividing it by the fifth number of characters.

[0149] Further, the electronic device may obtain the recall rate of the target OCR model by subtracting a quotient obtained by adding the first edit distance and the third edit distance and dividing it by the fifth number of characters.

[0150] The electronic device may be pre-set with a recall rate calculation formula. The electronic device may bring the edit distance into the recall rate calculation formula: Get the recall rate of the target OCR model. RE stands for recall rate, NUM replace Represents the first edit distance, NUM delete Represents the third edit distance, NUM gt The number of characters in the string representing the test text.

[0151] In some implementations, after the electronic device obtains the recognition accuracy and the recall rate of the target OCR model, it may also obtain the F1-score of the target OCR model based on the recognition accuracy and the recall rate.

[0152] The electronic device may be pre-set with an F1-score calculation formula, and the electronic device may bring the edit distance into the F1-score calculation formula: Get the F1-score of the target OCR model. RE stands for recall rate and PRE stands for recognition accuracy.

[0153] For example, see Fig.13 as well as Fig.14 . Fig.13 shows an interface diagram of recognition and model evaluation progress provided by an embodiment of the present application, Fig.14 The flowchart of the evaluation method of the optical character recognition model provided by an embodiment of the present application is shown. Fig.13 In the interface shown, the user can select the target OCR model to be evaluated in the UI interface of the client and fill in the necessary parameters; the necessary parameters may include APP_KEY, SECRET_KEY, and specified language.

[0154] For further information, please refer to Fig.14 , the electronic device can authenticate the interface call of the target OCR model according to the APP_KEY parameter and the SECRET_KEY parameter. The target OCR model can be called only after the APP_KEY parameter and the SECRET_KEY parameter are the same, that is, after the authentication is successful. Among them, after obtaining the specified language, the target OCR model can detect the text in the incoming target test image in the specified language library storing the test image set. If the user does not select the specified language, the target OCR model can use automatic recognition, that is, it can randomly obtain test images for text detection.

[0155] Among them, the electronic device can detect whether the necessary parameters are accurate, that is, determine whether the incoming APP_KEY parameter matches the SECRET_KEY parameter, and determine whether the test image set is passed in. And when it is determined that the incoming APP_KEY parameter matches the SECRET_KEY and that the test image set is passed in, subsequent text recognition operations can be performed on the test image. Among them, the match between the APP_KEY parameter and the SECRET_KEY parameter can be that the APP_KEY parameter is the same as the SECRET_KEY, or that the similarity between the APP_KEY parameter and the SECRET_KEY parameter exceeds the key matching threshold, then it is determined that the APP_KEY parameter matches the SECRET_KEY.

[0156] When it is determined that the input APP_KEY parameter does not match the SECRET_KEY or when it is determined that the test image set is not input into the electronic device, a prompt message may be generated for the user to input accurate and necessary parameters.

[0157] Furthermore, during the subsequent text recognition operation of the electronic device on the test image, the test image can be processed in a loop, or the test image can be converted into base64 format and then passed to the OCR interface of the target OCR model. Optionally, if the user specifies the language, the language type is also passed to the OCR interface. If not specified, it is automatically passed to the interface so that the target OCR model can automatically identify the language type of the text in the test image.

[0158] Furthermore, the electronic device can obtain the recognition result in JSON format output by the target OCR model after processing the test image, and convert the format to obtain the test text in txt format. It can also extract the text lines of the test text and the coordinates (left, top, right, bottom) of the area where each line of text is located, and write them into the corresponding text file line by line, and save them to the associated cloud server.

[0159] Furthermore, the electronic device can determine whether the user has uploaded the annotation corresponding to the test image. If it has been uploaded, it will query the annotation text corresponding to the test image in the cloud server according to the name, use it as a reference, and call the model evaluation algorithm to calculate the accuracy, recall rate and F1-score of the recognition result text output by the target OCR model, that is, the model evaluation result. Furthermore, the electronic device can also return the recognition result and model evaluation result to the client UI interface to display it to the user, and the user can also download the recognition result file.

[0160] Among them, the evaluation method of the optical character recognition model provided in this embodiment can evaluate the overall performance of the recognized text output by the model and the text box position of the recognized text, and combine the recognition accuracy and recall rate of the model evaluated by the text and text box area position, thereby improving the comprehensiveness and representativeness of the model evaluation.

[0161] It is understandable that the evaluation method of the optical character recognition model provided in this embodiment can horizontally evaluate multiple OCR models. The user inputs the test image set and the APPKey and secretKey used by the algorithm platform for authentication, and then obtains the recognition result, recognition accuracy, and recall rate of the current model. In addition, in the case of a large input data set, the system also provides the user with a progress display of the current recognition and model evaluation, thereby improving the user experience.

[0162] In addition, the evaluation method of the optical character recognition model provided in this embodiment, when the electronic device calls the OCR model, the general steps are: obtain the incoming APP_KEY and SECRET_KEY for model authentication, then obtain the incoming test image and specified language after the authentication is successful, and then call the target OCR model to perform text recognition on the test image, and after the recognition is completed, convert the recognition result into a format and output the final result. Therefore, the common steps of OCR execution can be extracted and converted into a general script. The user can configure the interface information of the OCR model to be evaluated, including competitive models and self-developed models, etc. After configuring the URL of the interface, parameter transmission and other information, the general script can be called to realize OCR recognition and comparative evaluation between models, which improves the versatility of the model evaluation method.

[0163] The evaluation method of the optical character recognition model provided in an embodiment of the present application is compared with Figure 1 The optical character recognition model evaluation method shown in the present embodiment can also obtain the recall rate of the target OCR model based on the edit distance. By combining the text box selection accuracy of the recognized text output by the model and the edit distance evaluation model between the recognized text and the test text, the recognition accuracy and recall rate of the model are obtained, so as to evaluate the performance of the model according to the recognition accuracy and recall rate of the model, thereby improving the comprehensiveness and representativeness of the model evaluation.

[0164] See also Fig.15 , Fig.15 The module block diagram of the optical character recognition model evaluation device provided by an embodiment of the present application is shown. The optical character recognition model evaluation device 200 is applied to the above electronic device. Fig.15 The process shown in the figure is described in detail. The evaluation device 200 of the optical character recognition model includes: a test image set acquisition module 210, a test image recognition module 220, an edit distance calculation module 230 and a recognition accuracy acquisition module 240, wherein:

[0165] The test image set acquisition module 210 is used to acquire a test image set, wherein the test image set includes multiple test images and annotated text corresponding to each of the test images, and the annotated text corresponding to each of the test images includes the test text included in each of the test images and the text box position of the test text.

[0166] The test image recognition module 220 is used to input the test image into a target optical character recognition (OCR) model, and obtain the recognized text in the test image output by the target OCR model, as well as the text box position of the recognized text.

[0167] The edit distance calculation module 230 is used to calculate the edit distance between the character string of the recognized text and the character string of the test text if the overlap between the text box position of the test text and the text box position of the recognized text is greater than an overlap threshold.

[0168] The recognition accuracy obtaining module 240 is used to obtain the recognition accuracy of the target OCR model based on the edit distance.

[0169] Furthermore, the test image recognition module 220 may include: a specified language acquisition unit, a target test image determination unit, and a test image recognition subunit, wherein:

[0170] The specified language acquisition unit is used to acquire the specified language.

[0171] A target test image determining unit is used to determine a target test image from the test image set based on the specified language.

[0172] The test image recognition subunit is used to input the target test image into the target OCR model, obtain the recognized text in the target test image output by the target OCR model, and the text box position of the recognized text.

[0173] Further, before calculating the edit distance between the character string of the recognized text and the character string of the test text if the overlap between the text box position of the test text and the text box position of the recognized text is greater than the overlap threshold, the number of the card processes is multiple, and the multiple card processes correspond to the same card business. The optical character recognition model evaluation device 200 may include: a text format determination module and a text box overlap calculation module, wherein:

[0174] The text format determination module is used to determine the text format of the annotated text corresponding to the test image.

[0175] The text box coincidence calculation module is used to calculate the coincidence between the text box position of the test text and the text box position of the recognition text if the text format is legal.

[0176] Furthermore, in the text box overlap calculation module, the legal text format includes: the annotated text corresponding to the test image includes the test text included in the test image; the coordinate direction of the text box position of the test text satisfies a preset direction; the width of the text box position of the test text is greater than a width threshold; and the height of the text box position of the test text is greater than a height threshold.

[0177] Furthermore, the number of the text box positions of the test text is at least one, the number of the text box positions of the recognized text is at least one, and the edit distance calculation module 230 may include: a target text box position determination unit for the test text, a target text box position determination unit for the recognized text, and an edit distance calculation subunit, wherein:

[0178] The target text box position determination unit of the test text is used to determine the target text box position of the test text based on at least one text box position of the test text.

[0179] The target text box position determination unit of the recognized text is used to determine the target text box position of the recognized text based on at least one text box position of the recognized text.

[0180] The edit distance calculation subunit is used to calculate the edit distance between the character string of the recognized text and the character string of the test text if the overlap between the target text box position of the test text and the target text box position of the recognized text is greater than the overlap threshold.

[0181] Furthermore, the target text box position determination unit of the test text may include: a first determination unit or a second determination unit, wherein:

[0182] The first determining unit is configured to determine, if the number of the text box positions of the test text is one, one text box position of the test text as a target text box position of the test text.

[0183] The second determining unit is configured to, if the number of the text box positions of the test text is at least two, combine at least two text box positions of the test text into a target text box position of the test text.

[0184] Furthermore, the target text box position determination unit for the recognized text may include: a third determination unit or a fourth determination unit, wherein:

[0185] The third determining unit is configured to determine one text box position of the recognized text as a target text box position of the recognized text if the number of the text box positions of the recognized text is one.

[0186] The fourth determining unit is configured to, if the number of the text box positions of the recognized text is at least two, combine at least two text box positions of the recognized text into a target text box position of the recognized text.

[0187] Further, the edit distance calculation module 230 may include: a first edit distance determination unit, a second edit distance determination unit, a third edit distance determination unit and an edit distance calculation subunit, wherein:

[0188] The first edit distance determining unit is used to obtain a first number of characters required to be replaced to convert the character string of the recognition text into the character string of the test text, and determine a first edit distance based on the first number of characters.

[0189] The second edit distance determining unit is used to obtain a second number of characters required to be inserted to convert the character string of the recognition text into the character string of the test text, and determine a second edit distance based on the second number of characters.

[0190] The third edit distance determining unit is used to obtain a third number of characters required to be deleted to convert the character string of the recognition text into the character string of the test text, and determine a third edit distance based on the third number of characters.

[0191] The edit distance calculation subunit is configured to obtain the edit distance based on the first edit distance, the second edit distance, and the third edit distance.

[0192] Furthermore, the recognition accuracy acquisition module 240 may include: a fourth character number determination unit and a recognition accuracy acquisition subunit, wherein:

[0193] The fourth character number determining unit is used to take the number of characters corresponding to the character string of the recognized text as the fourth character number.

[0194] The recognition accuracy obtaining subunit is used to obtain the recognition accuracy of the target OCR model by subtracting the quotient of the sum of the first edit distance and the second edit distance and dividing it by the fourth number of characters.

[0195] Furthermore, the optical character recognition model evaluation device 200 may also include: a recall rate acquisition module, wherein:

[0196] A recall rate obtaining module is used to obtain the recall rate of the target OCR model based on the edit distance.

[0197] Furthermore, the recall rate obtaining module may include: a fifth character number determining unit and a recall rate obtaining subunit, wherein:

[0198] The fifth character number determining unit is used to take the number of characters in the character string of the test text as the fifth character number.

[0199] The recall rate obtaining subunit is used to obtain the recall rate of the target OCR model by subtracting the quotient of the sum of the first edit distance and the third edit distance from one and dividing it by the fifth number of characters.

[0200] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices and modules can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here.

[0201] In several embodiments provided in the present application, the coupling between modules may be electrical, mechanical or other forms of coupling.

[0202] In addition, each functional module in each embodiment of the present application can be integrated into a processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The above integrated modules can be implemented in the form of hardware or software functional modules.

[0203] See also Fig.16 , which shows a structural block diagram of an electronic device 100 provided in an embodiment of the present application. The electronic device 100 may be an electronic device capable of running applications, such as a smart phone, a tablet computer, an e-book, etc. The electronic device 100 in the present application may include one or more of the following components: a processor 110, a memory 120, and one or more applications, wherein the one or more applications may be stored in the memory 120 and configured to be executed by one or more processors 110, and the one or more programs are configured to execute the method described in the aforementioned method embodiment.

[0204] Among them, the processor 110 may include one or more processing cores. The processor 110 uses various interfaces and lines to connect various parts of the entire electronic device 100, and executes various functions and processes data of the electronic device 100 by running or executing instructions, programs, code sets or instruction sets stored in the memory 120, and calling data stored in the memory 120. Optionally, the processor 110 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 110 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing the content to be displayed; and the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 110, but may be implemented separately through a communication chip.

[0205] The memory 120 may include a random access memory (RAM) or a read-only memory (ROM). The memory 120 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 120 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the following various method embodiments, etc. The data storage area may also store data (such as a phone book, audio and video data, chat record data) created by the electronic device 100 during use.

[0206] See also Fig.17 , which shows a structural block diagram of a computer-readable storage medium provided in an embodiment of the present application. The computer-readable medium 300 stores program codes, which can be called by a processor to execute the method described in the above method embodiment.

[0207] The computer readable storage medium 300 can be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk, or a ROM. Optionally, the computer readable storage medium 300 includes a non-transitory computer-readable storage medium. The computer readable storage medium 300 has storage space for program code 310 that performs any method steps in the above method. These program codes can be read from or written to one or more computer program products. The program code 310 can be compressed, for example, in an appropriate form.

[0208] In summary, the optical character recognition model evaluation method, device, electronic device and storage medium provided in the embodiments of the present application are implemented by obtaining a test image set, wherein the test image set includes multiple test images and annotated text corresponding to each test image, and the annotated text corresponding to each test image includes the test text included in each test image and the text box position of the test text; inputting the test image into the target optical character recognition (OCR) model to obtain the recognized text in the test image output by the target OCR model, and the text box position of the recognized text; if the overlap between the text box position of the test text and the text box position of the recognized text is greater than the overlap threshold, then calculating the edit distance between the character string of the recognized text and the character string of the test text; obtaining the recognition accuracy of the target OCR model based on the edit distance, and then evaluating the model by combining the text box selection accuracy of the recognized text output by the model and the edit distance between the recognized text and the test text, thereby improving the comprehensiveness and representativeness of the model evaluation.

[0209] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A method for evaluating an optical character recognition model, characterized in that: The method comprises: Acquire a test image set, wherein the test image set includes a plurality of test images and annotated texts corresponding to each of the test images, and the annotated texts corresponding to each of the test images include a test text included in each of the test images and a text box position of the test text; Inputting the test image into a target optical character recognition (OCR) model, obtaining recognized text in the test image output by the target OCR model, and a text box position of the recognized text; If the overlap between the text box position of the test text and the text box position of the recognition text is greater than an overlap threshold, then calculating the edit distance between the character string of the recognition text and the character string of the test text; The recognition accuracy of the target OCR model is obtained based on the edit distance.

2. The method according to claim 1, characterized in that The step of inputting the test image into a target optical character recognition (OCR) model to obtain recognized text in the test image output by the target OCR model and a text box position of the recognized text includes: Get the specified language; determining a target test image from the test image set based on the specified language; The target test image is input into the target OCR model to obtain the recognized text in the target test image output by the target OCR model and the text box position of the recognized text.

3. The method according to claim 1, characterized in that: Before calculating the edit distance between the character string of the recognized text and the character string of the test text if the overlap between the text box position of the test text and the text box position of the recognized text is greater than the overlap threshold, the method further includes: Determining a text format of annotated text corresponding to the test image; If the text format is legal, then the degree of overlap between the text box position of the test text and the text box position of the recognition text is calculated.

4. The method according to claim 3, characterized in that The text format is legal, including: The annotated text corresponding to the test image includes the test text included in the test image; The coordinate direction of the text box position of the test text meets the preset direction; The width of the text box position of the test text is greater than a width threshold; and The height of the text box position of the test text is greater than the height threshold.

5. The method according to claim 1, characterized in that The number of text box positions of the test text is at least one, the number of text box positions of the recognized text is at least one, and if the overlap between the text box position of the test text and the text box position of the recognized text is greater than an overlap threshold, calculating the edit distance between the character string of the recognized text and the character string of the test text, comprising: Determining a target text box position of the test text based on at least one text box position of the test text; Determining a target text box position of the recognized text based on at least one text box position of the recognized text; If the degree of overlap between the target text box position of the test text and the target text box position of the recognized text is greater than the overlap threshold, the edit distance between the character string of the recognized text and the character string of the test text is calculated.

6. The method according to claim 5, characterized in that The step of determining a target text box position of the test text based on a text box position of at least one of the test texts comprises: If the number of the text box position of the test text is one, then determining one text box position of the test text as the target text box position of the test text; or If the number of the text box positions of the test text is at least two, at least two text box positions of the test text are combined into a target text box position of the test text.

7. The method according to claim 5, characterized in that The determining of a target text box position of the recognized text based on at least one text box position of the recognized text comprises: If the number of the text box position of the recognized text is one, then determining one text box position of the recognized text as the target text box position of the recognized text; or If the number of the text box positions of the recognized text is at least two, at least two text box positions of the recognized text are combined into a target text box position of the recognized text.

8. The method according to any one of claims 1 to 7, characterized in that: The calculating the edit distance between the character string of the recognition text and the character string of the test text comprises: Obtaining a first number of characters required to be replaced to convert the character string of the recognition text into the character string of the test text, and determining a first edit distance based on the first number of characters; Obtaining a second number of characters required to be inserted to convert the character string of the recognition text into the character string of the test text, and determining a second edit distance based on the second number of characters; Obtaining a third number of characters required to be deleted to convert the character string of the recognition text into the character string of the test text, and determining a third edit distance based on the third number of characters; The edit distance is obtained based on the first edit distance, the second edit distance, and the third edit distance.

9. The method according to claim 8, characterized in that The obtaining the recognition accuracy of the target OCR model based on the edit distance includes: The number of characters corresponding to the character string of the recognized text is taken as a fourth number of characters; The recognition accuracy of the target OCR model is obtained by subtracting a quotient obtained by adding the first edit distance and the second edit distance and dividing it by the fourth number of characters.

10. The method according to claim 8, characterized in that The method further comprises: The recall rate of the target OCR model is obtained based on the edit distance.

11. The method according to claim 10, characterized in that The obtaining the recall rate of the target OCR model based on the edit distance includes: The number of characters in the character string of the test text is taken as the fifth number of characters; The recall rate of the target OCR model is obtained by subtracting a quotient of the sum of the first edit distance and the third edit distance from one and dividing it by the fifth number of characters.

12. An evaluation device for an optical character recognition model, characterized in that: The device comprises: A test image set acquisition module, used to acquire a test image set, wherein the test image set includes a plurality of test images and annotated texts corresponding to each of the test images, and the annotated texts corresponding to each of the test images include the test text included in each of the test images and the text box position of the test text; A test image recognition module, used for inputting the test image into a target optical character recognition (OCR) model, obtaining recognized text in the test image output by the target OCR model, and a text box position of the recognized text; An edit distance calculation module, configured to calculate the edit distance between the character string of the recognized text and the character string of the test text if the overlap between the text box position of the test text and the text box position of the recognized text is greater than an overlap threshold; The recognition accuracy obtaining module is used to obtain the recognition accuracy of the target OCR model based on the edit distance.

13. An electronic device, characterized in that: include: one or more processors; Memory; One or more application programs, wherein the one or more application programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to execute the method according to any one of claims 1-11.

14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program codes, which can be called by a processor to execute the method according to any one of claims 1 to 11.

Citation Information

Cited By

  • OCR (Optical Character Recognition) curved document correction performance detection method based on multi-modal distance collaborative optimization

    CN120356228A

  • A method for detecting the performance of OCR curved document correction based on multimodal distance collaborative optimization

    CN120356228B