Official PyTorch Implementation for "Recurrent Video Deblurring with Blur-Invariant Motion Estimation and Pixel Volumes"

Overview

PVDNet: Recurrent Video Deblurring with Blur-Invariant Motion Estimation and Pixel Volumes

License CC BY-NC

This repository contains the official PyTorch implementation of the following paper:

Recurrent Video Deblurring with Blur-Invariant Motion Estimation and Pixel Volumes
Hyeongseok Son, Junyong Lee, Jonghyeop Lee, Sunghyun Cho, Seungyong Lee, TOG 2021 (presented at SIGGRAPH 2021)

About the Research

Click here

Overall Framework

Our video deblurring framework consists of three modules: a blur-invariant motion estimation network (BIMNet), a pixel volume generator, and a pixel volume-based deblurring network (PVDNet). We first train BIMNet; after it has converged, we combine the two networks with the pixel volume generator. We then fix the parameters of BIMNet and train PVDNet by training the entire network.

Blur-Invariant Motion Estimation Network (BIMNet)

To estimate motion between frames accurately, we adopt LiteFlowNet and train it with a blur-invariant loss so that the trained network can estimate blur-invariant optical flow between frames. We train BIMNet with a blur-invariant loss , which is defined as (refer Eq. 1 in the main paper):

The figure shows a qualitative comparison of different optical flow methods. The results of the other methods contain severely distorted structures due to errors in their optical flow maps. In contrast, the results of BIMNets show much less distortions.

Pixel Volume for Motion Compensation

We propose a novel pixel volume that provides multiple candidates for matching pixels between images. Moreover, a pixel volume provides an additional cue for motion compensation based on the majority.

Our pixel volume approach leads to the performance improvement of video deblurring by utilizing the multiple candidates in a pixel volume in two aspects: 1) in most cases, the majority cue for the correct match would help as the statistics (Sec. 4.4 in the main paper) shows, and 2) in other cases, PVDNet would exploit multiple candidates to estimate the correct match referring to nearby pixels with majority cues.

Getting Started

Prerequisites

Tested environment

Ubuntu18.04 Python 3.8.8 PyTorch 1.8.0 CUDA 10.2

  1. Environment setup

    $ git clone https://github.com/codeslake/PVDNet.git
    $ cd PVDNet
    
    $ conda create -y --name PVDNet python=3.8 && conda activate PVDNet
    # for CUDA10.2
    $ sh install_CUDA10.2.sh
    # for CUDA11.1
    $ sh install_CUDA11.1.sh
  2. Datasets

    • Download and unzip Su et al.'s dataset and Nah et al.'s dataset under [DATASET_ROOT]:

      ├── [DATASET_ROOT]
      │   ├── train_DVD
      │   ├── test_DVD
      │   ├── train_nah
      │   ├── test_nah
      

      Note:

      • [DATASET_ROOT] is currently set to ./datasets/video_deblur. It can be specified by modifying config.data_offset in ./configs/config.py.
  3. Pre-trained models

    • Download and unzip pretrained weights under ./ckpt/:

      ├── ./ckpt
      │   ├── BIMNet.pytorch
      │   ├── PVDNet_DVD.pytorch
      │   ├── PVDNet_nah.pytorch
      │   ├── PVDNet_large_nah.pytorch
      

Testing models of TOG2021

For PSNRs and SSIMs reported in the paper, we use the approach of Koehler et al. following Su et al., that first aligns two images using global translation to represent the ambiguity in the pixel location caused by blur.
Refer here for the evaluation code.

## Table 4 in the main paper (Evaluation on Su etal's dataset)
# Our final model 
CUDA_VISIBLE_DEVICES=0 python run.py --mode PVDNet_DVD --config config_PVDNet --data DVD --ckpt_abs_name ckpt/PVDNet_DVD.pytorch

## Table 5 in the main paper (Evaluation on Nah etal's dataset)
# Our final model 
CUDA_VISIBLE_DEVICES=0 python run.py --mode PVDNet_nah --config config_PVDNet --data nah --ckpt_abs_name ckpt/PVDNet_nah.pytorch

# Larger model
CUDA_VISIBLE_DEVICES=0 python run.py --mode PVDNet_large_nah --config config_PVDNet_large --data nah --ckpt_abs_name ckpt/PVDNet_large_nah.pytorch

