A text detection method and system based on lightweight neural network model

Through a text detection method based on a lightweight neural network model, the residual network is used to predict text categories and borders, combined with non-maximum suppression and clustering, to solve the problem of high manual screening costs in the existing technology and achieve rapid , accurate text detection, suitable for mobile terminals and complex scenes.

CN113298167BActive Publication Date: 2024-10-15SI-TECH INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110609381.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-06-01
Publication Date
2024-10-15
Estimated Expiration
2041-06-01

AI Technical Summary

Technical Problem

Existing text detection methods require manual screening in complex scenarios, resulting in high cost and low efficiency. Especially when mobile phone resources are limited, it is difficult to achieve light and efficient text detection.

Method used

Using a text detection method based on a lightweight neural network model, the text data is classified and bounded by spatial information, a residual network model is constructed, text categories and bounding boxes are predicted, and the final result is obtained through non-maximum suppression and clustering. Test results and reduce manual screening costs.

Benefits of technology

It achieves rapid classification and detection of text in pictures, reduces screening costs, and improves monitoring efficiency. It is suitable for text detection of the "name: content" type, and can detect text with an angled angle, making it suitable for mobile terminal deployment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113298167B_ABST
    Figure CN113298167B_ABST
Patent Text Reader

Abstract

The present invention provides a text detection method and system based on a lightweight neural network model, which relates to the field of image processing and neural networks, including: classifying text data and marking borders according to spatial information to obtain a training data set; constructing a lightweight neural network model, and training the neural network model through the training data set; predicting the text to be tested through the trained neural network model to obtain the text category, text border and border confidence; performing confidence screening for the border confidence, performing non-maximum suppression for the text border, and obtaining clear text lines; clustering the text lines according to the text category to obtain the final detection result. The present invention realizes the classification and detection of text with spatial information in the picture, and thus does not need to manually screen the detected text, thereby reducing the screening cost.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the fields of image processing and neural networks, and in particular to a text detection method and system based on a lightweight neural network model. Background Art

[0002] In the scenario of network text recognition, for complex scene image text recognition, first locating the position of the text can greatly improve the accuracy of text recognition. This positioning process is called text detection, which has always been a text hotspot. In addition, many text detection needs are currently on mobile phones. Due to memory constraints, mobile phones require lightweight applications, so research on lightweight neural network models is also a hot topic.

[0003] Currently, most of the existing text detection methods detect all the text in the image, which makes the manual screening cost huge. Summary of the invention

[0004] In response to the above problems, the present invention provides a text detection method and system based on a lightweight neural network model, which can realize the classification and detection of text with spatial information in pictures, thereby eliminating the need for manual screening of the detected text and reducing the screening cost.

[0005] To achieve the above object, the present invention provides a text detection method based on a lightweight neural network model, comprising:

[0006] Classify text data and mark borders according to spatial information to obtain a training data set;

[0007] Constructing a lightweight neural network model, and training the neural network model using the training data set;

[0008] Predicting the text to be tested by the trained neural network model to obtain the text category, text border and border confidence;

[0009] Confidence screening is performed on the border confidence, and non-maximum suppression is performed on the text border to obtain a clear text line;

[0010] The text lines are clustered according to the text categories to obtain a final detection result.

[0011] As a further improvement of the present invention, the text is classified and the borders are marked according to the spatial information to obtain a training data set; including:

[0012] Preset category labels;

[0013] Using a labeling tool to classify the text data according to the classification labels;

[0014] Use a quadrilateral to mark the border of each line of text.

[0015] As a further improvement of the present invention, the lightweight neural network model adopts a residual network;

[0016] The neural network model structure includes: CBR, RES residual block, POOL maximum pooling layer and Conv convolution layer;

[0017] The output of the neural network model includes a category branch and a coordinate branch. The category branch outputs the confidence that the text belongs to each category; the coordinate branch outputs the coordinate information of the text.

[0018] As a further improvement of the present invention, the training of the neural network model by using the training data set comprises:

