A ship plate image super-resolution method based on semantic information and gradient supervision

Through a method based on generative adversarial networks, combined with semantic information and gradient supervision, the problem of simple algorithm and insufficient data set in ship plate text image super-resolution is solved, and efficient improvement of ship plate text image clarity is achieved, improving shipping safety. performance and recognition accuracy.

CN113935899BActive Publication Date: 2024-09-13杭州志创科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

The existing technology has problems in super-resolution of ship sign text images, such as simple algorithm, data set that does not meet the actual scene, lack of semantic feature research and insufficient sharpening effect, resulting in unsatisfactory ship sign text recognition results.

Method used

Using a method based on generative adversarial networks, combined with semantic information and gradient supervision, by constructing a feature extraction network and a super-resolution reconstruction network, using bidirectional LSTM and gradient loss function, adversarial learning and residual connection optimization are performed to improve the resolution of ship plate text images. Rate.

Benefits of technology

It significantly improves the clarity of ship plate text, improves text recognition accuracy, enhances shipping safety, extends the working life of the camera, and provides an efficient super-resolution reconstruction method for ship plate text images.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113935899B
    Figure CN113935899B
Patent Text Reader

Abstract

The present invention discloses a ship plate image super-resolution method based on semantic information and gradient supervision. The present invention comprises: 1. collecting the original image of the ship and performing pre-processing. 2. constructing a feature extraction network and a super-resolution reconstruction network for the ship plate text to form a generative network model. Then, adversarial learning pre-training is performed through the DF2K data set to obtain a generative network pre-training model. 3. After introducing the BLSTM structure into the generative network pre-training model, the ship plate text data set is used for training. 4: When performing adversarial learning training, since the ship plate text area has a certain sharpness, in order to better guide the network to generate super-resolved ship plate text, a text gradient loss function is added to strengthen the supervision of the generative network. The present invention can significantly improve the clarity of the ship plate text, help humans quickly identify the ship plate information, facilitate the traffic control of sea and river shipping, and improve the safety of waterway shipping.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical fields of deep learning, image processing, intelligent management and monitoring of ships in navigation channels, and super-resolution reconstruction, and relates to a ship plate image super-resolution method based on a generative adversarial network and guided by semantic information and gradient supervision. Background Art

[0002] China's shipping waterway transportation system is well-developed, the inland river network structure is perfect, and the ports are densely distributed, which has greatly promoted the development of the cargo shipping industry. Inland waterway shipping has become an important part of the modern comprehensive transportation system and one of the main contents of the rational development and comprehensive utilization of water resources. According to statistics, the total volume of national waterway cargo transportation reached 706.59 million tons in October 2020 alone, and the cargo turnover reached 925.39819 million tons. Therefore, ensuring the standardization, efficiency and safety of ship driving is of great significance to the creation of a fully informationized and intelligent inland waterway shipping system, and is the basis for building a smart water "highway".

[0003] At present, the supervision of ships mainly relies on installing surveillance cameras on both sides of the canal, docks, ports, etc., and monitoring by taking images of ships (mainly images of ship license plate text hanging on ships). However, in the actual scenario of obtaining ship license plate text, due to factors such as the ship is too far away from the camera, poor air quality, old hardware equipment, and image transmission, the ship license plate text image captured by the camera often becomes blurred. Blurred ship license plate text images are not conducive to further ship license plate text recognition, nor are they conducive to being retained as evidence of illegal ship driving, and are even more detrimental to the safe driving of ships under the supervision of traffic control departments. Therefore, there is an urgent need for a solution to solve the blur of ship license plate text images and improve the resolution of ship license plate text.

[0004] At present, the main solutions are based on traditional methods and deep learning, but these solutions have many problems in the super-resolution of ship license plate text: 1) The traditional image super-resolution method has a relatively simple algorithm and does not perform well on blurred ship license plate text. 2) In the deep learning method, the method of using bicubic linear interpolation to construct a training data set cannot meet the application of actual scenarios. 3) The deep learning super-resolution method lacks research on the semantic characteristics of the ship license plate text area, which makes the algorithm's text super-resolution effect unsatisfactory. 4) The existing deep learning method is still lacking in processing text sharpening effects. Therefore, there is still a lack of super-resolution methods for ship license plate text. Summary of the invention

[0005] The purpose of the present invention is to provide a ship plate image super-resolution method based on semantic information and gradient supervision in view of the deficiencies of the prior art.

[0006] The technical solution adopted by the present invention comprises the following steps:

[0007] Step 1: Collect original ship images and preprocess them.

[0008] First, the original ship image (including the ship plate text) in the river is captured, and the position of the ship plate text is manually marked, and the high-resolution ship plate text area image (hereinafter referred to as HR text image) is cropped. Then the HR text image is downsampled and noise is added to generate a low-resolution ship plate text area image (hereinafter referred to as LR text image), completing the construction of the ship plate text dataset.

[0009] Step 2: For the ship plate text, construct a feature extraction network and a super-resolution reconstruction network to form a generative network model. Then, use the DF2K dataset for adversarial learning pre-training. Under the guidance of the discriminator, pre-train the parameters of the generative network model through adversarial learning to obtain a generative network pre-training model.

