Open Horizon service container demonstrating Node-RED Object Detection

Overview

service-node-red-object-detection

Open Horizon service container demonstrating Node-RED Object Detection.

This is an Open Horizon configuration to deploy an instance of the open-source Node-RED project. The Node-RED flow is designed to run in a web browser, so you will need to navigate to http://localhost:1880/ to use the software once it has been deployed.

The Node-RED flow demonstrates Object Detection using the node-red-contrib-tfjs-coco-ssd node. There is a sample image of an Apple and a Keyboard. If you have a webcam attached to your computer, you can take pictures of objects and detect objects defined in the coco-ssd model and dataset

The identified objects are annotated with bounding boxes using the node-red-node-annotate-image node.

Node-RED flow with Object Detection

Prerequisites

Tensorflow.js: The Tensorflow.js library will be installed into the container. Tensorflow.js is only available on certain OS/Hardware/processor combinations.

Management Hub: Install the Open Horizon Management Hub or have access to an existing hub in order to publish this service and register your edge node. You may also choose to use a downstream commercial distribution based on Open Horizon, such as IBM's Edge Application Manager. If you'd like to use the Open Horizon community hub, you may apply for a temporary account and have credentials sent to you.

Edge Node: You will need an x86 computer running Linux or macOS, or a Raspberry Pi computer (arm64) running Raspberry Pi OS, Ubuntu or Fedora to install and use Node-RED deployed by Open Horizon. You will need to install the Open Horizon agent software, anax, on the edge node and register it with a hub.

Optional utilities to install: With brew on macOS (you may need to install that as well), apt-get on Ubuntu or Raspberry Pi OS, yum on Fedora, install gcc, make, git, jq, curl, net-tools. Not all of those may exist on all platforms, and some may already be installed. But reflexively installing those has proven helpful in having the right tools available when you need them.

Installation

Clone the service-node-red-object-detection GitHub repo from a terminal prompt on the edge node and enter the folder where the artifacts were copied.

NOTE: This assumes that git has been installed on the edge node.

git clone https://github.com/open-horizon-services/service-node-red-object-detection.git
cd service-node-red-object-detection

Run make clean to confirm that the "make" utility is installed and working.

Confirm that you have the Open Horizon agent installed by using the CLI to check the version:

hzn version

It should return values for both the CLI and the Agent (actual version numbers may vary from those shown):

Horizon CLI version: 2.30.0-744
Horizon Agent version: 2.30.0-744

If it returns "Command not found", then the Open Horizon agent is not installed.

If it returns a version for the CLI but not the agent, then the agent is installed but not running. You may run it with systemctl horizon start on Linux or horizon-container start on macOS.

Check that the agent is in an unconfigured state, and that it can communicate with a hub. If you have the jq utility installed, run hzn node list | jq '.configstate.state' and check that the value returned is "unconfigured". If not, running make agent-stop or hzn unregister -f will put the agent in an unconfigured state. Run hzn node list | jq '.configuration' and check that the JSON returned shows values for the "exchange_version" property, as well as the "exchange_api" and "mms_api" properties showing URLs. If those do not, then the agent is not configured to communicate with a hub. If you do not have jq installed, run hzn node list and eyeball the sections mentioned above.

NOTE: If "exchange_version" is showing an empty value, you will not be able to publish and run the service. The only fix found to this condition thus far is to re-install the agent using these instructions:

hzn unregister -f # to ensure that the node is unregistered
systemctl horizon stop # for Linux, or "horizon-container stop" on macOS
export HZN_ORG_ID=myorg   # or whatever you customized it to
export HZN_EXCHANGE_USER_AUTH=admin:<admin-pw>   # use the pw deploy-mgmt-hub.sh displayed
export HZN_FSS_CSSURL=http://<mgmt-hub-ip>:9443/
curl -sSL https://github.com/open-horizon/anax/releases/latest/download/agent-install.sh | bash -s -- -i anax: -k css: -c css: -p IBM/pattern-ibm.helloworld -w '*' -T 120

Usage

To manually run this Node-RED container locally as a test, enter make run. This will start the Node-RED container. Enter make browse to open a browser to localhost:1880. When you are done, run make stop in the terminal to end the test.

To create the service definition, publish it to the hub, and then form an agreement to download and run Node-RED, enter make publish. When installation is complete and an agreement has been formed, exit the watch command with Control-C. You may then open a browser pointing to Node-RED by entering make browse or visiting http://localhost:1880/ in a web browser.

Advanced details

Debugging

The Makefile includes several targets to assist you in inspecting what is happening to see if they match your expectations. They include:

