Nick Bourdakos

@bourdakos1

Start Using TensorFlow.js — Without Leaving This Article

December 6th 2018

One of the largest obstacles for beginners getting experience with artificial intelligence and machine learning can honestly be the setup.

I’m not going to lie, there are still plenty of days that completely slip away, just trying to get Python, TensorFlow and my GPU to cooperate. Does this make me question my abilities as a competent software engineer? Yes, yes it does.

I digress.

So what is TensorFlow.js and how can it help us? From the official page, TensorFlow.js is, “A JavaScript library for training and deploying ML models in the browser and on Node.js.”

What does that mean for us? We can try it out right from this Medium article!

The Demo

In this demo we are using a deep learning model called “MobileNet”. MobileNet is a type of Convolution Neural Network, a model architecture that is good at image classification.

Note: To learn more about what artificial intelligence actually sees, check out my other article.

The Code

Using TensorFlow.js to classify an image with MobileNet is as easy as 3 lines of code:

mobilenet.load()
.then(model => model.classify(myImage))
.then(predictions => // Use predictions)

Final Thoughts

At the time of writing this post TensorFlow provides 5 official models, that are just as easy to use:

However, if none of these models suffice, you can also create/train your own, but that’s for another article.

For fun, I challenge you to look at the PoseNet documentation and try to match the results of the cover photo. But, if you get stuck here’s the code and demo:

Thanks for reading! If you have any questions, feel free to reach out at bourdakos1@gmail.com, connect with me on LinkedIn, or follow me on Medium and Twitter.

If you found this article helpful, it would mean a lot if you gave it some applause👏 and shared to help others find it! And feel free to leave a comment below.

More by Nick Bourdakos

More Related Stories