Small sample training method and device of OCR (Optical Character Recognition) model, electronic equipment and medium

By augmenting the small training dataset and introducing a task adaptation layer, the text detection and recognition layers of the OCR model are adaptively updated, solving the problems of low training efficiency and poor adaptability of existing OCR models, and achieving efficient and low-cost multi-task domain recognition capabilities.

CN122067255APending Publication Date: 2026-05-19INSPUR TIANYUAN COMM INFORMATION SYST CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
INSPUR TIANYUAN COMM INFORMATION SYST CO LTD
Filing Date
2025-12-17
Publication Date
2026-05-19

AI Technical Summary

Technical Problem

Existing OCR model training methods are inefficient, costly, and poorly adaptable, heavily relying on large-scale manually labeled data.

Method used

By augmenting the small training dataset, multiple meta-tasks are generated, and a task adaptation layer is introduced to adaptively update the parameters of the initial text detection layer, recognition layer, and correction layer. The model is trained using task domain identifiers.

Benefits of technology

It improves the training efficiency and generalization ability of OCR models, reduces training costs, and can efficiently handle recognition tasks in various task domains.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122067255A_ABST
    Figure CN122067255A_ABST
Patent Text Reader

Abstract

The invention provides a small sample training method and device for an OCR model, electronic equipment and a medium, and the method comprises the steps: carrying out the data enhancement of a small sample training data set, generating a plurality of meta-tasks, and enabling each meta-task to comprise a plurality of image samples and corresponding task domain identifiers and text recognition result labels; training an initial OCR (Optical Character Recognition) model by taking the plurality of image samples of each meta-task and the corresponding task domain identifiers as training samples and taking the text recognition result labels as sample labels; the initial OCR model comprises a task adaptation layer, an initial text detection layer, an initial text recognition layer and an initial correction layer; the task adaptation layer takes the task domain identifier as input to generate task adaptation parameters, and the task adaptation parameters are used for adaptively updating the parameters of the initial text detection layer, the initial text recognition layer and the initial correction layer. According to the invention, model training can be carried out based on small samples, the training efficiency is high, the generalization ability of the model is improved, and the training cost is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, and in particular to a method, apparatus, electronic device, and medium for small-sample training of an OCR model. Background Technology

[0002] Optical Character Recognition (OCR) technology, as a core branch of computer vision and document analysis, has undergone significant evolution from traditional pattern matching to deep learning-based technologies, and is now widely used in many scenarios such as document digitization, intelligent expense reimbursement, and identity authentication. However, mainstream deep OCR models heavily rely on large-scale manually labeled data, resulting in low training efficiency, high costs, and poor generalization ability. Summary of the Invention

[0003] This invention provides a method, apparatus, electronic device, and medium for small-sample training of an OCR model, to address the shortcomings of existing OCR model training methods, such as low efficiency, high cost, and poor adaptability.

[0004] This invention provides a few-shot training method for an OCR model, comprising: Data augmentation is performed on a small training dataset to generate multiple meta-tasks. Each meta-task includes multiple image samples as well as task domain identifiers and text recognition result labels for the multiple image samples. Using multiple image samples of each meta-task and the task domain identifiers of the multiple image samples as training samples, and the text recognition result labels of the multiple image samples as sample labels, an initial optical character recognition (OCR) model is trained. After training, the OCR model is obtained. The initial OCR model includes a task adaptation layer, an initial text detection layer, an initial text recognition layer, and an initial correction layer. The task adaptation layer takes the task domain identifier as input to generate task adaptation parameters, which are used to adaptively update the parameters of the initial text detection layer, the initial text recognition layer, and the initial correction layer.

[0005] In some embodiments, training the initial optical character recognition (OCR) model includes: The task domain identifiers of the multiple image samples are input into the task adaptation layer to obtain the task adaptation parameters output by the task adaptation layer. Based on the task adaptation parameters, the parameters of the initial text detection layer, the initial text recognition layer, and the initial correction layer are adaptively updated to obtain the text detection layer, the text recognition layer, and the correction layer. The text detection layer and the text recognition layer are trained using the multiple image samples as training samples and the text recognition result labels of the multiple image samples as sample labels.

