Image restoration method based on multi-mode pseudo-style embedding
The image restoration method through multi-modal pseudo-style embedding uses edge detection, boundary completion network and multi-modal pseudo-style generation network, combined with twin style encoder and attention operation, to solve the semantic error and texture imprecision in image restoration. solve the problem and achieve efficient image repair effects.
Patent Information
- Application Number
- CN202410596447.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-14
- Publication Date
- 2024-09-03
AI Technical Summary
Existing image repair technology has problems of semantic errors and information distortion when processing large-hole damaged images, and the problems of poor repair creativity and unrefined texture have not been effectively solved.
An image restoration method based on multi-modal pseudo-style embedding is adopted. The boundary map is obtained through edge detection, input into the boundary completion network for boundary completion, and the text description and boundary completion map are input into the multi-modal pseudo-style generation network to generate pseudo-style. Figure, utilizes Siamese style encoder and attention operation for feature extraction and fusion to achieve high-resolution inpainted image generation.
It effectively fills the information gap when the loss rate is large, generates a variety of style maps, increases the correlation of pixels in the global scope, improves the repair effect, and solves the problems of unrefined textures and poor creativity.
Smart Images

Figure CN118587122A
Abstract
Description
Technical Field
[0001] The present application belongs to the field of image processing technology, and specifically relates to an image restoration method based on multimodal pseudo-style embedding. Background Art
[0002] Image restoration is an important research topic in the field of computer vision and image processing. With the excellent performance of deep learning in the field of vision, the frontier of the field of vision is basically occupied by deep learning technology. The intersection of graphics and vision is a hot topic of discussion and research, especially image editing and image generation. Image restoration is a problem between image editing and image generation. Image restoration can be simply summarized as a problem of estimating the value of a missing part. How to efficiently restore large and irregular images is still a problem that needs to be improved and solved, and how to give the restored content rich texture is also a very challenging focus.
[0003] In recent years, many scholars have also contributed many algorithms in the field of deep learning image restoration, which can be summarized into three categories: 1) special convolutional network image restoration methods; 2) clue prior progressive restoration algorithms; 3) restoration algorithms based on attention mechanisms. For example, the partial convolutional network proposed by Guilin Liu et al. and the subsequent deformable convolutional network can be used to repair irregular damaged images and borrow feature blocks from distant areas. However, these methods do not take into account the problem of semantic ambiguity. As long as the damaged image has large holes, the correlation between the damaged center and the known area will be weakened, resulting in semantic errors. Jie Wu et al. used the intermediate prior to first repair the potential contour of the image, and then continued to use the two-stage self-attention to fill in the features to enrich the texture details. However, due to the high computational cost of self-attention, and some methods are prone to information distortion during the decoding process due to the large number of iterations. Later, many researchers focused on how to narrow the huge restoration information gap, and successively proposed more powerful attention mechanisms to capture potential correlations or obtain additional information from auxiliary conditions such as the frequency domain, but still did not consider the lack of reference information for the restoration task itself, and the improvement obtained by these improvements was still insufficient. Summary of the invention
[0004] The purpose of this application is to provide an image restoration method based on multimodal pseudo-style embedding, which solves the original defects of poor restoration creativity and rough texture on the basis of achieving high-performance restoration images, and introduces text modality to guide and enrich the restoration content.
[0005] In order to achieve the above purpose, the technical solution of this application is as follows:
[0006] An image restoration method based on multimodal pseudo-style embedding, comprising:
[0007] Obtain a boundary map of the image to be repaired through edge detection;
[0008] Input the boundary map into the boundary completion network, perform boundary completion to obtain a boundary completion map;
[0009] The text description and boundary completion map corresponding to the image to be repaired are input into the multimodal pseudo-style generation network to generate two different pseudo-style maps with rich text semantics.
[0010] The image to be restored and two different pseudo-style maps are input into the twin style encoder for feature extraction. The extracted features are subjected to attention operation to obtain the first reconstructed feature maps of three resolutions corresponding to the two different styles.
[0011] The first reconstructed feature maps of the same resolution of the two styles are fused to obtain the second reconstructed features, and then the second reconstructed features of the three resolutions are fused and upsampled in sequence according to the resolution to obtain the restored image.
[0012] Furthermore, the step of inputting the boundary map into a boundary completion network and performing boundary completion to obtain a boundary completion map includes:
[0013] Down-sample the boundary map to obtain the first feature map;
[0014] Resize the first feature map to obtain a second feature map;
[0015] After performing pixel-level self-attention operation on the second feature map, it is combined with the second feature map through residual connection to obtain the third feature map;
[0016] After performing a linear change operation on the third feature map, a residual connection is performed with the third feature map to obtain a fourth feature map;
[0017] After performing pixel-level self-attention and linear transformation operations again, an upsampling operation is used to convert the size to the original resolution to obtain a boundary completion map.
[0018] Furthermore, the text description and the boundary completion map corresponding to the image to be repaired are input into the multimodal pseudo-style generation network to generate two different pseudo-style maps with rich text semantics, including:
[0019] The boundary completion image is passed through a visual encoder to obtain latent codes of three spatial resolutions, and then mapped to the latent space through linear transformation to obtain the visual latent code;
[0020] The text description corresponding to the image to be repaired is passed through a text encoder to obtain a text potential code;
[0021] By constraining the visual latent code through the textual latent code, the visual latent code containing semantic features is obtained;
[0022] The visual latent code containing semantic features is input into the style decoder to obtain two different pseudo-style maps with rich text semantics.
[0023] Furthermore, the twin style encoder adopts pre-trained ResNet18.
[0024] Furthermore, the image to be restored and the two different pseudo-style maps are input into the twin style encoder for feature extraction, and the extracted features are subjected to an attention operation to obtain first reconstructed feature maps of three resolutions corresponding to the two different styles, including:
[0025] The first pseudo style map is passed through the twin style encoder to extract the three-resolution style features corresponding to the first pseudo style map;
[0026] The second pseudo-style map is passed through the twin style encoder to extract the three-resolution style features corresponding to the second pseudo-style map;
[0027] The image to be restored passes through the twin style encoder to extract the corresponding features of the image to be restored at three resolutions;
[0028] Perform attention operations on the three resolution style features corresponding to the first pseudo style map and the corresponding resolution image features to be restored, respectively, to obtain the first reconstructed feature maps of the three resolutions under the first style;
[0029] Perform attention operations on the three resolution style features corresponding to the second pseudo style map and the corresponding resolution image features to be restored, respectively, to obtain the first reconstructed feature maps of the three resolutions under the second style;
[0030] The attention operation includes:
[0031] Style Features S1 i And the image feature Y to be repaired i Perform convolution operations separately to obtain style feature S1 i The corresponding tensor V s , K s and Q s , and the image feature Y to be repaired i The corresponding tensor V o , K o and Q o ;
[0032] In the channel dimension, concatenate the corresponding Q s and Q o Q Concat ;
[0033] Then Q Concat Respectively and transposed K s and K oPerform matrix multiplication operation to obtain the corresponding attention feature map;
[0034] The attention feature map is obtained by s 、V o Performing matrix multiplication operation can obtain the reconstructed features Att1 and Att2 with style map attributes;
[0035] The reconstructed features Att1 and Att2 are convolved to obtain the final reconstructed feature map M1 i .
[0036] Furthermore, the second reconstructed features of the three resolutions are sequentially fused and up-sampled according to the resolutions to obtain a restored image, including:
[0037] The second reconstructed feature map with the lowest resolution is fused and up-sampled with the second reconstructed feature map with the medium resolution to obtain a first fused feature map;
[0038] The first fused feature map is fused and up-sampled with the second reconstructed feature with the highest resolution to obtain a second fused feature map;
[0039] Perform upsampling and convolution operations on the second fused feature map to obtain a repaired image;
[0040] The fusion upsampling performs the following operations:
[0041] The low-resolution feature map M L The new low-resolution feature map M is obtained through convolution operation low , and then the feature map M L and the new low-resolution feature map M low Upsample to obtain the first low-resolution feature map M low1 and the second low-resolution feature map M low2 ;
[0042] The high-resolution feature map M H The new high-resolution feature map M is obtained through convolution operation high ;
[0043] The first low-resolution feature map M low1 and the second low-resolution feature map M low2 Respectively with the new high-resolution feature map M high Perform element-wise multiplication, concatenation and convolution operations to obtain the fused feature map F.
[0044] This application proposes an image restoration method based on multimodal pseudo-style embedding, which uses the guidance of text modality to fill the information gap when the loss rate is large and generate multiple style maps. Then, a controllable style embedding twin network is used to process the style map and the image to be restored in parallel, in which the multi-style hybrid transformer module realizes the migration of style map texture and the filling of the image to be restored, increasing the correlation of pixels in the global range and achieving a better restoration effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 This is a flow chart of the image restoration method of this application.
[0046] Figure 2 A structural diagram of an implementation example of a boundary completion network.
[0047] Figure 3 A structural diagram of an embodiment of a multimodal pseudo-style generation network.
[0048] Figure 4 A structural diagram of an embodiment of a controllable style embedding twin network.
[0049] Figure 5 This is a schematic diagram of the attention module of an embodiment of the present application.
[0050] Figure 6 This is a schematic diagram of the fusion upsampling operation of this application. DETAILED DESCRIPTION
[0051] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0052] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application.
[0053] An embodiment of the present application, such as Figure 1 As shown, a method for image restoration based on multimodal pseudo-style embedding is provided, which makes full use of the advantages of multimodal rich semantics to achieve a high-quality restoration method for filling in controllable style attributes of occluded areas. It includes:
[0054] Step S1: Obtain a boundary map of the image to be repaired through edge detection.
[0055] In this step, a boundary map of the image to be repaired is obtained by edge detection. For example, the Canny operator widely used in edge detection is used to detect the position where the grayscale intensity changes most strongly in the image to be repaired X, and finally a boundary map E of the image to be repaired X is obtained.
[0056] Specifically, edge detection first uses Gaussian filtering to smooth the image, and then finds the gradient in the image. Non-maximum suppression technology can be applied on it to filter out non-edge pixels and highlight blurred boundaries. At the same time, a double threshold method is applied to determine potential boundaries, and finally the required boundary map E is obtained.
[0057] Step S2: input the boundary map into the boundary completion network to complete the boundary to obtain a boundary completion map.
[0058] The boundary map E is generated by the image to be repaired X, and the corresponding damaged area boundary clues need a specially constructed network to explore. Since the boundary map does not contain rich texture details, it is easier to predict boundary information through the network, so the boundary map E can be input into the boundary completion network to obtain the complete completion map R.
[0059] In a specific embodiment, the boundary completion network is as follows Figure 2 As shown, the boundary map is input into the boundary completion network, and the boundary completion is performed to obtain the boundary completion map, including:
[0060] Step 2.1: Downsample the boundary map to obtain the first feature map.
[0061] In this embodiment, the input boundary map E is first downsampled using a convolution kernel with a step size of 2 and a kernel size of 3 to obtain a first feature map with a resolution of 256.
[0062] Step 2.2: resize the first feature map to obtain a second feature map.
[0063] This step resizes E1 to facilitate subsequent pixel-level self-attention operations, transforming its size from N×C×H×W to N×L×C. Among them, N is the number of images processed simultaneously, C is the number of channels, H is the feature map height, W is the feature map width, and L is equal to H times W.
[0064] Step 2.3: After performing pixel-level self-attention operation on the second feature map, it is combined with the second feature map through residual connection to obtain the third feature map.
[0065] The pixel-level self-attention operation in this embodiment uses the following function definition:
[0066] selfAttention(Q,K,V)=Softmax(Q·K T )·V;
[0067] Among them, Q, K and V represent query, key and value respectively, which are respectively combined with weight parameter W by E1 Q , W K and W V Since pixel-level self-attention has the ability to focus on global boundary information, pixel-level self-attention calculation can be performed in the boundary completion network to generate potential boundaries.
[0068] The feature map generated after the pixel-level self-attention operation is then combined with the second feature map through a residual connection to obtain the third feature map.
[0069] Step 2.4: After performing a linear change operation on the third feature map, perform a residual connection with the third feature map to obtain the fourth feature map.
[0070] In this step, the third feature map is mapped to another linear space (vector space) through a linear transformation layer, which alleviates the limitation of the simple data domain distribution, makes the network more capable of fitting complex tasks, and thus enhances the network's learnability. After the linear transformation, a residual connection is made with the third feature map to obtain the fourth feature map.
[0071] It should be noted that in the boundary completion network, there are layer normalization operations before the pixel-level self-attention layer and the linear change layer. Layer normalization is an effective regularization technique. It makes the neural network easier to train and improves the generalization ability of the model by maintaining the consistency of data distribution at each level. I will not go into details here.
[0072] Step 2.5: Perform pixel-level self-attention and linear transformation operations again, and then use upsampling to convert the size to the original resolution to obtain a boundary completion map.
[0073] In this embodiment, the boundary information is predicted by a boundary completion network, and the boundary map of the image to be repaired is completed, so that a boundary completion map after boundary completion can be obtained.
[0074] Step S3: input the text description and boundary completion map corresponding to the image to be repaired into the multimodal pseudo-style generation network to generate two different pseudo-style maps with rich text semantics.
[0075] In this step, a multimodal pseudo-style generation network is constructed, which inputs the boundary completion map R and the text description corresponding to the image to be repaired, and finally generates a pseudo-style map S with rich text semantics.
[0076] Specifically, the boundary completion image R is used as the visual modality input, and the text description corresponding to the image to be repaired is additionally introduced as the text modality input. Taking the image to be repaired as a face image as an example, the corresponding text description contains information such as the facial features, emotions, expressions, and background of the face image. Different images can naturally have corresponding text descriptions, which are not listed here one by one.
[0077] In a specific embodiment, the multimodal pseudo-style generation network is as follows: Figure 3 As shown in the figure, the text description and boundary completion map corresponding to the image to be repaired are input into the multimodal pseudo-style generation network to generate two different pseudo-style maps with rich text semantics, including:
[0078] Step 3.1: Pass the boundary completion image through the visual encoder to encode the latent codes of three spatial resolutions, and then map them to the latent space through linear transformation to obtain the visual latent code.
[0079] Specifically, the boundary completion map R is input into the visual encoder, which has a structure of 6 layers of convolutional layers with a step size of 2, including batch normalization and activation functions. The visual encoder can obtain multi-level feature maps with different resolutions, and the resolutions are 512, 256, 128, 64, 32, and 16 respectively; it is worth noting that the number of output channels of the last three layers of convolutional layers is 512, so three feature maps with 512 channel numbers of 16, 32, and 64 are obtained. At this time, the feature map is limited by the original image distribution and it is difficult to modify it adaptively. Therefore, this embodiment adopts linear change operations and activation functions to achieve decoupling of feature attributes by mapping the original distribution features into the potential space W space.
[0080] Considering the limitations of feature map information at a single scale, we selected three resolution sizes of 16, 32, and 64, and performed convolution downsampling with a step size of 2 to obtain vectors that focus on different feature details. These vectors are concatenated, and then a linear transformation of 512 to 512 dimensions and an activation function are performed on these feature vectors to map them to the latent space W, thereby completing the decoupling of feature attributes and facilitating subsequent constraints, and obtaining the visual latent code w v .
[0081] Step 3.2: The text description corresponding to the image to be repaired is passed through a text encoder to obtain a text latent code.
[0082] Specifically, the text description of the image to be repaired is obtained through a CLIP pre-trained text encoder to obtain the text potential code w t .
[0083] Step 3.3: Constrain the visual latent code through the textual latent code to obtain the visual latent code containing semantic features.
[0084] Map the visual modality data and text modality data together into the W space to obtain the corresponding latent code w v and w t These latent codes can be trained to semantically align heteromodal information; at the same time, due to the low coupling degree of the characteristic attributes of these latent codes, constrained modification of these latent codes is allowed, ultimately achieving information interaction between modalities.
[0085] This embodiment is to v Modify the constraints and bring w closer in W space v and w t , so that w v In this process, w t Specific semantic features, get the visual latent code w containing semantic features v , the function used in the constraint process is defined as follows:
[0086]
[0087] Among them, w v and w t They represent the obtained visual latent code and textual latent code respectively, which have the same dimension. L means that the latent code has L layers, generally L is 18, and pi represents the weight of the i-th layer of the latent code. represents the L2 loss, represents the loss function of the constraint.
[0088] Step 3.4: Input the visual latent code containing semantic features into the style decoder to obtain two different pseudo-style maps with rich text semantics.
[0089] In this embodiment, the constrained w v It can be used as attribute embedding input into the style decoder. In this embodiment, the pre-trained styleGAN is selected as the style decoder to reduce the training time, and finally a variety of pseudo-style maps S with text semantics are obtained.
[0090] Step S4: input the image to be repaired and two different pseudo-style maps into the twin style encoder for feature extraction. The extracted features are subjected to an attention operation to obtain the first reconstructed feature maps of three resolutions corresponding to the two different styles.
[0091] Specifically, Figure 4 A specific implementation of a controllable style embedding twin network is shown, including a twin style encoder, an attention module, and a fusion decoder.
[0092] In this step, the image to be restored X and the two pseudo style maps S1 and S2 are input into the twin style encoder to perform feature extraction on the image to be restored X and the two pseudo style maps S1 and S2 respectively.
[0093] In a specific embodiment, the twin style encoder uses a pre-trained ResNet18. Feature extraction is performed on the image to be repaired X and the two pseudo style maps S1 and S2 to obtain feature maps Y with different resolutions. i 、S1 i and S2 i , where i represents the level of the encoder, the smaller i is, the deeper the layer is, i∈{1,2,3,4,5}.
[0094] Specifically, the pseudo style map S1 is downsampled by the convolution layer or pooling layer in ResNet18 to obtain style features S15, S14, S13, S12, and S11 with spatial resolutions of 512, 256, 128, 64, and 32; similarly, the pseudo style map S2 is downsampled by the convolution layer or pooling layer in ResNet18 to obtain style features S25, S24, S23, S22, and S21 with spatial resolutions of 512, 256, 128, 64, and 32; the image to be repaired X is downsampled by the convolution layer or pooling layer in ResNet18 to obtain the image feature Y to be repaired i The above encoder is pre-trained, which can speed up the overall network convergence performance.
[0095] Considering the need to use the rich texture of the pseudo style map to assist Y i Feature reconstruction, so in Y i 、S1 i and Y i 、S2 i The pixel correlation across the image is calculated through attention operation. It is worth noting that since the amount of attention calculation is proportional to the square of the input size, a feature map size that is too large will cause a huge computational burden. At the same time, it is also necessary to pay attention to the multi-scale information of the features. Therefore, this embodiment selects the deepest three layers of the encoder to perform attention operations; specifically, for Y i 、S1 i and Y i 、S2 i , i∈{1,2,3} respectively perform special attention operations to obtain the reconstructed feature M1 with style map attributes i and M2 i , i∈{1,2,3}; then M1 i and M2 i It will be sent to the fusion decoder to complete the fusion upsampling and obtain the repair result.
[0096] In a specific embodiment, the attention operation is implemented using a multi-style hybrid transformer module, as shown in the attached Figure 5 As shown, S1i and Y i For example, perform the following operations:
[0097] Style Features S1 i and Y i Convolution operations with a convolution kernel of 1 and a channel number of 512, 128, and 64 are performed respectively, and then the length and width are reduced to one dimension through size transformation to obtain S1 i The corresponding tensor V s , K s and Q s , and Y i The corresponding tensor V o , K o and Q o ;
[0098] In the channel dimension, concatenate the corresponding Q s and Q o Q Concat , then Q Concat It has both style characteristics and original image characteristics;
[0099] Then Q Concat Respectively and transposed K s and K o Perform matrix multiplication to obtain the corresponding attention feature map, which can fuse self-attention and cross-map attention in a single operation;
[0100] The attention feature map is obtained by s 、V o Performing matrix multiplication operation can obtain the reconstructed features Att1 and Att2 with style map attributes;
[0101] The reconstructed features Att1 and Att2 are convolved to obtain the final reconstructed feature map M1 i .
[0102] Similarly, style feature S2 i and Y i Performing the attention operation can obtain the reconstructed feature map M2 with style map attributes. i , I will not go into details here.
[0103] Step S5: fuse the first reconstructed feature maps of the same resolution of the two styles to obtain the second reconstructed features, and then fuse and upsample the second reconstructed features of the three resolutions in sequence according to the resolution to obtain the restored image.
[0104] The previous steps obtain multi-level reconstruction features M1 i and M2 i,This embodiment requires to efficiently fuse the texture coherently ,these features and perform an upsampling operation at the same time to obtain the ,restored image.
[0105] Specifically, for the reconstructed feature maps M1 of different resolution sizes i and M2 i , i∈{1,2,3}, first M1 i and M2 i The two features are combined in the channel dimension and a convolution operation with a convolution kernel of 1 is used to obtain a reconstructed feature map M with diverse style attributes. i Then, by fusion upsampling, the output repaired RGB result image is finally obtained.
[0106] In one embodiment, the second reconstructed features of three resolutions are sequentially fused and up-sampled according to the resolutions to obtain a restored image, including:
[0107] Step 5.1, fusing and up-sampling the second reconstructed feature map with the lowest resolution and the second reconstructed feature map with the medium resolution to obtain a first fused feature map;
[0108] Step 5.2, fusing and upsampling the first fused feature map with the second reconstructed feature with the highest resolution to obtain a second fused feature map;
[0109] Step 5.3: Perform upsampling and convolution operations on the second fused feature map to obtain a repaired image.
[0110] Among them, the fusion upsampling principle is as follows Figure 6 As shown, perform the following operations:
[0111] Step F1: transform the low-resolution feature map M L The new low-resolution feature map M is obtained through convolution operation low , and then the feature map M L and the new low-resolution feature map M low Upsample to obtain the first low-resolution feature map M low1 and the second low-resolution feature map M low2 .
[0112] Step F2: High-resolution feature map M H The new high-resolution feature map M is obtained through convolution operation high .
[0113] Step F3: First low-resolution feature map M low1 and the second low-resolution feature map M low2 Respectively with the new high-resolution feature map M high Perform element-wise multiplication and then concatenate and convolve to obtain the fused feature map F.
[0114] Specifically, the reconstructed feature map M with various style attributes i , i∈{1,2,3} as input, and select the adjacent layer outputs as the corresponding two inputs in order from deep to shallow. Taking M1 and M2 as examples, the low-resolution input M1 is named M L , a new low-resolution feature map M is obtained through a convolution operation with a convolution kernel of 1 low , respectively, for the original feature map M L And the new feature map M low Perform upsampling interpolation operation with resolution × 2 to obtain M low1 and M low2 ;
[0115] For the high-resolution feature M2 in the input (corresponding to the image type M H ), a new multi-channel high-resolution feature map M is obtained through a convolution operation with a convolution kernel of 1 and an output channel of twice the original channel. high , at this time M high With M low1 、M low2 Consistent resolution;
[0116] Two feature maps M low1 and M low2 Same resolution as M high Perform corresponding element multiplication operation;
[0117] The two new feature maps are concatenated in the channel dimension, and then a convolution operation with a convolution kernel of 1 is performed to obtain the fusion result of the features of different resolutions in adjacent layers, and finally the output multi-level reconstructed features are obtained, that is, the fused feature map F1;
[0118] Similarly, the fused feature maps F1 and M3 are used as two high- and low-resolution inputs, and after fusion upsampling, a multi-level reconstructed feature F2 is obtained;
[0119] Subsequently, since there is no additional reconstructed feature input, the feature is directly upsampled; specifically, bilinear interpolation and convolution operations with a convolution kernel of 1 are performed on feature F2 to double the feature resolution, obtaining feature F3; the above process is repeated twice, and the resolution is progressively expanded twice, and finally a complete RGB result image with the same resolution as the original input X is obtained.
[0120] This embodiment uses the guidance of text modal information to fill the information gap when the loss rate is large and generate multiple style maps. Then, the controllable style embedding twin network (twin style encoder, attention module and fusion decoder) is used to process the style map and the image to be repaired in parallel, among which the attention module (multi-style hybrid transformer module) realizes the migration of style map texture and the filling of the image to be repaired, increasing the correlation of pixels in the global range and achieving better repair effect.
[0121] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0122] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. An image restoration method based on multimodal pseudo-style embedding, characterized in that: The image restoration method based on multimodal pseudo-style embedding includes: Obtain a boundary map of the image to be repaired through edge detection; Input the boundary map into the boundary completion network, perform boundary completion to obtain a boundary completion map; The text description and boundary completion map corresponding to the image to be repaired are input into the multimodal pseudo-style generation network to generate two different pseudo-style maps with rich text semantics. The image to be restored and two different pseudo-style maps are input into the twin style encoder for feature extraction. The extracted features are subjected to attention operation to obtain the first reconstructed feature maps of three resolutions corresponding to the two different styles. The first reconstructed feature maps of the same resolution of the two styles are fused to obtain the second reconstructed features, and then the second reconstructed features of the three resolutions are fused and upsampled in sequence according to the resolution to obtain the restored image.
2. The image restoration method based on multimodal pseudo-style embedding according to claim 1, characterized in that: The step of inputting the boundary map into the boundary completion network and performing boundary completion to obtain the boundary completion map includes: Down-sample the boundary map to obtain the first feature map; Resize the first feature map to obtain a second feature map; After performing pixel-level self-attention operation on the second feature map, it is combined with the second feature map through residual connection to obtain the third feature map; After performing a linear change operation on the third feature map, a residual connection is performed with the third feature map to obtain a fourth feature map; After performing pixel-level self-attention and linear transformation operations again, an upsampling operation is used to convert the size to the original resolution to obtain a boundary completion map.
3. The image restoration method based on multimodal pseudo-style embedding according to claim 1, characterized in that: The text description and boundary completion map corresponding to the image to be repaired are input into the multimodal pseudo-style generation network to generate two different pseudo-style maps with rich text semantics, including: The boundary completion image is passed through a visual encoder to obtain latent codes of three spatial resolutions, and then mapped to the latent space through linear transformation to obtain the visual latent code; The text description corresponding to the image to be repaired is passed through a text encoder to obtain a text potential code; By constraining the visual latent code through the textual latent code, the visual latent code containing semantic features is obtained; The visual latent code containing semantic features is input into the style decoder to obtain two different pseudo-style maps with rich text semantics.
4. The image restoration method based on multimodal pseudo-style embedding according to claim 1, characterized in that: The twin style encoder adopts the pre-trained ResNet18.
5. The image restoration method based on multimodal pseudo-style embedding according to claim 1, characterized in that: The image to be restored and two different pseudo style maps are input into the twin style encoder for feature extraction. The extracted features are subjected to attention operation to obtain first reconstructed feature maps of three resolutions corresponding to two different styles, including: The first pseudo style map is passed through the twin style encoder to extract the three-resolution style features corresponding to the first pseudo style map; The second pseudo-style map is passed through the twin style encoder to extract the three-resolution style features corresponding to the second pseudo-style map; The image to be restored passes through the twin style encoder to extract the corresponding features of the image to be restored at three resolutions; Perform attention operations on the three resolution style features corresponding to the first pseudo style map and the corresponding resolution image features to be restored, respectively, to obtain the first reconstructed feature maps of the three resolutions under the first style; Perform attention operations on the three resolution style features corresponding to the second pseudo style map and the corresponding resolution image features to be restored, respectively, to obtain the first reconstructed feature maps of the three resolutions under the second style; The attention operation includes: Style Features S1 i And the image feature Y to be repaired i Perform convolution operations separately to obtain style feature S1 i The corresponding tensor V s , K s and Q s , and the image feature Y to be repaired i The corresponding tensor V o , K o and Q o ; In the channel dimension, concatenate the corresponding Q s and Q o Q Concat ; Then Q Concat Respectively and transposed K s and K o Perform matrix multiplication operation to obtain the corresponding attention feature map; The attention feature map is obtained by s 、V o Performing matrix multiplication operation can obtain the reconstructed features Att1 and Att2 with style map attributes; The reconstructed features Att1 and Att2 are convolved to obtain the final reconstructed feature map M1 i .
6. The image restoration method based on multimodal pseudo-style embedding according to claim 1, characterized in that: The second reconstructed features of the three resolutions are sequentially fused and up-sampled according to the resolutions to obtain a restored image, including: The second reconstructed feature map with the lowest resolution is fused and up-sampled with the second reconstructed feature map with the medium resolution to obtain a first fused feature map; The first fused feature map is fused and up-sampled with the second reconstructed feature with the highest resolution to obtain a second fused feature map; Perform upsampling and convolution operations on the second fused feature map to obtain a repaired image; The fusion upsampling performs the following operations: The low-resolution feature map M L The new low-resolution feature map M is obtained through convolution operation low , and then the feature map M L and the new low-resolution feature map M low Upsample to obtain the first low-resolution feature map M low1 and the second low-resolution feature map M low2 ; The high-resolution feature map M H The new high-resolution feature map M is obtained through convolution operation high ; The first low-resolution feature map M low1 and the second low-resolution feature map M low2 Respectively with the new high-resolution feature map M high Perform element-wise multiplication, concatenation and convolution operations to obtain the fused feature map F.
Citation Information
Cited By
Data processing method and device, storage medium and electronic equipment
CN121327198A