[0010] Step 3: Based on the generated network pre-training model, a bidirectional LSTM (BLSTM) structure is introduced to enhance the semantic feature extraction of the ship license text area; the ship license text dataset is used for training.

[0011] Step 4: During adversarial learning training, since the ship license plate text area has a certain sharpness, in order to better guide the network to generate super-resolved ship license plate text, a text gradient loss function is added to strengthen the supervision of the generation network.

[0012] The specific operations of step 1 are as follows:

[0013] 1-1. According to different lighting, distance, and clarity (blur), high-definition images and real blurred images of ships are taken in the river to enhance the diversity of the data set distribution. Then the ship plate text area in the high-definition image and the blurred image is cropped to obtain HR text images and real low-resolution ship plate text images. The real low-resolution ship plate text images are used as the test set for model verification after training.

[0014] 1-2. For the original noise part of the ship license plate text image, the variance and mean of the noise patch are restricted according to the set ship license plate text noise patch size, and the noise patch area with variance and mean within the set threshold range is selected and saved. After traversing all HR text images, the noise patch pool is obtained.

[0015] The mean and variance calculation formulas of the noise patch in the ship plate text image are as follows:

[0016]

[0017]

[0018] where x p represents the pth pixel value in the noise patch, p represents the total number of pixels in each noise patch, M represents the mean of the noise patch, and s 2 Represents the variance of the noise patch.

[0019] Since it is necessary to construct a low-resolution ship plate text image, the HR text image is scaled using bicubic interpolation to form a preliminary artificial blurred image. The downsampling formula is as follows:

[0020] I D =(I HR *K bic )↓s (3)

[0021] Among them, I D represents the initial artificial blurred image, I HR represents HR text image, K bic represents the bicubic interpolation kernel, and s represents the downsampling factor.

[0022] 1-3. Add noise to the preliminary artificial blurred image. There are three sources of noise, including Gaussian noise, JPEG compression noise, and the real noise extracted in step 1-2. Add noise to the preliminary artificial blurred image in the order of Gaussian noise, JPEG compression noise, and real noise to obtain the final LR text image. At this point, the construction of the ship plate text dataset is completed. The probability density of Gaussian noise is calculated as follows:

[0023]

[0024] Where x is a random variable, p(x) is the probability density, δ is the standard deviation, and μ is the mean. The formula for adding Gaussian noise, JPEG compressed noise, and real noise patches in sequence is as follows:

[0025] I LR =I D +n g +n jpeg +n i ,i∈{1,2,...,m} (5)

[0026] Among them, I LR Represents LR text image, I D represents the initial artificial blurred image, n g represents Gaussian noise, n jpeg represents JPEG compression noise, n i represents a noise patch randomly extracted from the noise patch pool. m represents the number of noise patches in the noise patch pool.

[0027] Described step 2, specific operation is as follows:

[0028] 2-1. For the ship license plate text, a feature extraction network and a super-resolution reconstruction network with an input data shape of (N, C, H, W) are constructed to form a generative network model. Because the ultimate goal is to train the ship license plate data, the network input shape is directly set for the ship license plate training here.

[0029] In the feature extraction part, in order to ensure the diversity and rich details of the generated images in the future, the standard BN layer is not used in the network. The network first uses the standard convolution layer to simply extract the low-resolution image features in the input DF2K dataset. Then, through a series of convolution modules, a sufficiently deep neural network is built to extract the abstract features of the image. In order to ensure the efficient propagation of shallow network features and avoid gradient disappearance, this method uses residual connections and dense connections to optimize the deep network. The calculation formula of residual connection is as follows:

[0030] x l =F(x l-1 )+x l-1 (6)

[0031] Among them, x l-1 represents the input features of the residual unit, F(x l-1 ) represents the learned weighted residual mapping, x l Represents the output features of the residual unit. The calculation formula for dense connection is as follows:

[0032] x l =F([x1,x2,...,x l-1 ]) (7)

[0033] where x1,x2,...,x l-1 represents the input features of the densely connected unit, F([x1,x2,...,x l-1 ]) represents the densely connected mapping function, x l Represents the output features of densely connected units.

[0034] Finally, through interpolation, convolution and activation operations, the image after feature extraction is super-reconstructed to obtain a super-resolution reconstructed image. The formula for convolution and activation is as follows:

[0035]

[0036] Where x is the input feature, y is the output feature after activation, w is the convolutional layer weight, b is the convolutional layer bias, and relu is the activation function.

[0037] 2-2. Perform adversarial learning pre-training using the DF2K dataset.

[0038] In the discriminant network, the generated image (super-resolution reconstructed image) and the real image (high-resolution image in the DF2K dataset) are input, and the parameters of the generated network model are pre-trained through adversarial learning, and finally a generated network pre-trained model with good parameter initialization is obtained. This part mainly includes the construction of the discriminant network and the construction of the loss function.

[0039] When building the discriminant network, convolutional layers, BN layers, and linear mapping layers are used as the main modules of the discriminant network. In the construction of the convolutional layer, a larger convolution kernel is used to enable the network to obtain a larger receptive field and extract the global information of the image, so that the discriminant network can better judge the authenticity of the image from the overall perspective of the image. After each layer of convolution, data normalization is performed, that is, a BN layer is added. This operation can stabilize network training and enhance robustness. The formula for data normalization is as follows:

