An image super-resolution method and system based on composite Transformer
By using a composite Transformer network in the image super-resolution model, combining residual composite and integrated Transformers, and alternately applying spatial and channel attention layers, the problem of insufficient global feature extraction capabilities is solved, and the image reconstruction quality and detail fidelity are significantly improved. Spend.
Patent Information
- Application Number
- CN202410626959.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-21
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2044-05-21
AI Technical Summary
Image super-resolution models in the existing technology have insufficient global feature extraction capabilities and cannot maximize the combination of window self-attention and channel self-attention, resulting in limited image reconstruction performance.
Using an image super-resolution network based on composite Transformer, by constructing a shallow feature extraction module, a deep feature extraction module and an image reconstruction module, combined with the residual composite Transformer and integrated Transformer, the spatial multi-head attention layer and the channel group attention layer are alternately applied , achieves dual feature aggregation between and within blocks, capturing global context and local features.
It achieves better global feature extraction, improves the quality of image reconstruction, takes into account the reconstruction effect of detailed texture and high-resolution images, avoids the loss of spatial information, and significantly improves the PSNR and SSIM performance of super-resolution images.
Smart Images

Figure CN118229532B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image super-resolution, and in particular to an image super-resolution method and system based on a composite Transformer. Background Art
[0002] Image super-resolution (SR) aims to reconstruct a high-resolution (HR) image with rich details from a low-resolution (LR) image. However, since an LR image can be reconstructed into multiple different HR images, the SR task is a highly ill-posed problem. Due to the powerful feature expression ability of Transformer, many excellent Transformer-based SR models have emerged in recent years. Transformer has good global feature mapping capabilities because it can establish long-distance dependencies between pixels, which is conducive to more comprehensive restoration of edge texture details of the image. These methods can significantly improve SR performance based on window self-attention or channel self-attention. However, there are few technical solutions that combine the two or only simply combine them and fail to maximize the global feature extraction capabilities of the two. Summary of the invention
[0003] The purpose of the present invention is to solve the problem of insufficient ability to extract global features of images in the prior art.
[0004] The technical solution adopted by the present invention to solve the technical problem is: to provide an image super-resolution method based on a composite Transformer, comprising the following steps:
[0005] Construct an image super-resolution network based on a composite Transformer;
[0006] The composite Transformer-based image super-resolution network is used to achieve super-resolution reconstruction of low-resolution images and output the corresponding high-resolution images.
[0007] The composite Transformer-based image super-resolution network includes a shallow feature extraction module, a deep feature extraction module and an image reconstruction module connected in sequence, the shallow feature extraction module processes the input low-resolution image to obtain shallow features and inputs them to the deep feature extraction module, the deep feature extraction module processes the shallow features to obtain deep features and inputs them to the image reconstruction module, and the image reconstruction module upsamples the deep features to obtain a super-resolution image; wherein the deep feature extraction module includes a plurality of residual groups connected in sequence, each residual group includes a residual composite Transformer and an integrated Transformer, the residual composite Transformer includes a spatial multi-head attention layer and a channel group attention layer, and the integrated Transformer includes an integrated self-attention and a convolutional feedforward network.
[0008] Preferably, the shallow feature extraction module extracts the low-resolution input image and its corresponding inverse Fourier transform image. Convolutional layers are used to generate shallow features Among them, H and W represent the height and width of the input image, and C represents the number of feature channels.
[0009] Preferably, for the nth residual group, its input is X n-1 and F f , X n-1 and F f After passing through a residual composite Transformer, Y is generated n and Y f , Y n and Y f Input and integrate Transformer together, and the output is X n ; Among them, the input X of the first residual group 1 =F S , the output of the last residual group X N After a convolutional layer, the deep feature F is generated D , N represents the number of residual groups.
[0010] Preferably, the residual composite Transformer comprises a number of alternately connected spatial multi-head attention layers and channel group attention layers, with a convolutional layer introduced at the end; the spatial multi-head attention layer comprises layer normalization, spatial multi-head attention, layer normalization and a convolutional feedforward network connected in sequence; the channel group attention layer comprises layer normalization, channel group attention, layer normalization and a convolutional feedforward network connected in sequence.
[0011] Preferably, the internal operation of the spatial multi-head attention includes the following steps:
[0012] The query matrix, key matrix and value matrix are generated by linear projection, denoted as Q1, K1 and V1 respectively. Q1, K1 and V1 are all in In space, it is represented as:
[0013] Q1=X S W Q , K1=XSWK,V1=X S W V ;
[0014] Among them, X S represents the input of spatial multi-head attention, is the linear projection corresponding to Q1, K1 and V1;
[0015] Divide Q1, K1, and V1 into non-overlapping windows and flatten each window to obtain Q s , K s and V s , Q s , K s and V s The size of Each window contains N w pixels; each window is divided into h heads, and the i-th head obtains Q s , K s and V s The i-th part of and V s i ; Output Y of the i-th head s i It is expressed as:
[0016]
[0017] Where D represents the relative position code, d represents the size of each head, d = C × h;
[0018] Through Y s i Deformation and concatenation to obtain output features It is expressed as:
[0019]
[0020] in It is a linear projection that combines all features.
[0021] Preferably, the internal operation of the channel group attention comprises the following steps:
[0022] The query matrix, key matrix and value matrix are generated by linear projection, denoted as Q2, K2 and V2 respectively. Q2, K2 and V2 are all in In space, it is represented as:
[0023] Q2=X C W Q , K2=X C W K , V2=X C W V ;
[0024] in, represents the input of the channel group attention, is the linear projection corresponding to Q2, K2 and V2;
[0025] Resize Q2, K2, and V2 to The transformed matrices are represented as Q c , K c and V c ;
[0026] Q c , K c and V c Divided into h heads, the i-th head obtains Q c , K c and V c The i-th part of and For the i-th head, the channel self-attention operation is performed, which is expressed as:
[0027]
[0028] in, represents the output of the i-th head; α is a learnable temperature parameter used to adjust the inner product before the softmax function;
[0029] Through all Cascade and transform to get output features It is expressed as:
[0030]
[0031] in It is a linear projection that combines all features.
[0032] Preferably, for the integrated Transformer in the nth residual group, given the input Y n , Y f And the Token reduction factor r, its internal operation is:
[0033] Y n and Y f Divide into N non-overlapping square windows with a side length of S;
[0034] Using three linear layers L Q , L K and L V To get Q3, K3 and V3:
[0035] Q3=Y n L Q , K3=Y f L K , V3=Y f L V ;
[0036] Among them, Q3 has a significant impact on Y n Keep the same channel dimension, while L K and L V Compress the channel dimension to C / r 2 ,get and
[0037] Transpose the spatial tokens in K3 and V3 to the channel dimension and get and
[0038] K p and V p To shrink, K p and V p The window size is reduced to S / r*S / r, and the channel dimension remains unchanged;
[0039] For Q3, the contraction of K p and the contracted V p Perform self-attention operation and get output X n , expressed as:
[0040]
[0041] Among them, RSA represents the integrated self-attention operation, B is the aligned relative position embedding, and d k is the dimension of the input vector.
[0042] Preferably, the image reconstruction module uses a sub-pixel convolution method to reconstruct the deep features F D Upsample to obtain high-resolution images Among them, H out Indicates height, W out Represents the image width; convolutional layers are used before and after the upsampling operation to aggregate features.
[0043] Preferably, a low-resolution image of dimensions H×W×C is used as input to an image super-resolution network based on a composite Transformer, and the output obtained is a high-resolution image of dimensions (H×scale)×(W×scale)×C, where scale is the magnification factor.
[0044] The present invention also provides an image super-resolution system based on a composite Transformer, comprising:
[0045] Network building module, used to build a composite Transformer-based image super-resolution network;
[0046] The network application module is used to realize super-resolution reconstruction of low-resolution images using a composite Transformer-based image super-resolution network and output the corresponding high-resolution image;
[0047] The composite Transformer-based image super-resolution network includes a shallow feature extraction module, a deep feature extraction module and an image reconstruction module connected in sequence, the shallow feature extraction module processes the input low-resolution image to obtain shallow features and inputs them to the deep feature extraction module, the deep feature extraction module processes the shallow features to obtain deep features and inputs them to the image reconstruction module, and the image reconstruction module upsamples the deep features to obtain a super-resolution image; wherein the deep feature extraction module includes a plurality of residual groups connected in sequence, each residual group includes a residual composite Transformer and an integrated Transformer, the residual composite Transformer includes a spatial multi-head attention layer and a channel group attention layer, and the integrated Transformer includes an integrated self-attention and a convolutional feedforward network.
[0048] The present invention has the following beneficial effects:
[0049] (1) Constructing a residual composite Transformer to aggregate features in both spatial and channel dimensions in both inter-block and intra-block ways. Specifically, spatial and channel self-attention are applied alternately in consecutive Transformers. This alternating strategy can capture global context and achieve inter-block feature aggregation, better extracting rich global and local features, so that the network can take into account the details and texture of the image and achieve high-quality reconstruction.
[0050] (2) In order to avoid the loss of spatial information, it is proposed to integrate Transformer, which reduces the number of channels and transfers the spatial information to the channel dimension, thereby reducing channel redundancy without losing spatial information, helping to reconstruct high-resolution images.
[0051] 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
[0052] Figure 1 A method step diagram of an embodiment of the present invention;
[0053] Figure 2 Schematic diagram of an image super-resolution network according to an embodiment of the present invention, wherein (a) is a schematic diagram of the entire network, and (b) is a schematic diagram of a residual composite Transformer;
[0054] Figure 3 Schematic diagram of the residual composite Transformer of an embodiment of the present invention, wherein (a) is a schematic diagram of a spatial multi-head attention layer and a channel group attention layer, (b) is a schematic diagram of a spatial multi-head attention layer, and (c) is a schematic diagram of a channel group attention layer;
[0055] Figure 4 A schematic diagram of an integrated Transformer according to an embodiment of the present invention;
[0056] Figure 5 A visualization diagram of different attention strategies used in embodiments of the present invention;
[0057] Figure 6 This is a diagram showing the subjective effects of the embodiments of the present invention and other SR methods at a 4x scaling factor;
[0058] Figure 7 4 is a system structure diagram of an embodiment of the present invention. DETAILED DESCRIPTION
[0059] See also Figure 1 FIG. 1 is a diagram showing steps of a method according to an embodiment of the present invention, comprising the following steps:
[0060] S101, building an image super-resolution network based on a composite Transformer;
[0061] S102, using a composite Transformer-based image super-resolution network to achieve super-resolution reconstruction of the low-resolution image and output a corresponding high-resolution image.
[0062] See also Figure 2As shown, it is a schematic diagram of an image super-resolution network of an embodiment of the present invention. The composite Transformer-based image super-resolution network (CTSR) includes a shallow feature extraction module, a deep feature extraction module and an image reconstruction module connected in sequence. The shallow feature extraction module processes the input low-resolution image to obtain shallow features and inputs them to the deep feature extraction module. The deep feature extraction module processes the shallow features to obtain deep features and inputs them to the image reconstruction module. The image reconstruction module upsamples the deep features to obtain a super-resolution image. The deep feature extraction module includes a plurality of sequentially connected residual groups, each of which includes a residual composite Transformer Block (RCTB) and a reconciled Transformer Layer (RTL). For the nth residual group, its input is X n-1 and F f , X n-1 and F f After passing through a residual composite Transformer, Y is generated n and Y f , Y n and Y f Input and integrate Transformer together, and the output is X n ; Among them, the input X of the first residual group 1 =F S , the output of the last residual group X N After a convolutional layer, the deep feature F is generated D , N represents the number of residual groups. Among them, the residual composite Transformer is one of the cores of the present invention, which realizes the inter-block feature aggregation between the spatial dimension and the channel dimension by alternately organizing the spatial multi-head attention layer (Spatial Multi-head Attention Layer, SMAL) and the channel group attention layer (Channel Group Attention Layer, CGAL), and introduces a convolutional layer (Conv) at the end to refine the features extracted from the Transformer block.
[0063] For details, see Figure 3 As shown in the figure, it is a schematic diagram of the residual composite Transformer of an embodiment of the present invention. As shown in (a), the spatial multi-head attention layer includes layer normalization, spatial multi-head attention (SMA), layer normalization and convolutional feedforward network connected in sequence; the channel group attention layer includes layer normalization, channel group attention (CGA), layer normalization and convolutional feedforward network connected in sequence.
[0064] Specifically, Figure 3 (b) is a schematic diagram of spatial multi-head attention, and its internal operation includes the following steps:
[0065] The query matrix, key matrix and value matrix are generated by linear projection, denoted as Q1, K1 and V1 respectively. Q1, K1 and V1 are all in In space, it is represented as:
[0066] Q1=X S W Q ,K1=X S W K ,V1=X S W V ;
[0067] Among them, X S represents the input of spatial multi-head attention, is the linear projection corresponding to Q1, K1 and V1;
[0068] Divide Q1, K1, and V1 into non-overlapping windows and flatten each window to obtain Q s , K s and V s , Q s , K s and V s The size of Each window contains N w pixels; each window is divided into h heads, and the i-th head obtains Q s , K s and V s The i-th part of and V s i ; Output Y of the i-th head s i It is expressed as:
[0069]
[0070] Where D represents the relative position code, d represents the size of each head, d = C × h;
[0071] Through Y s i Deformation and concatenation to obtain output features It is expressed as:
[0072]
[0073] in It is a linear projection that combines all features.
[0074] The spatial multi-head attention of the embodiment of the present invention is designed based on Swin-Transformer, and uses the shift window operation by default to capture more spatial information.
[0075] Specifically, Figure 3 (c) is a schematic diagram of the channel group attention, and its internal operation includes the following steps:
[0076] The query matrix, key matrix and value matrix are generated by linear projection, denoted as Q2, K2 and V2 respectively. Q2, K2 and V2 are all in In space, it is represented as:
[0077] Q2=X C W Q ,K2=X C W K ,V2=X C W V ;
[0078] in, represents the input of the channel group attention, is the linear projection corresponding to Q2, K2 and V2;
[0079] Resize Q2, K2, and V2 to The transformed matrices are represented as Q c , K c and V c ;
[0080] Q c , K c and V c Divided into h heads, the i-th head obtains Q c , K c and V c The i-th part of and For the i-th head, the channel self-attention operation is performed, which is expressed as:
[0081]
[0082] in, represents the output of the i-th head; α is a learnable temperature parameter used to adjust the inner product before the softmax function;
[0083] Through all Cascade and transform to get output features It is expressed as:
[0084]
[0085] in It is a linear projection that combines all features.
[0086] For details, see Figure 4 As shown, it is a schematic diagram of the integrated Transformer of an embodiment of the present invention. For the integrated Transformer in the nth residual group, given the input Y n , Y f And the Token reduction factor r, its internal operation is:
[0087] Y n and Y f Divide into N non-overlapping square windows with a side length of S;
[0088] Using three linear layers L Q , L K and L V To get Q3, K3 and V3:
[0089] Q3=Y n L Q ,K3=Y f L K ,V3=Y f L V ;
[0090] Among them, Q3 has a significant impact on Y n Keep the same channel dimension, while L K and L V Compress the channel dimension to C / r 2 ,get and
[0091] Transpose the spatial tokens in K3 and V3 to the channel dimension and get and
[0092] K p and V p To shrink, K p and V p The window size shrinks to S / r*S / r, and the channel dimension remains unchanged;
[0093] For Q3, the contraction of K p and the contracted V p Perform self-attention operation and get output X n , expressed as:
[0094]
[0095] Among them, RSA represents the integrated self-attention operation, B is the aligned relative position embedding, and d kis the dimension of the input vector.
[0096] In the process of integrating self-attention to transfer spatial information to the channel dimension, instead of downsampling the tokens first, each token is allowed to participate in the self-attention calculation independently, which makes the attention map more representative.
[0097] Specifically, the high-resolution image is reconstructed through the image reconstruction module Among them, H out is the height of the output image, W out Indicates the image width. In this module, this embodiment uses a sub-pixel convolution method to convolve the depth feature F D Upsampling is performed, and convolutional layers are used to aggregate features before and after the upsampling operation. A low-resolution image of 48×48×3 dimensions is used as input to the image super-resolution method based on a composite Transformer, and the output obtained is a high-resolution output of (48×scale)×(48×scale)×3 dimensions, where scale is the magnification factor, for example, scale is 2, 3, or 4.
[0098] When performing ablation tests on the embodiments of the present invention, it is always ensured that the basic modules and network structures used in different experimental projects in the same group of experiments are the same when testing the performance of a module, so as to stabilize non-experimental variables.
[0099] In the ablation study of the residual composite Transformer module, in order to study the effect of alternating SMA and CGA, several experiments were conducted and the results are listed in Table 1:
[0100] Table 1
[0101]
[0102] The first and second rows of the table mean replacing all attention modules in CTSR with CGA or SMA, where SW-SA adopts a window size of 8×8. The third row means alternating between applying CGA and SMA in consecutive Transformer blocks in CTSR. Comparing the three models, it can be observed that the model using SMA outperforms the model using CGA, while alternating between CGA and SMA achieves the best performance of 27.26dB. This shows that exploiting channel and spatial information is crucial for accurate image restoration.
[0103] In addition, Figure 5The last feature map before upsampling of the models with different attention strategies is visualized in Fig. 1. HR represents the real image, the image block represents the local area in the real image, and CGA, SMA, and CGA&SMA correspond to the feature maps of the models in the first, second, and third rows of Table 1, respectively. It can be observed that alternating application of CGA and SMA can obtain clearer textures and edges than the other two models. This further proves that the alternating strategy can effectively enhance the expression of features.
[0104] See also Figure 6 As shown in the figure, the reconstructed images of "102061" and "Zebra" by different models in the ×3SR task are shown. It can be seen that most SR methods (including HAN, EDSR, SwinIR, ELAN, etc.) cannot effectively restore lines, and even some reconstructed images have geometric distortion. In contrast, CTSR better maintains the image structure and reconstructs richer and clearer structural and texture details, effectively reducing artifacts.
[0105] The effects of the embodiment of the present invention and other SRs are compared through objective indicators. Tables 2-4 show the quantitative indicators of different methods in ×2, ×3 and ×4 SR tasks, where the best indicators are marked in bold and the suboptimal indicators are marked in underline:
[0106] Table 2×2SR tasks
[0107]
[0108] Table 3×3SR tasks
[0109]
[0110] Table 4×4SR tasks
[0111]
[0112] It can be seen that the proposed CTSR achieves better performance than other advanced SR methods in terms of PSNR and SSIM. Compared with SwinIR on Urban100 (×3) and Manga109 (×3), the PSNR gain of CTSR is 0.35dB and 0.23dB respectively, and the same is true for other magnification factors. This shows that CTSR can effectively capture richer global context information. Therefore, CTSR has strong global reasoning and detail preservation capabilities.
[0113] See also Figure 7 As shown, it is a system structure diagram of an embodiment of the present invention, including:
[0114] A network construction module 701 constructs an image super-resolution network based on a composite Transformer;
[0115] The network application module 702 is used to realize super-resolution reconstruction of low-resolution images by using a composite Transformer-based image super-resolution network and output a corresponding high-resolution image.
[0116] In summary, the best performance of 27.26 dB can be achieved by alternately applying two SAs in the embodiment of the present invention. This shows that the use of channel and spatial information is crucial for accurate image restoration and can effectively enhance the expression of features. The image structure is maintained, and richer and clearer structural and texture details are reconstructed, effectively reducing artifacts. This shows that CTSR can effectively capture richer global context information. Therefore, CTSR has powerful global reasoning and detail preservation capabilities.
[0117] 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. An image super-resolution method based on a composite Transformer, characterized in that: The following steps are involved: Construct an image super-resolution network based on a composite Transformer; The composite Transformer-based image super-resolution network is used to achieve super-resolution reconstruction of low-resolution images and output the corresponding high-resolution images. The composite Transformer-based image super-resolution network includes a shallow feature extraction module, a deep feature extraction module and an image reconstruction module connected in sequence, the shallow feature extraction module processes the input low-resolution image to obtain shallow features and inputs them to the deep feature extraction module, the deep feature extraction module processes the shallow features to obtain deep features and inputs them to the image reconstruction module, and the image reconstruction module upsamples the deep features to obtain a super-resolution image; wherein the deep feature extraction module includes a plurality of residual groups connected in sequence, each residual group includes a residual composite Transformer and an integrated Transformer, the residual composite Transformer includes a spatial multi-head attention layer and a channel group attention layer, and the integrated Transformer includes an integrated self-attention and a convolutional feedforward network; The shallow feature extraction module is used for the input low-resolution input image and its corresponding inverse Fourier transform image I LR , The convolutional layers are used to generate shallow features Fs, Among them, H and W represent the height and width of the input image, and C represents the number of feature channels; For the nth residual group, its input is X n-1 and F f , X n-1 and F f After passing through a residual composite Transformer, Y is generated n and Y f , Y n and Y f Input and integrate Transformer together, and the output is X n ; Among them, the input X1 of the first residual group = F S , the output of the last residual group X N 'After a convolutional layer, generate deep features F D , N' represents the number of residual groups; For the integrated Transformer in the nth residual group, given the input Yn, Y f And the Token reduction factor r, its internal operation is: Y n and Y f Divide into N non-overlapping square windows with a side length of S; Using three linear layers L Q , L K and L V To get Q3, K3 and V3: <h2 style=";text-align:left;direction:ltr">Q3=Y<h2 style=";text-align:left;direction:ltr"> n <h2 style=";text-align:left;direction:ltr"> L<h2 style=";text-align:left;direction:ltr"> Q <h2 style=";text-align:left;direction:ltr"> K3=Y<h2 style=";text-align:left;direction:ltr"> f <h2 style=";text-align:left;direction:ltr"> L<h2 style=";text-align:left;direction:ltr"> K <h2 style=";text-align:left;direction:ltr"> V3=Y<h2 style=";text-align:left;direction:ltr"> f <h2 style=";text-align:left;direction:ltr"> L<h2 style=";text-align:left;direction:ltr"> V <h2 style=";text-align:left;direction:ltr"> ; Among them, Q3 has a significant impact on Y n Keep the same channel dimension, while L K and L V Compress the channel dimension to C / r 2 ,get and Transpose the spatial tokens in K3 and V3 to the channel dimension and get and K p and V p To shrink, K p and V p The window size is reduced to S / r*S / r, and the channel dimension remains unchanged; For Q3, the contraction of K p and the contracted V p Perform self-attention operation and get output X n , expressed as: Among them, RSA represents the integrated self-attention operation, B is the aligned relative position embedding, and d k is the dimension of the input vector; The residual composite Transformer consists of several alternately connected spatial multi-head attention layers and channel group attention layers, with a convolutional layer introduced at the end; the spatial multi-head attention layer includes layer normalization, spatial multi-head attention, layer normalization and convolutional feedforward network connected in sequence; the channel group attention layer includes layer normalization, channel group attention, layer normalization and convolutional feedforward network connected in sequence.
2. The image super-resolution method based on composite Transformer according to claim 1, characterized in that: The internal operation of the spatial multi-head attention includes the following steps: The query matrix, key matrix and value matrix are generated by linear projection, denoted as Q1, K1 and V1 respectively. Q1, K1 and V1 are all in In space, it is represented as: Q1=X S W Q ,K1=X S W K ,V1=X S W V ; Among them, X S represents the input of spatial multi-head attention, is the linear projection corresponding to Q1, K1 and V1; Divide Q1, K1, and V1 into non-overlapping windows and flatten each window to obtain Q s , K s and V s , Q s , K s and V s The size of Each window contains N w pixels; each window is divided into h heads, and the i-th head obtains Q s , K s and V s The i-th part of and Output of the i-th head It is expressed as: Where D represents the relative position encoding, d represents the size of each head, d = C × h; Through Deformation and concatenation to obtain output features It is expressed as: in It is a linear projection that combines all features.
3. The image super-resolution method based on composite Transformer according to claim 1, characterized in that: The internal operation of the channel group attention includes the following steps: The query matrix, key matrix and value matrix are generated by linear projection, denoted as Q2, K2 and V2 respectively. Q2, K2 and V2 are all in In space, it is represented as: <h2 style=";text-align:left;direction:ltr">Q2=X<h2 style=";text-align:left;direction:ltr"> C <h2 style=";text-align:left;direction:ltr"> W<h2 style=";text-align:left;direction:ltr"> Q <h2 style=";text-align:left;direction:ltr"> K2=X<h2 style=";text-align:left;direction:ltr"> C <h2 style=";text-align:left;direction:ltr"> W<h2 style=";text-align:left;direction:ltr"> K <h2 style=";text-align:left;direction:ltr"> V2=X<h2 style=";text-align:left;direction:ltr"> C <h2 style=";text-align:left;direction:ltr"> W<h2 style=";text-align:left;direction:ltr"> V <h2 style=";text-align:left;direction:ltr"> ; in, represents the input of the channel group attention, W Q ,W K , is the linear projection corresponding to Q2, K2 and V2; Resize Q2, K2, and V2 to The transformed matrices are represented as Q c , K c and V c ; Q c , K c and V c Divided into h heads, the i-th head obtains Q c , K c and V c The i-th part of and For the i-th head, the channel self-attention operation is performed, which is expressed as: in, represents the output of the i-th head; α is a learnable temperature parameter used to adjust the inner product before the softmax function; Through all Cascade and transform to get output features It is expressed as: in It is a linear projection that combines all features.
4. The image super-resolution method based on composite Transformer according to claim 1, characterized in that: The image reconstruction module uses a sub-pixel convolution method to reconstruct the deep features F D Upsample to obtain high-resolution images Among them, H out Indicates height, W out Represents the image width; convolutional layers are used before and after the upsampling operation to aggregate features.
5. The image super-resolution method based on composite Transformer according to claim 1, characterized in that: The low-resolution image of H×W×C dimensions is used as the input of the image super-resolution network based on the composite Transformer, and the output is a high-resolution image of (H×scale)×(W×scale)×C dimensions, where scale is the magnification factor.
6. An image super-resolution system based on a composite Transformer, characterized in that: include: Network building module, used to build a composite Transformer-based image super-resolution network; The network application module is used to realize super-resolution reconstruction of low-resolution images using a composite Transformer-based image super-resolution network and output the corresponding high-resolution image; The composite Transformer-based image super-resolution network includes a shallow feature extraction module, a deep feature extraction module and an image reconstruction module connected in sequence, the shallow feature extraction module processes the input low-resolution image to obtain shallow features and inputs them to the deep feature extraction module, the deep feature extraction module processes the shallow features to obtain deep features and inputs them to the image reconstruction module, and the image reconstruction module upsamples the deep features to obtain a super-resolution image; wherein the deep feature extraction module includes a plurality of residual groups connected in sequence, each residual group includes a residual composite Transformer and an integrated Transformer, the residual composite Transformer includes a spatial multi-head attention layer and a channel group attention layer, and the integrated Transformer includes an integrated self-attention and a convolutional feedforward network; The shallow feature extraction module is used for the input low-resolution input image and its corresponding inverse Fourier transform image. Convolutional layers are used to generate shallow features Among them, H and W represent the height and width of the input image, and C represents the number of feature channels; For the nth residual group, its input is X n-1 and F f , X n-1 and F f After passing through a residual composite Transformer, Y is generated n and Y f , Y n and Y f Input and integrate Transformer together, and the output is X n ; Among them, the input X1 of the first residual group = F S , the output of the last residual group X N 'After a convolutional layer, generate deep features F D , N' represents the number of residual groups; For the integrated Transformer in the nth residual group, given the input Y n , Y f And the Token reduction factor r, its internal operation is: Y n and Y f Divide into N non-overlapping square windows with a side length of S; Using three linear layers L Q , L K and L V To get Q3, K3 and V3: <h2 style=";text-align:left;direction:ltr">Q3=Y<h2 style=";text-align:left;direction:ltr"> n <h2 style=";text-align:left;direction:ltr"> L<h2 style=";text-align:left;direction:ltr"> Q <h2 style=";text-align:left;direction:ltr"> K3=Y<h2 style=";text-align:left;direction:ltr"> f <h2 style=";text-align:left;direction:ltr"> L<h2 style=";text-align:left;direction:ltr"> K <h2 style=";text-align:left;direction:ltr"> V3=Y<h2 style=";text-align:left;direction:ltr"> f <h2 style=";text-align:left;direction:ltr"> L<h2 style=";text-align:left;direction:ltr"> V <h2 style=";text-align:left;direction:ltr"> ; Among them, Q3 has a significant impact on Y n Keep the same channel dimension, while L K and L V Compress the channel dimension to C / r 2 ,get and Transpose the spatial tokens in K3 and V3 to the channel dimension and get and K p and V p To shrink, K p and V p The window size is reduced to S / r*S / r, and the channel dimension remains unchanged; For Q3, the contraction of K p and the contracted V p Perform self-attention operation and get output X n , expressed as: Among them, RSA represents the integrated self-attention operation, B is the aligned relative position embedding, and d k is the dimension of the input vector; The residual composite Transformer consists of several alternately connected spatial multi-head attention layers and channel group attention layers, with a convolutional layer introduced at the end; the spatial multi-head attention layer includes layer normalization, spatial multi-head attention, layer normalization and convolutional feedforward network connected in sequence; the channel group attention layer includes layer normalization, channel group attention, layer normalization and convolutional feedforward network connected in sequence.
