Method and apparatus for recognizing text - Patents.com
The method enhances STR by creating a relational graph from feature maps to process spatial semantic features with a graph convolution network, addressing the complexity of natural scene text recognition and improving accuracy in diverse environments.
Patent Information
- Application Number
- JP2023575611
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Priority Date
- 2021-06-07
- Filing Date
- 2022-04-06
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2042-04-06
AI Technical Summary
Conventional Scene Text Recognition (STR) methods face significant challenges due to complex backgrounds and random character arrangements, leading to increased recognition difficulty compared to Optical Character Recognition (OCR).
A method and apparatus that utilize a feature map segmentation to create a relational graph with nodes representing pixel points and edges indicating spatial semantic features, processed by a pre-trained graph convolution network to enhance text recognition, incorporating two-dimensional spatial information and order relationships between characters.
Improves text recognition accuracy by preserving and utilizing two-dimensional spatial information, effectively handling complex backgrounds and diverse character forms in natural scenes, applicable to visually impaired navigation, autonomous driving, and augmented reality.
Smart Images

Figure 0007559263000014 
Figure 0007559263000015 
Figure 0007559263000016
Abstract
Description
[Technical field]
[0001] <CROSS REFERENCE TO RELATED APPLICATIONS> This disclosure claims priority to a Chinese patent application filed on June 7, 2021, bearing application number 202110632180.5 and entitled "Method and Apparatus for Recognizing Text," the entire text of which is incorporated herein by reference.
[0002] TECHNICAL FIELD Embodiments of the present disclosure relate to the field of computer technology, and in particular to a method and apparatus for recognizing text. [Background technology]
[0003] Traditional character recognition can be divided into two categories: OCR (Optical Character Recognition) and STR (Scene Text Recognition), where OCR usually refers to recognizing characters in high-quality scanned document images, and STR usually refers to recognizing characters in natural scene images.
[0004] Generally speaking, in the OCR recognition scenario, the image background is simple, the character arrangement is regular, and the font is standardized, whereas in the STR recognition scenario, the image background is complex, the character arrangement is random, and the font is diversified, so the recognition difficulty of STR is much greater than that of OCR.
[0005] STR has important practical applications in many areas, such as supporting navigation for the visually impaired, autonomous driving applications, text reading and translation in augmented reality, etc., and has attracted increasing attention in the computer vision industry. Traditional STR recognition methods usually locate text regions in an image and then recognize characters within the text regions. Summary of the Invention [Problem to be solved by the invention]
[0006] SUMMARY OF THE DISCLOSURE Embodiments of the present disclosure provide a method and apparatus for recognizing text. [Means for solving the problem]
[0007] In a first aspect, an embodiment of the present disclosure provides a method for recognizing text, the method including: obtaining a feature map by performing text instance segmentation for an image having text to be recognized; creating a relationship graph based on the feature map, where a node in the relationship graph represents a pixel point of the feature map, and an edge represents a similarity of spatial-semantic features of two connected nodes that is greater than a target threshold, and the spatial-semantic features include location features and category features of the pixel point indicated by the node; processing the relationship graph by a pre-trained graph convolutional network to obtain first text features corresponding to the image; and generating a text recognition result for the image based on the first text features.
[0008] In a second aspect, an embodiment of the present disclosure provides an apparatus for recognizing text, the apparatus including: a feature map acquisition unit configured to acquire a feature map by performing text instance segmentation for an image having text to be recognized; a relationship graph creation unit configured to create a relationship graph based on the feature map, where a node in the relationship graph represents a pixel point of the feature map, and an edge represents a similarity of spatial-semantic features of two connected nodes that is greater than a target threshold, and the spatial-semantic features include a location feature and a category feature of the pixel point indicated by the node; a graph convolution processing unit configured to process the relationship graph by a pre-trained graph convolution network to acquire first text features corresponding to the image; and a recognition unit configured to generate a text recognition result for the image based on the first text features.
[0009] In a third aspect, an embodiment of the present disclosure provides an electronic device comprising one or more processors and a storage device having one or more programs stored therein, the one or more programs, when executed by the one or more processors, causing the one or more processors to implement a method according to any of the embodiments of the first aspect.
[0010] In a fourth aspect, an embodiment of the present disclosure provides a computer readable medium having stored thereon a computer program which, when executed by a processor, implements a method according to any of the embodiments of the first aspect.
[0011] In a fifth aspect, an embodiment of the present disclosure provides a computer program product which, when executed by a processor, implements a method according to any of the embodiments of the first aspect. M provide.
[0012] Other features, objects and advantages of the present disclosure will become more apparent from a reading of the following detailed description of non-limiting embodiments, taken in conjunction with the drawings in which: [Brief description of the drawings]
[0013] [Figure 1] FIG. 1 illustrates an exemplary system architecture to which an embodiment of the present disclosure can be applied. [Diagram 2] 1 is a flow chart of one embodiment of a method for recognizing text according to the present disclosure. [Diagram 3] 1 is a flowchart of an embodiment of a feature map generation method in a method for recognizing text according to the present disclosure. [Figure 4] 4 is a flowchart of a further embodiment of a method for recognizing text according to the present disclosure. [Figure 5A] FIG. 2 is a schematic diagram of an exemplary application scene of the method for recognizing text according to the present disclosure; [Figure 5B]FIG. 2 is a schematic diagram of an exemplary application scene of the method for recognizing text according to the present disclosure; [Figure 5C] FIG. 2 is a schematic diagram of an exemplary application scene of the method for recognizing text according to the present disclosure; [Figure 6] 1 is a flowchart of one embodiment of a method for training a graph convolutional network, a language model, and a segmentation network in a method for recognizing text according to the present disclosure. [Figure 7] 1 is a structural schematic diagram of an embodiment of an apparatus for recognizing text according to the present disclosure; [Figure 8] FIG. 1 is a structural schematic diagram of an electronic device suitable for implementing an embodiment of the present disclosure. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0014] The present disclosure will be described in more detail below with reference to the drawings and embodiments. It should be understood that the specific embodiments described in this specification are merely for the purpose of explaining the related invention, and do not limit the invention. For the sake of convenience, only parts related to the invention are shown in the drawings.
[0015] In addition, the embodiments and features in the embodiments of the present disclosure can be combined with each other unless they are inconsistent. The present disclosure will be described in detail below with reference to the drawings and embodiments. Figure 1 shows an exemplary architecture 100 to which the embodiment of the method for recognizing text or the device for recognizing text according to the present disclosure can be applied.
[0016] 1, system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. Network 104 is used as a medium to provide a communications link between terminal devices 101, 102, 103 and server 105. Network 104 may include various types of connections, such as wires, wireless communications links, or fiber optic cables.
[0017] To send and receive messages, the terminal devices 101, 102, and 103 exchange information with a server 105 via a network 104. Various client applications can be installed on the terminal devices 101, 102, and 103. Examples of such applications include a browser application, a search application, an image processing application, and a deep learning framework.
[0018] The terminal devices 101, 102, and 103 may be hardware or software. If the terminal devices 101, 102, and 103 are hardware, they may be various electronic devices, including, but not limited to, smartphones, tablet computers, e-book readers, laptop computers, and desktop computers. If the terminal devices 101, 102, and 103 are software, they may be installed in the electronic devices exemplified above. They may be realized as multiple software or software modules (e.g., multiple software or software modules for providing distributed services), or as a single software or software module. There is no particular limitation here.
[0019] The server 105 may be a server that provides various services, for example, a server that provides back-end support to client applications installed on the terminal devices 101, 102, and 103. The server 105 may be hardware or software. If the server 105 is hardware, it may be implemented as a distributed server cluster consisting of multiple servers, or as a single server. If the server 105 is software, it may be realized as multiple software or software modules (e.g., multiple software or software modules for providing distributed services), or as a single software or software module. There is no particular limitation here.
[0020] It should be noted that the method for recognizing text according to the embodiment of the present disclosure is typically performed by the server 105, and accordingly, an apparatus for recognizing text is typically provided in the server 105.
[0021] Note that the terminal devices 101, 102, 103 may be equipped with an image processing application and process images having text to be recognized based on the image processing application, in which case the method for recognizing text may be executed by the terminal devices 101, 102, 103, and correspondingly the device for recognizing text may be provided in the terminal devices 101, 102, 103. In this case, the exemplary system architecture 100 may not include the server 105 and the network 104.
[0022] It should be understood that the numbers of terminal devices, networks and servers in Figure 1 are merely exemplary, and the numbers of terminal devices, networks and servers may be arbitrarily increased or decreased according to the needs of implementation.
[0023] The method and apparatus for recognizing text provided by the embodiment of the present disclosure obtains a feature map by segmenting text instances for an image having text to be recognized, then constructs a relationship graph corresponding to the feature map with the pixel points of the feature map as nodes and the similarities of the spatial semantic features of the nodes as edges, then processes the relationship graph by a graph convolution network to extract a first text feature of the text to be recognized in the image, and then uses the first text feature to generate a text recognition result corresponding to the image. Such a graph-based text recognition method takes into account the two-dimensional spatial information of the text in the image, and prevents the two-dimensional spatial information from being ignored by directly compressing the text features in the image into one-dimensional features, which helps to improve the text recognition effect.
[0024] Reference is now made to Figure 2, which illustrates a flow 200 of one embodiment of a method for recognizing text according to the present disclosure. The method for recognizing text includes the following steps:
[0025] In step 201, a feature map is obtained.
[0026] In this embodiment, the feature map can be obtained by segmenting text instances for an image having text to be recognized. The text to be recognized may be text of various contents. For example, the text to be recognized may include one or more kinds of text (e.g., alphabets, numbers, special symbols, Chinese characters, etc.). The image having text to be recognized may be various types of images.
[0027] Depending on the actual application scenario, the quality of the image having the text to be recognized may be different, and various attributes of the text to be recognized shown in the image, such as the position, writing style, etc., may be different.
[0028] The segmentation of a text instance may refer to detecting individual characters contained in a text to be recognized from an image and distinguishing the individual characters. In general, a feature map (MASK) obtained by segmenting a text instance may correspond to characters contained in the recognized text. The number of feature maps may be flexibly set according to actual application scenarios. For example, if the text to be recognized in an image contains only one character, the number of feature maps may be one.
[0029] Optionally, the number of feature maps is at least two. Or the engineer may pre-specify the number of feature maps. In general, the number of characters contained in the text to be recognized in the image may be estimated according to the actual application scene, and the number of feature maps set may be greater than the number of estimated characters to avoid missing recognition.
[0030] Specifically, the executing entity or other electronic device can obtain a feature map by segmenting text instances from an image having text to be recognized using various conventional instance segmentation methods.
[0031] In this embodiment, the method for recognizing text (such as the server 105 shown in FIG. 1) may locally store in advance a feature map obtained by segmenting text instances for an image having the text to be recognized, and the executing entity may directly obtain the feature map from the local storage device. The executing entity may also obtain the feature map from other storage devices such as a connected database, a third-party data platform, or the terminal devices 101, 102, 103 shown in FIG. 1.
[0032] In step 202, a relationship graph is created based on the feature map.
[0033] In this embodiment, after obtaining a feature map, a relationship graph can be obtained based on the feature map by treating each pixel point in the feature map as a node and creating edges based on the similarity between the spatial semantic features of the pixel points.
[0034] Here, the spatial semantic features of a pixel point may include a location feature and a category feature of the pixel point. The location feature of the pixel point may be used to represent the location of the pixel point in the feature map. The category feature of the pixel point may be used to represent the character category to which the pixel point belongs.
[0035] Character categories may be preset according to actual application scenes. For example, if the text to be recognized is a number, it may be divided into 11 character categories representing 0 to 9 and background.
[0036] In general, the location feature of a pixel point may be represented by the coordinates (e.g., abscissa and ordinate) of the pixel point in the feature map. The categorical property of the pixel point may be represented by a vector, which may represent the probability that the pixel point belongs to each predefined text category.
[0037] When creating the relationship graph, if the similarity of the spatial semantic features of two pixel points is greater than a target threshold, an edge can be established between the two pixel points. Conversely, if the similarity of the spatial semantic features of the two pixel points is not greater than the target threshold, an edge is not established between the two pixel points. Note that the target threshold may be preset by an engineer, or may be flexibly determined during the creation of the relationship graph. For example, the target threshold may be determined based on the spatial semantic similarity between each pixel point.
[0038] The similarity of the spatial semantic features may be flexibly determined by various methods. For example, the similarity of the position feature and the similarity of the category feature of two pixel points may be calculated, and the similarity of the position feature and the similarity of the category feature may be weighted and summed to obtain the similarity of the spatial semantic features of the two pixel points.
[0039] Optionally, if the number of feature maps is at least two, a corresponding relationship subgraph may be created for each feature map, and the relationship subgraphs corresponding to each feature map may be merged to obtain a final relationship graph. The relationship graphs may be combined by sequentially connecting each relationship subgraph according to the corresponding positional relationship in the image of each feature map. Specifically, for two relationship subgraphs, one node may be selected from each of the two relationship subgraphs and connected to achieve the connection of these two relationship subgraphs. The method of selecting a node from the relationship subgraph may be flexibly set, such as by selecting the root node.
[0040] In step 203, the relationship graph is processed using a pre-trained graph convolutional network to obtain a first text feature corresponding to the image.
[0041] In this embodiment, the graph convolutional network (GCN) can be generally regarded as a model that uses the Chebyshev first-order polynomial of the graph Laplacian to approximate the spectral convolution operation. From the perspective of spectral convolution, the graph convolutional network can be regarded as a special form of graph Laplacian smoothing. The convolution operation of the graph convolutional network can be regarded as transforming the feature information of each node and then sending it to the neighboring nodes of the node, and fusing the feature information of the neighboring nodes to update the feature information of each node.
[0042] Specifically, after updating the feature information (i.e., spatial semantic features) of each node using the graph convolutional network, the updated feature information of each node can be used to generate a first text feature corresponding to the image in various ways. The first text feature can represent the features of the text to be recognized in the image.
[0043] For example, the feature information of each node may be averaged or the maximum value may be taken, and the result of the processing may be set as the first text feature. Also, for example, the updated feature information of the node corresponding to the target pixel point in the feature map may be selected as the first text feature. Here, the target pixel point can be flexibly set.
[0044] As an example, the target pixel point may be pre-specified by an engineer, for example, the geometric center point of the feature map. As yet another example, the target pixel point may be a pixel point whose similarity between the corresponding node and each of the neighboring nodes is greater than a pre-specified threshold.
[0045] Step 204 generates a text recognition result for the image based on the first text feature.
[0046] In this embodiment, after obtaining the first text features, various conventional text recognition methods, such as text recognition methods based on recurrent neural networks and concatenated temporal classifiers, may be used to generate text recognition results corresponding to the first text features, so as to provide text recognition results corresponding to the image having the text to be recognized.
[0047] In some optional embodiments of this embodiment, the feature map obtained by segmenting the text instance for an image having the text to be recognized can represent the image features of the image regions in which each character in the text to be recognized is located, and the order features between other feature maps, where the order features can represent the order relationship between each feature map, and can be combined with the context of each character in the subsequent recognition process to more accurately recognize the character, thereby improving the accuracy of the recognition result.
[0048] Reference is now made to Fig. 3, which illustrates a flowchart 300 of an embodiment of a feature map generation scheme in a method for recognizing text according to an embodiment of the present disclosure. As shown in Fig. 3, a feature map obtained by performing text instance segmentation on an image having text to be recognized may be generated by the following steps:
[0049] In step 301, an image is input into a pre-trained convolutional neural network to obtain an initial feature map.
[0050] In this embodiment, a convolutional neural network may be used to convolve an image and extract various features of the image (texture features, color features, etc.) to obtain an initial feature map.
[0051] Optionally, the convolutional neural network may be implemented based on a feature pyramid network FPN and a residual network ResNet, where the stride of at least one convolutional layer before the output layer of the residual network may be set to 1, and the feature map output by the residual network may generate the input feature map of the feature pyramid network by deformable convolution.
[0052] Taking ResNet50 as an example, ResNet50 generally obtains an output feature map by processing an input image in five stages. If the feature maps output by processing the input image sequentially in five stages are S1 to S5, the convolution stride of stages 4 and 5 can be set to 1 to leave more background image information such as character texture and character boundaries in S4 and S5.
[0053] Then, the feature map S5 may be subjected to a deformable convolution process, the deformable convolution process feature map may be input to the FPN, and the final output feature map from the FPN may be used as the initial feature map. The deformable convolution allows the convolutional neural network to better adapt to the irregular boundaries of the text to be processed, thereby improving the accuracy of subsequent text recognition.
[0054] In step 302, text instance segmentation is performed on the initial feature map to obtain an instance feature map.
[0055] In this embodiment, the text instances can be segmented with respect to the initial feature map by various conventional instance segmentation methods to obtain the instance feature map.
[0056] Optionally, a PPM (Pyramid Pooling Module) network can be used to extract features of different receptive fields of the initial feature map, and then the features of different receptive fields can be concatenated and transformed in dimension. For example, parallel 1*1, 3*3, and 5*5 convolution layers can be used to extract features of the initial feature map respectively, and the features extracted by each convolution layer can be serially concatenated, and a 1*1 convolution layer can be used to perform dimension transformation for subsequent processing.
[0057] Optionally, after processing such as serializing features of different receptive fields and performing dimension transformation, further feature transformation may be performed using multiple stacked convolution layers based on the spatial attention mechanism to obtain features with enhanced spatial locations. For example, after serializing features of different receptive fields extracted as described above and performing dimension transformation, further 3*3 and 1*1 convolution layers can be used to obtain spatial attention feature maps. Then, text instances are segmented based on the obtained features with enhanced spatial locations.
[0058] In step 303, a text order segmentation is performed on the initial feature map to obtain an order feature map.
[0059] In this embodiment, in order to preserve the reading order of each character in the text to be recognized in the image, the initial feature map can be processed by various conventional text order segmentation methods to obtain an order feature map.
[0060] For example, the initial feature map can be input to a network built based on a convolutional encoder / decoder structure to perform simple convolutional downsampling and deconvolutional upsampling on the initial feature map to obtain an ordinal feature map.
[0061] In step 304, the instance feature map and the ordinal feature map are fused to obtain a feature map by performing text instance segmentation for the image having the text to be recognized.
[0062] In this embodiment, the obtained instance feature map and ordinal feature map are fused to obtain a feature map by performing text instance segmentation for an image having text to be recognized.
[0063] If there are at least two character instances in the instance feature map, the instance feature map can be fused with the ordinal feature maps corresponding to each character instance to obtain at least two fused feature maps.
[0064] Specifically, the instance feature map and the order feature map can be fused by various feature fusion methods. For example, the fusion of the instance feature map and the order feature map can be achieved by multiplying corresponding pixels of the instance feature map and the order feature map.
[0065] In some optional embodiments of this embodiment, the spatial semantic features of a node in the relationship graph created based on the feature map may further include an order feature of the feature map in which the pixel point indicated by the node resides.
[0066] Then, for a node in the relationship subgraph corresponding to each feature map, the spatial semantic features of the node may be generated by the following steps.
[0067] In step 1, the order value in each feature map of the feature map corresponding to the node is obtained.
[0068] In this step, since the feature maps are obtained by performing segmentation of text instances on the image having the text to be recognized, each feature map has an order relationship corresponding to the order between each segmented instance.
[0069] The order value can represent the sort position of each feature map. For example, 20 feature maps may be set in advance, and the order number of each feature map (one of 1 to 20) may be set as the order value of the feature map.
[0070] It is understood that the ordinal values corresponding to each pixel point in the same feature map are the same.
[0071] In step 2, an ordinal feature of the feature map corresponding to the node is determined based on the ordinal value of the feature map corresponding to the node.
[0072] In this step, the ordinal features of the feature maps can be represented by vectors. Therefore, by mapping each ordinal value to the same vector space, the ordinal features corresponding to each feature map can be obtained. Specifically, the mapping method can adopt various conventional mapping methods.
[0073] For example, the sequence values can be vectorized using sine and cosine functions of different wavelengths. As an example, the vector representation of each sequence value can be obtained using the following equation:
[0074]
number
[0075]
number
[0076] Here, z can represent an ordinal value. ε represents the vector dimension, which may be specifically set in advance by the engineer. i represents the number of elements in the vector. ε 2i represents the even elements in the vector, and ε 2i+1 represents the odd-numbered elements in a vector.
[0077] In step 3, the location feature, category feature and determined order feature of the pixel point indicated by the node are spliced to obtain the spatial semantic feature of the node.
[0078] In this step, the location feature, category feature and determined order feature of the pixel point indicated by the node are spliced in order to obtain the spatial semantic feature of the node, where both the location feature and category feature of the pixel point can be represented by a vector.
[0079] Optionally, for each node, the location features and category features of the pixel points can be first represented as vectors, and then the vector representations of the location features and category features of the node and the vector representation of the ordinal features of the node can be spliced together to obtain the spatial semantic features of the node.
[0080] For example, for any node, the horizontal coordinate of the node is X, the vertical coordinate is Y, and the category feature is P. X, Y, and P are mapped to vector expressions, and then the vector expressions corresponding to X, Y, and P are serially connected to form a vector expression corresponding to the position feature and category feature of the node. Here, the method of mapping X, Y, and P to a vector expression may adopt various conventional mapping methods.
[0081] For convenience of calculation, the dimensions of each vector representation may be kept the same. For example, the dimensions of each vector representation may be flexibly adjusted using 1×1 convolution.
[0082] Optionally, before splicing the vector representations corresponding to the positional and categorical features of the node and the vector representations of the ordinal features of the node, the vector representations corresponding to the positional and categorical features of the node can be normalized by various normalization methods, thereby reducing the vector elements and making them useful for subsequent calculations.
[0083] For example, normalization can be achieved by subtracting the vector representations corresponding to the location features and category features of the target node in the corresponding feature map from the vector representation of the node in question, and it is understood that the vector representations corresponding to the location features and category features of the target node are 0 after normalization.
[0084] The goal node may be predetermined by an engineer or may be flexibly set during the calculation process. For example, the goal node may be the root node of the feature map. In general, the geometric center point of the feature map may be set as the root node.
[0085] Optionally, the root node of the feature map may be determined by determining the Jaccard coefficient (IoU, Intersection over Union) of each node in the feature map with respect to the node and setting the node as the root node in response to determining that each Jaccard coefficient corresponding to the node is equal to or less than a preset threshold. Here, the Jaccard coefficient may represent the ratio of the number of elements in the intersection of the neighboring nodes of two nodes to the number of elements in the union of the neighboring nodes. The preset threshold may be preset by an engineer. In this manner, the pixel point for each character center can be efficiently selected as the root node, and the node distribution in the relationship subgraph corresponding to the feature map can be balanced.
[0086] In some optional embodiments of this embodiment, for two nodes, the similarity of spatial semantic features may be determined by the following steps.
[0087] In step 1, the Euclidean distance between two nodes is determined, and a first similarity measure is determined based on the determined Euclidean distance.
[0088] In this step, the Euclidean distance between two nodes is generally inversely proportional to the similarity of the spatial semantic features of the nodes. The first similarity may be determined in various ways based on this. For example, the first similarity may be calculated by the following formula:
[0089]
number
[0090] where p and q are two nodes. D(p,q) represents the Euclidean distance between p and q. H m and W m represent the height and width of the feature map, respectively. E s (p, q) represents the first similarity.
[0091] In step 2, we determine the cosine similarity of the categorical features corresponding to each of the two nodes.
[0092] In this step, the cosine similarity can be calculated using the vector representations of the categorical features corresponding to each of the two nodes according to the conventional method for calculating the cosine similarity.
[0093] In step 3, the similarity of the spatial semantic features of the two nodes is determined based on the first similarity and the cosine similarity.
[0094] In this step, the similarity of the spatial semantic features is generally directly proportional to the first similarity and also directly proportional to the cosine similarity. Based on this, the similarity of the spatial semantic features of two nodes may be determined in various ways. For example, the product of the first similarity and the cosine similarity may be directly calculated as the similarity of the spatial semantic features of the two nodes. This allows the similarity in various aspects such as the spatial position and category between the nodes to be comprehensively considered, which contributes to the creation of a more accurate relationship graph.
[0095] In some optional embodiments of this embodiment, when creating a relationship graph corresponding to the feature map, for each node, the similarity of spatial semantic features between the node and other nodes is calculated respectively, and a predetermined number of nodes are selected as neighboring nodes of the node in order from the node with the largest similarity to the node with the smallest similarity. That is, an edge can be established between the selected node and the node. Here, the predetermined number may be flexibly set according to a specific application scenario. For example, the predetermined number may be 8. This allows the complexity and accuracy of the created relationship graph to be more flexibly controlled, which is helpful for subsequent calculations.
[0096] In some optional embodiments of this embodiment, the graph convolution network may include a first graph convolution network and an output network, where the first graph convolution network may be used to transform the feature matrix of the created relation graph, and the output network may be used to select nodes from each relation subgraph respectively according to the output of the first graph convolution network, and aggregate the transformed features corresponding to the selected nodes from each relation subgraph respectively to obtain first text features.
[0097] Each relationship subgraph can be represented using a feature matrix and an adjacency matrix of the relationship graph, where the elements in the feature matrix are used to represent the features of the nodes in the relationship subgraph, and the adjacency matrix is used to represent the connectivity (e.g., the presence or absence of edges) between each node in the relationship subgraph.
[0098] The first graph convolutional network may adopt various conventional convolutional network structures to achieve the transformation of the feature matrix of the relationship graph.
[0099] Optionally, the first graph convolution network may include a first graph convolution sub-network and a second graph convolution sub-network, where the first graph convolution sub-network may be used to transform a feature matrix of a relationship graph, and the second graph convolution sub-network may be used to transform a feature matrix output from the first graph convolution sub-network according to a relationship sub-graph created based on an output of the first graph convolution sub-network.
[0100] In this case, the first graph convolution sub-network may convert the feature matrix of the relationship graph, and then recalculate the similarity between nodes and re-create edges according to the features of each node in the converted feature matrix. That is, the relationship sub-graph can be updated. The second graph convolution sub-network can process the updated relationship sub-graph.
[0101] The structures of the first graph convolutional sub-network and the second graph convolutional sub-network can be flexibly set by engineers according to actual application needs.
[0102] As an example, the processing process of the first graph convolution sub-network is shown in the following equation:
[0103]
number
[0104] where l is the number of convolutional layers in the first graph convolutional subnetwork. Y l represents the output of the lth layer. X l represents the input of the lth layer. W l are the network parameters learned by the first graph convolutional subnetwork. A represents the adjacency matrix of the relationship graph. I N represents a matrix of the same size as A, with all the elements of the main diagonal being 1.
[0105]
number
[0106] is a diagonal matrix. i and j represent row and column indices, respectively. σ represents a nonlinear activation function.
[0107]
number
[0108] indicates that the matrix is connected in a dimension.
[0109] The processing process of the second graph convolution sub-network is shown in the following equation:
[0110]
number
[0111] where l is the number of convolutional layers in the second graph convolutional subnetwork.
[0112]
number
[0113] represents the output of the lth layer.
[0114]
number
[0115] are the network parameters learned by the second graph convolutional subnetwork.
[0116]
number
[0117] is a matrix obtained based on the updated relationship graph, and the specific calculation method is the same as that in the first graph convolution sub-network described above.
[0118]
number
[0119] is the same as:
[0120] Specifically, the output network can recalculate the distance between nodes according to the update of the feature information of each node in the relationship graph represented by the output of the first graph convolution network, and then discard some of the nodes (e.g., discard half of the nodes) according to the distance from smallest to largest, thereby realizing a pooling operation and reducing the size of the corresponding feature map.
[0121] Optionally, the above-mentioned process of feature updating and node selection of the first graph convolution network and the output network may be repeated until only one node remains in each relation subgraph. Then, the feature information of the selected nodes in each relation subgraph may be sequentially spliced according to the order between the relation subgraphs to form a first text feature.
[0122] Through the repeated process of feature updating and node selection of the first graph convolution network and the output network, a node that can best represent the corresponding character instance in spatial relationship can be selected from each relationship sub-graph, so that the feature information of the node can be utilized for subsequent text recognition, which helps to improve the efficiency and accuracy of text recognition.
[0123] The method provided in the above embodiment of the present disclosure provides a graph-based text recognition method, specifically, a relationship graph is created from the feature map obtained by segmenting the text instances, the spatial semantic information of the text is expressed in a graph structure, and the relationship graph is subjected to graph convolution processing to extract two-dimensional spatial feature information of the text to be recognized in the image, and the order relationship between each character instance is matched to realize the recognition of the text to be recognized in the image.
[0124] Reference is now made to Fig. 4, which illustrates a flow 400 of a further embodiment of a method for recognizing text according to the present disclosure. This method for recognizing text includes the following steps:
[0125] In step 401, a feature map is obtained by performing text instance segmentation on an image having text to be recognized.
[0126] In step 402, a relationship graph is created based on the feature map.
[0127] In step 403, the relationship graph is processed using a pre-trained graph convolutional network to obtain a first text feature corresponding to the image.
[0128] In step 404, the feature map is processed using a pre-trained language model to obtain second text features corresponding to the image.
[0129] In this embodiment, the language model may be various conventional language models for text recognition, such as N-Gram model, HMM (Hidden Markov Model), BERT (Bidirectional Encoder Representations from Transformers), etc. In general, the feature representation of the string generated by the language model before the output layer may be selected as the second text feature.
[0130] Optionally, a pre-trained semantic feature extraction network can be used to process the feature map to obtain semantic features corresponding to the feature map. The semantic features are then input into the language model to obtain the second text features, where the semantic feature extraction network can adopt the structure of various conventional feature extraction networks.
[0131] For example, the semantic feature extraction network may include a pooling layer that pools feature maps and a linear layer that linearly transforms the output of the pooling layer. Specifically, the input feature map is first pooled, and the pooling result is linearly transformed to reduce the resolution of the image space and generate semantic features.
[0132] The language model may adopt the structure of various conventional natural language processing-based models, such as translation models, which achieve text recognition by predicting the semantics of each character instance using several character instances before and after it.
[0133] In step 405, a text recognition result for the image is generated based on the first text feature and the second text feature.
[0134] In this embodiment, the first text feature and the second text feature can be combined to generate the text recognition result of the image in various ways, for example, by adopting various conventional feature fusion methods to fuse the first text feature and the second text feature to obtain a fused text feature, and then recognizing the fused text feature to obtain the recognition result.
[0135] Because the text recognition process of the language model uses one-dimensional compressed feature information and ignores feature information in two-dimensional space, combining the graph-based text recognition method with the language model-based text recognition method enables more reliable text recognition using richer feature information.
[0136] Some optional embodiments of this embodiment generate text recognition results for the image based on the first text feature, the second text feature and the feature map.
[0137] Since the feature map itself can represent the image features of the text to be recognized, when performing text recognition using the first text feature and the second text feature, by combining it with the feature map obtained by segmenting the text instance, the expressiveness of the text features can be further enhanced, and the text recognition effect can be improved.
[0138] The specific recognition method may be flexibly set according to the actual application needs. For example, various conventional feature fusion methods can be used to fuse the first text feature, the second text feature and the feature map, and then the fused features can be used to predict the text recognition result.
[0139] Optionally, the first text feature, the second text feature, and the feature map can be input into a pre-trained feature fusion network to generate text recognition results for the image.
[0140] Here, the feature fusion network can be used to splice the first text feature, the second text feature and the feature map, and then linearly transform the obtained splicing result to obtain the text recognition result of the image. The structure of the feature fusion network may be preset by the engineer.
[0141] As an example, the processing process of the feature fusion network is shown in the following equation:
[0142]
number
[0143] where f t represents the fusion result of the feature fusion network. t, l t and g t W represents the feature map, the second text feature, and the first text feature, respectively. z and W f represents the linear transformation parameters that the feature fusion network aims to learn.
[0144]
number
[0145] represents multiplication between elements. ";" represents splicing by dimension. Sigmod is the activation function. t represents the quantity of feature maps obtained by performing text instance segmentation on images with text to be recognized.
[0146] In addition, since the feature map has an order relationship and the first text feature and the second text feature are also feature representations of character strings generated based on such an order relationship, each time fusion is performed, corresponding character features in the feature map, the second text feature, and the first text feature are fused to obtain the final fusion result.
[0147] In addition, since there is a contextual order relationship between corresponding character instances, there is also a contextual order relationship between feature maps. However, in the present disclosure, in the process of processing the feature maps, character instances corresponding to each feature map can be recognized in parallel, thereby improving processing efficiency.
[0148] For the contents not specifically described in this embodiment, reference may be made to the relevant description of the corresponding embodiment in FIG. 2, and the description thereof will be omitted here.
[0149] Continue to refer to Figure 5A, Figure 5B and Figure 5C, which are schematic diagrams of an exemplary application scene of the method for recognizing text according to the present embodiment. Specifically, as shown in Figure 5A, firstly obtain an image having text to be recognized, i.e., a text image, and then input the text image into a pre-trained convolutional network to extract an initial feature map, and then input the initial feature map into a text instance segmentation network and a text order segmentation network respectively to extract an instance feature map and an order feature map, and the obtained instance feature map and order feature map can be fused to form a plurality of feature maps corresponding to the text image.
[0150] Then, a relationship graph is created from the obtained feature maps, and the created relationship graph is processed using a pre-trained graph convolutional network to obtain a first text feature of the text image. At the same time, the obtained feature maps are processed using a language model to obtain a second text feature of the text image. Then, the obtained feature maps, the first text feature, and the second text feature are integrated to perform text recognition, and a text recognition result corresponding to the text image is obtained.
[0151] For the process of processing the obtained feature maps using a graph convolutional network and a language model, you may refer to Figure 5B. Specifically, first create a relationship subgraph corresponding to each feature map, then merge each relationship subgraph to obtain a relationship graph, and process the merged relationship graph using a graph convolutional network to obtain feature representations of nodes in the relationship graph. At the same time, first input the feature maps into a semantic feature extraction network to extract semantic features, and then use a translation model to form a feature representation of a string corresponding to the text to be recognized according to the semantic features.
[0152] Then, in order to fuse the feature representations of the nodes in the obtained relationship graph with the feature representations of the strings, a linear layer is used to perform processing such as dimensional conversion, and the feature representations of the nodes in the relationship graph and the feature representations of the strings are fused, and a text recognition result for the character image is generated from the fusion result.
[0153] For each feature map, the specific process of creating a corresponding relationship subgraph may refer to FIG. 5C. Specifically, first, the order feature of the feature map and the position feature and category feature of each pixel point in the feature map can be determined. Then, the order feature and the position feature are fused to form a vector representation of each node by a method such as mapping, thereby obtaining a feature matrix of the relationship subgraph consisting of the vector representation of each node. At the same time, the similarity between the nodes indicated by each pixel point is determined based on the category feature, and neighboring nodes are searched for for each node based on the similarity between the nodes to create edges, thereby forming an adjacency matrix of the relationship subgraph. After that, the obtained feature matrix and adjacency matrix are used to determine the feature matrix. Signature We can roughly represent the corresponding relationship subgraph.
[0154] The method provided by the above embodiment of the present disclosure allows the two recognition methods to learn from each other through dynamic fusion of the graph-based text recognition method and the language model-based text recognition method, and utilizes more information to perform text recognition, thereby improving the text recognition effect and better adapting to various character recognition situations such as complex background of images, uneven lighting, blurred images, and diversified character forms in text recognition of natural scenes. The method described in the above embodiment of the present disclosure can be applied to assist text recognition in real business scenarios such as navigation for visual impairments, automatic driving, and text reading and translation in augmented reality. Other real business scenarios to which the method in the embodiment of the present disclosure can be applied are not listed in this specification.
[0155] Next, reference is made to Fig. 6, which illustrates a flow 600 of an embodiment of a method for training a graph convolutional network, a language model, and a segmentation network in a method for recognizing text according to the present disclosure. As shown in Fig. 6, the graph convolutional network, the language model, and the segmentation network can be trained by the following steps.
[0156] In step 601, a labeled training data set and an unlabeled training data set are obtained.
[0157] In this embodiment, the training of the graph convolutional network, the language model, and the segmentation network may be performed by an executing entity of the above-mentioned method for recognizing text, or may be performed by other electronic devices. The executing entity that trains the graph convolutional network, the language model, and the segmentation network may obtain the labeled training data set and the unlabeled training data set from a local or other storage device.
[0158] Here, a labeled training dataset consists of labeled training data, and an unlabeled training dataset consists of unlabeled training data. A labeled training dataset may include labels with different granularity. For example, for character text recognition, the labels may include character set labels and word-level labels.
[0159] In step 602, a teacher-student network corresponding to the graph convolutional network, the language model, and the segmentation network is constructed, and the teacher-student network is trained using a labeled training dataset, an unlabeled training dataset, and a preset loss function.
[0160] In this embodiment, the teacher-student network is the network structure in transfer learning. The structures of the teacher network and the student network can be exactly the same or different. When the structures of the teacher network and the student network are the same, the parameter sharing of the structures of the teacher network and the student network can be realized based on the technology of EMA (such as exponential moving average).
[0161] In this embodiment, the input to the student network may include labeled training data and unlabeled training data, and the input to the teacher network may include only unlabeled training data. The loss function may include a first loss function, a second loss function, and a third loss function.
[0162] Here, the first loss function and the second loss function can respectively represent the difference between the output result of the student network on the labeled training data and the label of different granularity. For example, the first loss function can be used to determine the difference between the character-level recognition result output by the student network and the actual character-level label, and the second loss function can be used to determine the difference between the word-level recognition result output by the student network and the actual word-level label.
[0163] The third loss function can represent the difference in output results between the student network and the teacher network for the unlabeled training data, respectively. Specifically, the first loss function, the second loss function, and the third loss function (e.g., optimizing the sum of the three loss functions) can be combined to adjust the parameters of the graph convolutional network, the language model, and the segmentation network to complete the training of the graph convolutional network, the language model, and the segmentation network.
[0164] Note that the training of the various networks or models in this disclosure can all be achieved using various conventional machine learning training methods, and therefore will not be described here.
[0165] The training method for the graph convolutional network, the language model and the segmentation network provided by the above embodiments of the present disclosure uses labeled training data and unlabeled training data to jointly train the graph convolutional network, the language model and the segmentation network, thereby solving problems such as a lack of real training data and difficulty in labeling real data, and can improve the generalization and robustness of the entire network composed of the graph convolutional network, the language model and the segmentation network, thereby helping to improve the accuracy of text recognition results.
[0166] Further referring to FIG. 7, as an embodiment of the method shown in each of the above figures, the present disclosure provides an embodiment of an apparatus for recognizing text, which embodiment of the apparatus corresponds to the embodiment of the method shown in FIG. 2, and which can be specifically applied to various electronic devices.
[0167] As shown in FIG. 7, the apparatus 700 for recognizing text according to the present embodiment includes a feature map acquisition unit 701, a relationship graph creation unit 702, a graph convolution processing unit 703, and a recognition unit 704. The feature map acquisition unit 701 is configured to acquire a feature map by performing text instance segmentation for an image having text to be recognized. The relationship graph creation unit 702 is configured to create a relationship graph based on the feature map. A node in the relationship graph represents a pixel point of the feature map, and an edge represents that the similarity of spatial semantic features of two connected nodes is greater than a target threshold, and the spatial semantic features include a location feature and a category feature of the pixel point indicated by the node. The graph convolution processing unit 703 is configured to process the relationship graph by a pre-trained graph convolution network to acquire a first text feature corresponding to the image. The recognition unit 704 is configured to generate a text recognition result for the image based on the first text feature.
[0168] In this embodiment, the specific processing of the feature map acquisition unit 701, the relationship graph creation unit 702, the graph convolution processing unit 703, and the recognition unit 704 in the apparatus for recognizing text 700 and the technical effects achieved thereby may refer to the relevant descriptions of steps 201, 202, 203, and 204 in the corresponding embodiment of FIG. 2, and the description thereof will be omitted here.
[0169] In some optional embodiments of this embodiment, the apparatus 700 for recognizing text further includes a language model processing unit (not shown) configured to process the feature map by a pre-trained language model to obtain second text features corresponding to the image, and the recognition unit 704 is further configured to generate a text recognition result for the image based on the first text features and the second text features.
[0170] In some optional embodiments of this embodiment, the recognition unit 704 is further configured to generate a text recognition result for the image based on the first text feature, the second text feature and the feature map.
[0171] In some optional embodiments of this embodiment, the feature maps are at least two feature maps, and the relationship graph creation unit 702 is further configured to: for a feature map of the at least two feature maps, create a relationship sub-graph corresponding to the feature map, and merge the relationship sub-graphs corresponding to each of the feature maps to obtain a relationship graph.
[0172] In some optional embodiments of this embodiment, one of the at least two feature maps is used to represent image features of the image region in which each character in the text to be recognized is located, and order features among the other feature maps.
[0173] In some optional embodiments of this embodiment, the feature map is generated by the steps of inputting the image into a pre-trained convolutional neural network to obtain an initial feature map, performing text instance segmentation on the initial feature map to obtain an instance feature map, performing text order segmentation on the initial feature map to obtain an order feature map, and fusing the instance feature map and the order feature map to perform text instance segmentation on the image having the text to be recognized to obtain a feature map.
[0174] In some optional embodiments of this embodiment, the convolutional neural network is realized based on a feature pyramid network and a residual network, where the stride of at least one convolutional layer before the output layer of the residual network is 1, and the feature map output by the residual network generates the input feature map of the feature pyramid network through deformable convolution.
[0175] In some optional embodiments of this embodiment, the language model processing unit is further configured to: process the feature map with a pre-trained semantic feature extraction network to obtain semantic features corresponding to the feature map, the semantic feature extraction network including a pooling layer that pools the feature map and a linear layer that linearly transforms an output of the pooling layer; and input the semantic features into a language model to obtain second text features.
[0176] In some optional embodiments of this embodiment, the spatial semantic feature further includes an order feature of a feature map in which a pixel point indicated by the node is located. For a node in the relation subgraph, the spatial semantic feature of the node is generated by: obtaining order values in at least two feature maps of the feature maps corresponding to the node, determining order features of the feature maps corresponding to the node according to the order values, and splicing the location feature, the category feature and the determined order feature of the pixel point indicated by the node to obtain the spatial semantic feature of the node.
[0177] In some optional embodiments of this embodiment, the similarity of spatial semantic features of two nodes is determined by the steps of determining a Euclidean distance between the two nodes and determining a first similarity based on the determined Euclidean distance, determining a cosine similarity of categorical features corresponding to each of the two nodes, and determining a similarity of spatial semantic features of the two nodes based on the first similarity and the cosine similarity.
[0178] In some optional embodiments of this embodiment, the relationship graph creating unit 702 is further configured to sequentially connect the root nodes of adjacent relationship subgraphs according to an order relationship between each relationship subgraph.
[0179] In some optional embodiments of this embodiment, the root node of the feature map is determined by: determining, for a node in the feature map, a Jaccard coefficient (IoU, Intersection over Union) between the node and each of the other nodes, where the Jaccard coefficient represents the ratio of the number of elements in the intersection of the neighboring nodes of two nodes to the number of elements in the union of the neighboring nodes; and determining that the node is a root node in response to determining that each of the corresponding Jaccard coefficients of the node is not greater than a predetermined threshold.
[0180] In some optional embodiments of this embodiment, the graph convolution network includes a first graph convolution network and an output network, where the first graph convolution network is used to transform the feature matrix of the relationship graph, and the output network is used to select nodes from each relationship subgraph respectively according to the output of the first graph convolution network, and aggregate transformed features corresponding to the selected nodes from each relationship subgraph respectively to obtain first text features.
[0181] In some optional embodiments of this embodiment, the first graph convolution network includes a first graph convolution sub-network for transforming a feature matrix of a relationship graph, and a second graph convolution sub-network for transforming a feature matrix output from the first graph convolution sub-network based on a relationship graph created based on an output of the first graph convolution sub-network.
[0182] In some optional embodiments of this embodiment, the recognition unit 704 is further configured to input the first text feature, the second text feature and the feature map into a pre-trained feature fusion network to generate a text recognition result for the image, splice the first text feature, the second text feature and the feature map by the feature fusion network, and perform a linear transformation on the obtained splicing result to obtain a text recognition result for the image.
[0183] In some optional embodiments of this embodiment, the step of performing text instance segmentation on the initial feature map to obtain the instance feature map includes performing text instance segmentation on the initial feature map by a pre-trained text instance segmentation network to obtain the instance feature map. The step of performing text order segmentation on the initial feature map to obtain the order feature map includes performing text order segmentation on the initial feature map by a pre-trained text order segmentation network to obtain the order feature map. The graph convolution network, the language model, and the segmentation network are trained by the following training steps: the segmentation network includes a convolutional neural network, a text instance segmentation network, and a text order segmentation network. The training step includes obtaining a labeled training dataset and an unlabeled training dataset, which are training data including labels of different granularities, and constructing a teacher-student network corresponding to the graph convolution network, the language model, and the segmentation network, and training the teacher-student network using the labeled training dataset, the unlabeled training dataset, and a preset loss function. The input of the student network includes labeled training data and unlabeled training data. The input of the teacher network includes unlabeled training data. The loss function includes a first loss function, a second loss function, and a third loss function. The first loss function and the second loss function respectively represent the difference between the output result of the student network on the labeled training data and the labels of different granularities, and the third loss function represents the difference between the output result of the student network on the unlabeled training data and the output result of the teacher network on the unlabeled training data.
[0184] In the device provided by the above embodiment of the present disclosure, the feature map acquisition unit acquires a feature map by performing text instance segmentation for an image having text to be recognized. The relationship graph creation unit creates a relationship graph based on the feature map. A node in the relationship graph represents a pixel point of the feature map, and an edge represents that the similarity of the spatial semantic features of two connected nodes is greater than a target threshold, and the spatial semantic features include the location feature and the category feature of the pixel point indicated by the node. The graph convolution processing unit processes the relationship graph by a pre-trained graph convolution network to obtain a first text feature corresponding to the image. The recognition unit generates a text recognition result for the image based on the first text feature. Thereby, graph-based text recognition is realized, and such a manner can take into account the two-dimensional spatial information of the text in the image, which is helpful to improve the text recognition effect.
[0185] Hereinafter, reference will be made to FIG. 8, which is a structural schematic diagram showing an electronic device (e.g., the server shown in FIG. 1) 800 applied to realize the embodiment of the present application. The terminal device in the embodiment of the present disclosure includes, but is not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (tablet computers), PMPs (portable multimedia players), and in-vehicle terminals (e.g., car navigation terminals), as well as fixed terminals such as digital TVs and desktop computers. The server shown in FIG. 8 is merely an example and does not limit the functions and scope of use of the embodiment of the present disclosure.
[0186] 8, the electronic device 800 may include a processing unit (e.g., a central processing unit, a graphics processor, etc.) 801 capable of performing various suitable operations and processes according to programs stored in a read-only memory (ROM) 802 or programs loaded from a storage device 808 into a random access memory (RAM) 803. The RAM 803 further stores various programs and data necessary for the operation of the electronic device 800. The processing unit 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0187] Typically, the following devices may be connected to the I / O interface 805: input devices 806 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; output devices 807 including, for example, a liquid crystal display (LCD), speakers, vibrators, etc.; storage devices 808 including, for example, a magnetic tape, hard disk, etc.; and communication devices 809. The communication devices 809 allow the electronic device 800 to communicate wirelessly or wired with other devices to exchange data. Although FIG. 8 illustrates the electronic device 800 having various devices, it should be understood that it is not required to implement or include all of the devices illustrated. Optionally, more or less devices may be implemented. Each block illustrated in FIG. 8 may represent one device or multiple devices as desired.
[0188] In particular, according to embodiments of the present disclosure, the processes described with reference to the flowcharts above may be implemented as a computer software program. For example, embodiments of the present disclosure may be implemented as a computer program embodied in a computer readable medium. MThe computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication device 809, or may be installed from the storage device 808 or the ROM 802. When the computer program is executed by the processing device 801, it performs the above-mentioned functions defined in the method of the embodiment of the present disclosure.
[0189] It should be noted that the computer-readable medium described in the embodiments of the present disclosure may be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. The computer-readable storage medium may be, for example, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of the computer-readable storage medium may include, but are not limited to, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical memory, a magnetic memory, or any suitable combination thereof, electrically connected by one or more conductors. In the embodiments of the present disclosure, the computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by, or that can be embedded in, an instruction execution system, apparatus, or device. In the embodiments of the present disclosure, the computer-readable signal medium may include a data signal in baseband or propagated as part of a carrier wave, in which computer-readable program code is carried. Such a propagated data signal may take various forms, including, but not limited to, an electromagnetic signal, an optical signal, or any suitable combination thereof. The computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium. The computer-readable signal medium may transmit, propagate, or transmit a program used by or embedded in an instruction execution system, apparatus, or device. The program code contained in the computer-readable medium may be transmitted by any suitable medium, including, but not limited to, an electrical wire, an optical cable, RF (radio frequency), or the like, or any suitable combination thereof.
[0190] The computer-readable medium may be included in the electronic device or may be separate from the electronic device. The computer-readable medium carries one or more programs, which, when executed by the electronic device, causes the electronic device to perform the following steps: obtaining a feature map by performing text instance segmentation on an image having text to be recognized, creating a relationship graph based on the feature map, where nodes in the relationship graph represent pixel points of the feature map and edges represent spatial-semantic feature similarities between two connected nodes that are greater than a target threshold, and the spatial-semantic features include location features and category features of the pixel points indicated by the nodes; processing the relationship graph by a pre-trained graph convolutional network to obtain first text features corresponding to the image; and generating a text recognition result for the image based on the first text features.
[0191] Computer program code for carrying out the operations of the embodiments of the present disclosure can be written in one or more programming languages, or combinations thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and traditional procedural programming languages such as "C" or similar programming languages. The program code can run entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (e.g., via an Internet service provided by an Internet service provider).
[0192] The flowcharts and block diagrams in the drawings are examples of representations of architecture, functions and operations that can be realized by the systems, methods and computer programs according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagram may represent a module, a program segment, or a portion of code. The module, program segment, or portion of code includes one or more executable instructions for implementing a certain logic function. It is to be noted that in some alternative embodiments, the functions shown in the blocks may be executed in a different order than that shown in the drawings. For example, two blocks shown in succession may actually be executed substantially in parallel or may sometimes be executed in the reverse order, depending on the function involved. It should be further noted that all blocks in the block diagrams and / or flowcharts, as well as combinations of blocks in the block diagrams and / or flowcharts, may be implemented in a dedicated hardware-based system that executes a certain function or operation, or may be implemented in a combination of dedicated hardware and computer instructions.
[0193] The units described in the embodiments of the present disclosure may be implemented in software or hardware. The described units may be provided in a processor, and may be described, for example, as "a processor including a feature map acquisition unit, a relationship graph creation unit, a graph convolution processing unit, and a recognition unit." Here, the names of these units do not limit the units themselves in some cases, and for example, the feature map acquisition unit may be described as "a unit for acquiring a feature map by performing text instance segmentation on an image having text to be recognized."
[0194] The above description is merely a description of the preferred embodiments of the present disclosure and the technical principles applied thereto. Those skilled in the art should understand that the scope of the present disclosure is not limited to the technical solution consisting of a specific combination of the above-mentioned technical features, but should also include other technical solutions consisting of any combination of the above-mentioned technical features or their equivalent features within the scope of the above-mentioned disclosure. For example, the above features may be substituted with technical features having similar functions (but are not limited to these) disclosed in the embodiments of the present disclosure. [Explanation of symbols]
[0195] 100 System Architecture 101 Terminal Equipment 102 Terminal Equipment 103 Terminal Equipment 104 Network 105 Server 200 Flow 201 Steps 202 Steps 203 Steps 204 Steps 300 Flowchart 301 Steps 302 Steps 303 Steps 304 Steps 400 Flow 401 Steps 402 Steps 403 Step 404 Step 405 Steps 600 Flow 601 Steps 602 Steps 700 equipment 701 Feature Map Acquisition Unit 702 Relational Graph Creation Unit 703 Processing Unit 704 Recognition Unit 800 Electronic equipment 801 Processing equipment 802 Dedicated memory (ROM) 803 Random Access Memory (RAM) 804 Bus 805 I / O Interface 806 Input Device 807 Output Device 808 Storage device 809 Communication Equipment
Claims
1. 1. A method for recognizing text, comprising: - obtaining a feature map by performing text instance segmentation on an image having text to be recognized; creating a relationship graph based on the feature map, in which a node in the relationship graph represents a pixel point of the feature map, and an edge represents a similarity between spatial and semantic features of two connected nodes that is greater than a target threshold, and the spatial and semantic features include location features and category features of the pixel points represented by the nodes; processing the relationship graph with a pre-trained graph convolutional network to obtain first text features corresponding to the image; generating a text recognition result for the image based on the first text features; A method for recognizing text that includes
2. The method further includes processing the feature map with a pre-trained language model to obtain second text features corresponding to the image; generating a text recognition result for the image based on the first text feature comprises generating a text recognition result for the image based on the first text feature and the second text feature. The method of claim 1.
3. 3. The method of claim 2, wherein generating a text recognition result for the image based on the first text features and the second text features comprises generating a text recognition result for the image based on the first text features, the second text features and the feature map.
4. The feature map is at least two feature maps, The step of creating a relationship graph based on the feature maps includes the steps of: creating, for a feature map of the at least two feature maps, a relationship sub-graph corresponding to the feature map; and merging the relationship sub-graphs corresponding to each respective feature map to obtain the relationship graph.
5. 5. The method of claim 4, wherein a feature map of the at least two feature maps is used to represent image features of an image region in which each character in the text to be recognized is located, and order features among other feature maps.
6. The feature map is inputting the image into a pre-trained convolutional neural network to obtain an initial feature map; performing text instance segmentation on the initial feature map to obtain an instance feature map; performing text sequence segmentation on the initial feature map to obtain an order feature map; - fusing the instance feature map and the ordinal feature map to obtain a feature map obtained by performing text instance segmentation on an image having the text to be recognized; The method of claim 5 , wherein the compound is produced by
7. The convolutional neural network is realized based on a feature pyramid network and a residual network; At least one convolutional layer before the output layer of the residual network has a stride of 1; The method of claim 6 , wherein the feature maps output by the residual network generate input feature maps for the feature pyramid network through deformable convolution.
8. processing the feature map with a pre-trained language model to obtain second text features corresponding to the image, processing the feature map through a pre-trained semantic feature extraction network to obtain semantic features corresponding to the feature map, the semantic feature extraction network including a pooling layer for pooling the feature map and a linear layer for linearly transforming an output of the pooling layer; inputting the semantic features into the language model to obtain the second text features; 3. The method of claim 2 comprising:
9. The spatial semantic features further include an order feature of a feature map in which a pixel point represented by the node is located; For a node in the relation subgraph, the spatial semantic feature of the node is obtaining an order value in the at least two feature maps for a feature map corresponding to the node; determining an ordinal feature of a feature map corresponding to the node in response to the ordinal value; splicing the location feature, the category feature and the determined order feature of the pixel point indicated by the node to obtain a spatial semantic feature of the node; The method of claim 4 , wherein the compound is produced by
10. The similarity of spatial semantic features of two nodes is determining a Euclidean distance between two nodes and determining a first similarity measure based on the determined Euclidean distance; determining a cosine similarity between categorical features corresponding to each of the two nodes; determining a similarity of spatial semantic features of two nodes based on the first similarity and the cosine similarity; The method of claim 4, wherein the
11. The method of claim 4 , wherein the step of merging the relation subgraphs corresponding to each of the feature maps includes the step of sequentially connecting the root nodes of adjacent relation subgraphs according to an order relationship between the relation subgraphs.
12. The root node of the feature map is For a node in the feature map, determining a Jaccard coefficient between the node and each other node, the Jaccard coefficient representing the ratio of the number of elements in the intersection of the two nodes' neighbors to the number of elements in the union of the neighbors; determining that the node is a root node in response to determining that each corresponding Jaccard coefficient of the node is not greater than a preset threshold; The method of claim 11 , wherein the
13. the graph convolution network includes a first graph convolution network and an output network; a first graph convolution network is used to transform the feature matrix of the relationship graph; 5. The method of claim 4, wherein an output network is used to select a node from each relation subgraph respectively according to an output of the first graph convolution network, and to obtain the first text features by aggregating transformed features corresponding to the respectively selected nodes from each relation subgraph.
14. The first graph convolutional network comprises: a first graph convolution sub-network for transforming a feature matrix of the relationship graph; a second graph convolution sub-network for transforming a feature matrix output from the first graph convolution sub-network based on a relationship graph created based on an output of the first graph convolution sub-network; 14. The method of claim 13, comprising:
15. generating a text recognition result for the image based on the first text feature, the second text feature, and the feature map, 4. The method of claim 3, comprising inputting the first text feature, the second text feature and the feature map into a pre-trained feature fusion network to generate a text recognition result for the image, splicing the first text feature, the second text feature and the feature map by a feature fusion network, and performing a linear transformation on the obtained splicing result to obtain the text recognition result for the image.
16. performing text instance segmentation on the initial feature map to obtain an instance feature map includes performing text instance segmentation on the initial feature map by a pre-trained text instance segmentation network to obtain an instance feature map; performing text order segmentation on the initial feature map to obtain an ordinal feature map includes performing text order segmentation on the initial feature map by a pre-trained text order segmentation network to obtain an ordinal feature map; The graph convolutional network, the language model and the segmentation network are trained by the following training steps: the segmentation network includes the convolutional neural network, a text instance segmentation network, and a text order segmentation network; The training step includes: Obtaining a labeled training dataset and an unlabeled training dataset, the labeled training dataset being training data including labels with different granularities; constructing a teacher-student network corresponding to the graph convolutional network, the language model, and the segmentation network, and training the teacher-student network using the labeled training dataset, the unlabeled training dataset, and a pre-defined loss function; The inputs of the student network include labeled and unlabeled training data, The inputs of the teacher network include unlabeled training data, the loss function includes a first loss function, a second loss function, and a third loss function; The first loss function and the second loss function respectively represent the difference between the output results for the labeled training data from the student network and the labels with different granularities; The third loss function represents the difference between the output results for the unlabeled training data from the student network and the output results for the unlabeled training data from the teacher network. The method according to claim 6.
17. 1. An apparatus for recognizing text, comprising: a feature map obtaining unit configured to obtain a feature map by performing text instance segmentation on an image having text to be recognized; a relationship graph creation unit configured to create a relationship graph based on the feature map, in which a node in the relationship graph represents a pixel point of the feature map, and an edge represents a similarity of spatial-semantic features of two connected nodes that is greater than a target threshold, and the spatial-semantic features include a location feature and a category feature of the pixel point indicated by the node; a graph convolution processing unit configured to process the relationship graph through a pre-trained graph convolution network to obtain first text features corresponding to the image; a recognition unit configured to generate a text recognition result for the image based on the first text features; An apparatus for recognizing text comprising:
18. An electronic device comprising one or more processors and a storage device storing one or more programs, An electronic device, wherein said one or more programs, when executed by said one or more processors, cause said one or more processors to implement the method of any one of claims 1 to 16.
19. A computer readable medium having stored thereon a computer program which, when executed by a processor, implements the method according to any one of claims 1 to 16.
20. A computer program which, when executed by a processor, implements the method according to any one of claims 1 to 16.
Citation Information
Patent Citations
Text sequence recognition method and device, electronic equipment and storage medium
CN110659640A
Character recognition method and device and electronic equipment
CN111414913A
