Bill certificate image key information extraction method

By combining OCR and large language models, combined with image segmentation and classification technology, the problem of resource waste and insufficient accuracy in bill and document recognition is solved, and key information extraction with high accuracy and strong generalization is achieved, which is suitable for Various bills and certificates.

CN118570813AInactive Publication Date: 2024-08-30YOZOSOFT CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202410608129.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-16
Publication Date
2024-08-30
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In the recognition of bills and documents, the existing technology requires the development of different information extraction methods according to different types, resulting in a waste of resources and difficulty in data collection, and insufficient recognition accuracy and generalization.

Method used

Using a method that combines OCR recognition and large language models, through image segmentation, tilt correction and classification, different types of extraction prompts are set to uniformly extract the key information of bills and documents, using the pre-trained Vgg19 model and decoder structure, combined with the spatial pyramid The pooling layer and UNet image segmentation model realize unified extraction of different bills and documents.

Benefits of technology

It improves the accuracy and generalization of key information extraction from bills and document images, reduces the dependence on different image types, is suitable for existing bills and documents on the market, simplifies the information extraction process, and improves recognition efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118570813A
    Figure CN118570813A
Patent Text Reader

Abstract

The invention relates to the technical field of image recognition, and particularly discloses a bill and certificate image key information extraction method, which comprises the following steps: acquiring an original bill and certificate image, and processing the original bill and certificate image to obtain a processed bill and certificate image; carrying out OCR (Optical Character Recognition) on the processed bill and certificate image to obtain a character recognition result of the processed bill and certificate image; classifying the processed bill and certificate images to obtain a classification result of the processed bill and certificate images; setting different bill and certificate key information extraction prompt words according to a classification result of the processed bill and certificate images; and inputting the character recognition result of the processed bill and certificate image and the corresponding bill and certificate key information extraction prompt words into the large language model so as to extract key information in the character recognition result. The bill and certificate image key information extraction method provided by the invention is relatively high in accuracy and generalization, and greatly facilitates the requirement of extracting key information according to the image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image recognition, and more specifically, to a method for extracting key information from a bill document image. Background Art

[0002] With the rapid development of computer vision technology, especially deep learning technology, the recognition of bills and certificates has become a hot research direction in academia. However, the same is true in the industrial world, because the use of bills and certificates is closely related to people's business and social activities and is an important part of people's lives, so the recognition of bills and certificates is of great commercial value. However, there are many types of bills and certificates. Most existing methods will develop different recognition methods for extracting key information from different bills or certificates, which will consume too much manpower and resources. In addition, it is not easy to collect a large amount of bill and certificate data. Summary of the invention

[0003] The purpose of the present invention is to overcome the deficiencies in the prior art. The present invention provides a method for extracting key information from bill document images, which has high extraction accuracy and stronger generalization.

[0004] As a first aspect of the present invention, a method for extracting key information from a bill document image is provided, the method comprising the following steps: Step S1: obtaining an original bill image or an original certificate image; Step S2: Processing the original bill image or the original certificate image to obtain a processed bill image or a processed certificate image; Step S3: performing OCR recognition on the processed bill image or the processed certificate image to obtain a character recognition result of the processed bill image or the processed certificate image; and classifying the processed bill image or the processed certificate image to obtain a classification result of the processed bill image or the processed certificate image; Step S4: setting different prompts for extracting key information of bills according to the classification results of the processed bill images, or setting different prompts for extracting key information of certificates according to the classification results of the processed certificate images; Step S5: input the character recognition result of the processed bill image and the corresponding bill key information extraction prompt into the large language model to extract the key information in the character recognition result of the processed bill image; or input the character recognition result of the processed certificate image and the corresponding certificate key information extraction prompt into the large language model to extract the key information in the character recognition result of the processed certificate image.

