This repository implements the Super-Resolution Feedback Network (SRFBN-S) small variant (T=4, G=3, m=32) for ×4 image upsampling, trained on DIV2K and evaluated on Urban100.
SRFBN-S-x4/
├── data/
│ ├── DIV2K_train_HR/
│ └── HIGH_x4_Urban100/
├── logs/ # PSNR/SSIM plots
├── outputs/ # final_model.pth
├── src/
│ ├── datasets.py # Dataset classes with on-the-fly bicubic downsampling
│ ├── model.py # SRFBN-S network implementation
│ ├── utils.py
│ ├── train.py
│ └── test.py
└── README.md
-
Train:
python src/train.py --hr_dir data/DIV2K_train_HR
- Trains for 37 epochs.. was initially meant to train for 300 epochs (LR=1e-4, halved at epoch 200).
- Saves plots to
logs/train_metrics.pngand model weights tooutputs/final_model.pth.
-
Test:
python src/test.py --hr_dir data/HIGH_x4_Urban100 \ --model_path outputs/final_model.pth \ --save_sr- Prints average PSNR/SSIM on Urban100.
- Add
--save_srto write SR images tooutputs/sr_images/.
During development we encountered and resolved several issues:
-
Shape Mismatch in
model.py:- Problem: The
ConvTranspose2dparameters (kernel, stride, padding) were hard-coded for ×2, causing output size 80→160 mismatch. - Fix: Made the deconvolution kernel (
k),stride, andpaddingdynamic based onscale(2, 3, or 4), matching the bicubic skip connection exactly.
- Problem: The
-
SSIM Window Size Exceeds Image Extent:
- Problem: Small patches (<7×7) from random cropping triggered
ValueError: win_size exceeds image extentinskimage.metrics.ssim. - Fix: Updated
utils.ssimto compute a dynamic oddwin_size <= min(height, width), and wrap calls intry/except. On failure (or too-small crops) we fall back to PSNR.
- Problem: Small patches (<7×7) from random cropping triggered
-
Data Loading Bottlenecks:
- Initial: Used tensor-based resizing (
torchvision.transforms.functional.resize) for LR generation, and reloaded test images each batch. - Optimizations:
- Switch train-time downsampling to PIL’s
Image.resize(faster C implementation). - Preload all Urban100 HR images into memory (
__init__ofSRTestDataset) to eliminate I/O overhead during inference.
- Switch train-time downsampling to PIL’s
- Initial: Used tensor-based resizing (
- Paper: Feedback Network for Image Super-Resolution, CVPR 2019.
- Author code: https://github.com/Paper99/SRFBN_CVPR19
Feel free to tweak hyperparameters, extend to other scales, or integrate additional speed-ups (e.g., grouped convolutions, checkpointing). Thanks