The official pytorch implementation of the paper NAFSSR: Stereo Image Super-Resolution Using NAFNet. You can get more infomation about NAFSSR with folloing links: [video]/[slides]/[poster].
This paper proposes a simple baseline named NAFSSR for stereo image super-resolution. We use a stack of NAFNet's Block (NAFBlock) for intra-view feature extraction and combine it with Stereo Cross Attention Modules (SCAM) for cross-view feature interaction.
NAFSSR outperforms the state-of-the-art methods on the KITTI 2012, KITTI 2015, Middlebury, and Flickr1024 datasets. With NAFSSR, we won 1st place in the NTIRE 2022 Stereo Image Super-resolution Challenge.
![]() |
![]() |
|---|---|
| Training Process | Test Process |
This implementation based on BasicSR which is a open source toolbox for image/video restoration tasks and HINet
python 3.9.5
pytorch 1.11.0
cuda 11.3git clone https://github.com/megvii-research/NAFNet
cd NAFNet
pip install -r requirements.txt
python setup.py develop --no_cuda_ext
Follow previous works, our models are trained with Flickr1024 and Middlebury datasets, which is exactly the same as iPASSR. Please visit their homepage and follow their instructions to download and prepare the datasets.
The structure of datasets directory should be like
stereo
├── datasets
│ ├── Train_patches_x4
│ │ ├── 000001
│ │ ├── 000002
│ │ │ ├── hr0.png
│ │ │ ├── hr1.png
│ │ │ ├── lr0.png
│ │ │ └── lr1.png
│ │ ├── ...
│ │ ├── 040651
│ │ └── 040652
| ├── Val_patches_x4
│ │ ├── 000001
│ │ ├── 000002
│ │ │ ├── hr0.png
│ │ │ ├── hr1.png
│ │ │ ├── lr0.png
│ │ │ └── lr1.png
│ │ ├── ...
│ │ ├── 003329
│ │ └── 003330
We choose the ID 701-800 from the raw training sets to be as our validation sets.
Follow previous works, we have prepared datasets that we need.Now please follow processing blow to train the model.
-
NAFNet-L for 4x SR:
python -m torch.distributed.launch --nproc_per_node=8 --master_port=4321 basicsr/train.py -opt options/train/NAFSSR/NAFSSR-L_x4.yml --launcher pytorch -
NAFNet-T for 4x SR for High or Low frequency information:
class PairedStereoImageDataset(data.Dataset):
...
...
return {
'lq': img_lq_h,
'gt': img_gt_h,
# 'lq_h': img_lq_h,
# 'gt_h': img_gt_h,
# 'lq_l': img_lq_l,
# 'gt_l': img_gt_l,
'lq_path': os.path.join(self.lq_folder, self.lq_files[index]),
'gt_path': os.path.join(self.gt_folder, self.gt_files[index]),
}
def __len__(self):
return self.nums
class PairedStereoImageDataset(data.Dataset):
...
...
return {
'lq': img_lq_l,
'gt': img_gt_l,
# 'lq_h': img_lq_h,
# 'gt_h': img_gt_h,
# 'lq_l': img_lq_l,
# 'gt_l': img_gt_l,
'lq_path': os.path.join(self.lq_folder, self.lq_files[index]),
'gt_path': os.path.join(self.gt_folder, self.gt_files[index]),
}
def __len__(self):
return self.nums
python -m torch.distributed.launch --nproc_per_node=8 --master_port=4321 basicsr/train.py -opt options/train/NAFSSR/NAFSSR-T_x4.yml --launcher pytorch
- 8 gpus by default. Set
--nproc_per_nodeto # of gpus for distributed validation.
| name | scale | #Params | PSNR | SSIM | pretrained models | configs |
|---|---|---|---|---|---|---|
| NAFSSR-T | x4 | 0.46M | 23.69 | 0.7384 | gdrive | baidu | train | test |
| NAFSSR-S | x4 | 1.56M | 23.88 | 0.7468 | gdrive | baidu | train | test |
| NAFSSR-B | x4 | 6.80M | 24.07 | 0.7551 | gdrive | baidu | train | test |
| NAFSSR-L | x4 | 23.83M | 24.17 | 0.7589 | gdrive | baidu | train | test |
PSNR/SSIM are evaluate on Flickr1024 test set.
- NAFSSR-T for 4x SR:
python -m torch.distributed.launch --nproc_per_node=1 --master_port=4321 basicsr/test.py -opt ./options/test/NAFSSR/NAFSSR-T_x4.yml --launcher pytorch
- NAFSSR-S for 4x SR:
python -m torch.distributed.launch --nproc_per_node=1 --master_port=4321 basicsr/test.py -opt ./options/test/NAFSSR/NAFSSR-S_x4.yml --launcher pytorch
- NAFSSR-B for 4x SR:
python -m torch.distributed.launch --nproc_per_node=1 --master_port=4321 basicsr/test.py -opt ./options/test/NAFSSR/NAFSSR-B_x4.yml --launcher pytorch
- NAFSSR-L for 4x SR:
python -m torch.distributed.launch --nproc_per_node=1 --master_port=4321 basicsr/test.py -opt ./options/test/NAFSSR/NAFSSR-L_x4.yml --launcher pytorch
- Test by a single gpu by default. Set
--nproc_per_nodeto # of gpus for distributed validation.
python ./basicsr/batch_ssr.py
- Stereo Image Inference Demo:
- Stereo Image Super-resolution:
python basicsr/demo_ssr.py -opt options/test/NAFSSR/NAFSSR-L_4x.yml -opt1 options/test/NAFSSR/NAFSSR-T_4x.yml \ --input_l_path ./demo/lr_img_l.png --input_r_path ./demo/lr_img_r.png \ --output_l_path ./demo/sr_img_l.png --output_r_path ./demo/sr_img_r.png--input_l_path: the path of the degraded left image--input_r_path: the path of the degraded right image--output_l_path: the path to save the predicted left image--output_r_path: the path to save the predicted right image