[0006] In some embodiments, training the text detection layer and the text recognition layer includes: The multiple image samples are input into the text detection layer to obtain the text regions of the multiple image samples output by the text detection layer; The text regions of the multiple image samples are input into the text recognition layer to obtain the text recognition results of the multiple image samples output by the text recognition layer; The text recognition results of the multiple image samples and the text recognition result labels of the multiple image samples are input into the correction layer to obtain the corrected text recognition results output by the correction layer; Based on the corrected text recognition results and the text recognition results, the parameters of the text detection layer and the text recognition layer are iteratively optimized.

[0007] In some embodiments, inputting the plurality of image samples into the text detection layer to obtain the text regions of the plurality of image samples output by the text detection layer includes: The multiple image samples are input into the text detection layer, which performs text detection on the multiple image samples based on an adaptive anchor box generation mechanism and outputs the text regions of the multiple image samples.

[0008] In some embodiments, inputting the text regions of the plurality of image samples into the text recognition layer to obtain the text recognition results of the plurality of image samples output by the text recognition layer includes: The text regions of the multiple image samples are input into the text recognition layer, which extracts the character stroke features of the text region of each image sample. The character stroke features of the text region are matched with multiple preset character prototype features. The text recognition result of the text region is determined based on the matching result, and the text recognition result of the multiple image samples is output.

[0009] In some embodiments, the step of inputting the text recognition results of the plurality of image samples and the text recognition result labels of the plurality of image samples into the correction layer to obtain the corrected text recognition result output by the correction layer includes: The text recognition results of the multiple image samples and the text recognition result labels of the multiple image samples are input to the correction layer. The correction layer corrects the text recognition results of the multiple image samples based on the text recognition result labels of the multiple image samples and the pre-built target task knowledge base, and outputs the corrected text recognition results. The process of determining the target task knowledge base includes: Based on the task type in the task adaptation parameters, the target task knowledge base is determined from a variety of pre-built task knowledge bases.

[0010] In some embodiments, the data augmentation of the small sample training dataset to generate multiple meta-tasks includes: Construct a small sample training dataset, which includes multiple original image samples from multiple task domains; Dynamic adaptive data augmentation is performed on the original image samples of the multiple task domains to obtain augmented sample data; The enhanced sample data is preprocessed by cross-domain alignment, data cleaning, and data filtering to construct a training dataset, which includes multiple image samples and text recognition result labels for multiple image samples. Based on the training dataset, multiple meta-tasks are generated.

[0011] The present invention also provides a few-shot training device for an OCR model, comprising: The data processing unit is used to perform data augmentation on the small sample training dataset and generate multiple meta-tasks. Each meta-task includes multiple image samples and task domain identifiers and text recognition result labels of the multiple image samples. The training unit is used to train an initial optical character recognition (OCR) model using multiple image samples of each meta-task and the task domain identifiers of the multiple image samples as training samples, and the text recognition result labels of the multiple image samples as sample labels. After training, the OCR model is obtained. The initial OCR model includes a task adaptation layer, an initial text detection layer, an initial text recognition layer, and an initial correction layer. The task adaptation layer takes the task domain identifier as input to generate task adaptation parameters, which are used to adaptively update the parameters of the initial text detection layer, the initial text recognition layer, and the initial correction layer.

[0012] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement a few-sample training method for any of the OCR models described above.

[0013] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a few-sample training method for the OCR model as described above.

[0014] The present invention provides a method, apparatus, electronic device, and medium for training OCR models using small samples. This method generates multiple meta-tasks by augmenting the small sample training dataset. Multiple image samples and corresponding task domain identifiers for each meta-task are used as training samples, and text recognition result labels are used as sample labels to train an initial optical character recognition (OCR) model. The initial OCR model incorporates a task adaptation layer, which generates task adaptation parameters and adaptively updates the parameters of the initial text detection layer, initial text recognition layer, and initial correction layer. This improves training efficiency and the model's generalization ability while reducing training costs. Attached Figure Description