[0005] Furthermore, the processing of the original bill image or the original certificate image to obtain a processed bill image or a processed certificate image further includes: Using an image segmentation model to segment the original bill image into a bill background image and a bill main body image; or using an image segmentation model to segment the original document image into a document background image and a document main body image; Crop and extract the segmented bill main body image, or crop and extract the segmented certificate main body image; The extracted bill main body image is tilt-corrected to obtain a corrected bill main body image, i.e., the processed bill image; or the extracted certificate main body image is tilt-corrected to obtain a corrected certificate main body image, i.e., the processed certificate image.

[0006] Furthermore, the method of segmenting the original bill image into a bill background image and a bill main body image by using an image segmentation model; or segmenting the original certificate image into a certificate background image and a certificate main body image by using an image segmentation model, further includes: (1) The original bill image or the original document image is subjected to a pre-trained Vgg19 model to extract features of the original bill image or the original document image, and features of three different convolutional layers in the pre-trained Vgg19 model are extracted, and the features of the three different convolutional layers are used as feature codes of the image and connected to the three decoding blocks in the decoder respectively; (2) Inputting the features of the original bill image or the features of the original certificate image into the spatial pyramid pooling layer ASPP to output the features of the pooled original bill image or the features of the pooled original certificate image; (3) The pooled features output by the spatial pyramid pooling layer ASPP and the features of the three different convolutional layers are input into the three decoding blocks of the decoder; the features output by the three decoding blocks are sent to a 1 × 1 convolution and then pass through a sigmoid activation function to segment whether it is a target or a background.

[0007] Furthermore, the decoding block includes upsampling, connection, convolution, BatchNorm and Relu activation, wherein each step in the decoding block uses bilinear upsampling to increase the spatial dimension of the input feature map, and then uses a skip connection to connect it with the feature maps from three different convolutional layers of the pre-trained Vgg19 model, and then passes through a 3*3 convolution block, a BatchNorm normalization block and a Relu activation layer.

[0008] Furthermore, the classifying the processed bill image or the processed certificate image to obtain the classification result of the processed bill image or the classification result of the processed certificate image further includes: The processed ticket images are classified into train tickets and vendor receipts; or the processed document images are classified into identity cards, driver's licenses and vehicle registration certificates.

[0009] Furthermore, the step of setting different prompts for extracting key information of bills according to the classification results of the processed bill images, or setting different prompts for extracting key information of certificates according to the classification results of the processed certificate images, further includes: When the processed ticket image is classified as a train ticket, a corresponding train ticket key information extraction prompt is set; When the processed bill image is classified as a vendor's receipt, a corresponding vendor's receipt key information extraction prompt is set; When the processed document image is classified as an ID card, a corresponding ID card key information extraction prompt is set; When the processed document image is classified as a driver's license, a corresponding prompt for extracting key information of the driver's license is set; When the processed certificate image is classified as a driving license, a corresponding driving license key information extraction prompt is set.

[0010] The method for extracting key information from bill and certificate images provided by the present invention has the following beneficial effects: the key information extraction of different bill and certificate images is unified into one framework by using OCR character recognition and a large language model, and it is no longer necessary to train different information extraction models according to different images. The method can be used to extract key information from existing bill or certificate images on the market. Compared with traditional key information extraction models, the method has higher accuracy and stronger generalization. In addition, according to different designed prompts, the model can be used to extract different key information in different scenarios, which greatly facilitates the need to extract key information from images. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] The accompanying drawings are used to provide further understanding of the present invention and constitute a part of the specification. Together with the following specific embodiments, they are used to explain the present invention, but do not constitute a limitation of the present invention.

[0012] Figure 1 The present invention provides a flowchart of the method for extracting key information from bill document images.

[0013] Figure 2 This is a flow chart of a specific implementation of the method for extracting key information from bill document images provided by the present invention.

[0014] Figure 3 This is a structural diagram of the image segmentation model provided by the present invention.

[0015] Figure 4A A schematic diagram of segmenting an original document image provided by the present invention.

[0016] Figure 4B A schematic diagram of segmenting an original bill image provided by the present invention.

[0017] Figure 5A This is a schematic diagram of the main image of the certificate after correction provided by the present invention.

