Skip to content

Imalne/PBaSR

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PBaSR

This is the PyTorch Repository for the paper A New Dataset and Framework for Real-World Blurred Images Super-Resolution

arXiv

framework_img framework_img

Basic Dependencies

  • Ubuntu >= 20.04
  • CUDA >= 11.1
  • Python 3.8

Installation

# git clone this repository
git clone 
cd PBaSR

# create new anaconda env 
conda create -n PBaSR python=3.8    
conda activate PBaSR                

# install python dependencies
pip3 install -r requirements.txt
python setup.py develop

Dataset Preparation for test and training

  • Download the ReBlurSR dataset from Google Drive and follow the Instructions to generate the training and validation datasets.

Training

The training codes and configs will be released soon.

Inference

  • Download the pretrained model weights from Google Drive
  • Put the pretrained model weights in experiments/pretrained_models
  • Download the synthetic testing LR images of DIV2K-Val from Google Drive
  • Modify the 'weight paths with comment' in options/test*.yml
# in option/test_PBaSR_ESRGAN.yml
path:
  pretrain_network_g: # PBaSR_ESRGAN's pretrained weight

# in option/test_PBaSR_FeMaSR.yml
path:
  pretrain_network_hq: ~ # the pretrained weight of FeMaSR's HQ stage
  pretrain_network_g: # PBaSR_FeMaSR's pretrained weight

# in option/test_PBaSR_SRFormer.yml
path:
  pretrain_network_g: # PBaSR_SRFormer's pretrained weight
  • Modify the 'val dataset paths with comment' in options/test*.yml
# dataset and data loader settings
datasets:
  val_1:
    name: DIV2K
    type: PairedImageBFDataset
    dataroot_gt: # HR dir path here
    dataroot_lq: # LR dir path here
    io_backend:
      type: disk
  
  val_2:
    ...
  
  val_3:
    ...
  • Run the following command to inference different PBaSR models
# inference the PBaSR-ESRGAN model
python basicsr/test.py -opt options/test_PBaSR_ESRGAN.yml

# inference the PBaSR-FeMaSR model
python basicsr/test.py -opt options/test_PBaSR_FeMaSR.yml

# inference the PBaSR-SRFormer model
python basicsr/test.py -opt options/test_PBaSR_SRFormer.yml
  • After inference, the SR image results will be saved in the result dir with the specified setting name in the option file.
# take the PBaSR-ESRGAN model as an example
results
└── test_PBaSR_ESRGAN
    ├── Visualization
    │   ├── DIV2K
    │   ├── ReBlurSR_Defocus
    │   └── ReBlurSR_Motion
    └── *.log  # log file

Evaluation

After inference, you can evaluate the results by differnt metrics in 'option/test_all_metric.yml' with the following command

python basicsr/test_result.py 
      --gt_dir # the ground truth HR dir path 
      --lq_dir # the SR result dir path
      --mask_dir # the blur mask dir path of HR, if not exist, do not mention this argument
      -opt  options/test_all_metric.yml

Extract final weight from the PBaSR model weight

Run the following command to extract the final weight from the PBaSR model weight

# extract final weight from PBaSR model weight
python basicsr/extract_final_params.py 
      -opt # the model config and path config of the PBaSR model
      -o # output path of the final weight,

for example, if you want to extract the final weight from the PBaSR-FeMaSR model weight, you can run the following command

python basicsr/extract_final_params.py 
      -opt options/test_PBaSR_FeMaSR.yml
      -o FeMaSR_final.pth

The extracted final weight is the same shape as the weight of the selected model used in the PBaSR and can be directly used for intialization of the basic anchor model. For example, you can modify the config options/test_final_weight_of_PBaSR_FeMaSR.yml like above and run the following command to check the extracted final weight of PBaSR-FeMaSR

python basicsr/test.py -opt options/test_final_weight_of_PBaSR_FeMaSR.yml

Acknowledgement

This project is based on BasicSR, FeMaSR and SRFormer.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages