Visual Deep Computer Vision

Or how you can run deep learning algorithms for computer vision without being an expert.

Favio Vázquez
Towards Data Science

--

Introduction

Deep learning has powered and solved a variety of computer vision problems, such as object detection, motion tracking, action recognition, human pose estimation, semantic segmentation and more.

The biggest advances in the field has been possible due to Convolutional Neural Networks (CNNs). CNNs have the unique capability of feature learning, that is, of automatically learning features based on the given dataset. CNNs are also invariant to transformations, which is a great asset for certain computer vision applications.

You can read more about them here:

And please see this great video by Brandon Rohrer about them:

How we normally do it

Normally we do computer vision with deep learning programming, and learning new APIs, some harder than others, some are really easy an expressive like Keras or PyTorch. For doing that you will need to understand deep learning, computer vision concepts, OpenCV and more. But there is one issue.

What if you want to run experiments, test different amount of epochs, parameters, estimators, optimizers and more. When you are programming those things start to become complicated. Here I want to show you a very simple but powerful way of doing computer vision with deep learning with a platform called Deep Learning Studio.

The new way

I’ve talked about the platform before, and if you want to have an overview of what you can do with it, see these articles:

But here I want to show you three super useful ways of using the platform for deep computer vision.

1. Uploading your Keras model and train it

Let’s say you created your Keras model in your own jupyter notebook or IDE. And you want to use the all the functionalities of the platform. Well that’s very simple.

What you have to do is go to the platform:

And launch the app (you have to create an account first, it’s free btw). When you are in the platform you will see this:

Then click on the arrow to upload your model. We are going to try with a CIFAR-10 model with convolutional networks in Keras. Something important here: The model should be compatible with Keras 1.2.2, that’s the only restriction we have right now.

We are going to upload the model created by the collaboration, you can access it here:

I created a gist if you want to copy it from here:

In the dimension ordering part choose Theano.

After that a new project will be created with the name of the Python file. Then click on Open and you will see:

In the data section choose cifar-10-public to be able to train the model. Btw, you can upload your own dataset o images if you want to train a different model.

Now if you click on the Model tab, you will see a visual representation of the code you just uploaded:

You can play with it and see different options. There you can change your Hyperparameters and of course train the model.

I’m using this configuration for the Hyperparameters:

Then you go and train your model. In the video bellow you can see how to use the training tab for a different problem:

2. Transforming your Keras code to Tensorflow, Pytorch, MXNet and more

Sometimes your manager or company will ask you to program your deep learning algorithms in different frameworks. If you don’t have the time to learn X number of new APIs with the platform you can transform your Keras code into different frameworks very easily.

In the Model tab, just click on the <> button, and you will see:

In the Available Options you can get your model in different frameworks:

Pytorch:

Tensorflow:

And you can get all of that for free. You can even download a desktop version and use your own GPUs, check it out here:

3. Deploy your models as Web Services or REST APIs:

Having a magic button to deploy your models would be awesome.

When you finish building your models, sadly a lot of times it rest on your computer forever. That’s just sad. Imagine a painter not being able to show his masterpiece to anyone.

With the deployment functionalities of DLS you will be able to see your model in action, both for you and others.

Let’s see how to do that.

When you are building your experiments, you put names to them. I will be deploying a model optimized by a SGD, named sgd-2 (this is just a name):

In the Inference/Deploy tab, click Deploy:

Choose the run, create a service name and then choose if you want to deploy with the instance you’re using or a remote instance.

If you do that it will ask you for more information. I’ll just deploy using my cloud instance:

After that, you will be seeing something like this:

If you remember the CIFAR-10 dataset consists of 60000 32x32 colour images in 10 classes. The classes are airplanes, cars, birds, cats, deer, dogs, frogs, horses, ships, and trucks. So let’s try to upload an image of an airplane to see if the model can detect it. I’ll be using this image of a ship:

http://www.seatrade-cruise.com/media/k2/items/cache/3356e0cd9331018e19a8cee016f484a2_XL.jpg

Remember that in our model ships are the 8th class. So I’ll just click on the upload panel:

Hit submit, and we see:

And there you have it! Your own computer vision model with deep learning deployed super easy!

Conclusions

Life is hard enough to make it more difficult. Every option we have to make it simpler we must take it, and if you are a programmer, data scientist, machine learning engineer, or something similar, I can assure you that some parts of what I showed here are making your struggle, day to day.

With these tools you can easily experiment, test and deploy your computer vision problems (and many more) with confidence. I hope you find value in this.

I’ll add more examples on different topics later :)

--

--

Data scientist, physicist and computer engineer. Love sharing ideas, thoughts and contributing to Open Source in Machine Learning and Deep Learning ;).