Image Classification of Dogs & Wolves in Pytorch

Dhimaz Purnama Adjhi

Sosial Media


12 orang menyukai ini
Suka

Summary

Although dogs and wolves are two different species of animals, but they have a lot in common. This is because they are evolutionary cousins, who share a number of common physical, biological, and behavioral characteristics. In some cases, they even look similar. This has resulted in non dog lovers having at least been mistaken and confused between dogs or wolves. Even more so if the person distinguishes between the siberian husky dog and the wolf. To combat this, I created an Image Classification between dogs and wolves on Pytorch. The creation of this image classification is expected to be useful for educational needs in children as well as research needs involving fauna. Using the CNN model and datasets obtained from kaggle of 2000 in the form of various photos of dog and wolf types, the accuracy results achieved in this image classification managed to reach 90%.

Description

The plot for creating an image classification between a dog and a wolf is as follows:

Import All Libraries To Be Used & Prepare Runtime GPU on Google Collab

Get & Clean Data 
Take a dataset of 2000 images of various types of dogs and wolves from the kaggle, then save them on the gdrive. On google collab, download the dataset using gdown and unzip the file. After that, do data cleaning by checking whether there are images in the folder in the form of gray scale or non-image files, if yes, then remove them.

Prepare & Manipulate Data
At this stage, pre-process the data by resizing the image and converting it into tensor format. Next, take the total value of the image on the dataset which is worth 2000 to be processed in defining train_set and test_set. I define the ratio for train_set and test_set is 9 to 1 or 9:1.

Build Model & Train Model 
I used the CNN model for the classification of this image, as well as specifying the Loss Function and Optimizer using Adam. After that train with a vulnerable 30 epoch.


Test Data
Finally, test the model that we have created and save the trained model. Load saved model and test it on test data.

If the output index shows a result of 1, then the output of the prediction defines the wolf. Meanwhile, if the output index shows a result of 0, then the output prediction defines the dog.

The First Attempt


The Second Attempt


The Third Attempt



 

Informasi Course Terkait
  Kategori: Artificial Intelligence
  Course: Basic Framework Deep Learning dengan Pytorch