[0019] Outputting the predicted category of the characters in each training data in the training data set through the category branch of the neural network model in sequence;

[0020] The coordinate information of the text frame is obtained by splicing multiple rectangular frames with fixed widths;

[0021] Calculate the category loss based on the predicted category obtained by the neural network model and the true category in the training dataset;

[0022] The regression loss in the regression task is calculated based on the bounding box coordinate information obtained by the neural network model and the real bounding box coordinate information in the dataset is trained;

[0023] The parameters of the neural network model are updated according to the category loss and the regression loss to obtain the trained neural network model.

[0024] As a further improvement of the present invention, the step of training the neural network model by using the training data set further comprises:

[0025] First, the training data set is enhanced to increase the number of samples of the training data;

[0026] The data enhancement methods include cropping pictures, changing the brightness of a channel of the picture, changing the order of three channels of the picture, and fusing irrelevant pictures with the training data set.

[0027] As a further improvement of the present invention, the category loss and the regression loss are calculated using cross entropy loss and mean square error respectively;

[0028] When calculating the category loss and the regression loss, l2 regularization is added to enhance the generalization ability of the network and avoid overfitting of the neural network model after deep learning.

[0029] As a further improvement of the present invention, the method of predicting the text to be tested by the trained neural network model to obtain the text category, text border and border confidence comprises:

[0030] Identify the categories of each part of the text to be tested;

[0031] Use vertical rectangular frames of different colors to select different types of text;

[0032] Output the text pattern to be tested and the confidence of each vertical rectangular frame after the frame selection.

[0033] As a further improvement of the present invention, the confidence screening is performed on the border confidence, and non-maximum suppression is performed on the text border to obtain a clear text line; specifically including:

[0034] Performing confidence screening on the frame confidence to obtain the frame with the highest confidence, and outputting the screened text pattern to be tested;

[0035] Non-maximum suppression is performed on the text borders to remove borders with high overlap, thereby obtaining non-overlapping cleaned text lines.

[0036] As a further improvement of the present invention, clustering the text lines according to the character categories includes:

[0037] Group the borders of the same category and close distance into one row;

[0038] For borders in the same category with large text spacing but fixed left and right boundaries, left and right boundary clustering is performed again.

[0039] The present invention also discloses a text detection system based on a lightweight neural network, comprising: a training data acquisition module, a model training module, a text prediction module, and a post-processing module;

[0040] The training data acquisition module is used to:

[0041] Classify text data and mark borders according to spatial information to obtain a training data set;

[0042] The model training module is used to:

[0043] Constructing a lightweight neural network model, and training the neural network model using the training data set;

[0044] The text prediction module is used to:

[0045] Predicting the text to be tested by the trained neural network model to obtain the text category, text border and border confidence;

[0046] The post-processing module is used for:

[0047] Confidence screening is performed on the border confidence, and non-maximum suppression is performed on the text border to obtain a clear text line;

[0048] The text lines are clustered according to the text categories to obtain a final detection result.

[0049] Compared with the prior art, the present invention has the following beneficial effects:

[0050] The present invention realizes classification and detection of text with spatial information in a picture, has a fast detection speed, and no longer requires manual screening of the detected text, thereby reducing the screening cost; at the same time, during the monitoring process, unnecessary text in the picture is ignored, thereby improving the monitoring efficiency.

[0051] The present invention is particularly suitable for text detection of "Name: Content". Since text information has a sequential characteristic, unlike the targets in other target detection tasks which are independent, multiple vertical rectangular frames of fixed width are used to represent it, and then the vertical rectangular frames are post-processed and connected into a complete large rectangular frame, which improves the detection accuracy and can also detect text with tilted angles. At the same time, a classification task is added while predicting the text coordinates, so that text with spatial information in the picture can be detected and classified, which is beneficial to subsequent text recognition. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] Figure 1 A flowchart of a text detection method based on a lightweight neural network model disclosed in an embodiment of the present invention;

