Code Monkey home page Code Monkey logo

sinanw / cnn-image-classification Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 216 KB

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.

License: MIT License

Jupyter Notebook 100.00%
artificial-intelligence convolutional-neural-networks image-classification machine-learning neural-networks pytorch tensortflow

cnn-image-classification's Introduction

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 32x32 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

cnn-image-classification's People

Contributors

sinanw avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.