[0015] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0016] Figure 1 This is a flowchart illustrating the small-sample training method for the OCR model provided in this embodiment of the invention.

[0017] Figure 2 This is a flowchart illustrating the training process of the initial OCR model provided in this embodiment of the invention.

[0018] Figure 3 This is a schematic diagram of the structure of the small sample training device for the OCR model provided in the embodiment of the present invention.

[0019] Figure 4 This is a schematic diagram of the structure of the electronic device provided in an embodiment of the present invention. Detailed Implementation

[0020] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0021] The terms "first," "second," etc., used in this invention are used to distinguish similar objects, not to describe a specific order or sequence. It should be understood that such terms can be used interchangeably where appropriate so that embodiments of the invention can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first" and "second" are generally of the same class, not limited in number; for example, the first object can be one or more. Furthermore, in this invention, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.

[0022] Figure 1 This is a flowchart illustrating the few-sample training method for the OCR model provided in an embodiment of the present invention. Figure 1 As shown, a few-sample training method for an OCR model is provided, including the following steps: step 110 and step 120. This method's steps are merely one possible implementation of the present invention.

[0023] Step 110: Perform data augmentation on the small sample training dataset to generate multiple meta-tasks. Each meta-task includes multiple image samples and task domain identifiers and text recognition result labels for the multiple image samples.

[0024] The small sample training dataset contains training data for multiple different task domains, with each task domain having a very small amount of data. For example, the dataset might contain 10 invoice images, 15 road sign images, or 8 book page images.

[0025] Optionally, the small sample training dataset includes at least: original image samples from multiple task domains and their text recognition result labels.

[0026] In this embodiment of the invention, a meta-task simulates a complete few-shot learning scenario. Each meta-task contains a support set and a query set, both from the same task domain. The OCR model uses the support set for rapid learning or adaptation, then uses the query set to evaluate the effectiveness of the adaptation and calculates the loss to update the model parameters.

[0027] The task domain identifier can be a label or ID used to distinguish different tasks or scenarios. For example, a task domain identifier can be an invoice, a road sign, handwriting, or printed text.

[0028] In some embodiments, step 110 performs data augmentation on the small sample training dataset to generate multiple meta-tasks, including: Step 111: Construct a few-shot training dataset, which includes multiple original image samples from multiple task domains.

[0029] Optionally, multiple original image samples are screened using a multi-dimensional quality assessment model. The assessment metrics include character clarity, background interference, and annotation consistency. For samples with scores below a threshold, an automatic repair mechanism is triggered to repair them or they are directly removed.

[0030] Step 112: Perform dynamic adaptive data augmentation on the original image samples from multiple task domains to obtain augmented sample data.

[0031] Optionally, data augmentation is performed on each original image sample through geometric transformations, color and brightness transformations, noise injection, and blurring to generate a large number of new and diverse image samples. Geometric transformations include at least: random rotation, scaling, perspective transformation, and elastic distortion; color and brightness transformations include, but are not limited to: adjusting brightness, contrast, and saturation; noise injection includes, but is not limited to: adding Gaussian noise and salt-and-pepper noise; blurring includes, but is not limited to: Gaussian blurring and motion blurring.

[0032] Optionally, based on the text features of multiple original image samples in each task domain, a data augmentation strategy corresponding to each task domain is determined, and data augmentation is performed on multiple original image samples in each task domain according to the data augmentation strategy corresponding to each task domain.

[0033] Specifically, a data augmentation controller is constructed based on a meta-learning framework. This controller dynamically adjusts the augmentation strategy by analyzing the text features of multiple original image samples from different task domains. For example, for a specific financial document recognition task, the controller prioritizes augmentation methods such as paper structure combinations and graphical table diffusion simulation to generate synthetic samples consistent with financial styles. For text tasks in the context of expense reimbursement, the controller focuses on simulating complex real-world conditions, selecting augmentation methods such as lighting changes, occlusion simulation, and handwriting simulation. Adversarial generation constraints are introduced during the data augmentation process. A discriminator distinguishes between real and synthetic samples, ensuring the authenticity of the augmented sample data and preventing the OCR model from learning ineffective features.