[0053] Figure 2 A schematic diagram of a text detection system based on a lightweight neural network model disclosed in an embodiment of the present invention;

[0054] Figure 3 A schematic diagram of the effect of labeling training data in a training data set disclosed in an embodiment of the present invention;

[0055] Figure 4 A schematic diagram of a neural network model structure disclosed in an embodiment of the present invention;

[0056] Figure 5 A vertical rectangular frame annotation diagram output by a neural network model disclosed in an embodiment of the present invention;

[0057] Figure 6 A vertical rectangular frame annotation diagram after confidence screening disclosed in an embodiment of the present invention;

[0058] Figure 7A vertical rectangular frame annotation diagram after non-maximum suppression is performed according to an embodiment of the present invention;

[0059] Figure 8 A vertical rectangular frame annotation diagram after clustering borders of the same category disclosed in an embodiment of the present invention;

[0060] Fig. 9 This is a vertical rectangular frame annotation diagram after left and right boundaries are clustered according to an embodiment of the present invention. DETAILED DESCRIPTION

[0061] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0062] The present invention is further described in detail below in conjunction with the accompanying drawings:

[0063] like Figure 1 As shown, the present invention provides a text detection method based on a lightweight neural network model, comprising:

[0064] S1. Classify text data and mark borders according to spatial information to obtain a training data set;

[0065] Preset classification labels, such as "name" and "content";

[0066] Use annotation tools to classify text data according to classification labels.

[0067] Use quadrilaterals to mark the borders of each line of text, where the red box is used to mark the "name" category and the green box is used to mark the "content" category. The result is as follows Figure 3 shown.

[0068] S2. Build a lightweight neural network model and train the neural network model using a training data set;

[0069] in,

[0070] (1) The lightweight neural network model uses a residual network;

[0071] The neural network model structure includes: CBR, RES residual block, POOL maximum pooling layer and Conv convolution layer;

[0072] The output of the neural network model includes a category branch and a coordinate branch. The category branch outputs the confidence that the text belongs to each category; the coordinate branch outputs the coordinate information of the text.

[0073] (2) The neural network model training process includes:

[0074] S21, first perform data enhancement on the training data set to increase the number of samples of the training data; data enhancement methods include cropping the image, changing the brightness of a channel of the image, changing the order of the three channels of the image, and using irrelevant images to merge with the training data set.

[0075] S22, outputting the predicted category of each character in the training data set through the category branch of the neural network model in turn;

[0076] S23, using a plurality of rectangular frames with fixed widths to splice together to obtain the frame coordinate information of the text;

[0077] S24, calculating the category loss according to the predicted category obtained by the neural network model and the actual category in the training data set;

[0078] The regression loss in the regression task is calculated based on the real bounding box coordinate information in the training data set according to the bounding box coordinate information obtained by the neural network model; the category loss and regression loss are calculated using the cross entropy loss and mean square error respectively; when calculating the category loss and regression loss, l2 regularization is added to enhance the generalization ability of the network and avoid overfitting after deep learning of the neural network model.

[0079] The overall expression of the loss function is as follows, where λ = 0.3 and μ = 0.025:

[0080]

[0081] After calculating the loss, the loss is back-propagated and the Adam optimizer is used to update the network parameters. Since the network is still seriously underfitting in the early stage of training, a larger learning rate can be used to update the network parameters, which can speed up the decline of the loss function. However, in the later stage of training, the network gradually fits the training data. If the network parameters are still updated with a larger learning rate, it is easy to cause the network to oscillate near the optimal point. Therefore, the exponential decay method is used to update the learning rate.

[0082] S25. Update the parameters of the neural network model according to the category loss and the regression loss to obtain the trained neural network model.

[0083] S3, predicting the text to be tested through the trained neural network model to obtain the text category, text border and border confidence;

[0084] Among them, include:

[0085] Identify the categories of each part of the text to be tested;

[0086] Use vertical rectangular frames of different colors to select different types of text;

[0087] Output the text pattern to be tested after the box selection and the confidence of each vertical rectangular box.