[0040]

[0041] Where x is the input data to be normalized, y is the normalized result, mean(x) and var(x) are the mean and variance of the input data, eps is the amount to prevent the denominator from being 0, and γ and β are trainable parameters.

[0042] Finally, the high-dimensional data of the image features is converted into a vector through the linear mapping layer, and finally the vector is mapped into the probability that the input image (super-resolution reconstructed image or high-resolution image in the DF2K dataset) is a true high-resolution image through the activation layer. The calculation formula of the linear mapping layer is as follows:

[0043] y=x·A T +b (10)

[0044] Where x is the input of the linear mapping layer, A T is the weight of the linear mapping layer, b is the bias of the linear mapping layer, and y is the output of the linear mapping layer.

[0045] The calculation formula of the Sigmoid activation function is as follows:

[0046]

[0047] Where x is the input data and f(x) is the probability.

[0048] 2-3. In the pre-trained network, the loss function is mainly composed of three parts: L1 loss, perceptual loss and adversarial loss. The total loss function calculation formula is as follows:

[0049] L total =λ1·L1+λ per ·L per +λ adv ·L adv (12)

[0050] Among them, L1, L per and L adv denote L1 loss, perceptual loss and adversarial loss, respectively, λ1, λ per and λ adv They represent the weights of the corresponding loss functions respectively.

[0051] The details of these three parts of losses are as follows:

[0052] 1) L1 loss measures the spatial distance between two images. It can calculate the pixel-level error between two images (HR and SR), and can enhance the pixel-level similarity between the two images, thereby guiding the network to better generate SR images. The calculation formula of L1 loss function is as follows:

[0053] L1=mean(ι(x,y)) (13)

[0054] ι(x,y)={c1,...,c N} T ,c i =|x i -y i | (14)

[0055] Where N represents the batch size, x and y represent images of any size with the same shape, c represents the pixel-level difference between the two images, and mean represents the mean operation of all elements.

[0056] 2) Perceptual loss: By inputting the HR image and SR image into the pre-trained deep network respectively, and then extracting the feature image after the convolution of the intermediate layer as the perceptual feature, the perceptual loss can be obtained by calculating the L1 distance between the perceptual features of the HR image and the SR image according to the L1 loss calculation formula.

[0057] 3) Adversarial loss measures the error of the network discriminator in distinguishing images. During training, each time the adversarial loss function is calculated, a batch of real images and generated images are input to the discriminator to determine the probability that the input image is a real image. The formula for calculating the adversarial loss function is as follows:

[0058]

[0059] Among them, G represents the generating network, D represents the discriminant network, E represents the expectation, x represents the real image data, z represents the input data of the generating network, and G(z) represents the generated image data. By performing maximum minimization on the above expressions, the optimization of the parameters of the discriminant network D and the generating network G can be completed. It should be pointed out that D(·) represents the probability of judging that the content in the brackets is the real image data.

[0060] Described step 3, specific operation is as follows:

[0061] On the basis of the generative network pre-training model, a semantic information extraction module is added to make the fine-tuned generative network pre-training model better adapt to the training of the ship plate text dataset. In the feature extraction part of the pre-trained generative network model, a bidirectional LSTM module is added to extract the semantic features of the ship plate text, thereby guiding the network to better generate super-resolution ship plate text information. The calculation formula of the LSTM module is as follows:

[0062]

[0063] Among them, x t represents the input data at time t, w is the weight, h t represents the implicit state at time t, h′ t represents the candidate hidden state at time t, r t represents the forget gate at time t, z t represents the update gate at time t, σ represents the sigmoid activation function, and tanh is also an activation function.

[0064] The specific operations of step 4 are as follows:

[0065] When using the ship license plate text dataset for adversarial learning training, since the text area has a certain sharpness, in order to better guide the network to generate super-resolution ship license plate text, this method adds a text gradient loss function to strengthen the supervision of the generation network.

[0066] The gradient loss function is a loss specifically designed to sharpen image edges. This method calculates the gradient by subtracting the image pixels after translation. Based on the RGB three-channel color image, the image is translated one pixel to the left and right respectively, and then the two translated images are subtracted to obtain the horizontal gradient of the original color image. Similarly, the image is translated one pixel up and down respectively, and then the two translated images are subtracted to obtain the vertical gradient of the original color image. Then, according to the following formula, the final color image gradient loss can be obtained:

[0067]

[0068] Among them, r, l, t, and b represent the image after translation to the right, left, upward, and downward, respectively.

[0069] By calculating the image gradient, the sharpness of the ship plate text area can be improved during the training of the ship plate text data set, thereby improving the clarity of the ship plate text area. Therefore, the loss function of the entire network is:

[0070] L total =λ gra ·L gra +λ1·L1+λ per ·L per +λ adv ·L adv (18)

[0071] Among them, L gra , L1, L per and L adv Respectively represent gradient loss, L1 loss, perceptual loss and adversarial loss, λ gra ,λ1,λ per and λ adv They represent the weights of the corresponding loss functions respectively.

[0072] Finally, by updating the network structure and loss function based on the pre-trained model and then training the ship license plate text dataset, the network is able to complete the super-resolution improvement of the ship license plate text images.

[0073] The benefits of the present invention are as follows:

