Giter Club home page Giter Club logo

pbasr's Introduction

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.

pbasr's People

Contributors

imalne avatar

Stargazers

Tianyu Ding avatar wind222 avatar  avatar

Watchers

 avatar

pbasr's Issues

Question

Can you open source the training code?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.