[0088] S4, performing confidence screening on the border confidence, performing non-maximum suppression on the text border, and obtaining a clear text line;

[0089] Specifically include:

[0090] Perform confidence screening on the border confidence, obtain the border with the highest confidence, and output the screened text pattern to be tested;

[0091] Non-maximum suppression is performed on text borders to remove borders with high overlap and obtain non-overlapping cleaned text lines.

[0092] S5. Cluster the text lines according to the text categories to obtain the final detection results.

[0093] in,

[0094] Group the borders of the same category and close distance into one row;

[0095] For borders in the same category with large text spacing but fixed left and right boundaries, left and right boundary clustering is performed again.

[0096] like Figure 2 As shown, the present invention also provides a system for implementing S1 to S5, including: a training data acquisition module, a model training module, a text prediction module, and a post-processing module;

[0097] Training data acquisition module, used for:

[0098] Classify text data and mark borders according to spatial information to obtain a training data set;

[0099] Model training module, used to:

[0100] Build a lightweight neural network model and train the neural network model using a training data set;

[0101] Text prediction module, used for:

[0102] The trained neural network model is used to predict the text to be tested, and the text category, text border and border confidence are obtained;

[0103] Post-processing modules for:

[0104] Confidence screening is performed on the border confidence, and non-maximum suppression is performed on the text border to obtain clear text lines;

[0105] The text lines are clustered according to the text categories to obtain the final detection results.

[0106] Example:

[0107] The present invention is particularly suitable for the physical space information of the elements in the image to be detected including text, such as a field like "Gender: Female". Conventional certificate files are all in this format. Taking the recognition of certificate-type images as an example, the details are as follows:

[0108] Step 1: Classify and label the text data according to the spatial information to obtain a training data set;

[0109] Preset classification labels, such as "name" and "content";

[0110] Use annotation tools to classify text data according to classification labels.

[0111] Use quadrilaterals to mark the borders of each line of text, where the red box is used to mark the "name" category and the green box is used to mark the "content" category. The result is as follows Figure 3 shown.

[0112] Step 2: Build a lightweight neural network model, such as Figure 4 As shown, the neural network model is trained by training the data set;

[0113] Step 3: Predict the text to be tested by the trained neural network model to obtain the text category, text border and border confidence;

[0114] Among them, include:

[0115] Identify the categories of each part of the text to be tested;

[0116] Use vertical rectangular frames of different colors to select different types of text;

[0117] like Figure 5 As shown, the text pattern to be tested and the confidence of each vertical rectangular box after the box selection are output;

[0118] Step 4: Confidence screening is performed on the border confidence, and non-maximum suppression is performed on the text border to obtain a clear text line;

[0119] Specifically include:

[0120] Confidence screening is performed on the border confidence to obtain the border with the highest confidence, and the filtered text pattern to be tested is output, such as Figure 6 As shown;

[0121] Non-maximum suppression is performed on the text borders to remove the borders with high overlap and obtain non-overlapping cleaned text lines, such as Figure 7 shown.

[0122] Step 5: Cluster the text lines according to the borders of "name" and "content" to obtain the final detection results.

[0123] in,

[0124] The borders of the same category and close distance are grouped into one row, and we get Figure 8 The pattern shown;

[0125] for Figure 8 For the words in the "name" category, since the words in a row are too far apart, there may be missing words after clustering. We perform left and right boundary clustering again to get the final detection result, as shown in the figure below. Fig. 9 shown.

[0126] Advantages of the present invention:

[0127] (1) It realizes classification and detection of text with spatial information in images. The detection speed is fast and there is no need for manual screening of detected text, which reduces the screening cost. At the same time, during the monitoring process, unnecessary text in the image is ignored, which improves the monitoring efficiency.

[0128] (2) It is particularly suitable for text detection of "name: content". Since text information has the characteristics of sequence, unlike the independent targets in other target detection tasks, it is represented by multiple vertical rectangular frames of fixed width, and then the vertical rectangular frames are post-processed and connected into a complete large rectangular frame, which improves the detection accuracy and can also detect text with tilted angles. At the same time, the classification task is added while predicting the text coordinates, so the text with spatial information in the image can be detected and classified, which is conducive to subsequent text recognition.