[0034] Step 113 performs cross-domain alignment, data cleaning, and data filtering preprocessing on the enhanced sample data to construct a training dataset. The training dataset includes multiple image samples and text recognition result labels for multiple image samples.

[0035] Optionally, a meta-domain adaptation network is employed to perform cross-domain alignment on the enhanced sample data. During the meta-training phase, the meta-domain adaptation network learns the separation mechanism between cross-domain general features and domain-specific features, and during the preprocessing phase, it automatically filters domain-specific features while retaining the core text features.

[0036] Step 114: Generate multiple meta-tasks based on the training dataset.

[0037] Step 120: Using multiple image samples and task domain identifiers of multiple image samples for each meta-task as training samples, and the text recognition result labels of multiple image samples as sample labels, train the initial optical character recognition OCR model. After training, the OCR model is obtained. The initial OCR model includes: a task adaptation layer, an initial text detection layer, an initial text recognition layer, and an initial correction layer. The task adaptation layer takes the task domain identifier as input and generates task adaptation parameters, which are used to adaptively update the parameters of the initial text detection layer, the initial text recognition layer, and the initial correction layer.

[0038] The task adaptation parameters are a set of specific values ​​or weights generated by the task adaptation layer. By dynamically generating the task adaptation parameters, the initial text detection layer, initial recognition layer, and initial correction layer can be fine-tuned in real time to optimize their performance to adapt to the current task domain.

[0039] Understandably, traditional methods typically require training a dedicated model for each task type, leading to high development and maintenance costs. This invention, by introducing a task adaptation layer, allows for efficient handling of various recognition tasks across different task domains using only a single unified model. When processing images from a specific task domain, the model can be adjusted to become an expert model for that domain, improving text recognition accuracy and enhancing adaptability. Furthermore, when supporting images from new task domains, there's no need to train from scratch, significantly improving model training efficiency and system scalability.

[0040] In this embodiment of the invention, multiple meta-tasks are generated by data augmentation on a small training dataset; multiple image samples and corresponding task domain identifiers of each meta-task are used as training samples, and text recognition result labels are used as sample labels to train an initial OCR model; the initial OCR model introduces a task adaptation layer, which can generate task adaptation parameters and adaptively update the parameters of the initial text detection layer, initial text recognition layer and initial correction layer, thereby improving training efficiency and the generalization ability of the model and reducing training costs.

[0041] Figure 2 This is a flowchart illustrating the training process of the initial OCR model provided in an embodiment of the present invention. Figure 2 As shown, in some embodiments, training the initial OCR model includes: Step 210: Input the task domain identifiers of multiple image samples into the task adaptation layer to obtain the task adaptation parameters output by the task adaptation layer; Optionally, obtain a pre-built mapping table between task domains and task adaptation parameters; query the task adaptation parameters corresponding to the task domain identifier in the mapping table.

[0042] Optionally, the mapping table can be updated periodically.

[0043] Step 220: Based on the task adaptation parameters, adaptively update the parameters of the initial text detection layer, the initial text recognition layer, and the initial correction layer to obtain the text detection layer, the text recognition layer, and the correction layer.

[0044] Understandably, by adaptively updating the parameters of the initial text detection layer, initial text recognition layer, and initial correction layer based on task-adaptive parameters, the model exhibits high flexibility and improves training efficiency.

[0045] Step 230: Using multiple image samples as training samples and the text recognition result labels of multiple image samples as sample labels, train the text detection layer and the text recognition layer.

[0046] In this embodiment of the invention, the task domain identifiers of multiple image samples are input into the task adaptation layer to obtain the task adaptation parameters output by the task adaptation layer. Based on the task adaptation parameters, the parameters of the initial text detection layer, the initial text recognition layer, and the initial correction layer are adaptively updated to obtain the text detection layer, the text recognition layer, and the correction layer. The text detection layer and the text recognition layer are trained using multiple image samples as training samples and the text recognition result labels of multiple image samples as sample labels, which improves the efficiency of model training and reduces the cost of model training.

[0047] In some embodiments, training the text detection layer and the text recognition layer in step 230 includes: Step 231: Input multiple image samples into the text detection layer to obtain the text regions of multiple image samples output by the text detection layer.