make log to see both the event logs and the service logs.

make deploy-check to see if the properties and constraints that you've configured match each other to potentially form an agreement.

make browse to see if the Node-RED Editor is responding.

make attach to connect to the running container and open a shell inside it.

Note The service-node-red-object-detection container by default runs in un-privileged mode, but it may require privileged conditions in certain cases (For eg: to detect specific hardware). In that case you can manually add "--privileged" flag in the Makefile under docker-run command.

All Makefile targets

  • default - init run browse
  • init - optionally create the docker volume
  • run - manually run the Node-RED container locally as a test
  • browse - open the Node-RED UI in a web browser
  • check - view current settings
  • stop - halt a locally-run container
  • dev - manually run Node-RED locally and connect to a terminal in the container
  • test - request the Node-RED Editor UI from the terminal to confirm that it is running and available
  • clean - remove the container image and docker volume
  • distclean - clean (see above) AND unregister the node and remove the service files from the hub
  • build - build the container
  • push - push the container to a container registry
  • publish-service - Publish the service definition file to the hub in your organization
  • remove-service - Remove the service definition file from the hub in your organization
  • publish-service-policy - Publish the service policy file to the hub in your org
  • remove-service-policy - Remove the service policy file from the hub in your org
  • publish-deployment-policy - Publish a deployment policy for the service to the hub in your org
  • remove-deployment-policy - Remove a deployment policy for the service from the hub in your org
  • agent-run - register your agent's node policy with the hub
  • publish - Publish the service def, service policy, deployment policy, and then register your agent
  • agent-stop - unregister your agent with the hub, halting all agreements and stopping containers
  • deploy-check - confirm that a registered agent is compatible with the service and deployment
  • log - check the agent event logs

Authors

Node-RED flow with Object Detection WebCam


Enjoy! Give us feedback if you have suggestions on how to improve this tutorial.

You might also like...

A web app demonstrating how the Fourier series can be used to approximate user-inputted line drawing

Fourier Series Animation An interactive React web app that demonstrates how an arbitrary user-inputted line drawing can be approximated using the Four

Dec 22, 2022

Defacement detection with deep learning

 Defacement detection with deep learning

In0ri is a defacement detection system utilizing a image-classification convolutional neural network. Introduction When monitoring a website, In0ri wi

Nov 30, 2022

Ethereum smart contract gas cost waste pattern detection and patching tool

Ethereum smart contract gas cost waste pattern detection and patching tool

Ethereum smart contract gas cost waste pattern detection and patching tool

Mar 23, 2022

A facial recognition/detection app with Angular using Microsoft's Face API

A facial recognition/detection app with Angular using Microsoft's Face API

Deja-Vu Overview Deja-Vu is a client side application generated with Angular CLI version 13. The core function of this application is to detect, recog

Jul 30, 2022

API4AI Samples: Face Detection and Recognition

 API4AI Samples: Face Detection and Recognition

API4AI is cloud-native computer vision & AI platform for startups, enterprises and individual developers. This repository contains sample mini apps that utilizes Facial Image Analysis API provided by API4AI.

May 24, 2022

Implement MTCNN with Tensorflow.js. A face detection framework with MTCNN and Tensorflow.js

Implement MTCNN with Tensorflow.js. A face detection framework with MTCNN and Tensorflow.js