[0018] Figure 5B This is a schematic diagram of the corrected bill main body image provided by the present invention.

[0019] Fig. 6A for Figure 5A Schematic diagram of the character recognition results of the document main image after correction.

[0020] Figure 6B for Figure 5B Schematic diagram of the character recognition results of the bill body image after correction.

[0021] Fig. 7A for Fig. 6A Schematic diagram of key information extraction results of character recognition results.

[0022] Figure 7B for Figure 6B Schematic diagram of key information extraction results of character recognition results. DETAILED DESCRIPTION

[0023] In order to further explain the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the specific implementation method, structure, characteristics and effects of a method for extracting key information from a bill document image proposed by the present invention are described in detail below in combination with the accompanying drawings and preferred embodiments. Obviously, the described embodiments are part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the protection scope of the present invention.

[0024] In this embodiment, a method for extracting key information from a bill document image is provided. Figure 1 As shown, the method for extracting key information from a bill document image comprises the following steps: Step S1: obtaining an original bill image or an original certificate image; Step S2: Processing the original bill image or the original certificate image to obtain a processed bill image or a processed certificate image; Preferably, if Figure 2 As shown, the processing of the original bill image or the original certificate image to obtain a processed bill image or a processed certificate image also includes: Using an image segmentation model to segment the original bill image into a bill background image and a bill main body image; or using an image segmentation model to segment the original document image into a document background image and a document main body image; Figure 4A Display the target segmentation results of the driving license image. Figure 4B Display the target segmentation results of vendor receipts.

[0025] It should be noted that segmentation here means extracting the main image of the bill or certificate in the photo-taking scene and removing the parts outside the main image, because there may be interference information outside the main image, such as redundant text, which will affect the subsequent recognition and extraction.

[0026] When taking photos of bills or certificates, there will be redundant information. In order to avoid interference in the subsequent recognition, we use image segmentation to extract the main part of the bill or certificate image. Here we use a modified and simplified UNet image segmentation model. This model uses Vgg19 as the encoder, and the decoder consists of three decoding blocks with the same structure, such as Figure 3 This structure has rich multi-scale features and low computational and memory costs. It has strong feature extraction capabilities and high segmentation accuracy, and is more accurate in processing detail information.

[0027] Specifically, Figure 3 As shown, the method of using an image segmentation model to segment the original bill image into a bill background image and a bill main body image; or using an image segmentation model to segment the original document image into a document background image and a document main body image, further comprising: (1) The original bill image or the original certificate image is passed through a pre-trained Vgg19 model to extract the features of the original bill image or the original certificate image, and the features of three different convolutional layers in the pre-trained Vgg19 model (these three convolutional layers are block1_conv2 layer, block2_conv2 layer, block3_conv4 layer) are extracted, and the features of the three different convolutional layers are used as the feature encoding of the image and connected to the three decoding blocks in the decoder respectively; the reason for using the features of three different layers here is that the shallow features are rich in details and sufficient in position information, but less in semantic information; while the high-level features contain rich semantic information, but the positions are relatively rough. Therefore, the low-level and high-level features are combined to obtain richer image features; (2) inputting the features of the original bill image or the features of the original certificate image into the spatial pyramid pooling layer ASPP, using the spatial pyramid pooling layer ASPP to capture context information, so as to output the features of the pooled original bill image or the features of the pooled original certificate image; (3) The pooled features output by the spatial pyramid pooling layer ASPP and the features of the three different convolutional layers are input into the three decoding blocks of the decoder; the features output by the three decoding blocks are sent to a 1 × 1 convolution, and then pass through a sigmoid activation function to segment whether it is a target or a background. The decoding block includes upsampling, connection, convolution, BatchNorm and Relu activation, wherein each step in the decoding block uses bilinear upsampling to increase the spatial dimension of the input feature map, and then uses a jump connection to connect it with the feature maps of the three different convolutional layers from the pre-trained Vgg19 model. These jump connections are used to improve the quality of the feature map, and then pass through a 3*3 convolution block, a BatchNorm normalization block and a Relu activation layer.

