Image Classification Using fastai library
It is easy for human to identify different types of objects. Human visual system is very good at identifying and recognizing objects but what about the computers? can we provide intelligence to computer so that it can think just like humans in object recognition task?
let’s start with something interesting, the “Hello World” problem of deep learning that is dogs and cats identification in an image. We are going to make a model that can identify whether a given image consist of dogs or cats picture in it.We will consider Kaggle Dogs vs Cats dataset.
There are 25,000 labelled dog and cats photo available for training. following are the steps to follow for cats vs dogs classification model:
Step 1: Import libraries used by fastai
Step 2: specify PATH to data folder and Check for GPUs availability
sz is the size that the images will be resized to in order to ensure that the training runs quickly. for now, we will take 224 as image size.
The programming framework used behind the scene to work with Nvidia GPUs is called CUDA. In addition, NVidia provides special accelerated function for deep learning in package CuDNN. Following lines return true if you have working Nvidia gpu.
Step 3: First look at Cats picture
the default folder structure for using fastai library should be train and valid directories. Each directory will have subdirectory for each class you want to recognize. In this case, ‘dogs’ and ‘cats’
Step 4: Our First Model
we will use pretrained model that is model created by someone else to solve a different model. we will use model trained on ImageNet dataset. The model is convolutional Neural Network model( CNN) that builds state of the art result for computer vision.
we will be using resnet 34 model. resnet 34 won ImageNet challenge in 2015.
So, here is how to train and evaluate dogs vs cats model in 3 line of code:
How good is this model? we will analyse result in next blog……
source: fast.ai