Text image super-resolution reconstruction method based on text assistance
By introducing a gated text detection module and a convolution block attention mechanism into text image super-resolution reconstruction, combined with the text auxiliary loss function, the problem of low accuracy in low-resolution text image recognition is solved and high-quality text images are achieved. Super-resolution reconstruction and readability improvement.
Patent Information
- Application Number
- PCT/CN2023/122653
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-03-15
- Filing Date
- 2023-09-28
- Publication Date
- 2024-09-19
AI Technical Summary
The accuracy of existing technology decreases when recognizing low-resolution text images, and traditional super-resolution algorithms ignore the classification information in text images, making it difficult to simultaneously improve image resolution and text readability.
A text-assisted text image super-resolution reconstruction method is adopted, by replacing the residual module in the deep residual network with a gated text detection module, adding a convolutional block attention module and multiple gated text detection modules, combined with sub-pixel The convolutional upsampling layer and Tanh activation layer propose a text-assisted loss function to fuse image and text features to improve the quality of super-resolution reconstruction.
It improves the quality and readability of text image super-resolution reconstruction, enhances the model's ability to focus on text parts, and improves the accuracy of text recognition.
Smart Images

Figure CN2023122653_19092024_PF_FP_ABST
Abstract
Description
A text-assisted text image super-resolution reconstruction method Technical Field
[0001] The invention relates to a text-assisted text image super-resolution reconstruction method, belonging to the technical field of image processing. Background Art
[0002] Images are important carriers of information, and image processing technology is a crucial component of information processing. Image resolution is a crucial factor in image processing. Image resolution influences the difficulty and visual quality of visual tasks. High-resolution images provide clearer details and greater clarity, facilitating analysis, decision-making, and visual experience. However, acquiring high-resolution images often requires expensive image acquisition equipment. Image super-resolution reconstruction technology is a practical and effective solution to this problem.
[0003] Image super-resolution involves reconstructing a low-resolution image into a high-resolution one using a specific algorithm. Image super-resolution reconstructs the high-resolution image solely through computer processing, reducing the additional cost of high-precision image acquisition equipment. Super-resolution technology can also minimize image degradation caused by poor image acquisition or compression during transmission. Therefore, research on image super-resolution algorithms is of great significance.
[0004] Traditional image super-resolution algorithms can be categorized into two types: interpolation-based and reconstruction-based. With the rapid development of deep learning in recent years, image super-resolution algorithms have also begun to be closely integrated with deep learning. The key idea behind deep learning-based image super-resolution algorithms is to train a neural network model using high-resolution and low-resolution images to characterize the mapping relationship between the two. Deep residual networks, in particular, extract features from images using multiple residual modules. Skip-links are used to connect the network input to the output to ensure overall network stability and reduce the difficulty of convergence during training.
[0005] Text recognition is one of the most fundamental and important tasks in computer vision, providing the foundation for subsequent text-related applications. Existing text recognizers achieve satisfactory results on clear scene text images. However, recognition accuracy drops sharply when recognizing low-resolution text images.
[0006] Summary of the Invention
[0007] Objective: To overcome the shortcomings of the existing technology, the present invention provides a text-assisted text image super-resolution reconstruction method, which can use the super-resolution of text images as a preprocessing task for text recognition, thereby improving the accuracy of text recognition.
[0008] Technical solution: To solve the above technical problems, the technical solution adopted by the present invention is:
[0009] In a first aspect, the present invention provides a text-assisted text image super-resolution reconstruction method, comprising:
[0010] Obtain a low-resolution text image to be reconstructed;
[0011] Inputting the low-resolution text image into a pre-trained text image super-resolution reconstruction model, and determining a text image super-resolution reconstruction result based on an output of the model;
[0012] The method for constructing and training the text image super-resolution reconstruction model includes:
[0013] Get text image dataset;
[0014] The pre-built text image super-resolution reconstruction model is trained using the text image dataset to obtain a trained text image super-resolution reconstruction model.
[0015] In some embodiments, inputting the low-resolution text image into a pre-trained text image super-resolution reconstruction model, and determining a text image super-resolution reconstruction result based on an output of the model, includes:
[0016] The RGB image and grayscale image corresponding to the low-resolution text image are used as four-channel image input. The shallow features are first extracted through a convolution layer with a 3*3 convolution kernel and a ReLU activation layer to obtain the first feature map.
[0017] The first feature map is input into the convolution block attention module to obtain the channel and spatial attention weights of the image, and a feature map with attention weights is obtained;
[0018] The feature map with attention weights is extracted through multiple gated text detection modules to obtain text sequence features;
[0019] Perform a skip-layer connection between the text sequence features output by the gated text detection module and the first feature map, and add them together to obtain a new feature map;
[0020] The new feature map is input into the sub-pixel convolution upsampling layer and the Tanh activation layer to obtain the output super-resolution reconstructed four-channel text image.
[0021] In some embodiments, a method for constructing a text image super-resolution reconstruction model includes:
[0022] The residual module in the deep residual network is replaced by the gated text detection module, and a convolutional block attention module is added before the gated text detection module.
[0023] In some embodiments, the processing process of the convolutional block attention module is:
[0024] The channel and spatial attention weights of the image are inferred along the channel and spatial dimensions of the first feature map of the input, and then multiplied with the first feature map of the input to achieve adaptive adjustment of the features and obtain a feature map with attention weights.
[0025] In some embodiments, the gated text detection module extracts image features by passing the feature map through two convolution layers with a convolution kernel of 3*3 and a BN layer in sequence, and then uses the LSTM module to extract horizontal text features and vertical text features from the horizontal and vertical directions respectively. The image features, horizontal text features and vertical text features are fused through the gated feature fusion method and input into the next gated text detection module.
[0026] In some embodiments, the formula for gated feature fusion is:
[0027] Where n represents the number of features, W i represents the trainable weights, F i represents the input feature, F g Represents the weighted features of the output.
[0028] In some embodiments, the loss function used in the training process of the text image super-resolution reconstruction model is: L = L2 + αL TA
[0029] Among them, L2 is the mean square error loss function, L TA is the text-assisted loss function, and α is the hyperparameter of the ratio of the two loss functions;
[0030] The formula for the mean square error loss function is:
[0031] Where MSE stands for mean square error, x and y represent two images of size M×N, and x ij ,y ij Indicates the value of a pixel;
[0032] The formula of the text-assisted loss function is:
[0033] Among them, I HR represents the original high-resolution text image, I SR represents the super-resolution text image generated by the network, Represents the one-dimensional vector generated by the pre-trained text recognition network encoder for the image, and ||·||2 represents the 2-norm.
[0034] In some embodiments, during the training process, the super-resolution image generated by the text image super-resolution reconstruction model and the corresponding original high-resolution image are respectively input into the encoder of the pre-trained text recognition network model to obtain the corresponding one-dimensional recognition sequence, and the similarity of the text content of the two images is measured by the similarity of the two text image recognition sequences.
[0035] In a second aspect, the present invention provides a text-assisted text image super-resolution reconstruction device, comprising a processor and a storage medium;
[0036] The storage medium is used to store instructions;
[0037] The processor is configured to operate according to the instructions to execute the steps of the method according to the first aspect.
[0038] In a third aspect, the present invention provides a storage medium having a computer program stored thereon, which implements the steps of the method described in the first aspect when executed by a processor.
[0039] In a fourth aspect, the present invention provides a device comprising:
[0040] One or more processors, one or more memories, and one or more programs, wherein the one or more programs are stored in the one or more memories and configured to be executed by the one or more processors, and the one or more programs include instructions for executing any of the methods described in the first aspect.
[0041] Beneficial effects: The text-assisted text image super-resolution reconstruction method provided by the present invention has the following advantages:
[0042] 1. The text image super-resolution model disclosed in the present invention introduces an attention mechanism to assign different weights to feature maps. Compared with other common text image super-resolution models, the super-resolution and subsequent text detection can better focus on the text part, thereby improving the reconstruction quality of the model.
[0043] 2. The text image super-resolution model disclosed in the present invention integrates text sequence features with image texture features. Compared with other common super-resolution models, it fully mines and utilizes the text information in low-resolution images, which helps to improve the super-resolution reconstruction quality of text images.
[0044] 3. In a further technical solution of the present invention, a text-assisted loss is proposed. Compared with the original loss function, the text-assisted loss reflects both the text content and resolution of the text image, which helps to generate high-resolution text images with better readability. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] FIG1 is a flow chart of a method for text image super-resolution reconstruction based on text assistance according to an embodiment of the present invention;
[0046] FIG2 is a schematic diagram of a network framework of a text image super-resolution reconstruction model according to an embodiment of the present invention;
[0047] FIG3 is a schematic diagram of a gated text detection module according to an embodiment of the present invention. DETAILED DESCRIPTION
[0048] The present invention will be further described below in conjunction with the accompanying drawings and examples. The following examples are only used to more clearly illustrate the technical solutions of the present invention and are not intended to limit the scope of protection of the present invention.
[0049] In the description of the present invention, "several" means more than one, "plurality" means more than two, "greater than," "less than," and "exceed" are understood to exclude the number itself, while "above," "below," and "within" are understood to include the number itself. The use of "first" and "second" in the description is solely for the purpose of distinguishing technical features and should not be construed as indicating or implying relative importance, implicitly specifying the number of the indicated technical features, or implicitly specifying the order of the indicated technical features.
[0050] In the description of the present invention, reference to terms such as "one embodiment," "some embodiments," "illustrative embodiments," "examples," "specific examples," or "some examples" means that the specific features, structures, materials, or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the exemplary expressions of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.
[0051] Currently, deep learning-based image super-resolution has achieved impressive performance, but most methods aim to restore the detailed textures of natural images. The task of text image super-resolution reconstruction, on the other hand, focuses on improving the readability of text while simultaneously increasing image resolution. Treating text images as natural images for super-resolution ignores the classification information provided by the text itself. Therefore, compared to general image super-resolution reconstruction algorithms, text image super-resolution reconstruction requires a targeted algorithm to achieve satisfactory super-resolution reconstruction results.
[0052] The present invention discloses a text-assisted super-resolution reconstruction method for text images. Based on a deep residual network (ResNet), the method replaces the residual module therein with the gated text detection module proposed by the present invention, uses convolutional layers to extract image features, and then uses a bidirectional gated recurrent unit (GRU) to extract sequence features; the original skip-layer links in the residual module are changed to a gated feature fusion mechanism, which is connected through multiple gated text detection modules to extract deep features. On the other hand, the method adds a convolutional block attention mechanism module (CBAM) to the network, and further enhances the extraction of text sequence features by inputting features with channel and spatial attention weights into the gated text detection module. In addition, the method proposes a new loss function, called text-assisted loss, which takes into account both image resolution and text readability, effectively improving the performance of the text image super-resolution model.
[0053] Example 1
[0054] A text-assisted text image super-resolution reconstruction method, comprising:
[0055] Obtain a low-resolution text image to be reconstructed;
[0056] Inputting the low-resolution text image into a pre-trained text image super-resolution reconstruction model, and determining a text image super-resolution reconstruction result based on an output of the model;
[0057] The method for constructing and training the text image super-resolution reconstruction model includes:
[0058] Get text image dataset;
[0059] The pre-built text image super-resolution reconstruction model is trained using the text image dataset to obtain a trained text image super-resolution reconstruction model.
[0060] In some embodiments, a text-assisted text image super-resolution reconstruction method, as shown in FIG1 , includes the following steps:
[0061] S1: Acquire a text image dataset. In this embodiment, the text image dataset is a Textzoom dataset.
[0062] S2: The dataset is divided into a test set and a validation set. The text image super-resolution reconstruction model is input. The model network framework diagram is shown in Figure 2.
[0063] The RGB image and its grayscale image corresponding to the low-resolution image are used as four-channel image inputs. The shallow features are first extracted through a convolution layer with a 3*3 convolution kernel and a Relu activation layer. The feature map is input into the convolution block attention module to obtain the channel and spatial attention weights of the image, and the text sequence features are further extracted through multiple gated text detection modules. The features output by the gated text detection module are concatenated with the features output by the first convolution layer to obtain a new feature map. The new feature map is input into the sub-pixel convolution upsampling layer (DeConv) and the Tanh activation layer, and finally the super-resolution reconstructed four-channel text image is output.
[0064] The convolution block attention module infers the attention weights of the input feature map along the channel and spatial dimensions, and then multiplies it with the input feature map to achieve adaptive adjustment of the features.
[0065] As shown in Figure 3, the gated text detection module proposed in this embodiment further extracts image features by passing the feature map through two convolution layers with a 3*3 convolution kernel and a BN layer. Then, the LSTM module is used to extract text features from the horizontal and vertical directions respectively. The three features are fused through a gated feature fusion method and input into the next gated text detection module.
[0066] The formula for gated feature fusion is:
[0067] Where n represents the number of features, W i represents the trainable weights, F i represents the input feature, F g Represents the weighted features of the output.
[0068] S3: Construct the loss function of the text image super-resolution network. The overall loss function of the network is: L = L2 + αL TA
[0069] Among them, L2 is the mean square error loss function, L TA is the text-assisted loss function, and α is the hyperparameter of the ratio of the two loss functions.
[0070] The mean square error function is a commonly used loss function in the field of image processing. The specific formula is:
[0071] Where x and y represent two images of size M×N, x ij ,y ij Represents the value of a pixel. The mean square error is used to measure the pixel-level similarity between two images.
[0072] The specific formula of the text auxiliary loss function proposed in this invention is:
[0073] Among them, I HR Represents the original high-resolution text map, I SR represents the super-resolution text image generated by the network, Represents a one-dimensional vector generated by passing an image through a pre-trained text recognition network encoder.
[0074] In this example, the text recognition network uses a pre-trained RCNN text recognition network. The super-resolution image generated by the network and the original high-resolution image are input into the RCNN model's encoder to obtain the corresponding one-dimensional recognition sequence. The similarity of the text content of the two images is measured by the similarity of the recognition sequences of the two text images.
[0075] S4: Training the text image super-resolution network, specifically including:
[0076] S4.1: Convert the low-resolution image into an RGB image and its grayscale image as a four-channel image input;
[0077] S4.2: Input the four-channel image obtained in S4.1 into the convolutional layer to extract shallow features and obtain a feature map;
[0078] S4.3: Input the feature map obtained in S4.2 into the convolutional block attention module to obtain the channel and spatial attention weights of the image;
[0079] S4.4: The feature map with attention weights obtained in S4.3 is passed through multiple gated text detection modules to further extract text sequence features;
[0080] S4.5: Perform a skip-layer connection on the features output by S4.4 and the features output by S4.2, and add them together to obtain a new feature map;
[0081] S4.6: The feature map obtained in S4.5 is upsampled by sub-pixel convolution and outputted as a super-resolution result by a convolution layer.
[0082] S4.7: Iterate the process from S4.1 to S4.6 and use the loss function to supervise network training.
[0083] For a low-resolution text image, we first use forward propagation to calculate the total error, then use backpropagation to calculate the partial derivatives of each weight parameter. Finally, we update the weight parameters using gradient descent. We iterate this process, saving the model weight parameters that minimize the loss function to obtain the trained super-resolution network model.
[0084] S5: Inputting the low-resolution text image to be processed into the text image super-resolution reconstruction model to obtain a high-resolution text image.
[0085] This example uses a 64-bit Ubuntu 18.04.5 operating system, Python 3.6.9, torch 1.10.1, and torchvision 0.11.2 software environments, and an NVIDIA RTX 3090 GPU to complete the model training. The training process uses the Adam optimizer and sets the learning rate to 10. -4 , the number of training iterations is 500 times, and the total training time is about 40 hours.
[0086] Example 2
[0087] In a second aspect, this embodiment provides a text-assisted text image super-resolution reconstruction device, comprising a processor and a storage medium;
[0088] The storage medium is used to store instructions;
[0089] The processor is configured to operate according to the instructions to execute the steps of the method according to embodiment 1.
[0090] Example 3
[0091] In a third aspect, this embodiment provides a storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the method described in Example 1 are implemented.
[0092] Example 4
[0093] In a fourth aspect, the present invention provides a device comprising:
[0094] One or more processors, one or more memories, and one or more programs, wherein the one or more programs are stored in the one or more memories and are configured to be executed by the one or more processors, and the one or more programs include instructions for executing any of the methods described in Example 1.
[0095] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0096] The present application is described with reference to the flow chart and / or block diagram of the method, device (system), and computer program product according to the embodiment of the present application. It should be understood that each flow process and / or box in the flow chart and / or block diagram and the combination of the flow process and / or box in the flow chart and / or block diagram can be realized by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processing machine or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a device for realizing the function specified in one flow chart flow or multiple flows and / or one box or multiple boxes of the block diagram.
[0097] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a product including an instruction device that implements the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0098] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0099] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A text image super-resolution reconstruction method based on text assistance, characterized in that: include: Obtain a low-resolution text image to be reconstructed; Inputting the low-resolution text image into a pre-trained text image super-resolution reconstruction model, and determining a text image super-resolution reconstruction result according to an output of the model; The construction and training method of the text image super-resolution reconstruction model includes: Get the text image dataset; The pre-constructed text image super-resolution reconstruction model is trained using the text image data set to obtain a trained text image super-resolution reconstruction model.
2. The text-assisted text image super-resolution reconstruction method according to claim 1, characterized in that: Inputting the low-resolution text image into a pre-trained text image super-resolution reconstruction model, and determining a text image super-resolution reconstruction result according to an output of the model, including: The RGB image and its grayscale image corresponding to the low-resolution text image are used as the four-channel image input. The shallow features are first extracted through a convolution layer with a convolution kernel of 3*3 and a Relu activation layer to obtain the first feature map. Input the first feature map into the convolution block attention module to obtain the channel and spatial attention weights of the image, and obtain a feature map with attention weights; The feature map with attention weights is extracted through multiple gated text detection modules to obtain text sequence features; Perform skip-layer connection on the text sequence features output by the gated text detection module and the first feature map, and add them to obtain a new feature map; The new feature map is input into the sub-pixel convolution upsampling layer and the Tanh activation layer to obtain the output super-resolution reconstructed four-channel text image.
3. The text-assisted text image super-resolution reconstruction method according to claim 2, characterized in that: The method for constructing a text image super-resolution reconstruction model includes: Replace the residual module in the deep residual network with the gated text detection module, and add a convolutional block attention module before the gated text detection module; The processing process of the convolutional block attention module is: The channel and spatial attention weights of the image are inferred along the channel and spatial dimensions of the first input feature map, and then multiplied with the first input feature map to achieve adaptive adjustment of the features and obtain a feature map with attention weights.
4. The text-assisted text image super-resolution reconstruction method according to claim 2, characterized in that: The gated text detection module extracts image features from the feature map through two convolution layers with a convolution kernel of 3*3 and a BN layer in sequence, and then uses the LSTM module to extract horizontal text features and vertical text features from the horizontal and vertical directions respectively. The image features, horizontal text features and vertical text features are fused through the gated feature fusion method and input into the next gated text detection module.
5. The text-assisted text image super-resolution reconstruction method according to claim 4, characterized in that: The formula for gated feature fusion is: Where n represents the number of feature types, W i represents the trainable weights, F i represents the input feature, F g Represents the weighted features of the output.
6. The text-assisted text image super-resolution reconstruction method according to claim 1, characterized in that: The loss function used in the training process of the text image super-resolution reconstruction model is: L = L2 + αLTA Among them, L2 is the mean square error loss function, L TA is the text-assisted loss function, and α is the hyperparameter of the ratio of the two loss functions; The formula for the mean square error loss function is: Where MSE stands for mean square error, x and y represent two images of size M×N, and x ij ,y ij Indicates the value of a pixel; The formula of the text-assisted loss function is: Among them, I HR represents the original high-resolution text image, I SR represents the super-resolution text image generated by the network, It represents the one-dimensional vector generated by the pre-trained text recognition network encoder of the image, and ||·||2 means taking the 2-norm.
7. The text-assisted text image super-resolution reconstruction method according to claim 6, characterized in that: During the training process, the super-resolution image generated by the text image super-resolution reconstruction model and the corresponding original high-resolution image are respectively input into the encoder of the pre-trained text recognition network model to obtain the corresponding one-dimensional recognition sequence. The similarity of the text content of the two images is measured by the similarity of the two text image recognition sequences.
8. A text image super-resolution reconstruction device based on text assistance, characterized in that: including processor and storage medium; The storage medium is used to store instructions; The processor is configured to operate according to the instructions to execute the steps of the method according to any one of claims 1 to 7.
9. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A device, characterized in that: include, One or more processors, one or more memories, and one or more programs, wherein the one or more programs are stored in the one or more memories and are configured to be executed by the one or more processors, and the one or more programs include instructions for executing any of the methods according to claims 1 to 7.
Citation Information
Patent Citations
Image super-resolution reconstruction method and device
CN114581300A
Super-resolution reconstruction method for Chinese text image
CN114626984A
Text recognition method and device based on OCR (Optical Character Recognition), storage medium and electronic equipment
CN115188000A
Text perception loss-based attention text super-resolution method
CN115713464A
Streetscape Chinese text image super-resolution reconstruction method
CN115797179A
Cited By
Aerial image detection method and device, storage medium and electronic equipment
CN119091335A
Infrared image super-resolution reconstruction method and system
CN120318075A
Text image super-resolution method and system based on lightweight convolutional neural network
CN120339077A
Mobile terminal image super-resolution method based on prompt calibration and multi-scale cascading
CN121147024A
