From e6b93263dcc1d067706b6c0eb93bacb6dd80cf16 Mon Sep 17 00:00:00 2001 From: dialAguirre Date: Mon, 15 Jan 2024 11:17:19 +0100 Subject: [PATCH] Added Grayify subflow and example This commit add a folder with the grayify subflow and example of how to use it. --- node-red/subflows/oscar_grayify/grayify.json | 387 ++++++++++++++ .../oscar_grayify/grayify_example.json | 481 ++++++++++++++++++ 2 files changed, 868 insertions(+) create mode 100644 node-red/subflows/oscar_grayify/grayify.json create mode 100644 node-red/subflows/oscar_grayify/grayify_example.json diff --git a/node-red/subflows/oscar_grayify/grayify.json b/node-red/subflows/oscar_grayify/grayify.json new file mode 100644 index 0000000..b26cb27 --- /dev/null +++ b/node-red/subflows/oscar_grayify/grayify.json @@ -0,0 +1,387 @@ +[ + { + "id": "17e086aba87b48d9", + "type": "subflow", + "name": "OSCAR Grayify Services", + "info": "
\n \n

OSCAR Grayify Services Node

\n
\n
\n
\n
\n

About Grayify

\n

This node supports highly-scalable event-driven image conversion to grayscale using the popular ImageMagick software.

\n

ImageMagick® is a free and open-source software suite for displaying, converting, and editing raster image and vector image files. It can read and write over 200 image file formats, and can support a wide range of image manipulation operations, such as resizing, cropping, and color correction.

\n \n
\n
\n

About Cowsay Service in OSCAR

\n

The goal of this service is to have:

\n
    \n
  • An input bucket created in Minio on which the user uploads the files to be converted.
  • \n
  • A function that is triggered upon each file upload in order to trigger the file conversion, which is automatically handled by an elastic Kubernetes cluster that provisions additional nodes on-demand if required.
  • \n
  • An output bucket created in Minio on which the user will find the converted files.
  • \n
\n

For more information consult:

\n \n
\n
\n

Inputs

\n

The input variables will be the basic variables (OSCAR server url and credentials). In addition to the name that has been given to the grayify service on the server. Inside the input msg.payload must be the text to write. With all these elements, the service token is searched and then a request is made to the service ( POST /run/{serviceName}).

\n \n
\n
\n

Outputs

\n

The node returns through msg.payload the grayscale image (base64), which can be used in image display nodes such as images preview node.

\n
\n
\n
\n ", + "category": "OSCAR", + "in": [ + { + "x": 40, + "y": 140, + "wires": [ + { + "id": "84dc89f39647f833" + } + ] + } + ], + "out": [ + { + "x": 1480, + "y": 200, + "wires": [ + { + "id": "ae8a50a4693c5d99", + "port": 0 + } + ] + }, + { + "x": 1080, + "y": 360, + "wires": [ + { + "id": "0d3b58fb7162dcd3", + "port": 0 + } + ] + } + ], + "env": [ + { + "name": "Server", + "type": "str", + "value": "", + "ui": { + "icon": "font-awesome/fa-globe" + } + }, + { + "name": "Service Name", + "type": "str", + "value": "", + "ui": { + "icon": "font-awesome/fa-pencil" + } + }, + { + "name": "Token", + "type": "cred", + "ui": { + "icon": "font-awesome/fa-key" + } + } + ], + "meta": { + "module": "node-red-contrib-oscar-grayify", + "version": "1.0.0", + "author": "Vicente Rodriguez Benitez ", + "desc": "Grayify Services at OSCAR", + "keywords": "node-red, oscar,grayify", + "license": "Apache-2.0" + }, + "color": "#3FADB5", + "outputLabels": [ + "Output image", + "Output data (complete json)" + ], + "icon": "font-awesome/fa-image", + "status": { + "x": 1420, + "y": 40, + "wires": [ + { + "id": "efeec0bcbcf76b24", + "port": 0 + }, + { + "id": "6e691a86cf1cc71c", + "port": 0 + } + ] + } + }, + { + "id": "84dc89f39647f833", + "type": "change", + "z": "17e086aba87b48d9", + "name": "", + "rules": [ + { + "t": "set", + "p": "oscar_server", + "pt": "msg", + "to": "Server", + "tot": "env" + }, + { + "t": "set", + "p": "token", + "pt": "msg", + "to": "Token", + "tot": "env" + }, + { + "t": "set", + "p": "image", + "pt": "msg", + "to": "payload", + "tot": "msg" + }, + { + "t": "set", + "p": "grayify", + "pt": "msg", + "to": "Service Name", + "tot": "env" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 160, + "y": 140, + "wires": [ + [ + "efeec0bcbcf76b24", + "204de5f7959c78d8" + ] + ] + }, + { + "id": "204de5f7959c78d8", + "type": "function", + "z": "17e086aba87b48d9", + "name": "Send plants-token", + "func": "\nvar token_grayify = msg.token;\n\n\nmsg.headers = {\n Authorization: \"Bearer \" + token_grayify\n}\n\nmsg.payload = msg.image;\nmsg.url = msg.oscar_server+\"/run/\"+msg.grayify;\n\nreturn msg;\n\n", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 310, + "y": 200, + "wires": [ + [ + "90c96bd44065f1a7" + ] + ] + }, + { + "id": "90c96bd44065f1a7", + "type": "base64", + "z": "17e086aba87b48d9", + "name": "", + "action": "", + "property": "payload", + "x": 480, + "y": 200, + "wires": [ + [ + "0d3b58fb7162dcd3" + ] + ] + }, + { + "id": "0d3b58fb7162dcd3", + "type": "http request", + "z": "17e086aba87b48d9", + "name": "Grayify Services Run", + "method": "POST", + "ret": "obj", + "paytoqs": "ignore", + "url": "", + "tls": "", + "persist": false, + "proxy": "", + "insecureHTTPParser": false, + "authType": "", + "senderr": false, + "headers": [], + "x": 660, + "y": 200, + "wires": [ + [ + "5f4ab2ca0ecd79d0" + ] + ] + }, + { + "id": "5f4ab2ca0ecd79d0", + "type": "string", + "z": "17e086aba87b48d9", + "name": "", + "methods": [ + { + "name": "delLeftMost", + "params": [ + { + "type": "str", + "value": "response" + } + ] + } + ], + "prop": "payload", + "propout": "payload", + "object": "msg", + "objectout": "msg", + "x": 870, + "y": 200, + "wires": [ + [ + "c99409e95147841e" + ] + ] + }, + { + "id": "c99409e95147841e", + "type": "base64", + "z": "17e086aba87b48d9", + "name": "", + "action": "", + "property": "payload", + "x": 1020, + "y": 200, + "wires": [ + [ + "ae8a50a4693c5d99" + ] + ] + }, + { + "id": "efeec0bcbcf76b24", + "type": "change", + "z": "17e086aba87b48d9", + "name": "Start Service", + "rules": [ + { + "t": "set", + "p": "payload", + "pt": "msg", + "to": "Processing....", + "tot": "str" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 350, + "y": 40, + "wires": [ + [] + ] + }, + { + "id": "6e691a86cf1cc71c", + "type": "change", + "z": "17e086aba87b48d9", + "name": "End Service", + "rules": [ + { + "t": "set", + "p": "payload", + "pt": "msg", + "to": "Finished....", + "tot": "str" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 1330, + "y": 140, + "wires": [ + [] + ] + }, + { + "id": "ae8a50a4693c5d99", + "type": "change", + "z": "17e086aba87b48d9", + "name": "Clear Data", + "rules": [ + { + "t": "set", + "p": "token", + "pt": "msg", + "to": "", + "tot": "str" + }, + { + "t": "set", + "p": "oscar_server", + "pt": "msg", + "to": "", + "tot": "str" + }, + { + "t": "set", + "p": "grayify", + "pt": "msg", + "to": "", + "tot": "str" + }, + { + "t": "set", + "p": "image", + "pt": "msg", + "to": "", + "tot": "str" + }, + { + "t": "set", + "p": "token_grayify", + "pt": "msg", + "to": "", + "tot": "str" + }, + { + "t": "set", + "p": "url", + "pt": "msg", + "to": "", + "tot": "str" + }, + { + "t": "set", + "p": "filename", + "pt": "msg", + "to": "", + "tot": "str" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 1170, + "y": 200, + "wires": [ + [ + "6e691a86cf1cc71c" + ] + ] + }, + { + "id": "39de3a7d58f9a244", + "type": "subflow:17e086aba87b48d9", + "z": "117ff88f2b90822d", + "name": "", + "env": [ + { + "name": "Token", + "type": "cred" + } + ], + "credentials": { + "Token": "" + }, + "x": 810, + "y": 320, + "wires": [ + [ + "92508ec6be81f534" + ], + [] + ] + } +] \ No newline at end of file diff --git a/node-red/subflows/oscar_grayify/grayify_example.json b/node-red/subflows/oscar_grayify/grayify_example.json new file mode 100644 index 0000000..3f85099 --- /dev/null +++ b/node-red/subflows/oscar_grayify/grayify_example.json @@ -0,0 +1,481 @@ +[ + { + "id": "17e086aba87b48d9", + "type": "subflow", + "name": "OSCAR Grayify Services", + "info": "
\n \n

OSCAR Grayify Services Node

\n
\n
\n
\n
\n

About Grayify

\n

This node supports highly-scalable event-driven image conversion to grayscale using the popular ImageMagick software.

\n

ImageMagick® is a free and open-source software suite for displaying, converting, and editing raster image and vector image files. It can read and write over 200 image file formats, and can support a wide range of image manipulation operations, such as resizing, cropping, and color correction.

\n \n
\n
\n

About Cowsay Service in OSCAR

\n

The goal of this service is to have:

\n
    \n
  • An input bucket created in Minio on which the user uploads the files to be converted.
  • \n
  • A function that is triggered upon each file upload in order to trigger the file conversion, which is automatically handled by an elastic Kubernetes cluster that provisions additional nodes on-demand if required.
  • \n
  • An output bucket created in Minio on which the user will find the converted files.
  • \n
\n

For more information consult:

\n \n
\n
\n

Inputs

\n

The input variables will be the basic variables (OSCAR server url and credentials). In addition to the name that has been given to the grayify service on the server. Inside the input msg.payload must be the text to write. With all these elements, the service token is searched and then a request is made to the service ( POST /run/{serviceName}).

\n \n
\n
\n

Outputs

\n

The node returns through msg.payload the grayscale image (base64), which can be used in image display nodes such as images preview node.

\n
\n
\n
\n
\n GRyCAP (Grupo de Grid y Computación de Altas Prestaciones) - UPV\n
", + "category": "OSCAR", + "in": [ + { + "x": 40, + "y": 140, + "wires": [ + { + "id": "84dc89f39647f833" + } + ] + } + ], + "out": [ + { + "x": 1480, + "y": 200, + "wires": [ + { + "id": "ae8a50a4693c5d99", + "port": 0 + } + ] + }, + { + "x": 1080, + "y": 360, + "wires": [ + { + "id": "0d3b58fb7162dcd3", + "port": 0 + } + ] + } + ], + "env": [ + { + "name": "Server", + "type": "str", + "value": "", + "ui": { + "icon": "font-awesome/fa-globe" + } + }, + { + "name": "Service Name", + "type": "str", + "value": "", + "ui": { + "icon": "font-awesome/fa-pencil" + } + }, + { + "name": "Token", + "type": "cred", + "ui": { + "icon": "font-awesome/fa-key" + } + } + ], + "meta": { + "module": "node-red-contrib-oscar-grayify", + "version": "1.0.0", + "author": "Vicente Rodriguez Benitez ", + "desc": "Grayify Services at OSCAR", + "keywords": "node-red, oscar,grayify", + "license": "Apache-2.0" + }, + "color": "#3FADB5", + "outputLabels": [ + "Output image", + "Output data (complete json)" + ], + "icon": "font-awesome/fa-image", + "status": { + "x": 1420, + "y": 40, + "wires": [ + { + "id": "efeec0bcbcf76b24", + "port": 0 + }, + { + "id": "6e691a86cf1cc71c", + "port": 0 + } + ] + } + }, + { + "id": "84dc89f39647f833", + "type": "change", + "z": "17e086aba87b48d9", + "name": "", + "rules": [ + { + "t": "set", + "p": "oscar_server", + "pt": "msg", + "to": "Server", + "tot": "env" + }, + { + "t": "set", + "p": "token", + "pt": "msg", + "to": "Token", + "tot": "env" + }, + { + "t": "set", + "p": "image", + "pt": "msg", + "to": "payload", + "tot": "msg" + }, + { + "t": "set", + "p": "grayify", + "pt": "msg", + "to": "Service Name", + "tot": "env" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 160, + "y": 140, + "wires": [ + [ + "efeec0bcbcf76b24", + "204de5f7959c78d8" + ] + ] + }, + { + "id": "204de5f7959c78d8", + "type": "function", + "z": "17e086aba87b48d9", + "name": "Send plants-token", + "func": "\nvar token_grayify = msg.token;\n\n\nmsg.headers = {\n Authorization: \"Bearer \" + token_grayify\n}\n\nmsg.payload = msg.image;\nmsg.url = msg.oscar_server+\"/run/\"+msg.grayify;\n\nreturn msg;\n\n", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 310, + "y": 200, + "wires": [ + [ + "90c96bd44065f1a7" + ] + ] + }, + { + "id": "90c96bd44065f1a7", + "type": "base64", + "z": "17e086aba87b48d9", + "name": "", + "action": "", + "property": "payload", + "x": 480, + "y": 200, + "wires": [ + [ + "0d3b58fb7162dcd3" + ] + ] + }, + { + "id": "0d3b58fb7162dcd3", + "type": "http request", + "z": "17e086aba87b48d9", + "name": "Grayify Services Run", + "method": "POST", + "ret": "obj", + "paytoqs": "ignore", + "url": "", + "tls": "", + "persist": false, + "proxy": "", + "insecureHTTPParser": false, + "authType": "", + "senderr": false, + "headers": [], + "x": 660, + "y": 200, + "wires": [ + [ + "5f4ab2ca0ecd79d0" + ] + ] + }, + { + "id": "5f4ab2ca0ecd79d0", + "type": "string", + "z": "17e086aba87b48d9", + "name": "", + "methods": [ + { + "name": "delLeftMost", + "params": [ + { + "type": "str", + "value": "response" + } + ] + } + ], + "prop": "payload", + "propout": "payload", + "object": "msg", + "objectout": "msg", + "x": 870, + "y": 200, + "wires": [ + [ + "c99409e95147841e" + ] + ] + }, + { + "id": "c99409e95147841e", + "type": "base64", + "z": "17e086aba87b48d9", + "name": "", + "action": "", + "property": "payload", + "x": 1020, + "y": 200, + "wires": [ + [ + "ae8a50a4693c5d99" + ] + ] + }, + { + "id": "efeec0bcbcf76b24", + "type": "change", + "z": "17e086aba87b48d9", + "name": "Start Service", + "rules": [ + { + "t": "set", + "p": "payload", + "pt": "msg", + "to": "Processing....", + "tot": "str" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 350, + "y": 40, + "wires": [ + [] + ] + }, + { + "id": "6e691a86cf1cc71c", + "type": "change", + "z": "17e086aba87b48d9", + "name": "End Service", + "rules": [ + { + "t": "set", + "p": "payload", + "pt": "msg", + "to": "Finished....", + "tot": "str" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 1330, + "y": 140, + "wires": [ + [] + ] + }, + { + "id": "ae8a50a4693c5d99", + "type": "change", + "z": "17e086aba87b48d9", + "name": "Clear Data", + "rules": [ + { + "t": "set", + "p": "token", + "pt": "msg", + "to": "", + "tot": "str" + }, + { + "t": "set", + "p": "oscar_server", + "pt": "msg", + "to": "", + "tot": "str" + }, + { + "t": "set", + "p": "grayify", + "pt": "msg", + "to": "", + "tot": "str" + }, + { + "t": "set", + "p": "image", + "pt": "msg", + "to": "", + "tot": "str" + }, + { + "t": "set", + "p": "token_grayify", + "pt": "msg", + "to": "", + "tot": "str" + }, + { + "t": "set", + "p": "url", + "pt": "msg", + "to": "", + "tot": "str" + }, + { + "t": "set", + "p": "filename", + "pt": "msg", + "to": "", + "tot": "str" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 1170, + "y": 200, + "wires": [ + [ + "6e691a86cf1cc71c" + ] + ] + }, + { + "id": "5be3088216428df5", + "type": "inject", + "z": "117ff88f2b90822d", + "name": "IMAGE", + "props": [ + { + "p": "payload" + }, + { + "p": "topic", + "vt": "str" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "", + "payloadType": "date", + "x": 410, + "y": 420, + "wires": [ + [ + "a1c1c4d1249223f2" + ] + ] + }, + { + "id": "a1c1c4d1249223f2", + "type": "http request", + "z": "117ff88f2b90822d", + "name": "LOAD", + "method": "GET", + "ret": "bin", + "paytoqs": "body", + "url": "https://jooinn.com/images/red-rose-flower.jpg", + "tls": "", + "persist": false, + "proxy": "", + "insecureHTTPParser": false, + "authType": "", + "senderr": false, + "headers": [], + "x": 570, + "y": 420, + "wires": [ + [ + "8442170fef8e226e", + "39de3a7d58f9a244" + ] + ] + }, + { + "id": "8442170fef8e226e", + "type": "image", + "z": "117ff88f2b90822d", + "name": "", + "width": 160, + "data": "payload", + "dataType": "msg", + "thumbnail": false, + "active": true, + "pass": false, + "outputs": 0, + "x": 780, + "y": 520, + "wires": [] + }, + { + "id": "92508ec6be81f534", + "type": "debug", + "z": "117ff88f2b90822d", + "name": "debug 3", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "payload", + "targetType": "msg", + "statusVal": "", + "statusType": "auto", + "x": 1120, + "y": 320, + "wires": [] + }, + { + "id": "39de3a7d58f9a244", + "type": "subflow:17e086aba87b48d9", + "z": "117ff88f2b90822d", + "name": "", + "env": [ + { + "name": "Server", + "value": "https://inference.cloud.ai4eosc.eu", + "type": "str" + }, + { + "name": "Service Name", + "value": "grayify", + "type": "str" + }, + { + "name": "Token", + "type": "cred" + } + ], + "x": 810, + "y": 320, + "wires": [ + [ + "92508ec6be81f534" + ], + [] + ] + } +] \ No newline at end of file