mtcnn-tfjs Implement mtcnn with Tensorflow.js What is this? A face detection framework with MTCNN and Tensorflow.js Give me a ⭐️ , if you like it ❤️ (

Nov 23, 2022

With this script you can bypass both root detection and ssl pinning for your android app.

frida_rootansslbypas ██████╗ ██████╗ ██████╗ ████████╗ █████╗ ███╗ ██╗██████╗ ███████╗███████╗██╗ ██████╗ ██╗ ██╗██████╗ █████╗

Dec 24, 2022

An Anime Game launcher for Linux with automatic patching fixing detection of Linux/Wine and telemetry disabling

An Anime Game launcher for Linux with automatic patching fixing detection of Linux/Wine and telemetry disabling

An Anime Game launcher for Linux with automatic patching fixing detection of Linux/Wine and telemetry disabling

Jan 4, 2023

This is food detection WebApp, which will tell users about the nutrients value of particular food image which they upload

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

Sep 8, 2022
Comments
  • ubi9/nodejs-16-minimal rebase

    ubi9/nodejs-16-minimal rebase

    Signed-off-by: John Walicki [email protected]

    This PR rebases on the latest ubi9 images that close several CVE vulnerabilities

    +FROM registry.access.redhat.com/ubi9:9.0.0-1690 as build
    

    and

    +FROM registry.access.redhat.com/ubi9/nodejs-16-minimal:1-78
    
    opened by johnwalicki 0
  • Bug: node.js tensorflow binding does not compile on arm64

    Bug: node.js tensorflow binding does not compile on arm64

    The Node-RED service container will run on arm64 but the COCO SSD node fails because the node.js tensorflow binding does not compile successfully. Object detection fails.

    I've been down this rabbit hole before with node-gyp and libtensorflow on arm64.

    To test manually, on a Raspberry Pi, run/exec into a container, copy in the package.json, install the gcc toolchains, install the npm dev dependencies, try to compile npm rebuild @tensorflow/tfjs-node --build-from-source

    "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" --verbose --module_name=tfjs_binding --module_path="./lib/napi-v{napi_build_version}"
    

    will compile the .o objects but fails when linking.

    SOLINK_MODULE(target) Release/obj.target/tfjs_binding.node
    /usr/bin/ld: skipping incompatible /opt/app-root/data/node_modules/@tensorflow/tfjs-node/deps/lib/libtensorflow.so when searching for -ltensorflow
    /usr/bin/ld: cannot find -ltensorflow
    

    The /opt/app-root/data/node_modules/@tensorflow/tfjs-node/deps/lib/libtensorflow_framework.so.1.14.0 and libtensorflow.so.1.14.0 exist but don't link.

    Over the past 5 years, I've dug deep here. Maybe one time I found success on a Jetson Nano by reusing a CUDA gpu lib.... (?)

    Opening this ticket so others might not fall down the hole as deep as I have.

    opened by johnwalicki 1
Owner
null
This document introduces an early implementation of the Node-RED runtime that runs on resource-constrained microcontrollers (MCUs).

Node-RED MCU Edition Copyright 2022, Moddable Tech, Inc. All rights reserved. Peter Hoddie Updated June 25, 2022 Introduction This document introduces

Peter Hoddie 53 Jan 3, 2023
Node.js TypeScript project demonstrating a Prisma integration with PostgreSQL

Prisma with PostgreSQL, TypeScript, Serverless and Parameter Store This project is the outcome of following the Prisma Getting Started guide. In addit

Christian Rich 10 Aug 28, 2022
A quick and easy to use security reconnaissance webapp tool, does OSINT, analysis and red-teaming in both passive and active mode. Written in nodeJS and Electron.

ᵔᴥᵔ RedJoust A quick and easy to use security reconnaissance webapp tool, does OSINT, analysis and red-teaming in both passive and active mode. Writte

Dave 17 Oct 31, 2022
A pleasing darker theme made mostly with complementary purple and blue colors, occasionally with a touch of pink or red.

Nebula Float away in space with a beautiful blurple oriented color theme. DISCLAIMER: ⚠️ This theme is not as high contrast as other themes. A pleasin

catgirlkelly 5 Nov 23, 2022
VS Code extension that adds a red error squiggle to every word in your code.

Dumbisense Dumbisense is a VS Code extension that adds a red error squiggle to every word in your code, with an interesting error message and dino ima

Maggie Liu 9 Sep 3, 2022
RedEye is a visual analytic tool supporting Red & Blue Team operations

RedEye Red Team C2 Log Visualization RedEye is an open-source analytic tool developed by CISA and DOE’s Pacific Northwest National Laboratory to assis

Cybersecurity and Infrastructure Security Agency 2.1k Jan 3, 2023
Types generator will help user to create TS types from JSON. Just paste your single object JSON the Types generator will auto-generate the interfaces for you. You can give a name for the root object

Types generator Types generator is a utility tool that will help User to create TS Interfaces from JSON. All you have to do is paste your single objec

Vineeth.TR 16 Dec 6, 2022
A repository demonstrating functional techniques with C# 10 and the similarities between JavaScript, TypeScript, and C#.

Building up from JavaScript to TypeScript to C# 10 and .NET 6 This repository is meant to highlight some of the various functional techniques availabl

Charles Chen 67 Dec 30, 2022
Demonstrating the Dashboard++ method of organizing a vault in Obsidian

Information This repository is an Obsidian vault that demonstrates using the Dashboard++ method for organizing and navigating notes. For further detai

null 194 Jan 3, 2023
This project is an educational asset demonstrating the use of AWS amplify, Graphql API, Appsync, Material UI and amazon cognito. T

This project is an educational asset demonstrating the use of AWS amplify, Graphql API, Appsync, Material UI and amazon cognito. This project belongs to Black bird and this repo will remain dormant until final decision.

Shikhar 7 Oct 12, 2022