[0028] Crop and extract the segmented bill main body image, or crop and extract the segmented certificate main body image; The extracted bill main body image is tilt-corrected to obtain a corrected bill main body image, i.e., the processed bill image; or the extracted certificate main body image is tilt-corrected to obtain a corrected certificate main body image, i.e., the processed certificate image.

[0029] It should be noted that, since the image of a bill or certificate may be tilted in a photo shooting scenario, it is necessary to perform tilt correction on the tilted image. The corrected image is very important for improving the accuracy of OCR recognition.

[0030] The present invention uses the method of searching contours and the minimum circumscribed rectangle in opencv to crop and extract the main part of the image. Then, the cropped and extracted image is tilted. The tilt correction technology is relatively mature. There are methods that use deep learning for correction and traditional methods for correction. We choose the traditional method for correction. Here, the Hough transform straight line detection algorithm is used to determine the tilt angle of the image, and appropriate rotation or affine transformation is applied to achieve the tilt correction of the image. Figure 5A The results of cropping, extracting and correcting the main image of the driving license are shown. Figure 5B The results of cropping, extracting and correcting the main image of the vendor receipt are shown. It can be seen that good effects are achieved for both the tilt correction of internal images (such as driving licenses) and the tilt correction of the entire image (such as vendor receipts).

[0031] Step S3: performing OCR recognition on the processed bill image or the processed certificate image to obtain a character recognition result of the processed bill image or the processed certificate image; and classifying the processed bill image or the processed certificate image to obtain a classification result of the processed bill image or the processed certificate image; It should be noted that the present invention selects Baidu's PaddleOCR to perform text recognition on these bill images and certificate images. PaddleOCR has a high accuracy in Chinese character recognition and can meet the requirements even without additional training. Fig. 6A and 6B The characters recognition results of the driving license and the merchant receipt are shown respectively.

[0032] Preferably, if Figure 2 As shown, the processing of classifying the processed bill image or the processed certificate image to obtain the classification result of the processed bill image or the classification result of the processed certificate image also includes: The processed ticket images are classified into train tickets and vendor receipts; or the processed document images are classified into identity cards, driver's licenses and vehicle registration certificates.

[0033] It should be noted that here the corrected images are classified and OCR recognized at the same time. For the convenience of research and explanation, the images are temporarily divided into five categories, namely, the ID card, driver's license and vehicle registration card; the ticket class is train tickets and vendor receipts. The purpose of classification is that the key information fields in these tickets and certificates are different, and different key information extraction prompts are designed based on these different information.

[0034] Step S4: setting different prompts for extracting key information of bills according to the classification results of the processed bill images, or setting different prompts for extracting key information of certificates according to the classification results of the processed certificate images; Preferably, the step of setting different prompts for extracting key information of bills according to the classification results of the processed bill images, or setting different prompts for extracting key information of certificates according to the classification results of the processed certificate images, further comprises: When the processed ticket image is classified as a train ticket, a corresponding train ticket key information extraction prompt is set; When the processed bill image is classified as a vendor's receipt, a corresponding vendor's receipt key information extraction prompt is set; When the processed document image is classified as an ID card, a corresponding ID card key information extraction prompt is set; When the processed document image is classified as a driver's license, a corresponding prompt for extracting key information of the driver's license is set; When the processed certificate image is classified as a driving license, a corresponding driving license key information extraction prompt is set.

[0035] It should be noted that the present invention extracts key information from identity cards, driver's licenses, vehicle registration certificates, train tickets and vendor receipts. Before the extraction, the images of these bills and certificates are classified and predicted, and different prompts of the large language model for key information extraction are designed according to the predicted categories.

[0036] In order to classify, the present invention collects about 500 bill images and document images, about 100 images of each category, and then enhances these image data to expand the data volume to about 2500. The lightweight classification model ShuffleNet is selected to classify the bill images and document images. The number of training categories is 5, corresponding to identity cards, driver's licenses, vehicle registration certificates, train tickets, and vendor receipts.