[0048] Optionally, an adaptive anchor box generation mechanism and a knowledge distillation algorithm are used to perform text detection on multiple image samples.

[0049] Optionally, the text detection layer in the meta-training phase can be used as the teacher network, and its discriminative knowledge of text regions can be transferred to a lightweight student network using feature distillation loss. The student network retains only the core convolutional layers of the teacher network and learns by mimicking the feature map response patterns of the teacher network. For example, training on digital train tickets can be done based on general electronic invoices and train tickets, retaining the original invoice fields and adding train ticket-related travel information, requiring only a small number of digital train ticket samples to achieve the desired training effect.

[0050] In some embodiments, multiple image samples are input to a text detection layer to obtain text regions of multiple image samples output by the text detection layer, including: Input multiple image samples into the text detection layer. The text detection layer performs text detection on the multiple image samples based on the adaptive anchor box generation mechanism and outputs the text regions of the multiple image samples.

[0051] Optionally, construct a dynamic anchor box library based on the statistical features of the text bounding boxes of small samples. For example, for the ID number detection task, by analyzing 10 samples, exclusive anchor boxes with an aspect ratio of 6:1 and a rotation angle of ±5° can be generated. At the same time, introduce an anchor box evolution algorithm to dynamically adjust the anchor box parameters according to the detection loss during the training process.

[0052] Step 232: Input the text regions of the multiple image samples into the text recognition layer to obtain the text recognition results of the multiple image samples output by the text recognition layer.

[0053] Optionally, extract the feature of the character strokes of the text regions of the multiple image samples, such as the horizontal, vertical, left-falling and right-falling coordinates of the character "wood".

[0054] In some embodiments, inputting the text regions of the multiple image samples into the text recognition layer to obtain the text recognition results of the multiple image samples output by the text recognition layer includes: Input the text regions of the multiple image samples into the text recognition layer. The text recognition layer extracts the character stroke features of the text regions of each image sample, matches the character stroke features of the text regions with multiple preset character prototype features, determines the text recognition results of the text regions according to the matching results, and outputs the text recognition results of the multiple image samples.

[0055] Optionally, input the text regions of the multiple image samples into the text recognition layer. The text recognition layer extracts the character stroke features and / or word order features of the text regions of each image sample, matches the character stroke features of the text regions with multiple preset character prototype features, and / or matches the word order features of the text regions with multiple preset word order features, determines the text recognition results of the text regions according to the matching results, and outputs the text recognition results of the multiple image samples.

[0056] Optionally, the text recognition layer includes a meta character prototype network.

[0057] Specifically, at the character level, generate feature prototypes through the support set. For example, the prototype of the character "Zhang" is the feature mean of 5 samples; at the sequence level, learn the context prototype of the text sequence, such as the word order feature of "Beijing City". In the meta-test stage, classify the new samples by calculating the distances between the new samples and the two-level prototypes.

[0058] Step 233: Input the text recognition results of the multiple image samples and the text recognition result labels of the multiple image samples into the correction layer to obtain the corrected text recognition results output by the correction layer.

[0059] Optionally, an error correction meta-knowledge base is pre-built to store common error patterns and their correction strategies. For new few-sample tasks, relevant error correction rules are quickly activated through error pattern matching algorithms. For example, in contract text recognition, the "consistency between the official seal name and the name of Party A" verification rule is prioritized. Simultaneously, context-aware correction is introduced to perform semantic scoring on the recognition sequence, correcting low-scoring sequences to high semantic consistency results.

[0060] In some embodiments, the text recognition results of multiple image samples and the text recognition result labels of multiple image samples are input into the correction layer to obtain the corrected text recognition result output by the correction layer, including: The text recognition results of multiple image samples, along with the text recognition result labels of multiple image samples, are input into the correction layer. The correction layer corrects the text recognition results of multiple image samples based on the text recognition result labels of multiple image samples and a pre-built target task knowledge base, and outputs the corrected text recognition results. The process of determining the target task knowledge base includes: Based on the task type in the task adaptation parameters, the target task knowledge base is determined from a variety of pre-built task knowledge bases.

