Start Using TensorFlow.js — Without Leaving This Article by@bourdakos1

Start Using TensorFlow.js — Without Leaving This Article

Nick Bourdakos HackerNoon profile picture

Nick Bourdakos

Computer vision addict at IBM

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:

.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 [email protected], 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.


Signup or Login to Join the Discussion


Related Stories