Home

Awesome

Swin2-MoSE: A New Single Image Super-Resolution Model for Remote Sensing

Official PyTorch implementation of Swin2-MoSE.

PWC PWC PWC

In this paper, we propose Swin2-MoSE model, an enhanced version of Swin2SR for Single-Image Super-Resolution for Remote Sensing.

<img src="images/fig1.jpg" width="800" height="auto" alt="Swin2-MoSE Aarchitecture"> <img src="images/fig2.jpg" width="800" height="auto" alt="Swin2-MoSE MoE-SM"> <img src="images/fig3.jpg" width="800" height="auto" alt="Swin2-MoSE Positional Encoding">

Authors: Leonardo Rossi, Vittorio Bernuzzi, Tomaso Fontanini, Massimo Bertozzi, Andrea Prati.

IMP Lab - Dipartimento di Ingegneria e Architettura

University of Parma, Italy

Abstract

Due to the limitations of current optical and sensor technologies and the high cost of updating them, the spectral and spatial resolution of satellites may not always meet desired requirements. For these reasons, Remote-Sensing Single-Image Super-Resolution (RS-SISR) techniques have gained significant interest.

In this paper, we propose Swin2-MoSE model, an enhanced version of Swin2SR.

Our model introduces MoE-SM, an enhanced Mixture-of-Experts (MoE) to replace the Feed-Forward inside all Transformer block. MoE-SM is designed with Smart-Merger, and new layer for merging the output of individual experts, and with a new way to split the work between experts, defining a new per-example strategy instead of the commonly used per-token one.

Furthermore, we analyze how positional encodings interact with each other, demonstrating that per-channel bias and per-head bias can positively cooperate.

Finally, we propose to use a combination of Normalized-Cross-Correlation (NCC) and Structural Similarity Index Measure (SSIM) losses, to avoid typical MSE loss limitations.

Experimental results demonstrate that Swin2-MoSE outperforms SOTA by up to 0.377 ~ 0.958 dB (PSNR) on task of 2x, 3x and 4x resolution-upscaling (Sen2Venus and OLI2MSI datasets). We show the efficacy of Swin2-MoSE, applying it to a semantic segmentation task (SeasoNet dataset).

Usage

Installation

$ git clone https://github.com/IMPLabUniPr/swin2-mose/tree/official_code
$ cd swin2-mose
$ conda env create -n swin2_mose_env --file environment.yml
$ conda activate swin2_mose_env

Prepare Sen2Venus dataset

  1. After you downloaded the files from Sen2Venus official website, unzip them inside the ./datasets/sen2venus_original directory.

  2. Run the script split.py to split the dataset in training (~80%) and test (~20%):

python scripts/sen2venus/split.py --input ./datasets/sen2venus_original --output ./data/sen2venus

After the successfull execution of the script, you will find train.csv and test.csv files inside the ./data/sen2venus.

Note: if you want to skip this run and use our train.csv and test.csv files directly, you can download them from Release v1.0 page.

  1. Run the script rebuild.py to rebuild the dataset in a compatible format:
python scripts/sen2venus/rebuild.py --data ./datasets/sen2venus_original --output ./data/sen2venus

If everything went well, you will have the following files structure:

data/sen2venus
├── test
│   ├── 000000_ALSACE_2018-02-14.pt
│   ├── 000001_ALSACE_2018-02-14.pt
|   ...
├── test.csv
├── train
│   ├── 000000_ALSACE_2018-02-14.pt
│   ├── 000001_ALSACE_2018-02-14.pt
|   ...
└── train.csv

Note about Sen2venus: we found a small error in file name convention!

On paper, authors wrote for 4x files, the following:

{id}_05m_b5b6b7b8a.pt   -   5m patches (256×256 pix.) for S2 B5, B6, B7 and B8A (from VENµS)
{id}_20m_b5b6b7b8a.pt   -   20m patches (64×64 pix.) for S2 B5, B6, B7 and B8A (from Sentinel-2)

But, we found the following name conventions:

ALSACE_C_32ULU_2018-02-14_05m_b4b5b6b8a.pt
ALSACE_C_32ULU_2018-02-14_20m_b4b5b6b8a.pt

Prepare OLI2MSI dataset

Download from the OLI2MSI official website and unzip it inside the ./data/oli2msi directory.

If everything went well, you will have the following files structure:

data/oli2msi
├── test_hr
│   ├── L8_126038_20190923_S2B_20190923_T49RCQ_N0071.TIF
│   ├── L8_126038_20190923_S2B_20190923_T49RCQ_N0108.TIF
|   ...
├── test_lr
│   ├── L8_126038_20190923_S2B_20190923_T49RCQ_N0071.TIF
│   ├── L8_126038_20190923_S2B_20190923_T49RCQ_N0108.TIF
|   ...
├── train_hr
│   ├── L8_126038_20190923_S2B_20190923_T49RBQ_N0008.TIF
│   ├── L8_126038_20190923_S2B_20190923_T49RBQ_N0015.TIF
|   ...
└── train_lr
    ├── L8_126038_20190923_S2B_20190923_T49RBQ_N0008.TIF
    ├── L8_126038_20190923_S2B_20190923_T49RBQ_N0015.TIF
    ...

Prepare SeasoNet dataset

Download from the SeasoNet official website and unzip it inside the ./data/SeasoNet/data directory.

If everything went well, you will have the following files structure:

