Giter Site home page Giter Site logo

saifullahbijapur / petimageclassification Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mayur7garg/petimageclassification

0.0 0.0 0.0 242.84 MB

Image classification using Convolutional Neural Network (CNN) in tensorflow.keras for Oxford IIIT Pet Image dataset containing 7,390 images of pets spanning across 37 different classes.

Jupyter Notebook 100.00%

petimageclassification's Introduction

Pet Image Classification

Image classification using Deep CNN in tensorflow.keras for Oxford IIIT Pet image dataset.

Explanation Video

Pet Image Classification

Click on the image link above to redirect to the YouTube video.

Dataset

The dataset for this project can be downloaded from any of the following links:

This dataset consists of 7390 images of pets spanning 37 classes with about 200 images per class. The images vary vastly in size, aspect ratio, pose, lightning, etc. All images in the dataset are within the same folder and the associated class information for each image is present in the file name itself.

Project Requirements

The external libraries required for running Train.ipynb are:

  1. numpy
  2. matplotlib
  3. sklearn/scikit-learn
  4. tensorflow (Version 2.3.0 preferred)
  5. tqdm (Optional. If unavailable, make changes accordingly)

Data Preprocessing

  • Firstly, the class names of all images were extracted from the image file names to create the target variable.
  • The dataset was then divided into train, validation and test datasets. 10% of the entire dataset was used as a test dataset and 10% of the remaining as the validation dataset.
  • Since all images have different sizes and aspect ratios, the images were loaded with fixed 256*256 resolution with padding. The padding helps prevent distortion due to stretching or shrinking of images when changing its aspect ratio.
  • Keras' ImageDataGenerator was used for image augmentation during training with small values for rotation, shift, shear, zoom etc.

Model

The model used is a deep Convolutional Neural Network and was created using tensorflow.keras Sequential API.

The different layers used in this model are as follows:

  • Input
  • Convolution 2D
  • Max Pooling 2D
  • Batch Normalization
  • Dropout
  • Dense

The model makes sure of Early Stopping and Tensorboard callbacks to prevent overfitting and monitor training respectively.

Model Structure

Model Structure

Accuracy and Loss

Accuracy and Loss

Confusion Matrix for Validation data

Confusion Matrix

Metrics

Train Validation Test
Count of Records 5,985 666 739
Sparse Categorical Cross-entropy 0.7314 1.1199 1.0731
Sparse Categorical Accuracy 76.19% 66.37% 66.57%

ย 

TensorBoard

Use the command tensorboard --logdir tensorboard_logs/fit using the command line from the project's root directory to open the TensorBoard GUI in your browser.

Notes

  • Make sure to update the BASE_PATH constant in Train.ipynb to reflect the location where your dataset is stored.
  • The model was trained on NVIDIA Geforce GTX 1650 (6 GB) and the Train.ipynb took about 3 hours to run to completion.

Developed by - Mayur Garg

petimageclassification's People

Contributors

mayur7garg 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.