[0129] (3) In the present invention, only 9 residual blocks are used. Compared with the commonly used residual network, up to 50 residual blocks are used. The system model capacity is small, and it can not only provide a cloud service interface, but also realize deployment on mobile terminals.

[0130] (4) The training process of the present invention uses exponential decay to update the learning rate, which can quickly and effectively make the network reach the optimal point. At the same time, different methods are used to load training data and increase data samples to prevent network overfitting.

[0131] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A text detection method based on a lightweight neural network model, characterized in that: include: The text data is classified and the borders are marked according to the spatial information to obtain a training data set; wherein the classification labels are preset, including: name and content; the text data is classified according to the classification labels using a marking tool; and the borders of each line of text are marked using a quadrilateral; Construct a lightweight neural network model, and train the neural network model through the training data set; wherein, it includes: outputting the predicted category of the characters in each training data in the training data set through the category branch of the neural network model in turn; obtaining the border coordinate information of the characters by splicing multiple rectangular frames with fixed widths; calculating the category loss according to the predicted category obtained by the neural network model and the real category in the training data set; calculating the regression loss in the regression task according to the border coordinate information obtained by the neural network model and the real border coordinate information in the training data set; updating the parameters of the neural network model according to the category loss and the regression loss to obtain the trained neural network model; predicting the text to be tested through the trained neural network model to obtain the character category, character border and border confidence; Confidence screening is performed on the border confidence, and non-maximum suppression is performed on the text border to obtain a clear text line; wherein, confidence screening is performed on the border confidence to obtain the border with the highest confidence, and the screened text pattern to be tested is output; non-maximum suppression is performed on the text border to remove borders with high overlap, and non-overlapping clear text lines are obtained; The text lines are clustered according to the text categories, wherein the borders of the same category and close distance are clustered into one line; for borders of the same category with large text intervals but fixed left and right borders, left and right borders are clustered again to obtain the final detection result.

2. The text detection method according to claim 1, characterized in that: The lightweight neural network model adopts a residual network; The neural network model structure includes: CBR, RES residual block, POOL maximum pooling layer and Conv convolution layer; The output of the neural network model includes a category branch and a coordinate branch. The category branch outputs the confidence that the text belongs to each category; the coordinate branch outputs the coordinate information of the text.

3. The text detection method according to claim 1, characterized in that: The category loss and regression loss are calculated using cross entropy loss and mean square error respectively; When calculating the category loss and the regression loss, l2 regularization is added.

4. The text detection method according to claim 1, characterized in that: The step of training the neural network model by using the training data set also includes: First, the training data set is enhanced to increase the number of samples of the training data; The data enhancement methods include cropping pictures, changing the brightness of a channel of the picture, changing the order of three channels of the picture, and fusing irrelevant pictures with the training data set.

5. The text detection method according to claim 1, characterized in that: The method of predicting the text to be tested by the trained neural network model to obtain the text category, text border and border confidence includes: Identify the categories of each part of the text to be tested; Use vertical rectangular frames of different colors to select different types of text; Output the text pattern to be tested and the confidence of each vertical rectangular frame after the frame selection.

6. A system for implementing the text detection method according to any one of claims 1 to 5, characterized in that: include: Training data acquisition module, model training module, text prediction module, and post-processing module; The training data acquisition module is used to: Classify text data and mark borders according to spatial information to obtain a training data set; The model training module is used to: Constructing a lightweight neural network model, and training the neural network model using the training data set; The text prediction module is used to: Predicting the text to be tested by the trained neural network model to obtain the text category, text border and border confidence; The post-processing module is used for: Confidence screening is performed on the border confidence, and non-maximum suppression is performed on the text border to obtain a clear text line; The text lines are clustered according to the text categories to obtain a final detection result.