[0037] Step S5: input the character recognition result of the processed bill image and the corresponding bill key information extraction prompt into the large language model to extract the key information in the character recognition result of the processed bill image; or input the character recognition result of the processed certificate image and the corresponding certificate key information extraction prompt into the large language model to extract the key information in the character recognition result of the processed certificate image.

[0038] It should be noted that the large language model understands and extracts key information from the character recognition results based on the prompts. In the final comparison of several open source large language models, the present invention selected BaiChuan2-13B-Chat as the large language model for key information extraction because BaiChuan2-13B-Chat has a relatively high accuracy in information extraction. The present invention designs prompts for identity cards, driver's licenses, vehicle registration certificates, train tickets, and vendor receipts. The prompts are designed as follows.

[0039] (1) Prompt framework. The current task is to extract the specified key information from the OCR character recognition results. The OCR character recognition results are surrounded by symbols, including the recognized text, and the order is from left to right and from top to bottom in the original image. The specified key information is surrounded by [] symbols. Please note that the OCR character recognition results may have problems such as long sentences being cut off, unreasonable word segmentation, and corresponding misalignment. It is necessary to make a comprehensive judgment based on the context semantics to extract accurate key information. The output is in json format. Let's start: OCR text: {to fill in the recognized characters}. Key information to be extracted: [to fill in the name of the key information field to be extracted].

[0040] (2) ID card prompt. Fill in the recognized characters in the corresponding position in (1). Key information fields are, for example, [name, gender, ethnicity, birthplace, address, citizen ID number].

[0041] (3) Driver's license prompt. Fill in the recognized characters in the corresponding position in (1). Key information fields may include [name, address, license number, type of vehicle, validity period].

[0042] (4) Driving license prompt. Fill in the recognized characters in the corresponding position in (1). Key information fields are, for example, [license plate number, vehicle type, owner, nature of use, brand, license plate number, vehicle identification code, engine number, registration date, issuance date].

[0043] (5) Train ticket prompts. Fill in the recognized characters in the corresponding positions in (1). Key information fields may be [name, time, train number, starting station, end station].

[0044] (6) Prompt message for vendor receipt. Fill in the recognized characters into the corresponding position in (1). Key information fields may be [product name quantity unit price subtotal consumption total].

[0045] like Fig. 7A and 7B As shown, the present invention selects the key information extraction results of the driving license and the vendor receipt for display. After comparing the extracted key information with the corresponding image, it is found that the extracted key information has a high accuracy.

[0046] The present invention provides a method for extracting key information from bill and document images, which uses OCR character recognition and a large language model to unify the key information extraction of different bill and document images into a framework, and no longer needs to train different information extraction models according to different images. This method can be used to extract key information from existing bill or document images on the market. Compared with traditional key information extraction models, this method has higher accuracy and stronger generalization. In addition, according to different designed prompts, the model can be used to extract different key information in different scenarios, which greatly facilitates the need to extract key information based on images.

[0047] The above description is only a preferred embodiment of the present invention and does not limit the present invention in any form. Although the present invention has been disclosed as a preferred embodiment as above, it is not used to limit the present invention. Any technician familiar with this profession can make some changes or modifications to equivalent embodiments of equivalent changes using the technical contents disclosed above without departing from the scope of the technical solution of the present invention. However, any simple modification, equivalent change and modification made to the above embodiments based on the technical essence of the present invention without departing from the content of the technical solution of the present invention still falls within the scope of the technical solution of the present invention.

Claims

