Text detection model training method and device, text detection method and device
Through the combination of feature extraction, pooling and fusion layers, combined with data amplification technology, the accuracy problem of the text detection model in complex backgrounds is solved, the detection efficiency and generalization are improved, and the cost of manual annotation is reduced.
Patent Information
- Application Number
- CN202110109985.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-01-27
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2041-01-27
AI Technical Summary
Existing text detection models are prone to miss detection or misjudgment when detecting text in complex backgrounds, and rely on manual annotation of data, which is costly and do not fully utilize the connections between image channels, resulting in low detection accuracy.
Using a combination of feature extraction layer, feature pooling layer and feature fusion layer, prediction boxes are generated by extracting multi-scale initial feature maps, pooling and fusion, and training models based on loss values to enhance feature connections and receptive fields, combined with data expansion Add technology to improve model generalization.
It improves the accuracy and recognition efficiency of the text detection model in complex backgrounds, reduces the phenomenon of missed detection of small targets, reduces the dependence on manual annotation data, and enhances the generalization ability of the model.
Smart Images

Figure CN112818975B
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a text detection model training method and apparatus, a text detection method and apparatus, a computing device, and a computer-readable storage medium. Background Art
[0002] With the rapid development of computer technology, the field of image processing has also developed rapidly. Among them, text detection is also a very important branch in the field of image processing.
[0003] Most of the existing text detection is based on manually annotated text images as model training data. Training images require a lot of manpower and material resources to annotate them, or it costs a lot of money to purchase annotated data, which is very costly. In addition, most of the existing text detection models do not consider the connection between image channels. When detecting text areas in complex backgrounds (such as complex colors, complex textures, etc.), omissions often occur. The final text detection position is often inaccurate, and misjudgments may occur.
[0004] Therefore, how to solve the above problems has become a problem that needs to be solved urgently by technical personnel. Summary of the invention
[0005] In view of this, the embodiments of the present application provide a text detection model training method and apparatus, a text detection method and apparatus, a computing device, and a computer-readable storage medium to address the technical defects existing in the prior art.
[0006] According to a first aspect of an embodiment of the present application, a text detection model training method is provided, comprising:
[0007] Inputting a target training image into a text detection model, wherein the target training image is annotated with a corresponding annotation box, and the text detection model includes a feature extraction layer, a feature pooling layer, and a feature fusion layer;
[0008] Extracting a plurality of initial feature maps of different scales corresponding to the target training image through the feature extraction layer;
[0009] Pooling the multiple initial feature maps of different scales through the feature pooling layer to obtain multiple enhanced feature maps of different scales;
[0010] The plurality of enhanced feature maps of different scales are fused through the feature fusion layer to obtain a plurality of prediction frames;
[0011] A target prediction box is determined from the multiple prediction boxes, a loss value is determined based on the target prediction box and a label box corresponding to the target training image, and the text detection model is trained according to the loss value until a training stop condition is reached.
[0012] According to a second aspect of an embodiment of the present application, a text detection method is provided, comprising:
[0013] Acquire an image to be detected, wherein the image to be detected includes text to be detected;
[0014] Inputting the image to be detected into a pre-trained text detection model, wherein the text detection model is obtained by training using the above-mentioned text detection model training method;
[0015] The text detection model generates a predicted text box corresponding to the text to be detected in response to the image to be detected as input.
[0016] According to a third aspect of an embodiment of the present application, a text detection model training device is provided, comprising:
[0017] An acquisition module is configured to input a target training image into a text detection model, wherein the target training image is annotated with a corresponding annotation box, and the text detection model includes a feature extraction layer, a feature pooling layer, and a feature fusion layer;
[0018] An extraction module, configured to extract a plurality of initial feature maps of different scales corresponding to the target training image through the feature extraction layer;
[0019] A pooling module is configured to pool the multiple initial feature maps of different scales through the feature pooling layer to obtain multiple enhanced feature maps of different scales;
[0020] A fusion module is configured to fuse the multiple enhanced feature maps of different scales through the feature fusion layer to obtain multiple prediction boxes;
[0021] The training module is configured to determine a target prediction box from the multiple prediction boxes, determine a loss value based on the target prediction box and a label box corresponding to the target training image, and train the text detection model according to the loss value until a training stop condition is reached.
[0022] According to a fourth aspect of an embodiment of the present application, a text detection device is provided, including:
[0023] An acquisition module is configured to acquire an image to be detected, wherein the image to be detected includes text to be detected;
[0024] An input module is configured to input the image to be detected into a pre-trained text detection model, wherein the text detection model is obtained by training using the above-mentioned text detection model training method;
[0025] The generation module is configured so that the text detection model generates a predicted text box corresponding to the text to be detected in response to the image to be detected as input.
[0026] According to a fifth aspect of an embodiment of the present application, a computing device is provided, comprising a memory, a processor, and computer instructions stored in the memory and executable on the processor, wherein the processor implements the steps of the text detection model training method or the text detection method when executing the instructions.
[0027] According to a sixth aspect of an embodiment of the present application, a computer-readable storage medium is provided, which stores computer instructions, and when the instructions are executed by a processor, the steps of the text detection model training method or the text detection method are implemented.
[0028] According to a seventh aspect of an embodiment of the present application, a chip is provided, which stores computer instructions, and when the instructions are executed by the chip, the steps of the text detection model training method or the text detection method are implemented.
[0029] The text detection model training method provided by the embodiment of the present application includes: inputting a target training image into a text detection model, wherein the target training image is annotated with a corresponding annotation box, and the text detection model includes a feature extraction layer, a feature pooling layer, and a feature fusion layer; extracting multiple initial feature maps of different scales corresponding to the target training image through the feature extraction layer; pooling the multiple initial feature maps of different scales through the feature pooling layer to obtain multiple enhanced feature maps of different scales; fusing the multiple enhanced feature maps of different scales through the feature fusion layer to obtain multiple prediction boxes; determining a target prediction box among the multiple prediction boxes, determining a loss value based on the target prediction box and the annotation box corresponding to the target training image, and training the text detection model according to the loss value until the training stop condition is reached. The text detection model provided by the method can effectively enhance the connection between features through the feature extraction layer, effectively enhance the accuracy of text in complex background areas, and at the same time increase the network structure of the feature pooling layer, which can effectively increase the receptive field of the target area, reduce the phenomenon of missed detection of small target objects, and enhance the recognition accuracy of the text detection model as a whole, and improve the recognition efficiency.
[0030] Secondly, a new form of data augmentation is adopted to solve the problem of inaccurate recognition caused by insufficient manually labeled data and target occlusion, while also enhancing the generalization of the text detection model. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 is a structural block diagram of a computing device provided in an embodiment of the present application;
[0032] Figure 2is a flowchart of a text detection model training method provided in an embodiment of the present application;
[0033] Figure 3 is a schematic diagram of a text detection model training method provided by another embodiment of the present application;
[0034] Figure 4 is a flowchart of a text detection method provided in an embodiment of the present application;
[0035] Figure 5 It is a structural diagram of a text detection model training device provided in an embodiment of the present application;
[0036] Figure 6 It is a structural diagram of a text detection device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0037] Many specific details are described in the following description to facilitate a full understanding of the present application. However, the present application can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of the present application, so the present application is not limited by the specific implementation disclosed below.
[0038] The terms used in one or more embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of the present application. The singular forms of "a", "said" and "the" used in one or more embodiments of the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of the present application refers to and includes any or all possible combinations of one or more associated listed items.
[0039] It should be understood that, although the terms first, second, etc. may be used to describe various information in one or more embodiments of the present application, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of the present application, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "in response to determination".
[0040] First, the terms involved in one or more embodiments of the present invention are explained.
[0041] Text detection: Given a text image, automatically locate the location of the text.
[0042] K-means clustering: K-means clustering algorithm is an iterative clustering analysis algorithm. Its steps are to divide the data into K groups in advance, randomly select K objects as the initial cluster centers, and then calculate the distance between each object and each seed cluster center, and assign each object to the cluster center closest to it. Each time an object is assigned, the cluster center of the cluster will be recalculated based on the existing objects in the cluster.
[0043] Yolov3: Based on the Darknet-53 target detection network structure, Darknet is a feature extraction network based on a residual structure.
[0044] FPN: Feature Pyramin Networks, a multi-scale object detection method.
[0045] Attention mechanism: Atteniton is a resource allocation mechanism, which can be understood as reallocating resources that were originally evenly distributed according to the importance of the attention object.
[0046] ASPP: atrous spatial pyramid pooling, a method of parallel sampling of a given input using atrous convolutions with different sampling rates.
[0047] Logistic layer: A network structure used for classification, used to classify detection boxes.
[0048] IOU: An indicator used to calculate the overlap between evaluation detection boxes.
[0049] In the present application, a text detection model training method and apparatus, a text detection method and apparatus, a computing device, and a computer-readable storage medium are provided, which are described in detail one by one in the following embodiments.
[0050] Figure 1 The structure block diagram of a computing device 100 according to an embodiment of the present application is shown. The components of the computing device 100 include but are not limited to a memory 110 and a processor 120. The processor 120 is connected to the memory 110 via a bus 130, and the database 150 is used to store data.
[0051] The computing device 100 also includes an access device 140 that enables the computing device 100 to communicate via one or more networks 160. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 140 may include one or more of any type of network interface (e.g., a network interface card (NIC)) whether wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a World Wide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, a near field communication (NFC) interface, and the like.
[0052] In one embodiment of the present application, the above components of the computing device 100 and Figure 1 Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Figure 1 The computing device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of the present application. Those skilled in the art may add or replace other components as needed.
[0053] The computing device 100 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or PC. The computing device 100 may also be a mobile or stationary server.
[0054] The processor 120 may execute Figure 2 Steps in the text detection model training method shown. Figure 2 A flowchart of a text detection model training method according to an embodiment of the present application is shown, including steps 202 to 210.
[0055] Step 202: Input the target training image into the text detection model, wherein the target training image is annotated with a corresponding annotation box, and the text detection model includes a feature extraction layer, a feature pooling layer and a feature fusion layer.
[0056] The target training image is a text image used to train a text detection model. The text image is annotated with a corresponding annotation box, and the annotation box is used to identify the text area that needs to be recognized in the text image.
[0057] The text detection model is used to receive a text image, identify and mark the text area in the text image. The text detection module provided in the present application includes at least a feature extraction layer, a feature pooling layer and a feature fusion layer, wherein the feature extraction layer is preferably a feature extraction layer that integrates an attention mechanism.
[0058] In practical applications, before inputting the target training image into the text detection model, the method further includes:
[0059] Get the target training image in the preset training set.
[0060] The preset training set is a training set including a plurality of text images, and a large number of target training images are stored in the preset training set.
[0061] In practical applications, the target training images in the preset training set are based on a large number of manually annotated target detection images. Annotating images by manual annotation methods consumes a lot of manpower and time, which is time-consuming and laborious. Therefore, the training data in the training set can also be increased by expanding the data capacity of the training set. Specifically, obtaining the target training images in the preset training set includes:
[0062] Acquire an initial training set, wherein the initial training set includes a plurality of training images;
[0063] Perform data augmentation processing on the multiple training images to generate a data augmented training set.
[0064] The data augmentation processing of the multiple training images includes: performing data augmentation processing on the multiple training images in any one of or a combination of random cropping, random translation, contrast change, brightness change, transparency change, random occlusion, and random filling.
[0065] After obtaining an initial training set, it is necessary to perform data augmentation on the sample images in the training set. In addition to random cropping, stretching, contrast, brightness and transparency processing, data augmentation methods also include the Cutout algorithm (random occlusion) and the FMix algorithm (random filling). The Cutout algorithm randomly selects a square area of a fixed size and then fills it with all 0s; the FMix algorithm binarizes the image according to the high-frequency and low-frequency areas of the image, and then uses a mask to weight the pixels. The introduction of these two data augmentation algorithms can be used to solve the problem of insufficient target occlusion. Data augmentation can increase the samples of the training set, and it can also effectively alleviate the overfitting of the model, and can also bring stronger generalization capabilities to the model.
[0066] In target detection, there is usually a concept of a priori box. The a priori box is a pre-set width and height of common targets. When making predictions, the preset width and height can be used to help detect targets. The size of the priori box is usually obtained through K-means clustering. For example, in Yolov3, 9 priori boxes are usually obtained by clustering through the K-means clustering algorithm, and 3 priori boxes are set for large, medium and small scales respectively. The size of each size of the priori box is generated according to the clustering of training data in actual applications, and is not limited in this application. For example, the size of the priori box can be 116*90, 156*198, 373*326, 30*61, 62*45, 59*119, 10*13, 16*30, 33*23; it can also be 5*24, 5*36, 6*25, 9*65, 9*48, 9*70, 14*155, 15*178, 16*180, etc., among which, a larger prior box (such as 14*155, 15*178, 16*180) is applied on a smaller-scale feature map, which is suitable for detecting larger objects; a medium prior box (such as 9*65, 9*48, 9*70) is applied on a medium-scale feature map, which is suitable for detecting medium-sized objects; on a larger-scale feature map, a smaller prior box (such as 5*24, 5*36, 6*25) is applied, which is suitable for detecting smaller objects.
[0067] The training images may include images of various scenes, such as live broadcast scenes, game scenes, outdoor scenes, etc., and the training images may include various types of text information such as words, shapes, languages, etc., and at least one of the images or texts may be identified from the training images. The training images may include manually annotated annotation boxes, the positions of the annotation boxes are the positions to be identified, and the contents in the annotation boxes are the contents to be identified. The annotation boxes are usually rectangular annotation boxes, but may also be other polygonal annotation boxes. This is not limited in the present application. In actual applications, the preset training set may be divided into two parts, namely, a training subset and a test subset. During the model training process, the target training images are obtained from the training subset. After the model training is completed, the target detection images are obtained from the test subset to detect the performance of the model.
[0068] The text detection model trained in this application is used to detect the position of the text area in the text image, which can quickly and accurately locate the position of the text in the image, saving time and improving efficiency in subsequent text recognition. The text detection model provided in this application includes a feature extraction layer, a feature pooling layer, and a feature fusion layer that integrates the attention mechanism.
[0069] In a specific embodiment provided in the present application, the target training image is a photo of a resume A, and the name, age, and telephone number of resume A are marked with a label box. The target training image resume A is input into a text detection model for training. The text detection model includes a feature extraction layer, a feature pooling layer, and a feature fusion layer that integrate an attention mechanism.
[0070] Step 204: extracting a plurality of initial feature maps of different scales corresponding to the target training image through the feature extraction layer.
[0071] The feature extraction layer is preferably a feature extraction layer fused with an attention mechanism, the feature extraction layer fused with the attention mechanism includes multiple channels, the multiple channels are fused with the attention mechanism, and accordingly, the feature extraction layer extracts multiple initial feature maps of different scales corresponding to the target training image, including:
[0072] Initial feature maps of multiple different scales corresponding to the target training image are extracted through the multiple channels and the attention mechanism fused between the multiple channels.
[0073] The feature extraction layer integrating the attention mechanism preferably uses the improved Darknet-53 structure in Yolov3, that is, based on the Darknet-53 in Yolov3, an attention mechanism between channels is added. The Darknet-53 in Yolov3 is a fully convolutional network, which is used to extract multiple initial feature maps of different scales corresponding to the target training image. Specifically, the target training image is feature extracted through different feature channels, and the feature memory is screened and weighted in the channel dimension through the attention mechanism, which improves the detection performance and enhances the connection between channel features, and has a good effect on detecting text areas with complex features.
[0074] The feature extraction layer is used to extract the initial feature maps of the target training image at different scales, and output three feature images X1, X2, and X3 of different scales. The depths of X1, X2, and X3 are all 255, and the side lengths are in the order of 13:26:52. Three prediction boxes are output in each feature image, for a total of nine prediction boxes.
[0075] In a specific implementation provided in the present application, following the above example, the photo of resume A is input into Darknet-53-attention (a feature extraction layer integrating the attention mechanism) for feature extraction to obtain a feature image X1 at the scale of detecting large targets, a feature image X2 at the scale of detecting medium targets, and a feature image X3 at the scale of detecting small targets.
[0076] Step 206: pooling the multiple initial feature maps of different scales through the feature pooling layer to obtain multiple enhanced feature maps of different scales.
[0077] In practical applications, in order to ensure that the features of the image have a large receptive field and hope that the resolution of the feature map will not drop too much (too much resolution will lose the detailed information of the image boundary), the above problem can be solved by the method of dilated convolution. Preferably, in the text detection model provided in the present application, the feature pooling layer includes a dilated spatial convolution pooling pyramid;
[0078] Accordingly, the multiple initial feature maps of different scales are pooled by the feature pooling layer, including:
[0079] The multiple initial feature maps of different scales are pooled through the atrous spatial convolution pooling pyramid.
[0080] Atrous spatial pyramid pooling (ASPP), the ASPP layer plays the same role of increasing the receptive field without using pooling and downsampling operations. Each output of the convolution has a larger range of information, which increases the receptive field of view of the target area. Atrous convolutions with different sampling rates can effectively capture more scale information and reduce the phenomenon of missed detection of small target objects.
[0081] In a specific implementation provided in the present application, following the above example, feature images X1, X2 and X3 of different scales are input into the feature pooling layer for processing to obtain enhanced feature images Y1, Y2 and Y3 of multiple different scales after feature enhancement.
[0082] Step 208: The plurality of enhanced feature maps of different scales are fused through the feature fusion layer to obtain a plurality of prediction boxes.
[0083] Preferably, the feature fusion layer comprises a feature graph pyramid network;
[0084] The plurality of enhanced feature maps of different scales are fused through the feature fusion layer to obtain a plurality of prediction frames, including:
[0085] The plurality of enhanced feature maps of different scales are fused through the feature map pyramid network to obtain a plurality of prediction boxes and a score corresponding to each prediction box.
[0086] Feature Pyramin Networks (FPN), FPN solves the multi-scale problem in object detection and can be changed through network connections. Under the premise of basically not increasing the computational complexity of the original model, it greatly improves the performance of small object detection. In feature maps of different scales, the underlying feature semantic information is less, but the target position is accurate, and the high-level feature semantic information is rich, but the target position is relatively rough. The prediction of FPN is based on feature maps of different scales. It is performed independently through upsampling of high-level features and top-down connection of low-level features. Corresponding predictions are performed at each layer, and multiple different prediction results are output, and finally multiple prediction boxes are generated. At the same time, the score corresponding to each prediction box is also generated.
[0087] In a specific implementation provided in the present application, following the above example, multiple enhanced feature maps Y1, Y2 and Y3 of different scales are input into the feature fusion layer for processing, and prediction frames of multiple scales can be generated, each of which has a corresponding score.
[0088] Step 210: Determine a target prediction box from the multiple prediction boxes, determine a loss value based on the target prediction box and a label box corresponding to the target training image, and train the text detection model according to the loss value until a training stop condition is reached.
[0089] In practical applications, after obtaining the prediction frames in the above steps, the scores corresponding to each prediction frame may also be obtained. Accordingly, a target prediction frame is determined among the multiple prediction frames, including: determining the prediction frame with the highest score as the target prediction frame.
[0090] In practical applications, determining the loss value based on the target prediction box and the annotation box corresponding to the target training image includes:
[0091] A loss value is determined based on the position information of the target prediction box and the position information of the annotation box corresponding to the target training image.
[0092] After obtaining the predicted target prediction box, the position information of the target prediction box can be determined according to the coordinates of a vertex of the target prediction box and the length and width of the target prediction box. At the same time, the position information of the annotation box can be determined according to the coordinates of a vertex of the annotation box corresponding to the target training object and the length and width of the annotation box. The loss value can be determined based on the position information of the target prediction box and the position information of the annotation box corresponding to the target training image. There are many methods for determining the loss value, such as cross entropy loss function, maximum loss function, average loss function, etc. The specific method of calculating the loss value is not limited in this application, and it is subject to actual application.
[0093] Optionally, training the text detection model according to the loss value includes:
[0094] The model parameters in the feature extraction layer, the feature pooling layer and the feature fusion layer in the text detection model are adjusted according to the loss value.
[0095] Training the text detection model according to the loss value specifically involves adjusting model parameters in the feature extraction layer, feature pooling layer, and feature fusion layer in the text detection model according to the loss value.
[0096] According to the scores corresponding to the prediction boxes of different scales, the prediction box with the highest score is selected as the target prediction box, and the target prediction box is used as the predicted detection position of each area. The loss value is then determined based on the labeled box in the target training image, and the parameters of the text detection model are adjusted by backpropagation according to the loss value until the training stop condition is reached. The training stop condition can be a preset training round, or a loss value lower than a preset threshold, or a test based on the target detection image in the test subset, and the obtained target prediction box position and the overlapping area of the labeled box are greater than the preset threshold. The training stop condition is not specifically limited in this application.
[0097] In a specific implementation provided in the present application, a target prediction box 1 corresponding to the name in the resume, a target prediction box 2 corresponding to the age, and a target prediction box 3 corresponding to the phone number are respectively determined, and a loss value is calculated based on the target prediction box 1, the target prediction box 2, and the target prediction box 3 and the annotated box in the resume, and then the parameters of the text detection model are adjusted by back propagation based on the loss value. After training for a preset number of rounds, the text detection model is detected based on the target detection image in the test subset. When the overlap between the prediction box output by the text detection model and the annotated box in the target test image reaches more than 95%, that is, the IOU value is above 0.95, the text detection model is successfully trained.
[0098] The text detection model training method provided by the embodiment of the present application includes inputting a target training image into a text detection model, wherein the target training image is annotated with a corresponding annotation box, and the text detection model includes a feature extraction layer, a feature pooling layer, and a feature fusion layer; extracting multiple initial feature maps of different scales corresponding to the target training image through the feature extraction layer; pooling the multiple initial feature maps of different scales through the feature pooling layer to obtain multiple enhanced feature maps of different scales; fusing the multiple enhanced feature maps of different scales through the feature fusion layer to obtain multiple prediction boxes; determining a target prediction box among the multiple prediction boxes, determining a loss value based on the target prediction box and the annotation box corresponding to the target training image, and training the text detection model according to the loss value until the training stop condition is reached. The text detection model provided by the method can effectively enhance the connection between features through the feature extraction layer, effectively enhance the accuracy of text in complex background areas, and at the same time increase the network structure of the feature pooling layer, which can effectively increase the receptive field of the target area, reduce the phenomenon of missed detection of small target objects, and enhance the recognition accuracy of the text detection model as a whole, and improve the recognition efficiency.
[0099] Secondly, a new form of data augmentation is adopted to solve the problem of inaccurate recognition caused by insufficient manually labeled data and target occlusion, while also enhancing the generalization of the text detection model.
[0100] Figure 3 A schematic diagram of a text detection model training method provided by an embodiment of the present application is shown. Figure 3 As shown, the method includes steps 302 to 312.
[0101] Step 302: Obtain an initial training set.
[0102] Step 304: Perform data augmentation processing on the multiple training images to generate a data augmented training set.
[0103] Step 306: Determine the prior box of the training image through K-means clustering, and input the training image into the text detection model.
[0104] The text detection model includes a feature extraction layer of a fusion attention mechanism, a dilated spatial convolution pooling pyramid and a feature map pyramid network. The training image is input into the feature extraction layer of the fusion attention mechanism for feature extraction to obtain a plurality of initial feature maps of different scales; the plurality of initial feature maps of different scales are input into the spatial dilated convolution pooling pyramid network for feature enhancement to obtain a plurality of enhanced feature maps of different scales; the plurality of initial feature maps of different scales and the plurality of enhanced feature maps of different scales are input into the feature map pyramid network for feature fusion, and a plurality of prediction boxes are output.
[0105] Step 308: Obtain multiple prediction boxes output by the text detection model, and determine a target prediction box among the multiple prediction boxes.
[0106] Step 310: Determine a loss value based on the target prediction box and the annotation box corresponding to the target training image.
[0107] Step 312: Train the text detection model according to the loss value until a training stop condition is reached.
[0108] The text detection model training method provided in the embodiment of the present application can effectively enhance the connection between features and the accuracy of text in complex background areas through the feature extraction layer of the text detection model. At the same time, the network structure of the feature pooling layer is increased, which can effectively increase the receptive field of the target area and reduce the phenomenon of missed detection of small target objects, thereby enhancing the recognition accuracy of the text detection model as a whole and improving the recognition efficiency.
[0109] Secondly, a new form of data augmentation is adopted to solve the problem of inaccurate recognition caused by insufficient manually labeled data and target occlusion, while also enhancing the generalization of the text detection model.
[0110] Figure 4 A flow chart of a text detection method according to an embodiment of the present application is shown. The text detection method is described by taking text detection on a resume as an example, and includes steps 402 to 406.
[0111] Step 402: Acquire an image to be detected, wherein the image to be detected includes text to be detected.
[0112] In a specific embodiment provided in the present application, the obtained resume picture is the image to be detected, and the name, gender, date of birth, place of origin, contact information, work experience and other contents in the resume are the text to be detected.
[0113] Step 404: input the image to be detected into a pre-trained text detection model, wherein the text detection model is obtained by training using the above-mentioned text detection model training method.
[0114] In a specific embodiment provided in the present application, a resume image is input into a pre-trained text detection model.
[0115] Step 406: The text detection model generates a predicted text box corresponding to the text to be detected in response to the image to be detected as input.
[0116] In a specific embodiment provided in the present application, the text detection model responds to the resume image as input and generates a predicted text box on the resume image, and the predicted text box corresponds to the name, gender, date of birth, place of origin, contact information, work experience, etc. in the resume image.
[0117] Optionally, the method further comprises:
[0118] Performing text recognition on the content in the predicted text box based on the predicted text box;
[0119] Obtain text content information corresponding to the text to be detected.
[0120] In a specific embodiment provided by the present application, text recognition is performed on the content in the resume image based on the corresponding predicted text boxes for the name, gender, date of birth, native place, contact information, work experience, etc. in the resume image, and the text content in the corresponding predicted text box in the resume image is obtained, such as name: Zhang San, gender: male, date of birth: **** year ** month ** day, native place: certain place, etc. The obtained text content is filled into a preset structured table to realize the process of converting the resume image into a text resume.
[0121] The text detection method provided by the present application includes obtaining an image to be detected, wherein the image to be detected includes text to be detected; inputting the image to be detected into a pre-trained text detection model, wherein the text detection model is obtained by training using the above-mentioned text detection model training method; the text detection model generates a predicted text box corresponding to the text to be detected in response to the image to be detected as input. Through the text detection method of the present application, text images with complex backgrounds can be better identified, text content can be more accurately extracted, and the text image recognition effect can be improved.
[0122] Corresponding to the above text detection model training method embodiment, the present application also provides a text detection model training device embodiment, Figure 5 FIG. 1 is a schematic diagram showing the structure of a text detection model training device according to an embodiment of the present application. Figure 5 As shown, the device comprises:
[0123] An acquisition module 502 is configured to input a target training image into a text detection model, wherein the target training image is annotated with a corresponding annotation box, and the text detection model includes a feature extraction layer, a feature pooling layer, and a feature fusion layer;
[0124] An extraction module 504 is configured to extract a plurality of initial feature maps of different scales corresponding to the target training image through the feature extraction layer;
[0125] A pooling module 506 is configured to pool the multiple initial feature maps of different scales through the feature pooling layer to obtain multiple enhanced feature maps of different scales;
[0126] A fusion module 508 is configured to fuse the multiple enhanced feature maps of different scales through the feature fusion layer to obtain multiple prediction boxes;
[0127] The training module 510 is configured to determine a target prediction box from the multiple prediction boxes, determine a loss value based on the target prediction box and the annotation box corresponding to the target training image, and train the text detection model according to the loss value until a training stop condition is reached.
[0128] Optionally, the acquisition module 502 is further configured to acquire a target training image in a preset training set.
[0129] Optionally, the acquisition module 502 is further configured to:
[0130] Acquire an initial training set, wherein the initial training set includes a plurality of training images;
[0131] Perform data augmentation processing on the multiple training images to generate a data augmented training set.
[0132] Optionally, the acquisition module 502 is further configured to:
[0133] The multiple training images are subjected to any data augmentation processing including random cropping, random translation, contrast change, brightness change, transparency change, random occlusion, and random filling.
[0134] Optionally, the feature extraction layer integrating the attention mechanism includes multiple channels, and the attention mechanism is integrated between the multiple channels;
[0135] The extraction module 504 is further configured to:
[0136] Initial feature maps of multiple different scales corresponding to the target training image are extracted through the multiple channels and the attention mechanism fused between the multiple channels.
[0137] Optionally, the feature pooling layer includes a dilated spatial convolutional pooling pyramid;
[0138] The pooling module 506 is further configured to:
[0139] The multiple initial feature maps of different scales are pooled through the atrous spatial convolution pooling pyramid.
[0140] Optionally, the feature fusion layer includes a feature map pyramid network;
[0141] The fusion module 508 is further configured to:
[0142] The plurality of enhanced feature maps of different scales are fused through the feature map pyramid network to obtain a plurality of prediction boxes and a score corresponding to each prediction box.
[0143] Optionally, the training module 510 is further configured to:
[0144] Determine the prediction box with the highest score as the target prediction box.
[0145] Optionally, the training module 510 is further configured to:
[0146] A loss value is determined based on the position information of the target prediction box and the position information of the annotation box corresponding to the target training image.
[0147] Optionally, the training module 510 is further configured to:
[0148] The model parameters in the feature extraction layer, the feature pooling layer and the feature fusion layer in the text detection model are adjusted according to the loss value.
[0149] The text detection model training device provided by the embodiment of the present application includes inputting a target training image into a text detection model, wherein the target training image is annotated with a corresponding annotation box, and the text detection model includes a feature extraction layer, a feature pooling layer and a feature fusion layer; extracting multiple initial feature maps of different scales corresponding to the target training image through the feature extraction layer; pooling the multiple initial feature maps of different scales through the feature pooling layer to obtain multiple enhanced feature maps of different scales; fusing the multiple enhanced feature maps of different scales through the feature fusion layer to obtain multiple prediction boxes; determining a target prediction box among the multiple prediction boxes, determining a loss value based on the target prediction box and the annotation box corresponding to the target training image, and training the text detection model according to the loss value until the training stop condition is reached. The text detection model provided by the device can effectively enhance the connection between features through the feature extraction layer, effectively enhance the accuracy of text in complex background areas, and at the same time increase the network structure of the feature pooling layer, which can effectively increase the receptive field of the target area and reduce the phenomenon of missed detection of small target objects, thereby enhancing the recognition accuracy of the text detection model as a whole and improving the recognition efficiency. Secondly, a new form of data augmentation is adopted to solve the problem of inaccurate recognition caused by insufficient manually labeled data and target occlusion, while also enhancing the generalization of the text detection model.
[0150] The above is a schematic scheme of a text detection model training device of this embodiment. It should be noted that the technical scheme of the text detection model training device and the technical scheme of the above text detection model training method belong to the same concept, and the details not described in detail in the technical scheme of the text detection model training device can be found in the description of the technical scheme of the above text detection model training method.
[0151] Corresponding to the above text detection method embodiment, the present application also provides a text detection device embodiment, Figure 6 FIG. 2 shows a schematic diagram of the structure of a text detection device according to an embodiment of the present application. Figure 6 As shown, the device comprises:
[0152] The acquisition module 602 is configured to acquire an image to be detected, wherein the image to be detected includes text to be detected;
[0153] An input module 604 is configured to input the image to be detected into a pre-trained text detection model, wherein the text detection model is obtained by training using the above-mentioned text detection model training method;
[0154] The generation module 606 is configured so that the text detection model generates a predicted text box corresponding to the text to be detected in response to the image to be detected as input.
[0155] Optionally, the device further comprises:
[0156] The recognition module is configured to perform text recognition on the content in the predicted text box based on the predicted text box; and obtain text content information corresponding to the text to be detected.
[0157] The text detection device provided by the present application includes obtaining an image to be detected, wherein the image to be detected includes text to be detected; inputting the image to be detected into a pre-trained text detection model, wherein the text detection model is obtained by training using the above-mentioned text detection model training method; the text detection model generates a predicted text box corresponding to the text to be detected in response to the image to be detected as input. Through the text detection device of the present application, text images with complex backgrounds can be better identified, text content can be more accurately extracted, and the text image recognition effect can be improved.
[0158] The above is a schematic scheme of a text detection device of this embodiment. It should be noted that the technical scheme of the text detection device and the technical scheme of the above text detection method belong to the same concept, and the details not described in detail in the technical scheme of the text detection device can be referred to the description of the technical scheme of the above text detection method.
[0159] It should be noted that the components in the device claim should be understood as the functional modules that must be established to implement the steps of the program flow or the steps of the method, and the functional modules are not actually divided or separated. The device claim defined by such a group of functional modules should be understood as the functional module architecture of the solution mainly implemented by the computer program recorded in the specification, and should not be understood as the physical device that mainly implements the solution by hardware.
[0160] In one embodiment of the present application, a computing device is also provided, including a memory, a processor, and computer instructions stored in the memory and executable on the processor, wherein when the processor executes the instructions, the steps of the text detection model training method or the text detection method are implemented.
[0161] The above is a schematic scheme of a computing device of this embodiment. It should be noted that the technical scheme of the computing device and the technical scheme of the above-mentioned text detection model training method or text detection method belong to the same concept, and the details not described in detail in the technical scheme of the computing device can be referred to the description of the technical scheme of the above-mentioned text detection model training method or text detection method.
[0162] An embodiment of the present application also provides a computer-readable storage medium storing computer instructions, which, when executed by a processor, implement the steps of the text detection model training method or the text detection method as described above.
[0163] The above is a schematic scheme of a computer-readable storage medium of this embodiment. It should be noted that the technical scheme of the storage medium and the technical scheme of the above-mentioned text detection model training method or text detection method belong to the same concept, and the details not described in detail in the technical scheme of the storage medium can be referred to the description of the technical scheme of the above-mentioned text detection model training method or text detection method.
[0164] An embodiment of the present application discloses a chip storing computer instructions, which, when executed by a processor, implement the steps of the text detection model training method or the text detection method as described above.
[0165] The above describes specific embodiments of the present application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0166] The computer instructions include computer program codes, which may be in source code form, object code form, executable files or some intermediate forms, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0167] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described action sequence, because according to the present application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0168] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0169] The preferred embodiments of the present application disclosed above are only used to help explain the present application. The optional embodiments do not describe all the details in detail, nor do they limit the invention to the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of the present application. The present application selects and specifically describes these embodiments in order to better explain the principles and practical applications of the present application, so that those skilled in the art can understand and use the present application well. The present application is only limited by the claims and their full scope and equivalents.
Claims
1. A text detection model training method, characterized in that: include: Inputting a target training image into a text detection model, wherein the target training image is annotated with a corresponding annotation box, the text detection model comprises a feature extraction layer, a feature pooling layer and a feature fusion layer, the feature pooling layer comprises a dilated spatial convolutional pooling pyramid to expand the range of output information; Extracting a plurality of initial feature maps of different scales corresponding to the target training image through the feature extraction layer; Pooling the multiple initial feature maps of different scales through the feature pooling layer to obtain multiple enhanced feature maps of different scales; The plurality of enhanced feature maps of different scales are fused through the feature fusion layer to obtain a plurality of prediction frames; A target prediction box is determined from the multiple prediction boxes, a loss value is determined based on the target prediction box and a label box corresponding to the target training image, and the text detection model is trained according to the loss value until a training stop condition is reached.
2. The text detection model training method according to claim 1, characterized in that: Before feeding the target training image into the text detection model, it also includes: Get the target training image in the preset training set.
3. The text detection model training method according to claim 2, characterized in that: Get the target training images in the preset training set, including: Acquire an initial training set, wherein the initial training set includes a plurality of training images; Perform data augmentation processing on the multiple training images to generate a data augmented training set.
4. The text detection model training method according to claim 3, characterized in that: Performing data augmentation processing on the multiple training images includes: The multiple training images are subjected to any data augmentation processing including random cropping, random translation, contrast change, brightness change, transparency change, random occlusion, and random filling.
5. The text detection model training method according to claim 1, characterized in that: The feature extraction layer integrating the attention mechanism includes multiple channels, and the attention mechanism is integrated between multiple channels; Extracting a plurality of initial feature maps of different scales corresponding to the target training image through the feature extraction layer includes: Initial feature maps of multiple different scales corresponding to the target training image are extracted by fusing the multiple channels and the attention mechanism between the multiple channels.
6. The text detection model training method according to claim 1, characterized in that: Pooling the multiple initial feature maps of different scales through the feature pooling layer includes: The multiple initial feature maps of different scales are pooled through the atrous spatial convolution pooling pyramid.
7. The text detection model training method according to claim 1, characterized in that: The feature fusion layer includes a feature map pyramid network; The plurality of enhanced feature maps of different scales are fused through the feature fusion layer to obtain a plurality of prediction frames, including: The plurality of enhanced feature maps of different scales are fused through the feature map pyramid network to obtain a plurality of prediction boxes and a score corresponding to each prediction box.
8. The text detection model training method according to claim 7, characterized in that: Determining a target prediction frame from the multiple prediction frames includes: Determine the prediction box with the highest score as the target prediction box.
9. The text detection model training method according to claim 1, characterized in that: Determining a loss value based on the target prediction box and the annotation box corresponding to the target training image includes: A loss value is determined based on the position information of the target prediction box and the position information of the annotation box corresponding to the target training image.
10. The text detection model training method according to claim 1, characterized in that: Training the text detection model according to the loss value includes: The model parameters in the feature extraction layer, the feature pooling layer and the feature fusion layer in the text detection model are adjusted according to the loss value.
11. A text detection method, characterized in that: include: Acquire an image to be detected, wherein the image to be detected includes text to be detected; Inputting the image to be detected into a pre-trained text detection model, wherein the text detection model is obtained by training using the training method described in any one of claims 1 to 10, and the text detection model comprises a feature extraction layer, a feature pooling layer, and a feature fusion layer, wherein the feature pooling layer comprises a dilated spatial convolutional pooling pyramid to expand the range of output information; The text detection model generates a predicted text box corresponding to the text to be detected in response to the image to be detected as input.
12. The text detection method according to claim 11, characterized in that: The method further comprises: Performing text recognition on the content in the predicted text box based on the predicted text box; Obtain text content information corresponding to the text to be detected.
13. A text detection model training device, characterized in that: include: An acquisition module is configured to input a target training image into a text detection model, wherein the target training image is annotated with a corresponding annotation box, and the text detection model includes a feature extraction layer, a feature pooling layer, and a feature fusion layer, and the feature pooling layer includes a dilated spatial convolutional pooling pyramid to expand the range of output information; An extraction module, configured to extract a plurality of initial feature maps of different scales corresponding to the target training image through the feature extraction layer; A pooling module is configured to pool the multiple initial feature maps of different scales through the feature pooling layer to obtain multiple enhanced feature maps of different scales; A fusion module is configured to fuse the multiple enhanced feature maps of different scales through the feature fusion layer to obtain multiple prediction boxes; The training module is configured to determine a target prediction box from the multiple prediction boxes, determine a loss value based on the target prediction box and a label box corresponding to the target training image, and train the text detection model according to the loss value until a training stop condition is reached.
14. A text detection device, characterized in that: include: An acquisition module is configured to acquire an image to be detected, wherein the image to be detected includes text to be detected; An input module is configured to input the image to be detected into a pre-trained text detection model, wherein the text detection model is obtained by training the training method described in any one of claims 1 to 10, and the text detection model includes a feature extraction layer, a feature pooling layer and a feature fusion layer, and the feature pooling layer includes a dilated spatial convolutional pooling pyramid to expand the range of output information; The generation module is configured so that the text detection model generates a predicted text box corresponding to the text to be detected in response to the image to be detected as input.
15. A computing device comprising a memory, a processor, and computer instructions stored in the memory and executable on the processor, characterized in that: When the processor executes the instructions, the steps of the method described in any one of claims 1-10 or 11-12 are implemented.
16. A computer-readable storage medium storing computer instructions, characterized in that: When the instruction is executed by the processor, the steps of the method described in any one of claims 1-10 or 11-12 are implemented.
