How to train custom image classifier in 5 minutes

avatar
David Rajnoch
8. July 2017
Custom Dataset

Recognize images using Vize Classifier API

Today I will show how to set and test custom image classification engine using Vize.ai — Custom image classification API. We will prepare dataset, upload images, train classifier and test our classifier in the web interface. We need no coding experience unless we want to build API in our project. Let’s start now.

Prepare dataset

We want classifier to recognize person’s gender. First, we will need 20 images of each male and female. Let’s google “man” and “woman” and save 20 images of each. Here you can download my dataset. I tried to avoid fashion images and models so my dataset is general person images. I also searched for different culture types and skin tones so my dataset is as diverse as possible. I used only frontal images.

Custom Dataset

Male and female images in dataset

Upload dataset to Vize

We will need to create an account on Vize.ai. Visit the homepage then click “get started for free” and sign in using Google or GitHub account. We are ready to create a new task. A task is classification engine (convolutional network model) that lets us classify our images.

vize ai screenshot vize ai screenshot
vize ai screenshot

Homepage, signup page, task dashboard

We click on “New Task” button and fill name our classifier “male or female classifier”. We want to add two categories “male” and “female”. We can always add and delete category later. Click “Create” to move to image upload.

Name your task and create categories to sort

Name your task and create categories to sort

Now, we are going to click “Direct Upload” to upload images into our two categories. We can see 22 and 21 images uploaded on the image below. We can use “Edit” button to show images and move them from one category to another. To delete some images move them to new “delete” category and delete this category. We do not need any of this for now. Let’s click “Review and Train” in the top right corner.

Images uploaded into categories

Images uploaded into categories

Train classifier

In this step, we can review our categories. We are ready to click on “Start training” button.

Start custom classifier training

Start custom classifier training

A task is in training right now. It can take one to five hours depending on the number of images. Vize uses transfer learning and set of fine-tuned model architectures to reach the best possible accuracy on each task. Time to have a coffee now and wait for training to finish.

Classifier training finished

Classifier training finished

Test classifier

Our model is ready! We reached 93% accuracy on our 43 images dataset. We can now test it using Preview. We will click on “Deploy and preview” and then “Preview my task”. In our dataset “test” folder we can find some testing images to test our classifier.

Preview trained task — test classification

Preview trained task — test classification

Summary

We trained and tested our classifier using Vize web interface. This is the most simple way to build image classification engine. We reached 93% accuracy which we can increase to 100% with uploading more images. It is time to experiment with huge possibilities that image classification brings. In developers documentation we can also find sample code to implement REST API into our app.

What kind of application can we build using visual AI? Let me know about your ideas in comments.

This article was originally published by David Rajnoch.

Related Articles