Motion blur in videos and images is a fundamental problem in computer vision which leads to significant degradation of the image, impacting its quality. Many computer vision tasks like image/video analysis, object detection, and recognition rely on local features and descriptors and it is well known that motion blur decreases the performance of the traditional detectors and descriptors. Hence, in this project, we attempt to re-implement the DeblurGAN; an end-to-end learned method for motion deblurring, based on conditional GAN and content loss. We test the quality of de-blurred images by evaluating it on a real-world problem – Object detection. Here, we try to re-implement the image deblurring model presented by https://arxiv.org/pdf/1711.07064v4.pdf .
-
Generator.py: Consists of the definition of the Generator class and the Resnet block.
-
Discriminator.py: Consists of the definition of the Discriminator class.
-
CreateDataLoader: Consists of the definition of custom dataloader used to load the images for training and testing.
-
Losses.py: Consists of the different losses used to train the model.
-
utils.py: Consists of the definitions of various helper functions used throughout the code.
-
metrics.py: Consists of the definitions of metrics used to check the performance of the model.
-
constants.py: Consists of the values of different constants used throughout the project code.
-
train.py: Consists the code for actual training of model.
-
test.py: Consists the code for testing the model.
-
organize_gopro_dataset.py: Consists of code to organize the dataset into appropriate folders.
- NVIDIA GPU + CUDA CuDNN
- PyTorch
The GoPro Large dataset can be downloaded from: https://github.com/SeungjunNah/DeepDeblur_release
To organize the data into the proper folders run the organize_gopro_dataset.py file:
python organize_gopro_dataset.py --dir_in=GOPRO_Large --dir_out=images
To train the data run the below command:
python train.py
The training outputs a state_dict file with the weights and biases at the end of every 20 epochs. This file is used for testing.
To test the model:
Change the phase value in CreateDataLoader.py from phase = 'train/'
to phase = 'test/'
and enter the name of state_dict file in test.py file. For example, G.load_state_dict(torch.load('model_G_100.pt'))
.
python test.py