[0074] The present invention proposes a high-performance super-resolution reconstruction method specifically for ship plate text images. Through this method, the clarity of the ship plate text can be significantly improved, helping humans to quickly identify the ship plate information, facilitating the traffic control of sea and river shipping, and improving the safety of waterway shipping. Since there are few existing ship plate data sets, and the current method of constructing a data set cannot achieve good results in the training of the ship plate super-resolution network, the present invention re-collects the ship plate data and adopts a novel method of constructing a ship plate data set to train the super-resolution reconstruction network, so that the ship plate super-resolution reconstruction effect is greatly improved, which has certain reference significance for researchers in the same field. At the same time, the method uses a large data set DF2K to pre-train the network, further improving the effect of the ship plate super-resolution reconstruction. In addition, the bidirectional LSTM and gradient loss introduced in the method make full use of the semantic information of the ship plate and the unique attributes of the text edge. When testing reasoning, it can further improve the quality of the ship plate image after network super-resolution reconstruction without losing reasoning time.

[0075] This method makes full use of the ability of deep networks to extract abstract information from images, and uses the ideas of adversarial and residual learning to effectively improve the resolution of ship license images. The high-definition text information obtained by the ship license text image super-resolution method can be retained as evidence during the ship's navigation process. Not only that, the ship license text image super-resolution method has largely made up for the shortcomings of unclear images taken by old cameras, and to a certain extent extended the working life of the camera and improved resource utilization. Finally, the ship license text image super-resolution technology can also provide technical support for the ship license text image text recognition algorithm, by improving the clarity of the text, helping the ship license text recognition algorithm to improve recognition accuracy. The method proposed in the present invention has obvious advantages in terms of implementation difficulty, budget cost and economic benefits. BRIEF DESCRIPTION OF THE DRAWINGS

[0076] Figure 1 Schematic diagram of the process of the present invention;

[0077] Figure 2 The effect diagram of the application of the present invention on the text on the ship plate in actual scenarios. DETAILED DESCRIPTION

[0078] The technical solution of the present invention will be described clearly and completely below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0079] In view of this, the present invention proposes a ship license image super-resolution method based on semantic information and gradient supervision. Its main features are: 1) a batch of ship license data was collected through field investigation, and after processing, a ship license data set was artificially synthesized. 2) Good network initialization weights were obtained by pre-training on a large data set. 3) Taking full advantage of the unique advantages of ship license text, it is proposed to integrate a bidirectional LSTM module in the network to extract text semantic information, and by integrating the gradient loss function, guide the network to generate clearer text edges. On this basis, this method makes full use of the advantages of adversarial learning and residual learning to complete the resolution improvement of ship license text images in real natural scenes.

[0080] like Figure 1 As shown, the algorithm flow of the present invention mainly includes the following steps:

[0081] Step 1: Get the HR text image and the real blurred ship plate text image. Take photos of passing cargo ships (including ship plate text) on the bank of the Beijing-Hangzhou Grand Canal, manually mark the center position coordinates of the ship plate text, and crop a fixed size area centered on the ship plate text as the HR text image. Then extract the original noise of the HR text image and save it, then downsample and add noise to the HR text image to obtain the final LR text image. At this point, the ship plate text dataset consisting of HR-LR pairs has been processed.

[0082] Step 1.1, through shooting, finally obtain 1774 ship images with a resolution of 4752*3168 as native data. Then mark the center point of the ship plate text in the image to locate the position of the ship plate text. Considering the clarity and diversity of the data set, it is necessary to select more than 900 high-definition ship images from 1774 images according to different lighting, different distances, different clarity and different tones, in preparation for cropping high-definition ship plate text images; similarly, in order to fully test the model's ability to generate super-resolution images, 261 ship images with different blur levels are selected from 1774 images to prepare for cropping real low-resolution ship plate text images.

[0083] Step 1.2, crop the 900+ high-definition ship images to obtain images with a resolution of 480*480 that only contain the ship plate text area. At the same time, remove the cropped images with incomplete ship plate text to obtain the final 900 HR text images. Cropping the 261 blurred ship images can obtain 261 real blurred ship plate text images with a resolution of 120*120.

[0084] Step 1.3, set the patch size of the noise to be extracted and extract the noise. According to the network settings, the input HR text image will be divided into a series of sub-images with a resolution of 128*128, and the corresponding LR text image will be divided into sub-images with a resolution of 32*32. Therefore, the input noise patch is set to 32*32. Then convert the HR text color image into a grayscale image, and traverse the entire image with a step size of 32 pixels in the 32*32 area to obtain a series of noise patch candidate areas. Then calculate the mean and variance of each candidate area, and compare them with the set threshold (the minimum mean threshold is 0, and the maximum variance threshold is 20). If it meets the requirements, the location information of the noise patch is retained. Finally, the final noise patch is obtained by applying the location information of the noise patch to the color HR text image. Perform the above operations on all 900 HR text images to complete the extraction of all noise patches in the dataset.

[0085] Step 1.4, downsample the HR text image to obtain a preliminary artificial blurred image. Use the bicubic interpolation method in MATLAB software to downsample the HR text image to obtain a preliminary artificial blurred image of 120*120. The downsampling formula is as follows:

[0086] I D =(I HR *K bic )↓s