1. A method for extracting key information from bill document images. It is characterized in that The method for extracting key information from a bill document image comprises the following steps: Step S1: obtaining an original bill image or an original certificate image; Step S2: Processing the original bill image or the original certificate image to obtain a processed bill image or a processed certificate image; Step S3: performing OCR recognition on the processed bill image or the processed certificate image to obtain a character recognition result of the processed bill image or the processed certificate image; and classifying the processed bill image or the processed certificate image to obtain a classification result of the processed bill image or the processed certificate image; Step S4: setting different prompts for extracting key information of bills according to the classification results of the processed bill images, or setting different prompts for extracting key information of certificates according to the classification results of the processed certificate images; Step S5: inputting the character recognition result of the processed bill image and the corresponding bill key information extraction prompt into the large language model to extract the key information from the character recognition result of the processed bill image; Alternatively, the character recognition result of the processed document image and the corresponding document key information extraction prompt are input into a large language model to extract the key information from the character recognition result of the processed document image.

2. A method for extracting key information from a bill document image according to claim 1, It is characterized in that The processing of the original bill image or the original certificate image to obtain a processed bill image or a processed certificate image further includes: Using an image segmentation model to segment the original bill image into a bill background image and a bill main body image; or using an image segmentation model to segment the original document image into a document background image and a document main body image; Crop and extract the segmented bill main body image, or crop and extract the segmented certificate main body image; The extracted bill main body image is tilt-corrected to obtain a corrected bill main body image, i.e., the processed bill image; or the extracted certificate main body image is tilt-corrected to obtain a corrected certificate main body image, i.e., the processed certificate image.

3. A method for extracting key information from a bill document image according to claim 2, It is characterized in that The method of segmenting the original bill image into a bill background image and a bill main body image by using an image segmentation model; or segmenting the original document image into a document background image and a document main body image by using an image segmentation model, further comprises: (1) The original bill image or the original document image is subjected to a pre-trained Vgg19 model to extract features of the original bill image or the original document image, and features of three different convolutional layers in the pre-trained Vgg19 model are extracted, and the features of the three different convolutional layers are used as feature codes of the image and connected to the three decoding blocks in the decoder respectively; (2) Inputting the features of the original bill image or the features of the original certificate image into the spatial pyramid pooling layer ASPP to output the features of the pooled original bill image or the features of the pooled original certificate image; (3) The pooled features output by the spatial pyramid pooling layer ASPP and the features of the three different convolutional layers are input into the three decoding blocks of the decoder; the features output by the three decoding blocks are sent to a 1 × 1 convolution and then pass through a sigmoid activation function to segment whether it is a target or a background.

4. A method for extracting key information from a bill document image according to claim 3, It is characterized in that The decoding block includes upsampling, connection, convolution, BatchNorm and Relu activation, wherein each step in the decoding block uses bilinear upsampling to increase the spatial dimension of the input feature map, and then uses a skip connection to connect it with the feature maps from three different convolutional layers of the pre-trained Vgg19 model, and then passes through a 3*3 convolution block, a BatchNorm normalization block and a Relu activation layer.

5. A method for extracting key information from a bill document image according to claim 1, It is characterized in that The classifying the processed bill image or the processed certificate image to obtain the classification result of the processed bill image or the classification result of the processed certificate image further includes: The processed ticket images are classified into train tickets and vendor receipts; or the processed document images are classified into identity cards, driver's licenses and vehicle registration certificates.

6. A method for extracting key information from a bill document image according to claim 5, It is characterized in that The step of setting different prompts for extracting key information of bills according to the classification results of the processed bill images, or setting different prompts for extracting key information of certificates according to the classification results of the processed certificate images, further comprises: When the processed ticket image is classified as a train ticket, a corresponding train ticket key information extraction prompt is set; When the processed bill image is classified as a vendor's receipt, a corresponding vendor's receipt key information extraction prompt is set; When the processed document image is classified as an ID card, a corresponding ID card key information extraction prompt is set; When the processed document image is classified as a driver's license, a corresponding prompt for extracting key information of the driver's license is set; When the processed certificate image is classified as a driving license, a corresponding driving license key information extraction prompt is set.

Citation Information

Patent Citations

  • Medical image segmentation method based on double-type U-Net model

    CN113538346A

  • Big language model-based bill identification method and apparatus, and storage medium

    CN117253248A

  • OCR key information extraction method and model for medical bills

    CN117831043A