[0061] The target task knowledge base includes business rules for specific task domains. It can be automatically updated.

[0062] Optionally, business rules can be broken down into reusable meta-components, such as length validation, checksum algorithms, and format templates, and the compositional logic of these meta-components can be learned during the meta-training phase. In new tasks, rules can be instantiated with a small number of samples, and rule evolution is supported. When a rule variant is detected in a sample, the rule boundary is automatically expanded to avoid over-filtering of valid data.

[0063] Step 234: Based on the corrected text recognition results, iteratively optimize the parameters of the text detection layer and the text recognition layer.

[0064] In this embodiment of the invention, the text recognition results of multiple image samples, along with their corresponding labels, are input into a correction layer to obtain the corrected text recognition results output by the correction layer. Based on the corrected text recognition results and the text recognition results, the parameters of the text detection layer and the text recognition layer are iteratively optimized, enabling end-to-end co-evolution, enhancing the model's robustness, and improving its ability to handle fuzzy and complex text.

[0065] The following describes the small-sample training device for the OCR model provided in the embodiments of the present invention. The small-sample training device for the OCR model described below can be referred to in correspondence with the small-sample training method for the OCR model described above.

[0066] Figure 3 This is a schematic diagram of the structure of the small sample training device for the OCR model provided in an embodiment of the present invention, as shown below. Figure 3 As shown, the few-shot training device 300 for the OCR model includes: Data processing unit 310 is used to perform data augmentation on small sample training datasets and generate multiple meta-tasks. Each meta-task includes multiple image samples and task domain identifiers and text recognition result labels for multiple image samples. Training unit 320 is used to train an initial optical character recognition (OCR) model using multiple image samples of each meta-task and the task domain identifiers of the multiple image samples as training samples, and the text recognition result labels of the multiple image samples as sample labels. After training, the OCR model is obtained. The initial OCR model includes: a task adaptation layer, an initial text detection layer, an initial text recognition layer, and an initial correction layer. The task adaptation layer takes the task domain identifier as input and generates task adaptation parameters, which are used to adaptively update the parameters of the initial text detection layer, the initial text recognition layer, and the initial correction layer.

[0067] Optionally, training an initial optical character recognition (OCR) model includes: Input the task domain identifiers of multiple image samples into the task adaptation layer to obtain the task adaptation parameters output by the task adaptation layer; Based on the task adaptation parameters, the parameters of the initial text detection layer, the initial text recognition layer, and the initial correction layer are adaptively updated to obtain the text detection layer, the text recognition layer, and the correction layer. The text detection layer and the text recognition layer are trained using multiple image samples as training samples and the text recognition result labels of multiple image samples as sample labels.

[0068] Optionally, training the text detection layer and the text recognition layer includes: Multiple image samples are input into the text detection layer to obtain the text regions of the multiple image samples output by the text detection layer; The text regions of multiple image samples are input into the text recognition layer to obtain the text recognition results of multiple image samples output by the text recognition layer; The text recognition results of multiple image samples, along with the text recognition result labels of multiple image samples, are input into the correction layer to obtain the corrected text recognition result output by the correction layer. Based on the corrected text recognition results, the parameters of the text detection layer and the text recognition layer are iteratively optimized.

[0069] Optionally, multiple image samples are input into the text detection layer to obtain text regions of multiple image samples output by the text detection layer, including: Multiple image samples are input into the text detection layer, which performs text detection on the multiple image samples based on an adaptive anchor box generation mechanism and outputs the text regions of the multiple image samples.

[0070] Optionally, the text regions of multiple image samples are input into the text recognition layer to obtain the text recognition results of multiple image samples output by the text recognition layer, including: The text regions of multiple image samples are input into the text recognition layer. The text recognition layer extracts the character stroke features of the text region of each image sample, matches the character stroke features of the text region with multiple preset character prototype features, determines the text recognition result of the text region based on the matching result, and outputs the text recognition result of multiple image samples.

