Building an Image Processing Tool with Node-RED for Machine Vision

Are you looking to create a robust Machine Vision Application using Node-RED packages? In this blog post, we will walk you through the process of building a simple yet powerful machine vision solution for IoT developers, Industrial engineers, or system integrators.

With Node-RED packages, you can develop intelligent image classification solutions for your IoT projects. Whether you're a beginner in low-code IoT programming or an expert in machine vision, this article will provide you with valuable insights to excel in this exciting field. 

We built this image classification application in Prescient Designer, but you can do the same in Node-RED. If you’re already familiar with Node-RED, feel free to jump straight into the tutorial!

Table of Contents

Toolkit: Node-RED, TensorFlow, and Prescient Designer

We'll be using some open-source packages and libraries in this tutorial, so you can easily access them for this exercise.

Node-RED, TensorFlow and Prescient Designer are powerful tools in the context of IoT and machine vision, offering significant benefits for IoT developers, Industrial engineers, or system integrators.

Here's an expanded description of each tool and its key features: 

You'll be able to build this app quickly if you're already familiar with Node-RED. If you haven't used Node-RED before, it's still easy to start with the introductory video.

Node-RED

Node-RED is an open-source software application that allows low-code programming of IoT edge devices.

It provides a visual programming interface that simplifies the development process for industrial engineers and system integrators. 

Key features of Node-RED:

  • Low-code programming: Node-RED enables developers to create applications quickly and easily without extensive coding.

  • IoT integration: It supports a wide range of IoT devices and protocols, allowing seamless connectivity and data exchange.

  • Visual flow-based programming: Users can visually design the flow of data and logic by connecting nodes, making it intuitive and accessible.

  • Extensibility: Node-RED offers a vast library of pre-built nodes and integrations, allowing users to leverage existing functionality and extend the platform's capabilities.

Node-RED, though powerful for low-code IoT edge programming, faces limitations when scaling to large deployments. Learn how Prescient Designer can offer a better solution:

Drawbacks of Node-RED:

  • Handling High Data Volume: Node-RED's sequential data processing can cause bottlenecks with increased data. Prescient Designer's distributed processing architecture scales horizontally across multiple instances, efficiently managing high data volumes for faster processing.

  • Managing Complex Flows: Node-RED struggles with complex IoT deployments involving interconnected flows and intricate logic. Prescient Designer provides an intuitive interface, versioning, debugging tools, and collaboration features for effective design and maintenance of complex workflows.

  • Ensuring Fault Tolerance and High Availability: Node-RED lacks inherent fault tolerance mechanisms, risking flow disruption and data loss. Prescient Designer implements fault tolerance using clustering and replication, rerouting flows to available nodes during failures for uninterrupted operations.

  • Scaling Infrastructure and Resources: Scaling Node-RED deployments on individual machines can limit scalability and resource allocation. Prescient Designer leverages cloud infrastructure and containerization, facilitating easy deployment on scalable environments like Kubernetes for dynamic resource scaling.

Also, Learn About - Node-Red vs Prescient Designer

In conclusion, Prescient Designer overcomes Node-RED's scalability limitations through distributed processing, advanced flow management, fault tolerance, and flexible deployment options. 

Organizations can confidently build and manage large-scale IoT deployments, ensuring high performance, fault tolerance, and flexibility.

TensorFlow:

TensorFlow.js is an open-source JavaScript library that empowers developers to build, train, and run machine learning models in web browsers and Node.js environments.

It brings the power of TensorFlow, a popular machine-learning framework, to the JavaScript ecosystem.

Key features of TensorFlow:

  • In-browser machine learning: TensorFlow.js allows running machine learning models directly in the browser, eliminating the need for server-side processing.

  • Model training and conversion: Developers can train and convert models using popular machine learning frameworks like TensorFlow and then use them in JavaScript applications.

  • Accessibility: With TensorFlow.js, machine learning becomes accessible to web developers without the need for extensive knowledge of Python or other backend languages.

  • Real-time inference: It enables real-time predictions by executing models efficiently in the browser, ideal for applications like object detection or image classification.

Drawbacks of TensorFlow:

  • Complexity: TensorFlow can be complex for beginners due to its extensive API and low-level operations. It requires a good understanding of machine learning concepts and coding skills to effectively use and customize models.

  • Steep Learning Curve: TensorFlow has a steep learning curve compared to other machine learning frameworks. It requires time and effort to become proficient in using TensorFlow and leveraging its full potential.

  • Lack of Flexibility: TensorFlow's static graph computation model can limit flexibility, especially when dealing with dynamic models or architectures that require frequent modifications. This can make it challenging to experiment and iterate quickly during model development.

  • Deployment Challenges: Deploying TensorFlow models can be challenging, especially when integrating them into production systems. Compatibility issues, resource requirements, and dependencies can pose obstacles when deploying models on different platforms or environments.

  • Limited JavaScript Support: While TensorFlow.js provides JavaScript support, it is not as mature or feature-rich as the Python version of TensorFlow. Some advanced functionalities and pre-trained models available in TensorFlow may not be readily accessible in TensorFlow.js.

Prescient Designer:

Prescient Designer is designed to scale Node-RED and TensorFlow.js applications for large IoT deployments, offering advanced features and enterprise-class solutions.

