Main Content

Build a machine learning node for Node-RED using TensorFlow.js

Combine TensorFlow.js with Node-RED to create AI-enabled Node-RED applications in various environments

Lowering the barrier to entry for artificial intelligence (AI) is a goal that is continually strived for. Making AI more widely accessible will not only increase the number of people who actually use AI, but it will also help increase the spread and adoption of AI across many different fields. The world of machine learning can be daunting at first, but there are several approaches to simplify the entire AI app development process. One of these approaches is by combining the use of TensorFlow.js with Node-RED. This tutorial shows you how to use this approach to create AI-enabled Node-RED applications in various environments.

What is Node-RED?
Node-RED is an open source visual programming tool that offers a browser-based flow editor for wiring together devices, APIs, and services. It helps users visualize and design their event-driven applications. Providing a low-code style of application development, Node-RED can speed up development time and make app development more accessible to coders and non-coders alike. Built on Node.js, you can extend its features by creating your own nodes or by taking advantage of the JavaScript and npm ecosystems.

While Node-RED really shines for IoT workloads with the ability to run on devices like the Raspberry Pi, it can also be run on laptop and cloud environments for any event-driven application scenario. One of the core components of Node-RED is the node, many of which are provided by the community. Each Node-RED node has a well-defined purpose and acts as an essential building block for constructing flows. They usually take in some input and produce some output for use by other nodes. With enough of these nodes strung together, you can produce full-fledged applications. Learn more about using Node-RED.

Adding TensorFlow.js
While Node-RED provides the development environment, incorporating machine learning into your apps is another key component. TensorFlow.js fills this gap. The matching Node.js ecosystems make integrating the two technologies seamless, where a TensorFlow.js Node-RED node can easily be created, packaged, and uploaded to npm for sharing.

TensorFlow.js also provides the benefit of having models run directly on the device with no interaction with an external server or cloud. This alleviates most data security or Internet connectivity concerns. Also, with the growing availability of TensorFlow.js Node-RED nodes provided by the community, several different AI apps can be realized without writing a single line of code.

In this tutorial, we highlight:

Using publicly available TensorFlow.js Node-RED packages
Building your own TensorFlow.js Node-RED packages
Enabling TensorFlow.js on IoT devices
Deploying Node-RED to cloud environments”

Link to article