[0071] Optionally, the text recognition results of multiple image samples, along with the text recognition result labels of multiple image samples, are input into the correction layer to obtain the corrected text recognition results output by the correction layer, including: The text recognition results of multiple image samples, along with the text recognition result labels of multiple image samples, are input into the correction layer. The correction layer corrects the text recognition results of multiple image samples based on the text recognition result labels of multiple image samples and a pre-built target task knowledge base, and outputs the corrected text recognition results. The process of determining the target task knowledge base includes: Based on the task type in the task adaptation parameters, the target task knowledge base is determined from a variety of pre-built task knowledge bases.

[0072] Optionally, data augmentation can be performed on the small training dataset to generate multiple meta-tasks, including: Construct a few-shot training dataset, which includes multiple original image samples from multiple task domains; Dynamic adaptive data augmentation is performed on the original image samples from multiple task domains to obtain augmented sample data; The enhanced sample data is preprocessed by cross-domain alignment, data cleaning and data filtering to construct a training dataset, which includes multiple image samples and text recognition result labels for multiple image samples. Based on the training dataset, multiple meta-tasks are generated.

[0073] It should be noted that the small sample training device for the OCR model provided in this embodiment of the invention can implement all the method steps implemented in the above embodiment of the small sample training method for the OCR model, and can achieve the same technical effect. Here, the parts that are the same as those in the method embodiment and the beneficial effects will not be described in detail.

[0074] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention, such as... Figure 4 As shown, the electronic device may include: a processor 410, a communications interface 420, a memory 430, and a communications bus 440, wherein the processor 410, the communications interface 420, and the memory 430 communicate with each other through the communications bus 440. The processor 410 can call logic instructions in the memory 430 to execute a few-shot training method for the OCR model. This method includes: performing data augmentation on the few-shot training dataset to generate multiple meta-tasks, each meta-task including multiple image samples and task domain identifiers and text recognition result labels for the multiple image samples; training an initial optical character recognition OCR model using the multiple image samples and task domain identifiers of each meta-task as training samples, and the text recognition result labels of the multiple image samples as sample labels, and obtaining the OCR model after training; wherein, the initial OCR model includes: a task adaptation layer, an initial text detection layer, an initial text recognition layer, and an initial correction layer; the task adaptation layer takes the task domain identifier as input to generate task adaptation parameters, which are used to adaptively update the parameters of the initial text detection layer, the initial text recognition layer, and the initial correction layer.

[0075] Furthermore, the logical instructions in the aforementioned memory 430 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0076] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon. When executed by a processor, the computer program implements a few-sample training method for the OCR model provided by the above methods. The method includes: performing data augmentation on a few-sample training dataset to generate multiple meta-tasks, each meta-task including multiple image samples and task domain identifiers and text recognition result labels of the multiple image samples; training an initial optical character recognition OCR model using the multiple image samples and task domain identifiers of each meta-task as training samples, and using the text recognition result labels of the multiple image samples as sample labels; and obtaining an OCR model after training. The initial OCR model includes a task adaptation layer, an initial text detection layer, an initial text recognition layer, and an initial correction layer. The task adaptation layer takes the task domain identifiers as input and generates task adaptation parameters, which are used to adaptively update the parameters of the initial text detection layer, the initial text recognition layer, and the initial correction layer.

[0077] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0078] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0079] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions 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 invention.

Claims

1. A few-sample training method for an OCR model, characterized in that, include: Data augmentation is performed on a small training dataset to generate multiple meta-tasks. Each meta-task includes multiple image samples as well as task domain identifiers and text recognition result labels for the multiple image samples. Using multiple image samples of each meta-task and the task domain identifiers of the multiple image samples as training samples, and the text recognition result labels of the multiple image samples as sample labels, an initial optical character recognition (OCR) model is trained. After training, the OCR model is obtained. The initial OCR model includes a task adaptation layer, an initial text detection layer, an initial text recognition layer, and an initial correction layer. The task adaptation layer takes the task domain identifier as input to generate task adaptation parameters, which are used to adaptively update the parameters of the initial text detection layer, the initial text recognition layer, and the initial correction layer.

