Integration with Node-RED
Node-RED is a flow-based development tool for visual programming, widely used to connect hardware devices, APIs, and online services. Its browser-based editor makes creating and deploying automation workflows simple.
In the context of OSCAR integration, Node-RED can be deployed and configured to interact with OSCAR services using authentication tokens obtained after logging in or using tokens specific for the service.
Simple tutorial
This tutorial demonstrates a simple workflow that calls the YOLOv8 synchronous service. You will learn: - How to deploy a Node-RED instance - How to connect Node-RED to the YOLOv8 synchronous service - How to authenticate using a token - How to process image data through the workflow
Steps
-
Deploy YOLOv8
Go to the
OSCAR dashboard
and selectCreate service -> FDL
. Use the following configuration:FDL:
yaml functions: oscar: - oscar-cluster: name: yolov8-node-red memory: 4Gi cpu: '2.0' image: ai4oshub/ai4os-yolov8-torch:latest script: script.sh log_level: CRITICAL
Script: ```bash!/bin/bash
RENAMED_FILE="${INPUT_FILE_PATH}.png" mv "$INPUT_FILE_PATH" "$RENAMED_FILE" OUTPUT_FILE="$TMP_OUTPUT_DIR/output.png" deepaas-cli --deepaas_method_output="$OUTPUT_FILE" predict --files "$RENAMED_FILE" --accept image/png 2>&1 echo "Prediction was saved in: $OUTPUT_FILE" ```
-
Deploy Node-RED
In the
OSCAR dashboard
, go toFlows
(Sidebar panel). Enter the admin password and select or create a Bucket.After deploying Node-RED we need to navigate to its user interface.
ℹ️
If you get an nginx error, you need to wait a little bit for the service to run.
Log in with your credentials (the user is always admin).
-
Create a workflow in Node-RED
Now we will create a workflow that will fetch an image from internet, make a request to Yolo8 service and visualize the result.
We will need a the following list of components that can be found in the Node-RED sidebar menu:
- Common →
inject
node - Network →
HTTP request
node - Output →
image
node - OSCAR →
OSCAR YOLO8
node
Connect the components as shown:
To configure the
HTTP request
node (double-click it):- URL: URL of an image
- Payload: Send as request body
- Return: A binary buffer
To configure the
OSCAR YOLO8
node (double-click it):- Server: URL of the cluster
- Service Name: yolov8-node-red
- Token: Obtain the token from
OSCAR dashboard
→ Info (Sidebar panel) → Access token
- Common →
-
Test the workflow
After configuring your workflow, test it in the Node-RED Editor:
- Click
Deploy
(top right corner) - Click the
inject
node
You should see the result:
- Click