Skip to main content

Convolutional Neural Networks – Image Classification

 

The objective of this project is to carry out supervised image classification on a collection of colored images. It employs a convolutional neural network design and applies data augmentation and transformations to recognize the category of images from a predefined set of 10 classes.

Data Set (CIFAR-10)

 

The dataset used is CIFAR-10, which is a widely used benchmark dataset in the field of computer vision and machine learning. It serves as a standard dataset for training and evaluating machine learning algorithms, particularly for image classification tasks.

The dataset has the following features:

  • Consists of 60,000 32×32 color images in 10 classes, with 6,000 images per class.
  • Comprises 50,000 training images and 10,000 test images.
  • Classes: airplane, automobile, bird, cat, deer, dog, frog, horse, ship, and truck.

Image Classification Details

 

The project is implemented in several steps simulating the essential data processing and analysis phases.

  • We implemented the classification in both Tensorflow and PyTorch inside the notebooks folder.
  • Each step is represented in a specific section inside the corresponding notebook.

CIFAR-10 Classification: Tensorflow

 

Corresponding notebook: image-classification-tensorflow.ipynb

STEP 1 – Initialization: importing necessary libraries and modules.

STEP 2 – Loading Dataset: loading the dataset from keras library and checking its details.

STEP 3 – Image Preprocessing: data transformation and augmentation using ImageDataGenerator, as follows:

  1. Scaling the pixel values of the images to be in the range [0, 1].
  2. Randomly applying shear transformations to the images.
  3. Randomly applying zoom transformations to the images.
  4. Randomly flipping images horizontally.

STEP 4 – Building CNN Model: CNN model consists of the following Sequential layers:

  1. Input layer.
  2. Two convolutional layers with ReLU activation function and an increasing number of filters.
  3. Two max pooling layers following the convolutional layers.
  4. Flattening layer.
  5. Two dense/fully connected layers with ReLU activation function.
  6. Output layer with Softmax activation function.

STEP 5 – Model Training: model is compiled and trained using the following configurations:

STEP 6 – Performance Analysis: model accuracy is plotted and analyzed across the epochs.

  • Training and validation accuracy across epochs (Tensorflow):

CIFAR10 CNN Classification Results - Tensorflow

CIFAR-10 Classification: Pytorch

 

Corresponding notebook: image-classification-pytorch.ipynb

STEP 1 – Initialization: importing necessary libraries and modules.

STEP 2 – Loading and Transforming Dataset:

  • Loading the dataset from torchvision library using DataLoader:
    • Batch size: 32
    • Shuffle: True
  • Implementing data transformation and augmentation using Compose, as follows:
    • Randomly rotating images.
    • Randomly flipping images horizontally.
    • Randomly changing the brightness, contrast, saturation, and hue of the image (color jitter).
    • Scaling the pixel values of the images to be in the range [0, 1].

STEP 3 – Building CNN Model: using nn.Module:

  1. Input layer.
  2. Two convolutional layers with ReLU activation function and an increasing number of filters.
  3. Two max pooling layers following the convolutional layers.
  4. Flattening layer.
  5. Two dense/fully connected layers with ReLU activation function.
  6. Output layer with Softmax activation function.
  7. Optimizer: Adam.
  8. Loss function: CrossEntropyLoss.

STEP 4 – Model Training: model is trained using the following configurations:

  • Epochs: 25

STEP 5 – Performance Analysis: model accuracy is plotted and analyzed across the epochs.

  • Training and validation accuracy across epochs (PyTorch):

CIFAR10 CNN Classification Results - PyTorch

The Big Oxmox advised her not to do so, because there were thousands of bad Commas, wild Question Marks and devious Semikoli, but the Little Blind Text didn’t listen. She packed her seven versalia, put her initial into the belt and made herself on the way. When she reached the first hills of the Italic Mountains, she had a last view back on the skyline of her hometown Bookmarksgrove, the headline of Alphabet Village and the subline of her own road, the Line Lane. Pityful a rethoric question ran over her cheek, then she continued her way. On her way she met a copy.

Separated they live in Bookmarksgrove right at the coast of the Semantics, a large language ocean. A small river named Duden flows by their place and supplies it with the necessary regelialia. It is a paradisematic country, in which roasted parts of sentences fly into your mouth. Even the all-powerful Pointing has no control about the blind texts it is an almost unorthographic life One day however a small line of blind text by the name of Lorem Ipsum decided to leave for the far World of Grammar. The Big Oxmox advised her not to do so, because there were thousands of bad Commas, wild Question Marks and devious Semikoli, but the Little Blind Text didn’t listen. She packed her seven versalia, put her initial into the belt and made herself on the way. l using her.Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts. Separated they live in Bookmarksgrove right at the coast of the Semantics, a large language ocean. A small river named Duden flows by their place and supplies it with the necessary regelialia.

Leave a Reply