2. The method for training the OCR model using few samples according to claim 1, characterized in that, The training of the initial optical character recognition (OCR) model includes: The task domain identifiers of the multiple image samples are input into the task adaptation layer to obtain the task adaptation parameters output by the task adaptation layer. Based on the task adaptation parameters, the parameters of the initial text detection layer, the initial text recognition layer, and the initial correction layer are adaptively updated to obtain the text detection layer, the text recognition layer, and the correction layer. The text detection layer and the text recognition layer are trained using the multiple image samples as training samples and the text recognition result labels of the multiple image samples as sample labels.

3. The method for training the OCR model using small samples according to claim 2, characterized in that, Training the text detection layer and the text recognition layer includes: The multiple image samples are input into the text detection layer to obtain the text regions of the multiple image samples output by the text detection layer; The text regions of the multiple image samples are input into the text recognition layer to obtain the text recognition results of the multiple image samples output by the text recognition layer; The text recognition results of the multiple image samples and the text recognition result labels of the multiple image samples are input into the correction layer to obtain the corrected text recognition results output by the correction layer; Based on the corrected text recognition results and the text recognition results, the parameters of the text detection layer and the text recognition layer are iteratively optimized.

4. The method for training the OCR model using few samples according to claim 3, characterized in that, The step of inputting the plurality of image samples into the text detection layer to obtain the text regions of the plurality of image samples output by the text detection layer includes: The multiple image samples are input into the text detection layer, which performs text detection on the multiple image samples based on an adaptive anchor box generation mechanism and outputs the text regions of the multiple image samples.

5. The method for training the OCR model using few samples according to claim 3, characterized in that, The step of inputting the text regions of the multiple image samples into the text recognition layer to obtain the text recognition results of the multiple image samples output by the text recognition layer includes: The text regions of the multiple image samples are input into the text recognition layer, which extracts the character stroke features of the text region of each image sample. The character stroke features of the text region are matched with multiple preset character prototype features. The text recognition result of the text region is determined based on the matching result, and the text recognition result of the multiple image samples is output.

6. The method for training the OCR model using few samples according to claim 3, characterized in that, The step of inputting the text recognition results of the multiple image samples and the text recognition result labels of the multiple image samples into the correction layer to obtain the corrected text recognition result output by the correction layer includes: The text recognition results of the multiple image samples and the text recognition result labels of the multiple image samples are input to the correction layer. The correction layer corrects the text recognition results of the multiple image samples based on the text recognition result labels of the multiple image samples and the pre-built target task knowledge base, and outputs the corrected text recognition results. The process of determining the target task knowledge base includes: Based on the task type in the task adaptation parameters, the target task knowledge base is determined from a variety of pre-built task knowledge bases.

7. The method for training the OCR model using small samples according to claim 1, characterized in that, The process of augmenting the small training dataset to generate multiple meta-tasks includes: Construct a small sample training dataset, which includes multiple original image samples from multiple task domains; Dynamic adaptive data augmentation is performed on the original image samples of the multiple task domains to obtain augmented sample data; The enhanced sample data is preprocessed by cross-domain alignment, data cleaning, and data filtering to construct a training dataset, which includes multiple image samples and text recognition result labels for multiple image samples. Based on the training dataset, multiple meta-tasks are generated.

8. A small-sample training device for an OCR model, characterized in that, include: The data processing unit is used to perform data augmentation on the small sample training dataset and generate multiple meta-tasks. Each meta-task includes multiple image samples and task domain identifiers and text recognition result labels of the multiple image samples. The training unit is used to train an initial optical character recognition (OCR) model using multiple image samples of each meta-task and the task domain identifiers of the multiple image samples as training samples, and the text recognition result labels of the multiple image samples as sample labels. After training, the OCR model is obtained. The initial OCR model includes a task adaptation layer, an initial text detection layer, an initial text recognition layer, and an initial correction layer. The task adaptation layer takes the task domain identifier as input to generate task adaptation parameters, which are used to adaptively update the parameters of the initial text detection layer, the initial text recognition layer, and the initial correction layer.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the small sample training method of the OCR model as described in any one of claims 1 to 7.

10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the few-sample training method of the OCR model as described in any one of claims 1 to 7.