data/SeasoNet
└── data
    ├── fall
    │   ├── grid1
    │   └── grid2
    ├── meta.csv
    ├── snow
    │   ├── grid1
    │   └── grid2
    ├── splits
    │   ├── test.csv
    │   ├── train.csv
    │   └── val.csv
    ├── spring
    │   ├── grid1
    │   └── grid2
    ├── summer
    │   ├── grid1
    │   └── grid2
    └── winter
        ├── grid1
        └── grid2

Note about SeasoNet: SeasoNet could be easily downloaded by TorchGeo class, specifying the root directory ./data/SeasoNet/data/.

Download pretrained

Open Release v1.0 page and download .pt (pretrained) and .pkl (results) file.

Unzip them inside the output directory, obtaining the following directories structure:

output2/sen2venus_exp4_2x_v5/
├── checkpoints
│   └── model-70.pt
└── eval
    └── results-70.pt

Swin2-MoSE best configuration

# Sen2Venus 2x
CONFIG_FILE=cfgs/swin2_mose/sen2venus_2x_s2m.yml
# OLI2MSI 3x
CONFIG_FILE=cfgs/swin2_mose/oli2msi_3x_s2m.yml
# Sen2Venus 4x
CONFIG_FILE=cfgs/swin2_mose/sen2venus_4x_s2m.yml

Train

python src/main.py --phase train --config $CONFIG_FILE --output $OUT_DIR --epochs ${EPOCH} --epoch -1
python src/main_ssegm.py --phase train --config $CONFIG_FILE --output $OUT_DIR --epochs ${EPOCH} --epoch -1

Validate

python src/main.py --phase test --config $CONFIG_FILE --output $OUT_DIR --batch_size 32 --epoch ${EPOCH}
python src/main.py --phase test --config $CONFIG_FILE --batch_size 32 --eval_method bicubic

Show results

python src/main.py --phase vis --config $CONFIG_FILE --output $OUT_DIR --num_images 3 --epoch ${EPOCH}
python src/main.py --phase vis --config $CONFIG_FILE --output output/sen2venus_4x_bicubic --num_images 3 --eval_method bicubic
python src/main.py --phase vis --config $CONFIG_FILE --output output/sen2venus_4x_bicubic --num_images 3 --eval_method bicubic --dpi 1200
python src/main_ssegm.py --phase vis --config $CONFIG_FILE --output $OUT_DIR --num_images 2 --epoch ${EPOCH}
python src/main_ssegm.py --phase vis --config $CONFIG_FILE --output $OUT_DIR --num_images 2 --epoch ${EPOCH} --hide_sr

Compute mean/std

python src/main.py --phase mean_std --config $CONFIG_FILE
python src/main_ssegm.py --phase mean_std --config $CONFIG_FILE

Measure execution average time

python src/main.py --phase avg_time --config $CONFIG_FILE --repeat_times 1000 --warm_times 20 --batch_size 8

Results

Table 1

Ablation study on loss usage.

| # | Losses ||| Performace ||| Conf |

#NCCSSIMMSENCCSSIMPSNR
1x0.95500.580416.4503conf
2x0.95650.984745.5427conf
3x0.95460.982845.4759conf
4xx0.95720.984145.6986conf
5xx0.95490.982845.5163conf
6xxx0.95550.983345.5542conf

Table 2

Ablation study on positional encoding.

| # | Positional Encoding ||| Performace || Conf |

#RPElog CPBLePESSIMPSNR
1x0.984145.5855conf
2x0.984145.6986conf
3x0.984345.7278conf
4xx0.984545.8046conf
5xx0.984745.8539conf
6xx0.984345.6945conf
7xxx0.984645.8185conf

Table 3

Ablation study on positional encoding.

| # | | | MLP #Params || Performace || Latency | Conf |

#ArchSMAPCSPCSSIMPSNR(s)
1MLP32’67032’6700.984745.85390.194conf
2MoE 8/232’760132’4800.984545.86470.202conf
3MoE 8/2x32’779132’4990.984945.92720.212conf

Table 4

Quantitative comparison with SOTA models on Sen2Veµs and OLI2MS datasets.

| # | Model | Sen2Venus 2x || OLI2MSI 3x || Sen2Venus 4x || Conf |||

#SSIMPSNRSSIMPSNRSSIMPSNR2x3x4x
1Bicubic0.988345.55880.976842.18350.967442.0499
2SwinIR0.993848.70640.986043.74820.982545.3460confconfconf
3Swinfir0.994048.85320.986344.48290.983045.5500confconfconf
4Swin2SR0.994249.04670.988144.96140.982845.4759confconfconf
5Swin2-MoSE (ours)0.994849.47840.991245.91940.984945.9272confconfconf

Figure 11

Results for the Semantic Segmentation task on SeasoNet dataset.

#ModelConf
1FarSegconf
2FarSeg++conf
3FarSeg+S2MFEconf

License

See GPL v2 License.

Acknowledgement

Project ECS_00000033_ECOSISTER funded under the National Recovery and Resilience Plan (NRRP), Mission 4 Component 2 Investment 1.5 - funded by the European Union – NextGenerationEU. This research benefits from the HPC (High Performance Computing) facility of the University of Parma, Italy.

Citation

If you find our work useful in your research, please cite:

@article{rossi2024swin2,
  title={Swin2-MoSE: A New Single Image Super-Resolution Model for Remote Sensing},
  author={Rossi, Leonardo and Bernuzzi, Vittorio and Fontanini, Tomaso and Bertozzi, Massimo and Prati, Andrea},
  journal={arXiv preprint arXiv:2404.18924},
  year={2024}
}