Introduction

We concluded the last post by talking about two of indico’s transfer learning APIs – Custom Collection and Image Features. To give you an idea of how you can use Custom Collection, we decided to show you how to make a smart security camera using Python and a Raspberry Pi. In case you haven’t yet explored indico’s Custom Collection API or missed the end of the last post, the gist is that it allows you to quickly train a custom classifier for images or text, using your own dataset. What sets it apart from other training algorithms is that it can make accurate predictions from 5-10 examples, instead of requiring 50-100 thousand examples. As you can probably guess, the Custom Collection API uses a pre-trained deep CNN to extract features from images via transfer learning. Whereas the previous blog posts focused on the theory behind computer vision, this post will focus more on how to build your own computer vision system.

Data Collection

To get started, let’s train a classifier to recognize different people in the office. As with most machine learning problems, the first step is collecting a dataset. We went around the office and took four different pictures of each person that we wanted the camera to recognize.

With the dataset ready, the next step is to write a script which uploads the photos to a collection and begins training it. I’ve written it in Python, but we support several other languages if you have another preference.

Now that we have a trained model, we’re ready to start making predictions. However, before we jump into making predictions, it’s important that we validate that the model is working. We collect a separate validation set, which the classifier had never seen before, and make sure that the classifier predicts accurately.

It appears that everything is working! All that’s left is writing a web app that we can check to see if someone we know is at the door.

Security Camera App

The security camera app has two components; a web server and a camera client. The camera client periodically uploads images to the web server. The web server in turn uploads the images to the indico API and displays the results via a web app.

For the camera client, we set up a Raspberry Pi to take photos every five seconds and send the image to a server written in node.js. The user interface is a simple react app that shows which person the classifier believes is at the door. You can check out the code for the user interface on my GitHub.

The security camera web app

Other Ways You Can Use Collections

The power of the Custom Collection API extends beyond classifying faces and can be used to quickly solve any image recognition task. For example, business owners can train a collection to detect the emotions of their users and track how happy their customers are. Alternatively, you could train a classifier on pictures of your pantry and alert you when your favorite food runs out.

This post concludes our three part series on computer vision. Hopefully, you now understand how CNNs and transfer learning can be used to make robust image detection algorithms. Additionally, you too can build computer vision algorithms by using the Custom Collection API. If you have any questions or need help getting started, feel free to reach out to us at contact@indico.io!