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.
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
The dataset for this project is sourced from:
- Kaggle: Various image datasets containing both blurred (motion blurred and gaussian blurred) and bokeh images.
- HuggingFace: Bokeh images used to complement the dataset, and create the blurred manually using opencv (https://huggingface.co/datasets/comHannah/bokeh-dataset)
You can download the dataset from this link
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
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:
Below are the predictions generated by the model during testing.