A method, device, computer storage medium and terminal for text angle classification
By segmenting the original image and training sub-graph angle classification, combined with weighted information processing, the problem of low accuracy of text angle classification in the existing technology is solved, and higher classification accuracy and stability are achieved, and suitable for multiple types of contents A kind of application scenario.
Patent Information
- Application Number
- CN202011566516.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-25
- Publication Date
- 2024-12-13
- Estimated Expiration
- 2040-12-25
AI Technical Summary
The existing text angle classification algorithm cannot accurately classify text rotation angles in high definition and edge characteristics application scenarios, and it is especially difficult to distinguish angles such as 0 degrees, 90 degrees, 180 degrees and 270 degrees, resulting in low classification accuracy.
By segmenting the original image, the anchor combination is obtained, the angle classification probability values of each sub-graph are trained, and these probability values are processed using preset weighted information to determine the angle classification of the text, ensuring the accuracy of the classification results.
Improves the accuracy and stability of text angle classification, and is suitable for a variety of platforms, including mobile phones, tablets and embedded systems, and is suitable for medical images and fine industrialization.
Smart Images

Figure CN114692707B_ABST
Abstract
Description
Technical Field
[0001] This article relates to but is not limited to neural network technology, and in particular to a method, device, computer storage medium and terminal for text angle classification. Background Art
[0002] Currently, most classification models can only perform inference and classification through compressed entire images. This inference and classification method has great limitations in application scenarios that require high definition and edge features.
[0003] The text angle classification algorithm is a classification model that classifies the text rotation angle. For rotated text images, the text angle classification algorithm obtains the rotation angle of the text image through deep learning; when the text image is compressed, due to the reduction in clarity and the edge characteristics of the text, the text angle classification algorithm in the related technology cannot accurately classify the text rotation angle; for example: it is impossible to accurately classify the rotation angle of the text image into the following four angles: 0 degrees, 90 degrees, 180 degrees and 270 degrees, or angles with smaller degrees.
[0004] How to improve the accuracy of text angle classification algorithms has become a problem to be solved. Summary of the invention
[0005] The following is a summary of the subject matter described in detail herein. This summary is not intended to limit the scope of the claims.
[0006] Embodiments of the present invention provide a method, device, computer storage medium and terminal for text angle classification, which can improve the accuracy of text angle classification.
[0007] An embodiment of the present invention provides a method for text angle classification, comprising:
[0008] Train the anchor combinations obtained by segmenting the original image to obtain the probability value of the angle classification of each sub-image contained in each anchor combination;
[0009] The probability value of the angle classification of each sub-image contained in each anchor combination is processed by preset weighting information to obtain the output value of each anchor combination for angle classification;
[0010] The angle classification of the text is determined by the obtained output value for the angle classification.
[0011] In an exemplary embodiment, the training of the anchor combination obtained by segmenting the original image includes:
[0012] Packing the anchor combination according to a preset input size of the training model;
[0013] Inputting the packaged anchor combination into the training model for training;
[0014] Among them, when the resolution of the original image is smaller than the input size, packing the anchor combination according to the input size of the preset training model is to obtain a sub-image in the anchor combination whose size is larger than half of the original image size and smaller than the original image size; when the resolution of the original image is greater than or equal to the input size, packing the anchor combination according to the input size of the preset training model is to obtain a sub-image in the anchor combination whose size is larger than the input size and smaller than twice the input size.
[0015] In an exemplary embodiment, the weighted information includes: a weighted coefficient that is positively correlated with the amount of information contained in the text of the anchor combination.
[0016] In an exemplary embodiment, the weighting information includes:
[0017] a first weighting coefficient of each sub-graph included in the anchor combination, which is positively correlated with the amount of information of the text included in the sub-graph; and / or,
[0018] The distance between the anchor point of the anchor combination and the center of the original image is taken as the anchor point distance, and the second weighting coefficient of each anchor combination is negatively correlated with the anchor point distance.
[0019] In an exemplary embodiment, the probability value of the angle classification of each sub-image included in each anchor combination is processed by preset weighting information, including:
[0020] In the case where the weighting information includes the first weighting coefficient, the probability weighted sum of each sub-image is calculated according to the obtained probability value of the angle classification and the first weighting coefficient; the calculated probability weighted sum of each sub-image is accumulated according to the angle classification to obtain the output value for the angle classification of each anchor combination; or,
[0021] In the case where the weighting information includes the second weighting coefficient, for the probability value of the angle classification of each sub-image included in each anchor combination, each angle classification is calculated separately: the cumulative sum of the probability values of the current angle classification of all sub-images included in the anchor combination, and the cumulative sum of the probabilities of each anchor combination is obtained according to the cumulative sum of the probability values of each angle classification of all sub-images included in the anchor combination; the output value for angle classification of each anchor combination is obtained by using the calculated cumulative sum of the probabilities of each anchor combination and the second weighting coefficient; or,
[0022] In the case where the weighting information includes the first weighting coefficient and the second weighting coefficient, for each anchor combination: the probability weighted sum of each sub-image is calculated according to the obtained probability value of the angle classification and the first weighting coefficient; the calculated probability weighted sums of each sub-image are accumulated according to the angle classification to obtain the probability weighted sum of the anchor combination; the calculated probability weighted sum of each anchor combination and the second weighting coefficient are added to obtain the output value of the anchor combination for angle classification.
[0023] On the other hand, an embodiment of the present invention further provides a computer storage medium, in which a computer program is stored, and when the computer program is executed by a processor, the above-mentioned method of text angle classification is implemented.
[0024] In another aspect, an embodiment of the present invention further provides a terminal, comprising: a memory and a processor, wherein the memory stores a computer program; wherein:
[0025] The processor is configured to execute the computer program in the memory;
[0026] When the computer program is executed by the processor, the method for text angle classification as described above is implemented.
[0027] In another aspect, an embodiment of the present invention further provides a device for text angle classification, comprising: a training unit, a calculation unit and a determination unit; wherein:
[0028] The training unit is set as follows: training the anchor combination obtained by segmenting the original image to obtain the probability value of the angle classification of each sub-image contained in each anchor combination;
[0029] The calculation unit is configured to: process the obtained probability value of the angle classification of each sub-image included in each anchor combination through preset weighting information to obtain an output value of each anchor combination for angle classification;
[0030] The determination unit is configured to determine the angle classification of the text by using the obtained output value for angle classification.
[0031] In an exemplary embodiment, the training unit is configured as follows:
[0032] Packing the anchor combination according to a preset input size of the training model;
[0033] Inputting the packaged anchor combination into the training model for training;
[0034] Among them, when the resolution of the original image is smaller than the input size, packing the anchor combination according to the input size of the preset training model is to obtain a sub-image in the anchor combination whose size is larger than half of the original image size and smaller than the original image size; when the resolution of the original image is greater than or equal to the input size, packing the anchor combination according to the input size of the preset training model is to obtain a sub-image in the anchor combination whose size is larger than the input size and smaller than twice the input size.
[0035] In an exemplary embodiment, the weighted information includes: a weighted coefficient that is positively correlated with the amount of information contained in the text of the anchor combination.
[0036] In an exemplary embodiment, the weighting information includes:
[0037] a first weighting coefficient of each sub-graph included in the anchor combination, which is positively correlated with the amount of information of the text included in the sub-graph; and / or,
[0038] The distance between the anchor point of the anchor combination and the center of the original image is taken as the anchor point distance, and the second weighting coefficient of each anchor combination is negatively correlated with the anchor point distance.
[0039] In an exemplary embodiment, the computing unit is configured to:
[0040] In the case where the weighting information includes the first weighting coefficient, the probability weighted sum of each sub-image is calculated according to the obtained probability value of the angle classification and the first weighting coefficient; the calculated probability weighted sum of each sub-image is accumulated according to the angle classification to obtain the output value for the angle classification of each anchor combination; or,
[0041] In the case where the weighting information includes the second weighting coefficient, for the probability value of the angle classification of each sub-image included in each anchor combination, each angle classification is calculated separately: the cumulative sum of the probability values of the current angle classification of all sub-images included in the anchor combination, and the cumulative sum of the probabilities of each anchor combination is obtained according to the cumulative sum of the probability values of each angle classification of all sub-images included in the anchor combination; the output value for angle classification of each anchor combination is obtained by using the calculated cumulative sum of the probabilities of each anchor combination and the second weighting coefficient; or,
[0042] In the case where the weighting information includes the first weighting coefficient and the second weighting coefficient, for each anchor combination: the probability weighted sum of each sub-image is calculated according to the obtained probability value of the angle classification and the first weighting coefficient; the calculated probability weighted sums of each sub-image are accumulated according to the angle classification to obtain the probability weighted sum of the anchor combination; the calculated probability weighted sum of each anchor combination and the second weighting coefficient are added to obtain the output value of the anchor combination for angle classification.
[0043] The embodiment of the present invention determines the probability value of the angle classification of the segmented sub-image through anchor combination; processes the determined probability value of the angle classification based on preset weighting information to determine the angle classification of the text. The angle classification is determined based on the sub-image that maintains the resolution of the original image, thereby improving the accuracy of the text angle classification.
[0044] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures particularly pointed out in the description, claims and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] The accompanying drawings are used to provide a further understanding of the technical solution of the present invention and constitute a part of the specification. Together with the embodiments of the present application, they are used to explain the technical solution of the present invention and do not constitute a limitation on the technical solution of the present invention.
[0046] Figure 1 A flowchart of a method for text angle classification according to an embodiment of the present invention;
[0047] Figure 2 This is a schematic diagram of an anchor assembly according to an embodiment of the present invention;
[0048] Figure 3 This is a structural block diagram of a device for text angle classification according to an embodiment of the present invention. DETAILED DESCRIPTION
[0049] In order to make the purpose, technical solution and advantages of the present invention more clear, the embodiments of the present invention will be described in detail with reference to the accompanying drawings. It should be noted that the embodiments and features in the embodiments of the present application can be combined with each other arbitrarily without conflict.
[0050] The steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions. Also, although a logical sequence is shown in the flowchart, in some cases, the steps shown or described can be performed in a sequence different from that shown here.
[0051] Figure 1 Flow chart of the method for text angle classification according to an embodiment of the present invention, as shown in FIG. Figure 1 As shown, including:
[0052] Step 101: training anchor combinations obtained by segmenting the original image to obtain the probability value of angle classification of each sub-image contained in each anchor combination; here, the original image includes a document image of the angle to be detected;
[0053] The embodiment of the present invention avoids clarity problems during text angle classification by dividing the original image into sub-images.
[0054] In an exemplary embodiment, the anchor combination obtained by segmenting the original image is trained in the embodiment of the present invention to obtain the probability value of the angle classification of each sub-image included in each anchor combination, including:
[0055] Pack the anchor combinations according to the pre-set input size of the training model;
[0056] Input the packaged anchor combination into the training model for training;
[0057] Obtain the probability value of the angle classification of each sub-image contained in each anchor combination;
[0058] Among them, when the resolution of the original image is smaller than the input size, the anchor combination is packaged according to the input size of the preset training model to obtain a sub-image in the anchor combination whose size is larger than half of the original image size and smaller than the original image size; when the resolution of the original image is greater than or equal to the input size, the anchor combination is packaged according to the input size of the preset training model to obtain a sub-image in the anchor combination whose size is larger than the input size and smaller than twice the input size.
[0059] The packing in the embodiment of the present invention is to stack the sub-images in the anchor combination. The packing of the anchor combination is illustrated below by an example: assuming that the input size of the neural network is 448*448; then packing is to stack the sub-images in the anchor combination, for example, the anchor combination in step 101 is composed of 7 sub-images, that is, the anchor combination contains 7 sub-images, and these 7 sub-images are stacked into an array of 7*448*448*3 (3 is the number of red, green and blue channels of the sub-image); in addition, the sub-image size is set according to the original image resolution and the input size of the training model to ensure the clarity of the sub-image input to the training model.
[0060] In an exemplary embodiment, before step 101, the embodiment of the present invention further includes:
[0061] According to the preset anchor point and scale ratio information, the original image is segmented to obtain two or more anchor combinations; specifically, with the preset anchor point as the center point, the original image is segmented according to the scale ratio information to obtain multiple sub-images, and the obtained multiple sub-images constitute the anchor combination of the preset anchor point.
[0062] In the embodiment of the present invention, the anchor point refers to the center point of the sub-image included in the anchor combination obtained by segmentation. The anchor combination can be obtained by segmenting the original image according to the determined anchor point and the scale ratio information of the anchor combination; the anchor point can be analyzed and determined by those skilled in the art according to the application scenario, and the anchor points of different anchor combinations are different; the scale ratio information of each anchor combination is analyzed and determined by those skilled in the art according to the application scenario, and the sub-image segmented according to the anchor point and the scale ratio information belongs to one part of the original image. After those skilled in the art set the minimum unit size of the segmentation, the sub-image is cropped according to the scale ratio information according to the anchor point and the scale ratio information. Assuming that the size of the original image is 22400 pixels * 22400 pixels, with the lower left corner as the origin of the coordinate axis, the horizontal coordinate of each pixel is determined to be 0 to 22400 pixels by sorting the pixels from left to right, and the vertical coordinate of each pixel is determined to be 0 to 22400 pixels by sorting the pixels from bottom to top, and the anchor point of one of the anchor combinations is set to be located at 448 pixels * 448 pixels, and the scale ratio information (aspect ratio) of the anchor combination is: 1:2, 1:3, 3:1 and 2:1, and the minimum unit size of the segmentation is 224 pixels. Then, the center points of all sub-images contained in the anchor combination obtained by segmenting the original image are 448 pixels * 448 pixels, and the sizes of the sub-images obtained by segmentation are: 224 pixels * 448 pixels, 224 pixels * 672 pixels, 672 pixels * 224 pixels and 448 pixels * 224 pixels. The above minimum unit size can be analyzed and set by those skilled in the art according to the application scenario.
[0063] In an exemplary embodiment, the anchor point of the embodiment of the present invention can also be obtained by the following process:
[0064] Obtain an anchor point area; wherein the anchor point area is an area composed of positions with high information density of the text in the original image page. The information volume of the text can be obtained by statistical information volume calculation; it can also be calculated according to the number of characters in the preset text area, for example, setting the text area size for character count, counting the number of characters contained in the area of more than one text area size of the original image page, and using the number of characters as the information volume of the text. The area of more than one text area size of the original image page can start from a preset starting point, and the preset starting point can be any point in the original image page. In the embodiment of the present invention, the point in the upper left corner of the original image page is used as the preset starting point for explanation. According to the predetermined order, the area of the text area size with the preset starting point as the left vertex is obtained in sequence until all the areas of the text area size corresponding to the points of the original image page are obtained. The predetermined order can be in units of rows, and each row is in order from left to right, or in units of columns, and each column is in order from top to bottom; the preset starting point can also be the center point or other position point of the area of the text area size. In the embodiment of the present invention, other methods can also be used to obtain the area of more than one text area size of the original image page, which is not limited here. The information density threshold can be determined by a person skilled in the art based on the number of characters contained in the original image page through analysis; it can also be set based on the average number of characters contained in the text area size at each position. For example, if the average number of characters at several positions of the original image page according to the preset text area size is 30, then the information density threshold can be set to about 30 in the embodiment of the present invention, for example, the information density threshold is set to a value within 27 to 33. The text area whose information volume exceeds the information density threshold is determined as a position with high information density. In an exemplary embodiment, an area consisting of 3 / 4 times the height and 3 / 4 times the width of the original image page can be selected as the anchor area. In an exemplary embodiment, the vertical direction is the height of the original image page, and the horizontal direction is the width of the original image page. Specifically, the center point of the original image page is taken as the origin, the area height and the area width are obtained, and the area consisting of the area height and the area width is the anchor area. Among them, the area width can be set to take the center point of the original image page as the origin, and obtain the same width to the left and right in the horizontal direction, and the sum of the widths in the left and right directions is 3 / 4 times the width of the original image page; the area height is set to take the center point of the original image page as the origin, and obtain the same height upward and downward in the vertical direction, and the sum of the heights in the upward and downward directions is 3 / 4 times the height of the original image page.
[0065] According to the anchor point quantity requirement M, M points are selected as anchor points in the anchor point area; the anchor point selection in the anchor point area can be performed by random selection, or by receiving external instructions, or by pre-set selection rules; wherein M is a positive integer. In the case where the position of the anchor point is randomly selected, the embodiment of the present invention can assign different weights to each anchor point according to the different positions of the anchor points in the page. For example: the closer the anchor point is to the center of the page, the higher its weight; the more anchor points there are, the more accurate the effect, but the time consumed will also increase accordingly. In an exemplary instance, the scale ratio information in the embodiment of the present invention can be set according to different application scenarios of text angle classification.
[0066] In the embodiment of the present invention, the image to be detected is a picture whose angle classification is to be determined.
[0067] In an exemplary instance, the number of sub-graphs included in each anchor combination of an embodiment of the present invention may be more than three. By combining more than three sub-graphs with preset weighted information, it can be concluded through relevant principles of probability theory that the embodiment of the present invention can avoid edge characteristic problems in sub-graphs.
[0068] In an exemplary embodiment, before step 101 trains the anchor combination obtained by segmenting the original image, the method of the embodiment of the present invention further includes:
[0069] Perform feature extraction on more than one original image to obtain the features of each original image;
[0070] The features of each original image are mapped to the labeled space of the sample for training to obtain a training model.
[0071] In an exemplary embodiment, the embodiment of the present invention performs feature extraction on one or more original images, including:
[0072] The deep convolutional neural network is used to extract features from each original image. Here, feature extraction is the result of the output of the last layer of the deep convolutional neural network obtained after calculating the original image through the deep convolutional network.
[0073] In an exemplary embodiment, the sample of the embodiment of the present invention includes: a training image containing an angle classification result, that is, an image whose angle classification has been determined. The number of training images included in the sample of the embodiment of the present invention can be set according to the accuracy of the angle classification; in theory, the more samples there are, the higher the accuracy; in addition, the smaller the degree of angle classification, the richer the size ratio of the original image in the sample. The label space of the sample represents a collection of training images;
[0074] In an exemplary instance, an embodiment of the present invention maps the features of each original image obtained to the label space of the sample for training, which may include: inputting the extracted features into the fully connected layer of the deep convolutional neural network in the form of a feature map, and obtaining a 1*N matrix (N is a positive integer representing the number of angle classification categories, for example, the angle classification is 0 degrees, 90 degrees, 180 degrees and 270 degrees, then N is equal to 4) through the fully connected layer calculation; here, the 1*N matrix represents the probability value of the original image belonging to each angle classification.
[0075] It should be noted that the embodiments of the present invention may also refer to the existing model training methods in the related art to train and obtain the above-mentioned training model.
[0076] Step 102: Process the obtained probability value of angle classification of each sub-image included in each anchor combination by using preset weighting information to obtain an output value of each anchor combination for angle classification;
[0077] In an exemplary embodiment, the weighted information of the embodiment of the present invention includes: a weighted coefficient that is positively correlated with the amount of information of the text included in the anchor combination.
[0078] In an exemplary embodiment, the weighted information in the embodiment of the present invention includes:
[0079] A first weighting coefficient of each sub-graph included in the anchor combination, which is positively correlated with the amount of information of the text included in the sub-graph; and / or,
[0080] The distance between the anchor point of the anchor combination and the center of the original image is taken as the anchor point distance, and the second weighting coefficient of each anchor combination is negatively correlated with the anchor point distance.
[0081] In an exemplary embodiment, the probability value of the angle classification of each sub-image included in each anchor combination in the embodiment of the present invention is processed by preset weighting information, including:
[0082] In the case where the weighting information includes a first weighting coefficient, a probability weighted sum of each sub-image is calculated according to the obtained probability value of the angle classification and the first weighting coefficient; the calculated probability weighted sum of each sub-image is accumulated according to the angle classification to obtain the output value for the angle classification of each anchor combination; or,
[0083] In the case where the weighting information includes the second weighting coefficient, for the probability value of the angle classification of each sub-image included in each anchor combination, each angle classification is calculated respectively: the cumulative sum of the probability values of the current angle classification of all sub-images included in the anchor combination, and the cumulative sum of the probabilities of each anchor combination is obtained according to the cumulative sum of the probability values of each angle classification of all sub-images included in the anchor combination; the calculated cumulative sum of the probabilities of each anchor combination is multiplied by the corresponding second weighting coefficient to obtain the output value of each anchor combination for angle classification; or,
[0084] In the case where the weighted information includes a first weighting coefficient and a second weighting coefficient, for each anchor combination: the probability weighted sum of each sub-image is calculated according to the obtained probability value of the angle classification and the first weighting coefficient; the calculated probability weighted sums of each sub-image are accumulated according to the angle classification to obtain the probability weighted sum of the anchor combination; the calculated probability weighted sums of each anchor combination are multiplied by the corresponding second weighting coefficient to obtain the output value of each anchor combination for angle classification.
[0085] In an exemplary embodiment, the first weighting coefficient can be set by a person skilled in the art according to the amount of information (generally referring to the number of characters) of the text contained in the sub-image; generally, the greater the amount of information of the text contained in the sub-image, the greater the first weighting coefficient. By setting the first weighting coefficient, when performing text angle classification, the sub-image with a larger amount of text has a larger proportion in the text angle classification process, thereby improving the accuracy of text angle classification.
[0086] In an exemplary embodiment, calculating the probability weighted sum of each anchor combination in the embodiment of the present invention includes:
[0087] For each anchor combination, the probability weighted sum is calculated as follows:
[0088] Calculate the product of the probability value of the angle classification of the obtained sub-image and the first weighting coefficient of the sub-image belonging to different angle classifications respectively, to obtain the probability weighted value of the angle classification of each sub-image;
[0089] The probability weighted values of each subgraph in the obtained anchor combination are accumulated and calculated to obtain the probability weighted sum.
[0090] It should be noted that, when the weighting information does not include the first weighting coefficient, the first weighting coefficient may be set to 1.
[0091] In an exemplary embodiment, the second weighting coefficient can be set by a person skilled in the art according to the anchor point of the anchor combination; generally, the closer the anchor point of the anchor combination is to the center of the original image, the larger the second weighting coefficient is. When the anchor point is close to the center and edge of the original image, the amount of information of the text in the sub-image obtained by segmentation will be different. For the anchor combination with the anchor point close to the center of the original image, the text in the sub-image often contains more information. Therefore, by setting the second weighting coefficient, the weight of the anchor combination with the anchor point close to the center of the original image in the angle classification of the text is increased, thereby improving the accuracy of the text angle classification.
[0092] Step 103: Determine the angle classification of the text by using the output value obtained for angle classification.
[0093] It should be noted that after the embodiment of the present invention obtains the output value for angle classification, the angle classification with the largest value can be selected as the angle classification of the text by comparing the values corresponding to each angle classification in the output value.
[0094] The embodiment of the present invention determines the probability value of the angle classification of the segmented sub-image through anchor combination; processes the determined probability value of the angle classification based on preset weighting information to determine the angle classification of the text. The angle classification is determined based on the sub-image that maintains the resolution of the original image, thereby improving the accuracy of the text angle classification.
[0095] Figure 2 Schematic diagram of anchor assembly according to an embodiment of the present invention. Figure 2As shown in the figure, after setting the minimum unit size, the original image is segmented according to the anchor point and scale ratio information, and an anchor combination containing three sub-images can be obtained; assuming that the first weighted coefficient of the anchor combination is [0.9, 1.0, 1.0], the classification probability values of the angle classifications of 0 degrees, 90 degrees, 180 degrees and 270 degrees of the first sub-image are obtained through training the model: the classification probability values of the angle classifications of 0 degrees, 90 degrees, 180 degrees and 270 degrees of the second sub-image are [0.9, 0, 0, 0]; The classification probability value of the third sub-image is [0.8, 0, 0, 0]; the classification probability values of the angle classification of 0 degree, 90 degree, 180 degree and 270 degree of the third sub-image are [0.88, 0.1, 0.1, 0]; according to the first weighting coefficient, the weighted sum of the probabilities of the above anchor combinations is: [0.9, 0.0, 0.0, 0.0]*0.9+[0.8, 0.1, 0.0, 0.0]*1.0+[0.88, 0.1, 0.1, 0.0]*1.0 =[2.49, 0.2, 0.1, 0.0]; when multiple anchor combinations are included, the probability weighted sum of each anchor combination can be obtained by referring to the above calculation; after setting the second weighting coefficient according to the distance between the anchor point and the center of the original image, the output value for angle classification can be calculated according to the probability weighting of each anchor combination and the second weighting coefficient; assuming that the angle classification of the text in the embodiment of the present invention involves three anchor combinations, in addition to the above anchor combination, the probability weighted sums of the other two anchor combinations are: [2.80, 0.1, 0.0, 0.1] and [2.89, 0.1, 0.0, 0.1], and the preset second weighting coefficient is [0.9, 1.0, 1.2], then the output value for angle classification can be calculated by the following formula: [2.49, 0.2, 0.1, 0.0]*0.9+[2.80, 0.1, 0.0, 0.1]*1.0+[2.89, 0.1, 0.0, 0.1]*1.2 =[8.509, 0.4, 0.09, 0.22]; It can be directly seen from the output value that the values of the angle classifications of 0 degrees, 90 degrees, 180 degrees and 270 degrees are 8.509, 0.4, 0.09 and 0.22 respectively. According to the value size, it can be directly determined that the angle classification result of the text in the original image is zero degrees.
[0096] The embodiments of the present invention improve the accuracy and stability of angle classification, and can be applied to platforms including mobile phones, tablets, notebooks, and embedded systems. The embodiments of the present invention can also implement the above-mentioned method of text angle classification through other open source neural networks. In addition, in addition to being applied to text angle classification, the embodiments of the present invention can also be applied to fields including medical images, precision industrialization, etc.
[0097] An embodiment of the present invention also provides a computer storage medium, in which a computer program is stored. When the computer program is executed by a processor, the above-mentioned text angle classification method is implemented.
[0098] The embodiment of the present invention further provides a terminal, comprising: a memory and a processor, wherein a computer program is stored in the memory; wherein:
[0099] The processor is configured to execute the computer program in the memory;
[0100] When the computer program is executed by a processor, the method for text angle classification as described above is implemented.
[0101] Figure 3 The structure diagram of the device for text angle classification according to the embodiment of the present invention is as follows: Figure 3 As shown, it includes: a training unit, a calculation unit and a determination unit; wherein,
[0102] The training unit is set as follows: training the anchor combination obtained by segmenting the original image to obtain the probability value of the angle classification of each sub-image contained in each anchor combination;
[0103] The calculation unit is configured to: process the obtained probability value of the angle classification of each sub-image included in each anchor combination through preset weighting information to obtain an output value of each anchor combination for angle classification;
[0104] The determination unit is configured to determine the angle classification of the text by using the obtained output value for angle classification.
[0105] The embodiment of the present invention determines the probability value of the angle classification of the segmented sub-image through anchor combination; processes the determined probability value of the angle classification based on preset weighting information to determine the angle classification of the text. The angle classification is determined based on the sub-image that maintains the resolution of the original image, thereby improving the accuracy of the text angle classification.
[0106] In an exemplary embodiment, the training unit is configured as follows:
[0107] Pack the anchor combinations according to the pre-set input size of the training model;
[0108] Input the packaged anchor combination into the training model for training;
[0109] Obtain the probability value of the angle classification of each sub-image contained in each anchor combination;
[0110] Among them, when the resolution of the original image is smaller than the input size, the anchor combination is packaged according to the input size of the preset training model to obtain a sub-image in the anchor combination whose size is larger than half of the original image size and smaller than the original image size; when the resolution of the original image is greater than or equal to the input size, the anchor combination is packaged according to the input size of the preset training model to obtain a sub-image in the anchor combination whose size is larger than the input size and smaller than twice the input size.
[0111] In an exemplary embodiment, the weighted information of the embodiment of the present invention includes: a weighted coefficient that is positively correlated with the amount of information of the text included in the anchor combination.
[0112] The weighting coefficient of the embodiment of the present invention is positively correlated with the amount of information of the text contained in the anchor combination, and therefore, the accuracy of text angle classification can be further improved.
[0113] In one exemplary embodiment, the weighting information includes:
[0114] A first weighting coefficient of each sub-graph included in the anchor combination, which is positively correlated with the amount of information of the text included in the sub-graph; and / or,
[0115] The distance between the anchor point of the anchor combination and the center of the original image is taken as the anchor point distance, and the second weighting coefficient of each anchor combination is negatively correlated with the anchor point distance.
[0116] In an exemplary embodiment, the computing unit is configured as follows:
[0117] In the case where the weighting information includes a first weighting coefficient, a probability weighted sum of each sub-image is calculated according to the obtained probability value of the angle classification and the first weighting coefficient; the calculated probability weighted sum of each sub-image is accumulated according to the angle classification to obtain the output value for the angle classification of each anchor combination; or,
[0118] In the case where the weighting information includes the second weighting coefficient, for the probability value of the angle classification of each sub-image included in each anchor combination, each angle classification is calculated respectively: the cumulative sum of the probability values of the current angle classification of all sub-images included in the anchor combination, and the cumulative sum of the probabilities of each anchor combination is obtained according to the cumulative sum of the probability values of each angle classification of all sub-images included in the anchor combination; the calculated cumulative sum of the probabilities of each anchor combination is multiplied by the corresponding second weighting coefficient to obtain the output value of each anchor combination for angle classification; or,
[0119] In the case where the weighted information includes a first weighting coefficient and a second weighting coefficient, for each anchor combination: the probability weighted sum of each sub-image is calculated according to the obtained probability value of the angle classification and the first weighting coefficient; the calculated probability weighted sums of each sub-image are accumulated according to the angle classification to obtain the probability weighted sum of the anchor combination; the calculated probability weighted sums of each anchor combination are multiplied by the corresponding second weighting coefficient to obtain the output value of each anchor combination for angle classification.
[0120] “A person skilled in the art can understand that all or some steps, systems, and functional modules / units in the above disclosed methods can be implemented as software, firmware, hardware, and appropriate combinations thereof. In hardware implementations, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component can have multiple functions, or a function or step can be performed by several physical components in cooperation. Some or all components can be implemented as software executed by a processor, such as a digital signal processor or a microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit. Such software can be distributed on a computer-readable medium, which can include a computer storage medium (or a non-transitory medium) and a communication medium (or a transient medium). As is known in the art, As is well known to those skilled in the art, the term computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data. Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer. In addition, as is well known to those skilled in the art, communication media typically contains computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media. "
Claims
1. A method for text angle classification, It is characterized in that include: Train the anchor combinations obtained by segmenting the original image to obtain the probability value of the angle classification of each sub-image contained in each anchor combination; The probability value of the angle classification of each sub-image contained in each anchor combination is processed by preset weighting information to obtain the output value of each anchor combination for angle classification; Determining the angle classification of the text by using the obtained output value for angle classification; The weighting information includes: a first weighting coefficient of each sub-image included in the anchor combination, which is positively correlated with the amount of information of the text included in the sub-image; and / or a second weighting coefficient of each anchor combination, which is negatively correlated with the anchor distance, taking the distance between the anchor point of the anchor combination and the center of the original image as the anchor distance; The obtained probability value of the angle classification of each sub-image included in each anchor combination is processed by preset weighting information to obtain the output value of each anchor combination for angle classification, including: In the case where the weighting information includes the first weighting coefficient, the probability weighted sum of each sub-image is calculated according to the obtained probability value of the angle classification and the first weighting coefficient; the calculated probability weighted sum of each sub-image is accumulated according to the angle classification to obtain the output value for the angle classification of each anchor combination; or, In the case where the weighting information includes the second weighting coefficient, for the probability value of the angle classification of each sub-image included in each anchor combination, each angle classification is calculated separately: the cumulative sum of the probability values of the current angle classification of all sub-images included in the anchor combination is calculated, and the cumulative sum of the probabilities of each anchor combination is obtained according to the cumulative sum of the probability values of each angle classification of all sub-images included in the anchor combination; the output value for angle classification of each anchor combination is obtained according to the calculated cumulative sum of the probabilities of each anchor combination and the second weighting coefficient; or, In the case where the weighting information includes the first weighting coefficient and the second weighting coefficient, for each anchor combination: based on the obtained probability value of the angle classification and the first weighting coefficient, calculate the probability weighted sum of each sub-image; accumulate the calculated probability weighted sums of each sub-image according to the angle classification to obtain the probability weighted sum of the anchor combination; based on the calculated probability weighted sums of each anchor combination and the second weighting coefficient, obtain the output value of the anchor combination for angle classification.
2. The method according to claim 1, It is characterized in that The training of the anchor combination obtained by segmenting the original image includes: Packing the anchor combination according to a preset input size of the training model; Inputting the packaged anchor combination into the training model for training; Among them, when the resolution of the original image is smaller than the input size, packing the anchor combination according to the input size of the preset training model is to obtain a sub-image in the anchor combination whose size is larger than half of the original image size and smaller than the original image size; when the resolution of the original image is greater than or equal to the input size, packing the anchor combination according to the input size of the preset training model is to obtain a sub-image in the anchor combination whose size is larger than the input size and smaller than twice the input size.
3. A computer storage medium, wherein a computer program is stored in the computer storage medium, and when the computer program is executed by a processor, the method for text angle classification as described in any one of claims 1 to 2 is implemented.
4. A terminal, include: A memory and a processor, wherein the memory stores a computer program; wherein, The processor is configured to execute the computer program in the memory; When the computer program is executed by the processor, the method for text angle classification as described in any one of claims 1 to 2 is implemented.
5. A device for text angle classification, It is characterized in that include: training unit, calculation unit and determination unit; wherein, The training unit is set as follows: training the anchor combination obtained by segmenting the original image to obtain the probability value of the angle classification of each sub-image contained in each anchor combination; The calculation unit is configured to: process the obtained probability value of the angle classification of each sub-image included in each anchor combination through preset weighting information to obtain an output value of each anchor combination for angle classification; The determination unit is configured to: determine the angle classification of the text by obtaining the output value for angle classification; The weighting information includes: a first weighting coefficient of each sub-image included in the anchor combination, which is positively correlated with the amount of information of the text included in the sub-image; and / or a second weighting coefficient of each anchor combination, which is negatively correlated with the anchor distance, taking the distance between the anchor point of the anchor combination and the center of the original image as the anchor distance; The obtained probability value of the angle classification of each sub-image included in each anchor combination is processed by preset weighting information to obtain the output value of each anchor combination for angle classification, including: In the case where the weighting information includes the first weighting coefficient, the probability weighted sum of each sub-image is calculated according to the obtained probability value of the angle classification and the first weighting coefficient; the calculated probability weighted sum of each sub-image is accumulated according to the angle classification to obtain the output value for the angle classification of each anchor combination; or, In the case where the weighting information includes the second weighting coefficient, for the probability value of the angle classification of each sub-image included in each anchor combination, each angle classification is calculated separately: the cumulative sum of the probability values of the current angle classification of all sub-images included in the anchor combination is calculated, and the cumulative sum of the probabilities of each anchor combination is obtained according to the cumulative sum of the probability values of each angle classification of all sub-images included in the anchor combination; the output value for angle classification of each anchor combination is obtained according to the calculated cumulative sum of the probabilities of each anchor combination and the second weighting coefficient; or, In the case where the weighting information includes the first weighting coefficient and the second weighting coefficient, for each anchor combination: based on the obtained probability value of the angle classification and the first weighting coefficient, calculate the probability weighted sum of each sub-image; accumulate the calculated probability weighted sums of each sub-image according to the angle classification to obtain the probability weighted sum of the anchor combination; based on the calculated probability weighted sums of each anchor combination and the second weighting coefficient, obtain the output value of the anchor combination for angle classification.
6. The device according to claim 5, It is characterized in that The training unit is set as: Packing the anchor combination according to a preset input size of the training model; Inputting the packaged anchor combination into the training model for training; Among them, when the resolution of the original image is smaller than the input size, packing the anchor combination according to the input size of the preset training model is to obtain a sub-image in the anchor combination whose size is larger than half of the original image size and smaller than the original image size; when the resolution of the original image is greater than or equal to the input size, packing the anchor combination according to the input size of the preset training model is to obtain a sub-image in the anchor combination whose size is larger than the input size and smaller than twice the input size.