[0087] Among them, I D represents the initial artificial blurred ship plate text image after downsampling, I HR represents a high-resolution ship plate text image, K bic represents the bicubic interpolation kernel, s represents the downsampling factor, and s=4 is selected.

[0088] Step 1.5, add Gaussian noise, JPEG compressed noise and real noise patches extracted from the HR text image in turn. First, add Gaussian noise with a mean of 0 and a standard deviation of 8.0 to the generated preliminary artificial blurred image, and then perform JPEG compression on the image with a compression quality of 60 (the highest quality is 100). Finally, randomly extract noise patches from the noise patch library and superimpose them on the JPEG compressed ship license text image. The probability density of Gaussian noise is calculated as follows:

[0089]

[0090] Where x is a random variable, p(x) is the probability density, δ is the standard deviation, and μ is the mean. The formula for adding Gaussian noise, JPEG compressed noise, and real noise patches in sequence is as follows:

[0091] I LR =I D +n g +n jpeg +n i ,i∈{1,2,...,m}

[0092] Among them, I LR Represents LR text image, I D represents the downsampled image, n g represents Gaussian noise, n jpeg represents JPEG compression noise, n i represents a noise patch randomly extracted from the noise patch pool, and m represents the number of noise patches in the noise patch pool. Through the above operations, the final LR text image is obtained, and the construction of the HR-LR ship license text dataset is completed.

[0093] Step 2: For the ship plate text, construct a feature extraction network and a super-resolution reconstruction network with an input data shape of (N, C, H, W) to form a generative network. Then perform adversarial learning pre-training on the DF2K dataset. Under the guidance of the discriminator, input the generated image and the real image, and pre-train the parameters of the generative network model through adversarial learning, and finally obtain a generative network pre-training model with good parameter initialization. This part mainly includes the construction of the discriminant network and the construction of the loss function.

[0094] Step 2.1, build the feature extraction network. First, extract low-level features through the first layer of ordinary convolution module. The settings of this module are: input channel is 3, output channel is 64, convolution kernel size is 3*3, step size is 1, and padding is 1. Then enter the network part of high-level feature extraction. First, through dense connection, build dense connection units as shown in Table 1, so that the input feature map of each layer is the sum of the output feature maps of all previous layers; then perform one short residual connection inside each dense connection unit; 3 dense units constitute a residual connection group, and each residual connection group performs one long residual connection; stacking 23 residual connection groups constitutes the high-level feature extraction part of the generated network. Send the low-level features extracted by the first layer of convolution of the network to the high-level feature extraction part of the network to complete the extraction of abstract image features.

[0095] Table 1: Densely connected unit structure

[0096] Connection Layer Number of convolution kernels Convolution kernel size Step Length filling Conv1 32 3*3 1 1 Conv2 32 3*3 1 1 Conv3 32 3*3 1 1 Conv4 32 3*3 1 1 Conv5 64 3*3 1 1 LReLU / / / /

[0097] Step 2.2, super-resolution reconstruction network. First, construct an upsampling unit with a 2x magnification factor. Use the nearest neighbor difference method to magnify the feature map by 2x, and then perform a convolution operation on the feature map that has been magnified by 2x. The convolution settings are as follows: 3 input channels, 64 output channels, 3*3 convolution kernel size, 1 step size, and 1 padding. Finally, perform relu activation to obtain a 2x upsampling unit. By stacking two 2x upsampling units, the image can be super-resolution enhanced by x4.

[0098] Step 2.3, the construction of the discriminant network structure. First, through 64 3*3 convolution kernels, a convolution operation with a step size of 1 and a padding of 1 is performed on the input image to extract the low-level feature map (64 layers) of the image. Then, through 9 groups of small units consisting of convolution layers and 2-dimensional batch normalization function BN layers, more abstract high-dimensional features in the input image are continuously extracted. Moreover, as the features of the network extracting images become more and more abstract, the number of layers of the feature map is continuously deepened, and finally a 512-layer feature map is obtained, as shown in Table 2. Finally, through two layers of fully connected layers in series, the 3D feature map is mapped to 1000-dimensional and 100-dimensional vectors successively, and then after passing through the sigmoid activation layer, the probability that the input image is a real image is obtained. The probability that the input image is a real image obtained in this step will be used to calculate the adversarial loss function.

[0099] Table 2: Main structure of adversarial network

[0100]

[0101] Step 2.4, setting of loss function. The loss function consists of the following: L1 loss, perceptual loss and adversarial loss. L1 loss is a commonly used loss function in deep learning. In the field of image super-resolution, L1 loss aims to calculate the error between corresponding pixels of two (HR and SR) images. In order to construct a super-resolution image that is more in line with the visual effect of the human eye, this method adds perceptual loss to the loss function and combines it with a generative adversarial network. Through adversarial loss, the generator can generate more realistic images, and the discriminator can also have a stronger ability to distinguish the authenticity of the image (generated or real). The total loss function calculation formula is as follows:

[0102] L total =λ1·L1+λ per ·L per +λ adv ·L adv

[0103] Among them, L1, L per and L adv They represent L1 loss, perceptual loss and adversarial loss λ1, λ respectively. per and λ adv They represent the weights of the corresponding loss functions. In order to maximize the performance of the loss function, this method sets the weights of each loss function as follows: λ1 = 10 -2 ,λ per =1,λ adv =5*10 -3 .