It provides essential functionalities such as distributed programming, end-to-end security, recovery and rollback mechanisms, remote collaboration, communication, and application template solutions.

Key features of Prescient Designer:

  • Scalability: Prescient Designer excels at handling large-scale IoT deployments by efficiently managing and orchestrating multiple edge devices, overcoming the scalability challenges of Node-RED.

  • Advanced security: With robust security measures such as authentication, encryption, and access control, Prescient Designer ensures data privacy and integrity, offering enhanced security compared to Node-RED.

  • Collaboration: Prescient Designer fosters remote collaboration among teams, allowing multiple developers to work simultaneously on the same project. This feature promotes knowledge sharing and facilitates efficient teamwork, setting it apart from Node-RED.

  • Recovery and rollback: Prescient Designer incorporates mechanisms for application recovery and version rollback, ensuring stability and reliability in industrial IoT environments. This feature enhances the resilience and reliability of enterprise-class applications, distinguishing it from Node-RED.

  • Template solutions: Prescient Designer provides pre-built templates tailored for common industrial use cases. These templates accelerate development and reduce time-to-market for IoT applications, making them a valuable tool for enterprise-class applications and large-scale IoT deployments.

Where Prescient Shines Most

Prescient is an AI development platform that offers an alternative solution to the drawbacks of TensorFlow. 

Here's how Prescient can help:

  1. User-Friendly Interface: Prescient provides a user-friendly interface that simplifies the process of building, training, and deploying machine learning models. It abstracts away the complexities of TensorFlow, making it accessible to developers with varying levels of expertise.

  2. Drag-and-Drop Model Building: Prescient offers a drag-and-drop interface for building models, allowing developers to construct complex architectures without requiring in-depth knowledge of TensorFlow's low-level operations.

  3. Code Generation: Prescient generates optimized TensorFlow code behind the scenes, enabling developers to leverage the power and flexibility of TensorFlow without the need to manually write or understand complex code.

  4. Easy Deployment: Prescient simplifies the deployment process by providing options for deploying models to various platforms, such as web browsers, mobile devices, or cloud servers. It takes care of compatibility issues and streamlines the deployment workflow.

  5. JavaScript Support: Prescient offers robust JavaScript support, allowing developers to integrate machine learning models seamlessly into web applications. It bridges the gap between TensorFlow's capabilities and the JavaScript ecosystem, providing a more comprehensive solution.

By leveraging Prescient, developers can overcome the complexities and limitations of TensorFlow, enabling faster development, easier deployment, and improved accessibility for machine learning projects.

Getting Started with TensorFlow in Prescient Designer and Node-RED

This tutorial will work if you only have access to Node-RED, but it will be easier and more straightforward with Prescient Designer. Watch our video tutorial to walk you through this exercise.

Let's begin!

Here are the installation steps for the required nodes in a numbered list format:

  1. Install the node-red-contrib-browser-utils node from Palette Manager - This node provides a file injection node to upload files from the browser.

  2. Install the node-red-contrib-image-output node from Palette Manager - This node helps in viewing the image on the Node-RED editor.

  3. Install the @prescient-devices/node-red-contrib-usb-camera node from Palette Manager - This node enables image capturing from within Node-RED using a USB camera.

  4. Install the node-red-contrib-TensorFlow node from Palette Manager - This node contains pre-trained TensorFlow models. 

The node-red-contrib-TensorFlow node provides the following pre-trained TensorFlow models:

  • Object Detection: A node to identify objects in an image.

  • MediaPipe Hand Pose: A node to detect fingers in a hand.

  • MobileNet: A node to classify pictures with MobileNet.

  • PoseNet Model: A node to estimate human pose.

These nodes have been developed by Kazuhito Yokoi, a software engineer at Hitachi and an avid Node-RED contributor.

If you're using Prescient Designer, you can import the template using the Template Browser.

To successfully deploy this solution at the edge, you'll need the following:

  • Prescient Designer

  • Any USB camera

  • Raspberry Pi 3+ or a similar device

If you're using Node-RED only, you can download the flow used in this tutorial here - image classification json

Now that you have installed the required nodes, you can proceed with using MobileNet to classify images.

If you want to see the full list of supported classes, you can access them here

Conclusion

In this blog article, we discussed the importance of Image Classification in IoT projects and provided a step-by-step guide on how to develop a simple image classification application using Node-RED and TensorFlow.js. 

We highlighted the ease of use and accessibility of these tools, especially for beginners in low-code IoT programming and machine vision. We also acknowledged the limitations of Node-RED when it comes to scaling applications to large deployments. 

To overcome this challenge, we introduced Prescient Designer, a powerful tool built for enterprise-class applications and specifically designed for scaling large IoT deployments. We highlighted its advanced features such as distributed programming, end-to-end security, recovery and rollback, remote collaboration, and application template solutions.

Want to know more? Register for a FREE Webinar on how to Scale Node-RED to Enterprise-class IoT Applications.

Previous
Previous

Machine Vision Using Custom TensorFlow Models With Prescient Designer

Next
Next

We partnered with Bosch Rexroth ctrlX AUTOMATION - The future of Industry 4.0