Blog

Web Developer’s AI Guide

Webster’s dictionary defines Artificial Intelligence (AI)… yeah, we’re not doing that. We are not discussing the basics of AI and technology behind it. There are plenty of resources online that will give you insight into the basics of AI’s and help you scratch the surface of a deep and broad ecosystem that is the AI.

The goal of this article is to give you an overview of existing Open source AI frameworks and their implementations which can benefit your web, mobile or desktop app written in Javascript.

First, let’s give it some structure by showing the different domains of AI.

We will cover the most widely implemented ones:

AI dates back to the 1950’s and after decades of mostly theoretical work, we have only started seeing practical applications relatively recently. The growth in AI and Machine development we are experiencing today is the result of the following:

  1. Data availability — more than 3 billion people are using online services on estimated 17 billion devices. Companies provide services and collect data which is later used to train their algorithms.
  2. Computing power — the current stage in hardware development allows for broad implementation of AI algorithms that requires processing of large data sets.
  3. Innovations in algorithms — things like deep learning, or if you prefer, layered neural networks have a great impact on AI development growth.

Neural Networks Javascript Frameworks

ConvNetJS — a Javascript implementation of Neural network, a Deep Learning network developed originally at Stanford University. It is the most popular one on Github (9,000 stars), but the latest commit dates from 2016 so it is not exactly maintained around the clock.

Documentation is easy to understand and there are plenty of resources on their site that can show you where to begin with neural networks. However, bear in mind it is pretty low-level and not very ‘beginner friendly’. Even so, there is no doubt that the ConvNetJS is powerful.

You have the ability to build your own custom network with various types of layers. For instance, you could use convolutional type and create image recognizer. Other types you could include are general classifiers, regression prediction networks and more.

One of the most interesting examples of ConvNetJS usage I’ve came across is the project DeepTesla by a group of scientists gathered around MIT. Also, here you can find couple of implementations which will help you figure out how you might use ConvNetJS on your projects.

NeuroJs — what makes this framework interesting in terms of web development is that it was built with webpack and babel. Despite the lack of documentation and the fact that the latest commit occurred a year ago, you can still learn a lot about how this neural network works by checking out self-driving example code which is written in a very descriptive manner.

Brain.js — a library of Neural Networks written in JavaScript. Simple as that. It is also very popular on github and still well-maintained. It doesn’t have a traditional site with docs and best practices, but their github will provide you with a fair amount of places to visit and learn.

This article, for example, shows how it is fairly easy to setup your own neural network, train it and run it with brain.js. You can use any set of data like company’s online reviews, articles, emails and learn network to detect good or bad reviews, spam, urgent messages and more. You should try it and also give this demo a look.

SynapticJS — a Javascript architecture-free neural network library for node.js and the browser which means you can freely add layers to your network and build any type of network you need. It is well-documented, has a big community, lots of demos, examples and solid maintenance. With abundance of resources available, it is possible to really do serious research into this framework, which is fortunate since it is pretty low-level based.

Visual Perception Javascript Frameworks

OpenCV4nodejs — Asynchronous OpenCV 3.x nodejs. This library provides OpenCV and OpenCV-contrib API access written in Javascript. Maintenance and documentation are good but in order to really use this package you need to have a high level of understanding how OpenCV works. I’d rather turn to something more approachable, like this OpenCV — Node.js Tutorial Series that includes Face Detection, Deep Neural Nets, Hand Gesture Recognition, Machine Learning, etc.

Face-recognition.js — small but robust library whose API is so easy to read and use that in only 50 lines of code you can write your own script for face recognition and run with node. There is a really helpful blog post that will help you get started. It is a node library based on dlib a C++ library.

I’ve followed the aforementioned blog post and I now have an up and running face recognizer. I’ve run it on Mac, installed dlib, XQuartz, I’ve had node running and code written bellow, and, voila, it is working. Of course, this just basic implementation where you just scan the folder for images, extract faces, teach your model and preserve it in json file and then you can perform face recognition based on that model.

Natural Recognition Applications Javascript Framework

TensorFlow.js — yes, it is a machine learning framework developed by Google, very popular and very well maintained and yes, it can be used for many purposes, as you can see on their site. However, I’ve found this interesting implementation named deepSpeech developed by Mozilla and it is in fact a Natural Recognition implementation. It is a machine learning trained model based on Baidu’s Deep Speech research paper. You should really checkout TensorFlow.js, a lot of tutorials how to start, examples and documentation but, like with many mentioned here, pretty low-level.


So far only big companies like Google, Facebook, Amazon had the resources (time, money and data) to invest in AI development. And they did a great job, improving their search engines, ads management, face recognition algorithms etc.

That’s old news.

Over the last couple of years, with interest growing and all sorts of solutions emerging in Open Source community, it is not so expensive to try and apply one of the mentioned approaches. You could try training an AI algorithm with your own set of data and create great things that will bring value to your customer and, consequently, to you.

Easier said, than done, I agree, but you are a developer, you have to keep up with the good stuff. Just take a look at what AI did with Google Search, it is good and it is only going to get better.

Face it, sooner or later you will have to start learning, not necessarily to develop AI, but to apply and adjust existing solutions to your needs.

Oh, and also, be careful!