DLGSANet: Lightweight Dynamic Local and Global Self-Attention Networks for Image Super-Resolution

February 19, 2025 ยท View on GitHub

Project Page | Paper (ArXiv) | Supplemental Material

This repository is the official pytorch implementation of our paper, DLGSANet: Lightweight Dynamic Local and Global Self-Attention Networks for Image Super-Resolution.

Xiang Li1, Jinshan Pan1, Jinhui Tang1, Jiangxin Dong1

1IMAG Lab, Nanjing University of Science and Technology

Abstract: We propose an effective lightweight dynamic local and global self-attention network (DLGSANet) to solve image super-resolution. Our method explores the properties of Transformers while having low computational costs. Motivated by the network designs of Transformers, we develop a simple yet effective multi-head dynamic local self-attention (MHDLSA) module to extract local features efficiently. In addition, we note that existing Transformers usually explore all similarities of the tokens between the queries and keys for the feature aggregation. However, not all the tokens from the queries are relevant to those in keys, using all the similarities does not effectively facilitate the high-resolution image reconstruction. To overcome this problem, we develop a sparse global self-attention (SparseGSA) module to select the most useful similarity values so that the most useful global features can be better utilized for the high-resolution image reconstruction. We develop a hybrid dynamic-Transformer block(HDTB) that integrates the MHDLSA and SparseGSA for both local and global feature exploration. To ease the network training, we formulate the HDTBs into a residual hybrid dynamic-Transformer group (RHDTG). By embedding the RHDTGs into an end-to-end trainable network, we show that our proposed method has fewer network parameters and lower computational costs while achieving competitive performance against state-of-the-art ones in terms of accuracy.

Framework


Contents

The contents of this repository are as follows:

  1. Dependencies
  2. Train
  3. Test

Dependencies

  • Python
  • Pytorch (1.11 or 1.13)
  • basicsr
  • cupy-cuda

extra infos:

For more details of the dependencies, please refer to requirements.txt

Train

# For X2
sh ./demo_sbatch_file/SISR_ClassicDIV2K/train_SISR_ClassicDIV2K_Large_90C6G4B_DLGSANet_SRx2_scratch_img_size_48_lr5e_4.sh

# For X3
sh ./demo_sbatch_file/SISR_ClassicDIV2K/train_SISR_ClassicDIV2K_Large_90C6G4B_DLGSANet_SRx3_scratch_img_size_48_lr5e_4.sh

# For X4
sh ./demo_sbatch_file/SISR_ClassicDIV2K/train_SISR_ClassicDIV2K_Large_90C6G4B_DLGSANet_SRx4_scratch_img_size_48_lr5e_4.sh

Test

# For X2
sh ./demo_sbatch_file/SISR_ClassicDIV2K/test_SISR_ClassicDIV2K_Large_90C6G4B_DLGSANet_SRx2_scratch_img_size_48_lr5e_4.sh

# For X3
sh ./demo_sbatch_file/SISR_ClassicDIV2K/test_SISR_ClassicDIV2K_Large_90C6G4B_DLGSANet_SRx3_scratch_img_size_48_lr5e_4.sh

# For X4
sh ./demo_sbatch_file/SISR_ClassicDIV2K/test_SISR_ClassicDIV2K_Large_90C6G4B_DLGSANet_SRx4_scratch_img_size_48_lr5e_4.sh


Results

  • Pretrained models and visual results
DegradationModel ZooVisual Results
BI-Efficient SRGoogle DriveGoogle Drive
BI-Classic SRTo-DoTo-Do
BI-Classic SR (x4)Google Drive / Baidu Netdisk code:IMAGGoogle Drive / Baidu Netdisk code:IMAG
  • Lightweight models PSNR

Unfortunately, the lightweight models' pretrain models were lost. Additionally, the github project has not been updated for a year due to personal reasons. Recently, I rebuilt the framework and used a single 3090GPU to retrain the lightweight models using the same training settings as the paper (16 batchsize). The re-trained model and those in the study have a slightly varied PSNR (within 0.05dB) due to differences in devices and versions of Pytorch/Cuda. New pre-train models and visual results will be added on Baidu Netdisk and Google Drive. We recommend either training on your own for research purposes or using the new data from re-trained lightweight models.

DLGSANet-Tiny:

model-scaleSet5Set14BSDS100Urban100Manga109
Tiny-x2(paper)38.16 / 0.961133.92 / 0.920232.26 / 0.900732.82 / 0.934339.14 / 0.9777
Tiny-x238.1581 / 0.961533.8906 / 0.920032.2828 / 0.901732.8461 / 0.934339.1326 / 0.9780
Tiny-x3(paper)34.63 / 0.928830.57 / 0.845929.21 / 0.808328.69 / 0.863034.10 / 0.9480
Tiny-x334.6197 / 0.929330.5370 / 0.846929.2335 / 0.810028.7829 / 0.864534.0463 / 0.9477
Tiny-x4(paper)32.46 / 0.898428.79 / 0.786127.70 / 0.740826.55 / 0.800230.98 / 0.9137
Tiny-x432.4957 / 0.899228.7738 / 0.786227.7217 / 0.742626.5675 / 0.800630.9556 / 0.9142

DLGSANet-Light:

model-scaleSet5Set14BSDS100Urban100Manga109
Light-x2(paper)38.20 / 0.961233.89 / 0.920332.30 / 0.901232.94 / 0.935539.29 / 0.9780
Light-x238.1577 / 0.961534.0453 / 0.921632.3058 / 0.902032.9323 / 0.935439.1995 / 0.9780
Light-x3(paper)34.70 / 0.929530.58 / 0.846529.24 / 0.808928.83 / 0.865334.16 / 0.9483
Light-x334.6697 / 0.929830.5621 / 0.846629.2484 / 0.810128.8239 / 0.865534.1938 / 0.9483
Light-x4(paper)32.54 / 0.899328.84 / 0.787127.73 / 0.741526.66 / 0.803331.13 / 0.9161
Light-x432.5333 / 0.899828.6401 / 0.786427.7299 / 0.743426.6702 / 0.803631.0196 / 0.9154

Visual Results


To Do

Release pre-trained models of regular models

Release the visual results of BI super-resolution

Citation

If this work is helpful for your research, please consider citing the following BibTeX entry.

 @article{li2023dlgsanet,
      title={DLGSANet: Lightweight Dynamic Local and Global Self-Attention Networks for Image Super-Resolution}, 
      author={Li, Xiang and Pan, Jinshan and Tang, Jinhui and Dong, Jiangxin},
      journal={arXiv preprint arXiv:2301.02031},
      year={2023},
}

Acknowledgement

The foundation for the training process is BasicSR , which profited from the outstanding contribution of XPixelGroup .

The following research forms the foundation for the MHDLSA implementation:

On the Connection between Local Attention and Dynamic Depth-wise Convolution paper github

And the following research forms the foundation for the SparseGSA implementation:

Restormer: Efficient Transformer for High-Resolution Image Restoration paper github

Improving Image Restoration by Revisiting Global Information Aggregation paper github

Contact

This repo is currently maintained by Xiang Li (@neonleexiang) and is for academic research use only.