[0104] Step 2.4.1, setting of L1 loss function. The L1 loss function measures the spatial distance between two images, can calculate the pixel-level error of two images (HR and SR), can enhance the pixel-level similarity of the two images, and thus guide the network to better generate SR images. Its general expression is as follows:

[0105] L1=mean(ι(x,y))

[0106] ι(x,y)={c1,...,c N} T ,c i =|x i -y i |

[0107] Where N represents the batch size, x and y represent images of any size with the same shape, c represents the pixel-level difference between the two images, and mean represents the mean operation of all elements.

[0108] Step 2.4.2, setting of perceptual loss function. To obtain the perceptual loss function, this method inputs the HR image and SR image into the pre-trained convolutional neural network respectively, and then extracts the feature image after the 5th convolution as the perceptual feature. According to the L1 loss calculation formula in step 2.4.1, the L1 distance between the perceptual features of the HR text image and the SR image is calculated to obtain the perceptual loss.

[0109] Step 2.4.3, Generate adversarial network loss function settings. During training, unlike the classic method of calculating generative adversarial loss, each time the generative adversarial loss function is calculated, a batch of real images and generated images are input to the discriminator, and then back propagation is performed to optimize the parameters of the generative network and the discriminative network at the same time. The formula for calculating the generative adversarial loss function is as follows:

[0110]

[0111] Among them, G represents the generating network, D represents the discriminant network, E represents the expectation, x represents the real image data, and z represents the input data of the generating network. By performing maximum minimization on the above expressions, the parameters of the discriminant network D and the generating network G can be optimized.

[0112] Step 2.5, setting of other training parameters. During training, the initial learning rate is set to 10 -4 , and set the learning rate to decay with training. The number of iterations is 60,000, and the optimizer uses the Adam optimizer. The program runs in the Linux system of the Ubuntu distribution, the GPU is NVIDIA RTX3070, and the training time is about 9 hours.

[0113] Step 3, fine-tune the pre-trained network to extract text semantic information so that the network can adapt to the training of the ship plate text dataset. In order to super-resolution the ship plate text image, this method will add a bidirectional LSTM module to the feature extraction part of the pre-trained generative network to extract semantic features of the ship plate text, thereby guiding the network to better generate super-resolution ship plate text information. For the parameters in the LSTM module, use xavier_normal for initialization, batch_firsr is set to True, and the calculation formula of the LSTM module is as follows:

[0114] z t =σ(W z ·[h t-1 ,x t ])

[0115] r t =σ(W r ·[h t-1 ,x t ])

[0116] h′ t =tanh(W·[r t *h t-1 ,x t ])

[0117] h t =(1-z t )*h t-1 +z t *h′ t

[0118] Among them, x t represents the input data at time t, w is the weight, h t represents the implicit state at time t, h′ t represents the candidate hidden state at time t, r t represents the forget gate at time t, z t represents the update gate at time t, σ represents the sigmoid activation function, and tanh is also an activation function.

[0119] Step 4: When using the ship license plate text dataset for adversarial learning training, since the text area has a certain sharpness, in order to better guide the network to generate super-resolution ship license plate text, a text gradient loss function is added to strengthen the supervision of the generation network.

[0120] Step 4.1, in order to sharpen the edge of the ship plate text, this method introduces the gradient loss function. This method calculates the gradient by subtracting the image pixels. On the basis of the RGB three-channel color image, the image is translated one pixel to the left and right respectively, and then the two translated images are subtracted to obtain the horizontal gradient of the original color image. Similarly, the image is translated up and down by one pixel respectively, and then the two translated images are subtracted to obtain the vertical gradient of the original color image. Then calculate according to the following formula to get the final color image gradient loss:

[0121]

[0122] Among them, r, l, t, and b represent the image after translation to the right, left, upward, and downward, respectively. The gradient loss is integrated into the above loss function to obtain the entire loss function:

[0123] L total =λ gra ·L gra +λ1·L1+λ per ·L per +λ adv ·L adv

[0124] Among them, L gra , L1, L per and L adv Respectively represent gradient loss, L1 loss, perceptual loss and adversarial loss, λ gra ,λ1,λ per and λ adv They represent the weights of the corresponding loss functions. The weights are set to λ gra =10 -4 ,λ1=10 -2 ,λ per =1,λ adv =5*10 -3 .

[0125] Step 4.2, use the data enhancement tool provided by pytorch to perform data enhancement operations on the ship license plate text dataset, expand the ship license plate text dataset in three aspects: hue, saturation, and angle, and use the enhanced ship license plate text dataset to train on the fine-tuned network and loss function.

[0126] Step 4.3, setting of other training parameters. During training, the initial learning rate is set to 10 -4 , and set the learning rate to decay with training. The number of iterations is 80,000, and the optimizer uses the Adam optimizer. Running in Linux system, the GPU is NVIDIA RTX3070, and the training time is about 7+ hours.

[0127] Step 4.4, the model performance test is performed on the 261 real fuzzy license plate text data obtained in step 1 to complete the final training of the license plate text data. The test results are as follows: Figure 2 shown.

