/blur-or-bokeh

Primary LanguageJupyter Notebook

Blur Bokeh Detection using Residual Connection CNN

This project implements a Convolutional Neural Network (CNN) with residual connections to detect blur and bokeh in images. The dataset is sourced from Kaggle, with additional bokeh photos from HuggingFace. Blur effects, including motion and Gaussian blur, were applied manually to enhance the dataset. I provide the streamlit_app.py if you want to try the model. Do not forget to download the model first.

Table of Contents

Introduction

This project aims to classify images based on their focus quality. Specifically, it differentiates between blurred and bokeh images using a deep learning approach with residual connections to improve model performance and training efficiency.

Open Dataset Creation Notebook

Dataset

The dataset for this project is sourced from:

You can download the dataset from this link

Model Architecture

Below is an overview of the model:

  • Input Shape: Specify the input shape for the images.
  • Preprocessing: Rescales input pixel values to the range [0,1].
  • Entry Block: Convolutional layer with 128 filters of size 3x3 and a stride of 2, followed by ReLU activation.
  • Residual Blocks: Multiple blocks with varying filter sizes ([256, 512, 728]), each containing two convolutional layers with ReLU activation, max-pooling, and residual connections.
  • Final Convolutional Layer: 1024 filters of size 3x3 with ReLU activation.
  • Batch Normalization: Normalizes the activations of the previous layer.
  • Global Average Pooling: Averages the spatial dimensions.
  • Dropout: Applied for regularization.
  • Output Layer: Dense layer with sigmoid activation, returning logits for binary or multi-class classification tasks.

You can download the model in this link

Training and Evaluation

The model is trained with 20 epochs, using Adam Optimizer and Binary Crossentropy for the loss. The metrics that it uses is accuracy with result below: Plot History of Training

Results

Below are the predictions generated by the model during testing. Model Predictions