A defective video restoration method and system based on strong perception Transformer architecture
By introducing cross-stacked local perception Transformer and global perception Transformer structures into the video repair model, and combining multi-size window attention and a multi-head self-attention mechanism of global embedding vectors, the problem of blurred texture features and insufficient detail information in video repair is solved. , achieving a more detailed and consistent repair effect.
Patent Information
- Application Number
- CN202410912771.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-09
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2044-07-09
AI Technical Summary
Existing Transformer-based video repair models have weak capabilities in processing detailed textures, resulting in blurred texture features and lack of detailed information in the repaired area.
The cross-stacked local perception Transformer and global perception Transformer structures are used, combined with the multi-size window attention mechanism and the multi-head self-attention mechanism of the global embedding vector, to enhance the perception of local texture and global structure through feature extraction and texture information modeling. and structural information modeling, utilizing deconvolutional layers for video frame reconstruction.
While maintaining structural consistency, the detail of the repair results and the accuracy of texture information are significantly improved, and the problems of blurred texture features and lack of detailed information are solved.
Smart Images

Figure CN118469876B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of video processing technology, and in particular to a defective video repair method and system based on a strong perception Transformer architecture. Background Art
[0002] Video restoration refers to the process of filling and completing damaged areas in a video. Its application scenarios include restoration of old film and television materials, completion of damaged pixel blocks, and film and television post-processing, such as removal of subtitles, watermarks, and specific objects. The challenge of video restoration technology is that the restored area must have a certain rationality in the single-frame spatial content and maintain a high degree of consistency in the multi-frame time domain to improve visual quality and give people a smooth viewing experience.
[0003] Traditional video restoration methods are derived from single-frame image restoration technology. Directly applying image restoration methods to each frame of a video will result in time inconsistency problems such as distortion or jitter. Deep learning-based methods use learning from large-scale data sets to automatically capture complex features in images and videos. These methods show higher accuracy and generalization capabilities in video restoration tasks. Initially, 3D convolution was used to learn the temporal information between video frames to maintain temporal coherence. However, due to the limitations of the convolution receptive field, when the motion changes between consecutive frames are large, 3D convolution cannot fully capture the complete motion information, resulting in spatial misalignment between adjacent frames. To solve this problem, researchers introduced optical flow to propagate the missing areas, thereby effectively aligning the spatial content in adjacent frames. In addition, the Transformer architecture has achieved remarkable results in the field of computer vision with its powerful sequence modeling capabilities and parallel computing capabilities. The introduction of the Transformer architecture in video restoration makes up for the defects of the convolutional neural network's receptive field limitations, can capture the feature information of distant frames, and make the restoration content more reasonable. However, the Transformer-based video restoration model is better at capturing global structural information and has weaker modeling capabilities for detailed textures. Because Transformer is built based on the self-attention mechanism, it captures global information by establishing attention relationships between different positions, and can effectively understand the overall structure and layout of video frames, such as the relative positions and overall relationships of objects. However, when processing detailed textures, it is not as good as the strong local perception ability of the CNN model. Therefore, existing Transformer-based video restoration models usually have the problem of unclear texture features in the restoration area and lack of detailed information. Summary of the invention
[0004] The purpose of the present invention is to solve the problems existing in the prior art such as unclear texture features of the repaired area and lack of detail information.
[0005] The technical solution adopted by the present invention to solve the technical problem is: to provide a defective video restoration method based on a strong perception Transformer architecture, comprising the following steps:
[0006] The feature extraction module receives a defective video frame sequence to be repaired, extracts features from the video frames using a convolutional neural network, and outputs a first feature;
[0007] The strong perception Transformer module receives the first feature, uses a cross-stacked local perception Transformer and global perception Transformer structure to perform texture information modeling and structural information modeling on the first feature, and outputs the second feature;
[0008] The reconstruction module receives the second feature, uses a deconvolution layer to reconstruct the video frame, and outputs a repaired video frame sequence.
[0009] Preferably, the feature extraction module uses a convolutional neural network to extract features from video frames, including the following steps:
[0010] The defective video frame sequence to be repaired F={F1,...,F M},F i ∈R h×w×3 , i∈[0,M] is transformed into a feature map X with channel c i ∈R h / 4×w / 4×c ;
[0011] Each feature map is divided into overlapping k×k patches and linearly embedded into tokens. A frame token is represented by Z∈R (M×n)×d , d is the number of channels, n is the number of tokens in a frame, expressed as:
[0012]
[0013] h'=h / 4;
[0014] w'=w / 4;
[0015] Among them, h' and w' represent the feature map X i The height and width of , p is the padding, s is the stride;
[0016] Output tokens as the first feature to the strong perception Transformer module.
[0017] Preferably, the strong perception transformer module includes four groups of perception transformers connected in sequence, wherein the first group of perception transformers and the third group of perception transformers are local perception transformers, and the second group of perception transformers and the fourth group of perception transformers are global perception transformers; and a branch residual structure is also included between the local perception transformer and the global perception transformer;
[0018] The local-aware Transformer uses a multi-size window attention mechanism to model local features of the input features, and the global-aware Transformer uses a multi-head self-attention mechanism of the global embedding vector to model global features of the input features.
[0019] Preferably, the strong perception Transformer module performs texture information modeling and structure information modeling on the first feature, comprising the following steps:
[0020] The tokens output by the feature extraction module enter the first set of perceptual transformers, and the output of the first set of perceptual transformers enters the second set of perceptual transformers;
[0021] After the output of the first set of perception transformers and the output of the second set of perception transformers are feature fused, they enter the third set of perception transformers;
[0022] After the output of the second group of perception transformers and the output of the third group of perception transformers are feature fused, they enter the fourth group of perception transformers;
[0023] The output of the fourth set of perceptual Transformers is reshaped into a patch shape of k×k×c;
[0024] All patches correspond to feature maps X i Put it back to the original position and get the feature map It is output as the second feature to the reconstruction module.
[0025] Preferably, the local perception Transformer includes a normalization layer, a multi-size window multi-head self-attention, a normalization layer and a feedforward network layer connected in sequence.
[0026] Preferably, the structure of the local perception Transformer adopts a multi-size window attention mechanism to model local features, including the following steps:
[0027] The input Z∈R (M×n)×d Convert to Z'∈R M×h'×w'×d , h'×w'=n;
[0028] Divide Z' into overlapping 4×4 small-size windows and 16×16 large-size windows in space;
[0029] After the feature blocks of the large-size window are pooled, they are spliced with the feature blocks of the small-size window to obtain spliced features;
[0030] Perform multi-head self-attention calculation on the feature blocks and splicing features of the small-size window and output the attention features
[0031] Preferably, the global perception Transformer includes a normalization layer, a multi-size window multi-head self-attention using a global embedding vector, a normalization layer and a feedforward network layer connected in sequence.
[0032] Preferably, the global perception Transformer adopts a multi-head self-attention mechanism of a global embedding vector to model global features, which is expressed as:
[0033] O = Softmax(QE T +B2)Softmax(EK T +B1)V+DWC(V);
[0034] E = Pooling(Q);
[0035] Among them, O represents the output of the multi-head self-attention mechanism, Q, K and V represent the query matrix, key matrix and value matrix respectively, E represents the global embedding vector, Pooling represents the pooling operation, B1 and B2 both represent bias, and DWC represents the depth-wise separable convolution operation.
[0036] The present invention also provides a defective video restoration system based on a strong perception Transformer architecture, comprising:
[0037] A feature extraction module is used to receive a defective video frame sequence to be repaired and extract features from the video frames using a convolutional neural network;
[0038] The strong perception Transformer module is used to receive the extracted features and use the cross-stacked local perception Transformer and global perception Transformer structures to perform texture information modeling and structural information modeling on the extracted features;
[0039] The reconstruction module is used to receive texture information modeling and structure information modeling, use the deconvolution layer to reconstruct the video frame, and output the repaired video frame sequence.
[0040] The present invention has the following beneficial effects:
[0041] (1) The present invention designs a strong perception Transformer architecture, including a local perception Transformer and a global perception Transformer structure. The cross-stacking and branch residual fusion structure enhances the model's perception of global structure and local texture information, so that the restoration result can have more detailed texture information while maintaining structural consistency.
[0042] (2) The local perception Transformer of the present invention introduces multi-size window attention in the spatial dimension to enhance the capture of local texture information;
[0043] (3) The global-aware Transformer of the present invention sets a global embedding vector to aggregate the global information of the entire sequence and participate in the calculation of attention, so that the model can effectively utilize the global information while maintaining low computational complexity.
[0044] The present invention is further described in detail below in conjunction with the accompanying drawings and embodiments, but the present invention is not limited to the embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 A method step diagram of an embodiment of the present invention;
[0046] Figure 2 It is a schematic diagram of a flow chart of an embodiment of the present invention;
[0047] Figure 3 The local perception Transformer structure diagram and the global perception Transformer structure diagram of the embodiment of the present invention;
[0048] Figure 4 This is a flow chart of calculation of multi-size window attention according to an embodiment of the present invention;
[0049] Figure 5 A calculation flow chart of multi-head self-attention using a global embedding vector in an embodiment of the present invention;
[0050] Figure 6 4 is a system structure diagram of an embodiment of the present invention. DETAILED DESCRIPTION
[0051] See also Figure 1 and Figure 2 The method step diagram and flow chart of an embodiment of the present invention are shown, which include the following steps:
[0052] S101, a feature extraction module receives a defective video frame sequence to be repaired, extracts features from the video frames using a convolutional neural network, and outputs a first feature;
[0053] S102, the strong perception Transformer module receives the first feature, uses a cross-stacked local perception Transformer and global perception Transformer structure to perform texture information modeling and structural information modeling on the first feature, and outputs a second feature;
[0054] S103, the reconstruction module receives the second feature, uses a deconvolution layer to reconstruct the video frame, and outputs a repaired video frame sequence.
[0055] Specifically, the process of obtaining the first feature by the feature extraction module is as follows: for the defective video sequence F = {F1, ..., F M},F i ∈R h×w×3 , i∈[0,M], and transforms it into a feature map X with channel c based on a convolutional neural network i ∈R h / 4×w / 4×c , i∈[0,M]; then, each feature map is divided into overlapping k×k patches and linearly embedded into tokens, d is the number of channels of the token, and n is the number of tokens in one frame, expressed as:
[0056]
[0057] h'=h / 4;
[0058] w'=w / 4;
[0059] Among them, h' and w' represent the feature map X i The height and width of , p is the padding, and s is the step size. The tokens in this part are input into the strong perception Transformer architecture as the first feature.
[0060] The strong perception transformer module is the core part of the present invention. The module consists of four groups of cross-stacked local perception transformers and global perception transformers, which capture local texture information features and global structural features respectively. The first and third groups of perception transformers are local perception transformers, and the second and fourth groups of perception transformers are global perception transformers. At the same time, information is transmitted by branch residual fusion, making the repair content more reasonable and consistent.
[0061] Specifically, the local perception Transformer structure diagram and the global perception Transformer structure diagram are as follows Figure 3As shown in Figure 1, the traditional Transformer structure is adopted in the local perception Transformer and global perception Transformer blocks, including the normalization layer LayerNorm, multi-head self-attention calculation and feedforward network layer.
[0062] Specifically, the first feature Z∈R obtained from the feature extraction module (M×n)×d First enter the first set of perception Transformer and get Z1∈R (M×n)×d ; Then Z1∈R (M×n)×d Enter the second set of perception Transformer and get Z2∈R (M ×n)×d ; After residual fusion of Z2 and Z1, they enter the third set of perceptual Transformers to obtain Z3∈R (M×n)×d ; After residual fusion of Z3 and Z2, they enter the fourth set of perception Transformers to obtain Z4, which is the output of the entire architecture.
[0063] Specifically, the local-aware Transformer introduces a multi-size window attention mechanism in the spatial dimension to model local features, such as Figure 4 As shown, the input tokens are represented by Z∈R (M×n)×d Convert to Z'∈R M×h'×w'×d , h'×w'=n, divided into overlapping 4×4 small-size windows and 16×16 large-size windows in space, multi-head attention calculation is performed in the small-size window, and after pooling operation in the large-size window, it is spliced with the feature d blocks of the small-size window to perform multi-head attention calculation. Such an attention calculation strategy can better capture local texture information, thereby improving the performance and generalization ability of the model.
[0064] Specifically, the global-aware Transformer sets a global embedding vector to aggregate the global information of the entire sequence and participate in the calculation of attention, so that the model can effectively utilize global information while maintaining low computational complexity. Figure 5 As shown in the figure, the global embedding vector E is generated by pooling the query matrix Q, and softmax attention is calculated with K and V to aggregate global information and obtain global aggregate features. Then the global embedding vector is used as the key matrix K' for attention calculation, and the global aggregate features are used as the value matrix V' for attention calculation to perform softmax attention calculation with the query matrix Q. This part of the output is finally added to V after the depth-separable convolution operation to obtain the final output. The calculation formula of this module is
[0065] O = Softmax(QE T +B2)Softmax(EK T+B1)V+DWC(V);
[0066] Among them, Q,K,V∈R (M×n)×d ,E=Pooling(Q)∈R (M×m)×d ,B1∈R (M×m)×(M×n) ,B2∈R (M ×n)×(M×m) , B1, B2 are biases. m is set to a very small hyperparameter, so the attention module can effectively reduce the computational complexity.
[0067] Specifically, the strong perception Transformer module is for the last set of perception Transformer outputs First reshape it into a patch shape of k×k×c, and then all patches correspond to their original positions to obtain the feature map Output to the reconstruction module.
[0068] Finally, in the reconstruction module, several sets of deconvolution layers are used to transform the feature maps Decode and output the final repaired video
[0069] For details, see Figure 6 As shown, it is a system structure diagram of an embodiment of the present invention, including:
[0070] The feature extraction module 601 is used to receive a defective video frame sequence to be repaired and extract features from the video frames using a convolutional neural network;
[0071] A strong perception transformer module 602 is used to receive the extracted features and use a cross-stacked local perception transformer and global perception transformer structure to perform texture information modeling and structural information modeling on the extracted features;
[0072] The reconstruction module 603 is used to receive texture information modeling and structure information modeling, use a deconvolution layer to reconstruct video frames, and output a restored video frame sequence.
[0073] The present invention adopts cross-stacked local-aware Transformer and global-aware Transformer to model texture information and structural information, wherein a multi-size window attention calculation is introduced in the local-aware Transformer to capture local features in the spatial dimension, and a global embedding vector is set in the global-aware Transformer to gather the global information of the entire sequence, which greatly reduces the computational complexity while effectively capturing the global features, solves the problems of lack of detailed texture in the repaired area and mismatch between the global structure and the local texture in the current defective video repair method, and achieves better repair effect.
[0074] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A defective video restoration method based on a strong perception Transformer architecture, characterized in that: The following steps are involved: The feature extraction module receives a defective video frame sequence to be repaired, extracts features from the video frames using a convolutional neural network, and outputs a first feature; The strong perception Transformer module receives the first feature, uses a cross-stacked local perception Transformer and global perception Transformer structure to perform texture information modeling and structural information modeling on the first feature, and outputs the second feature; The reconstruction module receives the second feature, uses a deconvolution layer to reconstruct the video frame, and outputs a repaired video frame sequence; The strong perception transformer module includes four groups of perception transformers connected in sequence, wherein the first group of perception transformers and the third group of perception transformers are local perception transformers, and the second group of perception transformers and the fourth group of perception transformers are global perception transformers; and a branch residual structure is also included between the local perception transformer and the global perception transformer; The local-aware Transformer uses a multi-size window attention mechanism to model local features of the input features, and the global-aware Transformer uses a multi-head self-attention mechanism of the global embedding vector to model global features of the input features.
2. The defective video restoration method based on the strong perception Transformer architecture according to claim 1 is characterized in that: The feature extraction module uses a convolutional neural network to extract features from video frames, including the following steps: The defective video frame sequence to be repaired F={F1,...,F M },F i ∈R h×w×3 , i∈[0,M] is transformed into a feature map X with channel c i ∈R h / 4×w / 4×c ; Each feature map is divided into overlapping k×k patches and linearly embedded into tokens. A frame token is represented by Z∈R (M×n)×d , d is the number of channels, n is the number of tokens in a frame, expressed as: h'=h / 4; w'=w / 4; Among them, h' and w' represent the feature map X i The height and width of , p is the padding, s is the stride; Output tokens as the first feature to the strong perception Transformer module.
3. The defective video restoration method based on the strong perception Transformer architecture according to claim 2 is characterized in that: The strong perception Transformer module performs texture information modeling and structure information modeling on the first feature, including the following steps: The tokens output by the feature extraction module enter the first set of perceptual transformers, and the output of the first set of perceptual transformers enters the second set of perceptual transformers; After the output of the first set of perception transformers and the output of the second set of perception transformers are feature fused, they enter the third set of perception transformers; After the output of the second group of perception transformers and the output of the third group of perception transformers are feature fused, they enter the fourth group of perception transformers; The output of the fourth set of perceptual Transformers is reshaped into a patch shape of k×k×c; All patches correspond to feature maps X i Put it back to the original position and get the feature map It is output as the second feature to the reconstruction module.
4. The defective video restoration method based on the strong perception Transformer architecture according to claim 3 is characterized in that: The local perception Transformer includes a normalization layer, a multi-size window multi-head self-attention, a normalization layer and a feedforward network layer connected in sequence.
5. The defective video restoration method based on the strong perception Transformer architecture according to claim 4 is characterized in that: The structure of the local perception Transformer adopts a multi-size window attention mechanism to model local features, including the following steps: The input Z∈R (M×n)×d Convert to Z'∈R M×h'×w'×d , h'×w'=n; Divide Z' into overlapping 4×4 small-size windows and 16×16 large-size windows in space; After the feature blocks of the large-size window are pooled, they are spliced with the feature blocks of the small-size window to obtain spliced features; Perform multi-head self-attention calculation on the feature blocks and splicing features of the small-size window and output the attention features 6. The defective video restoration method based on the strong perception Transformer architecture according to claim 3 is characterized in that: The global perception Transformer includes a normalization layer, a multi-size window multi-head self-attention using a global embedding vector, a normalization layer, and a feedforward network layer connected in sequence.
7. The defective video restoration method based on the strong perception Transformer architecture according to claim 6 is characterized in that: The global perception Transformer uses a multi-head self-attention mechanism of the global embedding vector to model global features, which can be expressed as: O=Softmax(QE T +B2)Softmax(EK T +B1) / +DWC(V); E = Pooling(Q); Among them, O represents the output of the multi-head self-attention mechanism, Q, K and V represent the query matrix, key matrix and value matrix respectively, E represents the global embedding vector, Pooling represents the pooling operation, B1 and B2 both represent bias, and DWC represents the depth-wise separable convolution operation.
8. A defective video restoration system based on a strong perception Transformer architecture, characterized in that: include: A feature extraction module is used to receive a defective video frame sequence to be repaired and extract features from the video frames using a convolutional neural network; The strong perception Transformer module is used to receive the extracted features and use the cross-stacked local perception Transformer and global perception Transformer structures to perform texture information modeling and structural information modeling on the extracted features; The reconstruction module is used to receive texture information modeling and structure information modeling, use the deconvolution layer to reconstruct the video frame, and output the restored video frame sequence; The strong perception transformer module includes four groups of perception transformers connected in sequence, wherein the first group of perception transformers and the third group of perception transformers are local perception transformers, and the second group of perception transformers and the fourth group of perception transformers are global perception transformers; and a branch residual structure is also included between the local perception transformer and the global perception transformer; The local-aware Transformer uses a multi-size window attention mechanism to model local features of the input features, and the global-aware Transformer uses a multi-head self-attention mechanism of the global embedding vector to model global features of the input features.