[0128] At this point, the generative network structure in the entire network can complete the reconstruction from a 120*120 low-resolution ship license plate text image to a 480*480 super-resolution ship license plate text image, which is the final super-resolution generative network required.

[0129] The above is only a preferred embodiment of the present invention. It should be pointed out that ordinary technicians in this technical field can make several improvements and modifications without departing from the concept of the present invention. These improvements and modifications should also be regarded as within the scope of protection of the present invention.

Claims

1. A ship plate image super-resolution method based on semantic information and gradient supervision, characterized in that The following steps are involved: Step 1: Collect the original images of ships and perform preprocessing; First, we take the original ship image with ship plate text in the river, manually mark the position of the ship plate text, and crop it to get a high-resolution ship plate text area image, recorded as an HR text image; then we downsample the HR text image and add noise to generate a low-resolution ship plate text area image, recorded as an LR text image; thus, we complete the construction of the ship plate text dataset; Step 2: For the ship plate text, construct a feature extraction network and a super-resolution reconstruction network to form a generative network model; then perform adversarial learning pre-training on the DF2K dataset. Under the guidance of the discriminator, pre-train the parameters of the generative network model through adversarial learning to obtain a generative network pre-training model; Step 3: Introduce a bidirectional LSTM structure based on the generated network pre-training model to enhance the semantic feature extraction of the ship plate text area; use the ship plate text dataset for training; Step 4: During adversarial learning training, since the ship license plate text area has a certain sharpness, in order to better guide the network to generate super-resolved ship license plate text, a text gradient loss function is added to strengthen the supervision of the generation network.

2. The method for super-resolution of ship plate images based on semantic information and gradient supervision according to claim 1 is characterized in that The specific operations of step 1 are as follows: 1-1. According to different lighting, distance, and clarity, high-definition images and real blurred images of ships are taken in the river to enhance the diversity of the data set distribution; then the ship plate text area in the high-definition images and the real blurred images is cropped to obtain HR text images and real low-resolution ship plate text images, where the real low-resolution ship plate text images are used as the test set for model verification after training is completed; 1-2. Extract the native noise of the ship license text image. According to the set ship license text noise patch size, limit the variance and mean of the noise patch. Select and save the noise patch area whose variance and mean are within the set threshold range. After traversing all HR text images, obtain the noise pool. The mean and variance calculation formulas of the noise patch in the ship plate text image are as follows: where x p represents the pth pixel value in the noise patch, p represents the total number of pixels in each noise patch, M represents the mean of the noise patch, and s 2 Represents the variance of the noise patch; Since it is necessary to construct a low-resolution ship plate text image, the HR text image is scaled using bicubic interpolation to form a preliminary artificial blurred image; the downsampling formula is as follows: I D =(I HR *K bic )↓s (3) Among them, I D represents the initial artificial blurred image, I HR represents HR text image, K bic represents the bicubic interpolation kernel, and s represents the downsampling multiple; 1-3. Add noise to the preliminary artificial blurred image; the sources of noise include Gaussian noise, JPEG compression noise and the real noise extracted in step 1-2; add noise to the preliminary artificial blurred image in the order of Gaussian noise, JPEG compression noise and real noise to obtain the final LR text image, and the construction of the ship plate text dataset is completed at this time; the probability density of Gaussian noise is calculated as follows: Where x is a random variable, p(x) is the probability density, δ is the standard deviation, and μ is the mean. The formula for adding Gaussian noise, JPEG compressed noise, and real noise patches in sequence is as follows: I LR =I D +n g +n jpeg +n i ,i∈{1,2,...,m} (5) Among them, I LR Represents LR text image, I D represents the initial artificial blurred image, n g represents Gaussian noise, n jpeg represents JPEG compression noise, n i represents a noise patch randomly extracted from the noise patch pool; m represents the number of noise patches in the noise patch pool.

