A blur detection model trained to detect blurry images. Implemented with pytorch lightning.
The model is trained on a blur dataset from kaggle. The dataset consists of 1050 blurred and sharp images, consisting of 3x350 photos (motion-blurred, defocused-blurred, sharp).
The CNN model consists of 2x convolutional layers with pooling and dropout following 2x fully connected layers. For the first convolution layer a kernel size of 7x7 followed by a ReLU activation function, max pooling (2x2) and dropout (0.2) was chosen. In the second convolution layer a kernel of size 5x5 and again follow by ReLU, max pooling and dropout was applied. After the convolutions two fully connected layers (1024 units) are connected.
The model was designed with the help of pytorch lightning. For data preparation the training set was split into training, validation and test set with an 80/20 train/test and 90/10 validation/test split. For training the EarlyStopping callback of pytorch lightning based on validation loss was used to avoid overfitting of the model. A batch size of 128 was chosen and data augmentation in the train dataloader was performed. As input a cropped image of size 96x96 pixels was chosen, depending on hardware constraints this could be increased. After training for more than 200 epochs the model reached an accuracy of 81.91%.
Install requirements:
$ pip install -r requirements.txt
Prepare datasets by splitting into train, validation and test set:
$ python prepare_labels.py <path_to_datafolder>
Train model:
$ python train.py