Note:

  • Testing results will be saved in [LOG_ROOT]/PVDNet_TOG2021/[mode]/result/quanti_quali/[mode]_[epoch]/[data]/.
  • [LOG_ROOT] is set to ./logs/ by default. Refer here for more details about the logging.
  • options
    • --data: The name of a dataset to evaluate: DVD | nah | random. Default: DVD
      • The data structure can be modified in the function set_eval_path(..) in ./configs/config.py.
      • random is for testing models with any video frames, which should be placed as [DATASET_ROOT]/random/[video_name]/*.[jpg|png].

Wiki

Citation

If you find this code useful, please consider citing:

@artical{Son_2021_TOG,
    author = {Son, Hyeongseok and Lee, Junyong and Lee, Jonghyeop and Cho, Sunghyun and Lee, Seungyong},
    title = {Recurrent Video Deblurring with Blur-Invariant Motion Estimation and Pixel Volumes},
    journal = {ACM Transactions on Graphics},
    year = {2021}
}

Contact

Open an issue for any inquiries. You may also have contact with [email protected] or [email protected]

Resources

All material related to our paper is available by following links:

Link
The main paper
arXiv
Supplementary Files
Checkpoint Files
Su et al [2017]'s dataset (reference)
Nah et al. [2017]'s dataset (reference)

License

This software is being made available under the terms in the LICENSE file.

Any exemptions to these terms require a license from the Pohang University of Science and Technology.

About Coupe Project

Project ‘COUPE’ aims to develop software that evaluates and improves the quality of images and videos based on big visual data. To achieve the goal, we extract sharpness, color, composition features from images and develop technologies for restoring and improving by using them. In addition, personalization technology through user reference analysis is under study.

Please check out other Coupe repositories in our Posgraph github organization.

Useful Links

Comments
  • Division by zero

    Division by zero

    (PVDNet) PS D:\PVDNet> python run.py --mode PVDNet_large_nah --config config_PVDNet_large --data random --ckpt_abs_name ckpt/PVDNet_large_nah.pytorch Laoding Config for evaluation Traceback (most recent call last): File "run.py", line 311, in config = config_lib.get_config(args.project, args.mode, args.config) File "D:\PVDNet\configs\config_PVDNet_large.py", line 42, in get_config IpE = math.ceil((len(list(range(0, total_frame_num - (config.frame_itr_num-1), config.frame_itr_num)))) / actual_batch_size) * config.frame_itr_num ZeroDivisionError: division by zero

    opened by Michaelwhite34 29
  • Error training on Windows

    Error training on Windows

    Hi, I am getting the following error when I run this code on windows. Traceback (most recent call last): File "run.py", line 295, in trainer.train() File "run.py", line 69, in train self.ckpt_manager.save(self.model.get_network(), self.model.get_training_state(0), 0, score = [1e-8, 1e8]) File "D:\PVDNet-main\ckpt_manager.py", line 138, in save self._update_files() File "D:\PVDNet-main\ckpt_manager.py", line 148, in _update_files lines_prev = self._sort(lines[:-1]) File "D:\PVDNet-main\ckpt_manager.py", line 166, in _sort scores = [float(score.split(' ')[1]) for score in lines] File "D:\PVDNet-main\ckpt_manager.py", line 166, in scores = [float(score.split(' ')[1]) for score in lines] IndexError: list index out of range

    opened by wgp666 18
  • Trouble with training

    Trouble with training

    (PVDNet):CUDA_VISIBLE_DEVICES=0 python -B run.py --is_train --mode PVDNet_DVD --config config_PVDNet --trainer trainer --data DVD --LRS CA -b 2 -th 8 -dl -ss -dist Traceback (most recent call last): File "run.py", line 263, in init_dist() File "run.py", line 193, in init_dist rank = int(os.environ['RANK']) File "/home/liao/anaconda3/envs/PVDNet/lib/python3.8/os.py", line 675, in getitem raise KeyError(key) from None KeyError: 'RANK'

    opened by liaolianye666 5
  • Some problems about the testing results.

    Some problems about the testing results.

    Hi, this is a great job! But I have some questions about PVDNet. I have tested PVDNet (normal size version) on DVD and GOPRO with the checkpoint provided, however, the testing results are lower than those in the original paper. Specifically, I got 31.89 PSNR and 0.9236 SSIM on DVD, and 31.09 PSNR and 0.9140 SSIM on GOPRO. So, is there something wrong with the configuration?

    opened by ljzycmd 5
  • PermissionError: [Errno 13] Permission denied:

    PermissionError: [Errno 13] Permission denied:

    File "run.py", line 277, in config_lib.log_config(config.LOG_DIR.config, config) File "E:\code\python\PVDNet\configs\config.py", line 136, in log_config with open(path + '/config.txt', 'w') as f: PermissionError: [Errno 13] Permission denied: 'E:/code/python/PVDNet\PVDNet_TOG2021\PVDNet_DVD\config/config.txt'

    opened by huchunjun425 4
  • Could PVDNet Test for single picture?

    Could PVDNet Test for single picture?

    Thanks for your work! I have configured the environment for the project. I don't know whether it can be used in a single photo to blur it. I was hoping you could help me with that.

    opened by cynthia-you 2
  • Compilation terminated.

    Compilation terminated.

    D:\Anaconda3\envs\PVDNet\python.exe E:/code/python/PVDNet/run.py Laoding Config for evaluation Project : PVDNet_TOG2021 Mode : PVDNet_DVD Config: config_PVDNet Network: PVDNet Trainer: trainer Loading Model... initializing deblurring network Traceback (most recent call last): File "D:\Anaconda3\envs\PVDNet\lib\site-packages\cupy\cuda\compiler.py", line 685, in compile nvrtc.compileProgram(self.ptr, options) File "cupy_backends\cuda\libs\nvrtc.pyx", line 141, in cupy_backends.cuda.libs.nvrtc.compileProgram File "cupy_backends\cuda\libs\nvrtc.pyx", line 153, in cupy_backends.cuda.libs.nvrtc.compileProgram File "cupy_backends\cuda\libs\nvrtc.pyx", line 69, in cupy_backends.cuda.libs.nvrtc.check_status cupy_backends.cuda.libs.nvrtc.NVRTCError: NVRTC_ERROR_COMPILATION (6)

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last): File "E:/code/python/PVDNet/run.py", line 347, in eval(config) File "E:\code\python\PVDNet\eval.py", line 198, in eval eval_quan_qual(config) File "E:\code\python\PVDNet\eval.py", line 68, in eval_quan_qual blur_folder_path_list, blur_file_path_list, gt_file_path_list = init(config, mode) File "E:\code\python\PVDNet\eval.py", line 43, in init model = create_model(config) File "E:\code\python\PVDNet\models_init_.py", line 5, in create_model model = lib.Model(config) File "E:\code\python\PVDNet\models\trainers\trainer.py", line 44, in init Macs,params = get_model_complexity_info(self.network, (1, 3, 720, 1280), input_constructor = self.network.input_constructor, as_strings=False,print_per_layer_stat=config.is_verbose) File "D:\Anaconda3\envs\PVDNet\lib\site-packages\ptflops\flops_counter.py", line 34, in get_model_complexity_info _ = flops_model(**input) File "D:\Anaconda3\envs\PVDNet\lib\site-packages\torch\nn\modules\module.py", line 1148, in _call_impl result = forward_call(*input, **kwargs) File "E:\code\python\PVDNet\models\trainers\trainer.py", line 304, in forward w_bb = upsample(self.BIMNet(norm(I_curr_refined ), norm(I_prev_refined )), refine_h, refine_w) File "D:\Anaconda3\envs\PVDNet\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl return forward_call(*input, **kwargs) File "E:\code\python\PVDNet\models\archs\liteFlowNet.py", line 246, in forward tensorFlow = self.moduleMatching[intLevel](tensorFirst[intLevel], tensorSecond[intLevel], tensorFeaturesFirst[intLevel], tensorFeaturesSecond[intLevel], tensorFlow) File "D:\Anaconda3\envs\PVDNet\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl return forward_call(*input, **kwargs) File "E:\code\python\PVDNet\models\archs\liteFlowNet.py", line 118, in forward tensorCorrelation = torch.nn.functional.leaky_relu(input=FunctionCorrelation(tensorFirst=tensorFeaturesFirst, tensorSecond=tensorFeaturesSecond, intStride=1), negative_slope=0.1, inplace=False) File "E:\code\python\PVDNet\models\archs\torch_correlation_C11.py", line 403, in FunctionCorrelation return _FunctionCorrelation.apply(tensorFirst, tensorSecond, intStride) File "E:\code\python\PVDNet\models\archs\torch_correlation_C11.py", line 300, in forward cupy_launch('kernel_Correlation_rearrange', cupy_kernel('kernel_Correlation_rearrange', { File "cupy_core\raw.pyx", line 89, in cupy._core.raw.RawKernel.call File "cupy_core\raw.pyx", line 96, in cupy._core.raw.RawKernel.kernel.get File "cupy_core\raw.pyx", line 113, in cupy._core.raw.RawKernel._kernel File "cupy_util.pyx", line 67, in cupy._util.memoize.decorator.ret File "cupy_core\raw.pyx", line 547, in cupy._core.raw._get_raw_module File "cupy_core\core.pyx", line 2081, in cupy._core.core.compile_with_cache File "cupy_core\core.pyx", line 2141, in cupy._core.core.compile_with_cache File "D:\Anaconda3\envs\PVDNet\lib\site-packages\cupy\cuda\compiler.py", line 492, in _compile_module_with_cache return _compile_with_cache_cuda( File "D:\Anaconda3\envs\PVDNet\lib\site-packages\cupy\cuda\compiler.py", line 570, in _compile_with_cache_cuda ptx, mapping = compile_using_nvrtc( File "D:\Anaconda3\envs\PVDNet\lib\site-packages\cupy\cuda\compiler.py", line 321, in compile_using_nvrtc return _compile(source, options, cu_path, File "D:\Anaconda3\envs\PVDNet\lib\site-packages\cupy\cuda\compiler.py", line 305, in _compile compiled_obj, mapping = prog.compile(options, log_stream) File "D:\Anaconda3\envs\PVDNet\lib\site-packages\cupy\cuda\compiler.py", line 704, in compile raise CompileException(log, self.src, self.name, options, cupy.cuda.compiler.CompileException: Catastrophic error: cannot open source file "C:\Users\鑳℃烦淇奬AppData\Local\Temp\tmprv5reuna\d0f546e6b437468d05490e1069adb24672c7985b.cubin.cu"

    1 catastrophic error detected in the compilation of "C:\Users.....\AppData\Local\Temp\tmprv5reuna\d0f546e6b437468d05490e1069adb24672c7985b.cubin.cu". Compilation terminated.

    opened by huchunjun425 1
Owner
Junyong Lee
Ph.D candidate at POSTECH
Junyong Lee
StyleGAN2-ADA - Official PyTorch implementation

Abstract: Training generative adversarial networks (GAN) using too little data typically leads to discriminator overfitting, causing training to diverge. We propose an adaptive discriminator augmentation mechanism that significantly stabilizes training in limited data regimes.

NVIDIA Research Projects 3.2k Dec 30, 2022
Official PyTorch implementation of Joint Object Detection and Multi-Object Tracking with Graph Neural Networks

This is the official PyTorch implementation of our paper: "Joint Object Detection and Multi-Object Tracking with Graph Neural Networks". Our project website and video demos are here.

Richard Wang 443 Dec 6, 2022
Official pytorch implementation of paper "Image-to-image Translation via Hierarchical Style Disentanglement".

HiSD: Image-to-image Translation via Hierarchical Style Disentanglement Official pytorch implementation of paper "Image-to-image Translation

null 364 Dec 14, 2022
Official pytorch implementation of paper "Inception Convolution with Efficient Dilation Search" (CVPR 2021 Oral).

IC-Conv This repository is an official implementation of the paper Inception Convolution with Efficient Dilation Search. Getting Started Download Imag

Jie Liu 111 Dec 31, 2022
Official PyTorch Implementation of Unsupervised Learning of Scene Flow Estimation Fusing with Local Rigidity

UnRigidFlow This is the official PyTorch implementation of UnRigidFlow (IJCAI2019). Here are two sample results (~10MB gif for each) of our unsupervis

Liang Liu 28 Nov 16, 2022
Official implementation of our paper "LLA: Loss-aware Label Assignment for Dense Pedestrian Detection" in Pytorch.

LLA: Loss-aware Label Assignment for Dense Pedestrian Detection This project provides an implementation for "LLA: Loss-aware Label Assignment for Dens

null 35 Dec 6, 2022
An official implementation of "SFNet: Learning Object-aware Semantic Correspondence" (CVPR 2019, TPAMI 2020) in PyTorch.

PyTorch implementation of SFNet This is the implementation of the paper "SFNet: Learning Object-aware Semantic Correspondence". For more information,

CV Lab @ Yonsei University 87 Dec 30, 2022
Old Photo Restoration (Official PyTorch Implementation)

Bringing Old Photo Back to Life (CVPR 2020 oral)

Microsoft 11.3k Dec 30, 2022
Official PyTorch implementation of Spatial Dependency Networks.

Spatial Dependency Networks: Neural Layers for Improved Generative Image Modeling Đorđe Miladinović   Aleksandar Stanić   Stefan Bauer   Jürgen Schmid

Djordje Miladinovic 34 Jan 19, 2022
Official implementation of our CVPR2021 paper "OTA: Optimal Transport Assignment for Object Detection" in Pytorch.

OTA: Optimal Transport Assignment for Object Detection This project provides an implementation for our CVPR2021 paper "OTA: Optimal Transport Assignme

null 217 Jan 3, 2023
This is the official PyTorch implementation of the paper "TransFG: A Transformer Architecture for Fine-grained Recognition" (Ju He, Jie-Neng Chen, Shuai Liu, Adam Kortylewski, Cheng Yang, Yutong Bai, Changhu Wang, Alan Yuille).

TransFG: A Transformer Architecture for Fine-grained Recognition Official PyTorch code for the paper: TransFG: A Transformer Architecture for Fine-gra

Ju He 307 Jan 3, 2023
StyleGAN2-ADA - Official PyTorch implementation

Need Help? If you’re new to StyleGAN2-ADA and looking to get started, please check out this video series from a course Lia Coleman and I taught in Oct

Derrick Schultz 217 Jan 4, 2023
Official PyTorch implementation of "ArtFlow: Unbiased Image Style Transfer via Reversible Neural Flows"

ArtFlow Official PyTorch implementation of the paper: ArtFlow: Unbiased Image Style Transfer via Reversible Neural Flows Jie An*, Siyu Huang*, Yibing

null 123 Dec 27, 2022
Official PyTorch implementation of RobustNet (CVPR 2021 Oral)

RobustNet (CVPR 2021 Oral): Official Project Webpage Codes and pretrained models will be released soon. This repository provides the official PyTorch

Sungha Choi 173 Dec 21, 2022
Official PyTorch implementation for Generic Attention-model Explainability for Interpreting Bi-Modal and Encoder-Decoder Transformers, a novel method to visualize any Transformer-based network. Including examples for DETR, VQA.

PyTorch Implementation of Generic Attention-model Explainability for Interpreting Bi-Modal and Encoder-Decoder Transformers 1 Using Colab Please notic

Hila Chefer 489 Jan 7, 2023
[PyTorch] Official implementation of CVPR2021 paper "PointDSC: Robust Point Cloud Registration using Deep Spatial Consistency". https://arxiv.org/abs/2103.05465

PointDSC repository PyTorch implementation of PointDSC for CVPR'2021 paper "PointDSC: Robust Point Cloud Registration using Deep Spatial Consistency",

null 153 Dec 14, 2022
Official PyTorch implementation of MX-Font (Multiple Heads are Better than One: Few-shot Font Generation with Multiple Localized Experts)

Introduction Pytorch implementation of Multiple Heads are Better than One: Few-shot Font Generation with Multiple Localized Expert. | paper Song Park1

Clova AI Research 97 Dec 23, 2022
Official Pytorch implementation of 'GOCor: Bringing Globally Optimized Correspondence Volumes into Your Neural Network' (NeurIPS 2020)

Official implementation of GOCor This is the official implementation of our paper : GOCor: Bringing Globally Optimized Correspondence Volumes into You

Prune Truong 71 Nov 18, 2022
Official PyTorch Implementation of Hypercorrelation Squeeze for Few-Shot Segmentation, arXiv 2021

Hypercorrelation Squeeze for Few-Shot Segmentation This is the implementation of the paper "Hypercorrelation Squeeze for Few-Shot Segmentation" by Juh

Juhong Min 165 Dec 28, 2022