SimDeblur (Simple Deblurring) is an open source framework for image and video deblurring based on PyTorch, which contains most deep-learning based state-of-the-art deblurring algorithms. It is easy to implement your own image or video deblurring and restoration algorithms. To the best of our knowledge, this is the first general framework for image/video delburring.
<style> table { margin: auto; } </style>- Modular Design
The toolbox decomposes the deblurring framework into different components and one can easily construct a customized restoration framework by combining different modules.
- State-of-the-art
The toolbox contains most deep-learning based state-of-the-art deblurring algorithms, including MSCNN, SRN, DeblurGAN, EDVR, etc.
- Efficient Training
SimDeblur supports distributed data-parallel training.
[2022/2/18] We add PVDNet model for video deblurring. Note that it requires the pretrained BIMNet for motion estimation. Thus please modify the CKPT path of BIMNet in the source codes.
[2022/1/21] We add Restormer model. Note that it can only works on PyTorch1.8+.
[2022/1/20] We transfer some checkpoints from the open-sourced repos into SimDeblur framework! You can find them here.
[2022/1/1] Support real-world video deblurring dataset: BSD.
[2021/3/31] Support DVD, GoPro and REDS video deblurring datasets.
[2021/3/21] First release.
We will gradually release the checkpoints of each model in checkpoints.md.
-
Single Image Deblurring
-
Video Deblurring
-
Benchmarks
- Python 3 (Conda is recommended)
- Pytorch 1.5.1 (with GPU)
- CUDA 10.1+ with NVCC
- Clone the repositry or download the zip file
git clone https://github.com/ljzycmd/SimDeblur.git
- Install SimDeblur
# create a pytorch env conda create -n simdeblur python=3.7 conda activate simdeblur # install the packages cd SimDeblur bash Install.sh
You can open the Colab Notebook to learn about basic usage and see the deblurring performance.
The design of SimDeblur consists of FOUR main parts as follows:
Dataset | Model | Scheduler | Engine |
---|---|---|---|
Dataset-specific classes | The backbone, losses, and meta_archs | Opeimizer, LR scheduler | Trainer, and some hook function during model training process |
Note that the dataset, model and scheduler can be constructed with config (EasyDict) with corresponding build_{dataset, backbone, meta_arch, scheduler, optimizer, etc.} functions. The Trainer class automatically construct all reqiured elements for model training in a general way. This means that if you want to do some specific modeling training, you may modify the training logics.
You can construct a simple training process using the default Trainer as following:
from simdeblur.config import build_config, merge_args
from simdeblur.engine.parse_arguments import parse_arguments
from simdeblur.engine.trainer import Trainer
args = parse_arguments()
cfg = build_config(args.config_file)
cfg = merge_args(cfg, args)
cfg.args = args
trainer = Trainer(cfg)
trainer.train()
Then start training with single GPU:
CUDA_VISIBLE_DEVICES=0 bash ./tools/train.sh ./config/dbn/dbn_dvd.yaml 1
or multiple GPUs training:
CUDA_VISIBLE_DEVICES=0,1,2,3 bash ./tools/train.sh ./config/dbn/dbn_dvd.yaml 4
For the testing, SimDeblur only supports single GPU testing and Validation util now:
CUDA_VISIBLE_DEVICES=0 python test.py ./config/dbn/dbn_dvd.yaml PATH_TO_CKPT
SimDeblur also provides you to build some specific modules, including dataset, model, loss, etc.
Build a dataset:
from easydict import EasyDict as edict
from simdeblur.dataset import build_dataset
# construct configs of target dataset.
# SimDeblur adopts EasyDict to store configs.
dataset_cfg = edict({
"name": "DVD",
"mode": "train",
"sampling": "n_c",
"overlapping": True,
"interval": 1,
"root_gt": "./dataset/DVD/quantitative_datasets",
"num_frames": 5,
"augmentation": {
"RandomCrop": {
"size": [256, 256] },
"RandomHorizontalFlip": {
"p": 0.5 },
"RandomVerticalFlip": {
"p": 0.5 },
"RandomRotation90": {
"p": 0.5 },
}
})
dataset = build_dataset(dataset_cfg)
print(dataset[0])
Build a model:
from easydict import EasyDict as edict
from simdeblur.model import build_backbone
model_cfg = edict({
"name": "DBN",
"num_frames": 5,
"in_channels": 3,
"inner_channels": 64
})
model = build_backbone(model_cfg)
x = torch.randn(1, 5, 3, 256, 256)
out = model(x)
Build a loss:
from easydict import EasyDict as edict
from simdeblur.model import build_loss
criterion_cfg = {
"name": "MSELoss",
}
criterion = build_loss()
x = torch.randn(2, 3, 256, 256)
y = torch.randn(2, 3, 256, 256)
print(criterion(x, y))
And the optimizer and lr_scheduler also can be created by the functions "build_optimizer" and "build_lr_scheduler" in the simdeblur.scheduler, etc.
SimDeblur supports the most popular image and video deblurring datasets, including GOPRO, DVD, REDS, BSD. We design different data reading strategies that can meet the input requirements of different image and video deblurring models.
You can click here for more information about the design of the dataset.
The design spirit of SimDeblur comes most from Detectron2 [1], we highly thank for this amazing open-sourced toolbox. We also thank for the paper and code collections in Awesome-Deblurring repositry [2].
[1] facebookresearch. detectron2. https://github.com/facebookresearch/detectron2
[2] subeeshvasu. Awesome-Deblurring. https://github.com/subeeshvasu/Awesome-Deblurring
If SimDeblur helps your research or work, please consider citing SimDeblur.
@misc{cao2021simdeblur,
author = {Mingdeng Cao},
title = {SimDeblur: A Simple Framwork for Image and Video Deblurring},
howpublished = {\url{https://github.com/ljzycmd/SimDeblur}},
year = {2021}
}
Last, if you have any questions about SimDeblur, please feel free to open an new issue or contact me at mingdengcao [AT] gmail.com
, and I will try to solve your problem.