3. A ship plate image super-resolution method based on semantic information and gradient supervision according to claim 1 or 2, characterized in that The specific operation of step 2 is as follows: 2-1. For the ship plate text, a feature extraction network and a super-resolution reconstruction network with input data shape (N, C, H, W) are constructed to form a generative network model; In the feature extraction part, the network first uses a standard convolutional layer to simply extract the low-resolution image features in the input DF2K dataset; then, through a series of convolutional modules, a sufficiently deep neural network is built to extract the abstract features of the image. In order to ensure the efficient propagation of shallow network features and avoid gradient disappearance, residual connections and dense connections are used to optimize the deep network; the calculation formula of residual connection is as follows: x l =F(x l-1 )+x l-1 (6) Among them, x l-1 represents the input features of the residual unit, F(x l-1 ) represents the learned weighted residual mapping, x l Represents the output characteristics of the residual unit; the calculation formula for dense connections is as follows: x l =F([x1,x2,...,x l-1 ]) (7) where x1,x2,...,x l-1 represents the input features of the densely connected unit, F([x1,x2,...,x l-1 ]) represents the densely connected mapping function, x l Represents the output features of densely connected units; Finally, the image after feature extraction is super-resolution reconstructed through interpolation, convolution and activation operations to obtain a super-resolution reconstructed image; the convolution and activation formula is as follows: Where x is the input feature, y is the output feature after activation, w is the convolutional layer weight, b is the convolutional layer bias, and relu is the activation function; 2-2. Pre-training adversarial learning using the DF2K dataset; In the discriminant network, super-resolution reconstructed images and high-resolution images in the DF2K dataset are input, and the parameters of the generative network model are pre-trained through adversarial learning, and finally a generative network pre-training model with good parameter initialization is obtained; this part mainly includes the construction of the discriminant network and the construction of the loss function; When building the discriminant network, convolutional layer, BN layer and linear mapping layer are used as the main modules of the discriminant network; in the construction of the convolutional layer, a larger convolution kernel is used, and data normalization operation is performed after each convolution layer, that is, adding a BN layer. This operation can stabilize network training and enhance robustness; the formula for data normalization is as follows: Where x is the input data to be normalized, y is the normalized result, mean(x) and var(x) are the mean and variance of the input data, eps is the amount to prevent the denominator from being 0, and γ and β are trainable parameters; Finally, the high-dimensional data of the image features is converted into a vector through the linear mapping layer, and finally the vector is mapped into the probability that the input image is a true high-resolution image through the activation layer; the calculation formula of the linear mapping layer is as follows: y=x·A T +b (10) Where x is the input of the linear mapping layer, A T is the weight of the linear mapping layer, b is the bias of the linear mapping layer, and y is the output of the linear mapping layer; The calculation formula of the Sigmoid activation function is as follows: Where f(x) is the probability; 2-3. In the pre-trained network, the loss function is mainly composed of three parts: L1 loss, perceptual loss and adversarial loss; the total loss function calculation formula is as follows: L total =λ1·L1+λ per ·L per +λ adv ·L adv (12) Among them, L1, L per and L adv denote L1 loss, perceptual loss and adversarial loss, respectively, λ1, λ per and λ adv They represent the weights of the corresponding loss functions respectively.

4. The method for super-resolution of ship plate images based on semantic information and gradient supervision according to claim 3 is characterized in that The specific operation of the loss function described in step 2-3 is as follows: ①The L1 loss function calculation formula is as follows: L1=mean(ι(x,y)) (13) ι(x,y)={c1,...,c N } T ,c i =|x i -y i | (14) Where N represents the batch size, x and y represent images of the same shape and size, c represents the pixel-level difference between the two images, and mean represents the mean operation of all elements. ② Perceptual loss: By inputting the HR image and SR image into the pre-trained deep network respectively, and then extracting the feature image after the convolution of the intermediate layer as the perceptual feature; finally, according to the L1 loss calculation formula, the L1 distance between the perceptual features of the HR image and the SR image is calculated to obtain the perceptual loss; ③ The adversarial loss measures the error of the network discriminator's image discrimination results. During training, each time the adversarial loss function is calculated, a batch of real images and generated images are input to the discriminator to determine the probability that the input image is a real image. The formula for generating the adversarial loss function is as follows: Where G represents the generative network, D represents the discriminative network, E represents the expectation, x represents the real image data, z represents the input data of the generative network, and G(z) represents the generated image data. By performing maximum minimization on the above expressions, the parameters of the discriminative network D and the generative network G can be optimized. It should be noted that D(·) represents the probability of judging that the content in the brackets is the real image data.

5. The method for super-resolution of ship plate images based on semantic information and gradient supervision according to claim 3 is characterized in that Step 3: On the basis of the generative network pre-training model, a semantic information extraction module is added to make the fine-tuned generative network pre-training model better adapt to the training of the ship plate text data set; in the feature extraction part of the pre-trained generative network model, a bidirectional LSTM module is added to extract the semantic features of the ship plate text, thereby guiding the network to better generate super-resolution ship plate text information; the calculation formula of the LSTM module is as follows: Among them, x t represents the input data at time t, w is the weight, h t represents the implicit state at time t, h' t represents the candidate hidden state at time t, r t represents the forget gate at time t, z t represents the update gate at time t, σ represents the sigmoid activation function, and tanh is also an activation function.

6. The method for super-resolution of ship plate images based on semantic information and gradient supervision according to claim 5 is characterized in that Step 4: When using the ship license plate text dataset for adversarial learning training, since the text area has a certain sharpness, the text gradient loss function is added to strengthen the supervision of the generation network; Specifically, the gradient is calculated by subtracting the image pixels after translation; on the basis of the RGB three-channel color image, the image is translated to the left and right by one pixel respectively, and then the two translated images are subtracted to obtain the horizontal gradient of the original color image; similarly, the image is translated up and down by one pixel respectively, and then the two translated images are subtracted to obtain the vertical gradient of the original color image; then the final color image gradient loss can be obtained by calculating according to the following formula: Among them, r, l, t, and b represent the image after translation to the right, left, upward, and downward, respectively; By calculating the image gradient, the sharpness of the ship plate text area can be improved during the training of the ship plate text data set, thereby improving the clarity of the ship plate text area; thus, the loss function of the entire network is: L total =λ gra ·L gra +λ1·L1+λ per ·L per +λ adv ·L adv (18) Among them, L gra , L1, L per and L adv Respectively represent gradient loss, L1 loss, perceptual loss and adversarial loss, λ gra ,λ1,λ per and λ adv Respectively represent the weights of the corresponding loss functions; Finally, by updating the network structure and loss function based on the pre-trained model and then training the ship license plate text dataset, the network is able to complete the super-resolution improvement of the ship license plate text images.