Skip to content

Inferencer Node ​

Overview ​

The Inferencer node runs a vision model on the images of a message and writes the result to the message. The models run in the inference server, a Docker container that the node starts on first use and that every inferencer and OCR node of the Node-RED instance shares. The node talks to it over gRPC and passes the pixels through shared memory (/dev/shm).

A model can be a folder on the controller (/opt/storage/models), a model trained on the Rosepetal platform (downloaded through a firebase-config node), or one of the public checkpoints of the built-in catalog of default models.

Key Features ​

  • One shared server: two nodes on the same model load it once; models are evicted by a least-recently-used budget
  • Models from three sources: local folders, Firebase (downloaded on first use) and default models (public YOLO, RF-DETR and PaddleOCR checkpoints)
  • Static or dynamic model: one model chosen in the editor, or a model name read from msg, flow or global context on each message
  • Automatic warm-up: in static mode the model runs once on a synthetic image after it is loaded
  • Per-model configuration: thresholds, input size, class names and slicing of large images, from a form built for the model's framework and task
  • One result shape for every task, shared with the Triton nodes: relative coordinates and every box format
  • Promise mode: the message continues at once with a promise of the result
  • Debug image: the image with the result drawn on it, under the node in the editor
  • Timings at msg.performance.inference.<node name>

How a Prediction Runs ​

Each message goes through seven stages:

validate-request → resolve-model → ensure-model → process-images → execute-inference → convert-results → assemble-response
  1. validate-request: the node is ready, a gRPC client exists and the concurrency limit is not exceeded
  2. resolve-model: the configured model, or in dynamic mode the one named by the Model field
  3. ensure-model: downloads the model from Firebase, or prepares the default model, if it is not on the controller
  4. process-images: reads the image or images of the Input field and writes the pixels to /dev/shm
  5. execute-inference: sends the request to the inference server
  6. convert-results: turns the server's answer into the output shape
  7. assemble-response: writes the result and the timings to the message, draws the debug image and sets the status

Supported Model Types ​

The Advanced config tab builds its form from a config prefab, a template named <framework>_<task>.json. The package has prefabs for these combinations:

FrameworkTasks
YOLO (yolo)detection, segmentation, classification, oriented boxes (obb)
RF-DETR (rfdetr)detection, segmentation
DEIMv2 (deimv2)detection
RP-OD (rpod)detection
RP-CLASS (rpclass)classification
PaddlePaddle (paddle)detection, OCR, recognition, document rotation
anomalib (anomaly)anomaly
Pipelinesdetection + classification (detcls), segmentation + classification (segcls), OCR (pipeline_ocr)

A model whose framework and task have no prefab still runs; only the form is missing. TensorRT engines are served by the triton-inferencer node, not by this one.

Configuration ​

Settings Tab ​

PropertyDefaultMeaning
NameinferencerLabel of the node; also the key of its timings in msg.performance.inference
Input fieldimagemsg property with the image, or an array of images (see Image Format)
Output fieldinferencemsg property that receives the result
FirebasenoneOptional firebase-config node. With it, the models trained on the platform appear in the model list, and a model that is not on the controller is downloaded before it is used
Model sourceManualManual: the model chosen in Model Name. Dynamic: the model named on each message by Model field
Model NamenoneManual mode. A searchable list of the local models (✔), the Firebase models (☁) and the default models (★), with filters for each source. A model that is both local and in Firebase is listed once, as local
Model fieldmsg.modelNameDynamic mode. msg, flow or global property that holds the model name: the name of a folder in /opt/storage/models, or the id of a Firebase model
PromiseoffSends the message at once, with a promise of the result added to Promises field (see Promise Mode)
Promises fieldpromisesmsg property, an array, that receives the promises

Under Debug Image:

PropertyDefaultMeaning
Show debug imageoffShows the image with the result drawn on it under the node in the editor
Debug interval1Draws one message out of N
Debug image width160Width of the picture, in pixels
Box thickness2Stroke of the boxes, 1 to 10, scaled with the image the way rp-add-bbs scales it
Font size0.5Size of the captions, 0.3 to 2

The debug image is drawn on the device, by the renderer shared with ocr, triton-inferencer and vlm-online-inferencer, from the same result the message carries. What it shows depends on the task: box outlines with tag: confidence for detection, filled masks for segmentation and anomaly, the text of each box for OCR, and a corner tag for classification, recognition and document orientation.

In dynamic mode the tab also shows a summary of the inferencer requests. The Restart Containers button, after a confirmation, reconnects the node to the inference server, starting it again if it does not answer, and in manual mode loads the node's model again if the server does not hold it.

Advanced Config Tab ​

PropertyDefaultMeaning
Maximum concurrent predictions5Predictions of this node that can be in progress at once, 1 to 40. A message beyond the limit is not queued: it fails with Maximum concurrent predictions limit (5) exceeded.

In manual mode, the Model configuration section below shows a form built from the model's prefab and its own configuration file. The usual fields are:

  • image_shape: width and height the image is resized to
  • classes: one row per class, Original and Custom Name, to rename the classes of the result
  • confidence (default 0.25 for YOLO detection) and iou (0.7): thresholds of the detection and of the non-maximum suppression
  • slicer_configuration, for detection and segmentation: slicing_mode none or percentage_slices. With slices, the image is cut into a grid of x_grid_count × y_grid_count tiles that overlap by overlap_x and overlap_y (fractions from 0 to 0.5, default 0.1); the results of the tiles are joined with NMM or NMS, measuring the overlap as IOU or IOS, above IO_threshold (default 0.5)

The values changed in the form are saved with the node, per model, and sent with every prediction. Restore default config goes back to the model's own configuration.

Image Format ​

The Input field can hold one image or an array of images. Each image is one of:

1. Raw bitmap ​

javascript
{
  width: 1920,
  height: 1080,
  data: Buffer,           // raw pixels, channels interleaved
  colorSpace: "RGB",      // "GRAY", "RGB", "RGBA", "BGR" or "BGRA" (optional)
  channels: 3,            // 1, 3 or 4 (optional)
  dtype: "uint8"          // optional; only "uint8" is accepted
}

Without channels, the node computes it as data.length / (width × height). Without colorSpace, it takes GRAY, RGB or RGBA from the number of channels. A colorSpace that does not match the channels, a data of the wrong length, or another dtype fails with an error that says which. This is the format that from-dataset produces.

2. Encoded image ​

A Buffer with a JPEG, PNG or WebP file, decoded by the node, for example the output of a file in node set to a single Buffer object:

javascript
msg.image = msg.payload;
return msg;

3. Array of images ​

javascript
msg.image = [image1, image2, image3];

The images go to the server in one request, and the result is an array in the same order.

Input ​

Basic input ​

javascript
msg.image = imageBuffer;
return msg;

A message without an image in the Input field fails with The field msg.image must be an image or an array of images.

Dynamic model selection ​

javascript
// Model source: Dynamic, Model field: msg.modelName
msg.modelName = "rp-obj-labels-v3";
msg.image = imageBuffer;
return msg;

The first message for a model loads it, which can take from seconds to minutes. If the model is not on the controller and a Firebase connection is set, it is downloaded first.

Inferencer requests ​

A message whose msg.inferencerRequest.type is warmup or loadModel (any letter case) is a command for this node's model, not a prediction, and sends no output:

msg.inferencerRequestEffect
{ type: "warmup", modelName, image }Runs one silent prediction to load and prime the model. modelName is optional (default: the node's model). image is optional: then msg.image is used, and with neither the server makes a synthetic image
{ type: "loadModel", modelName }Downloads the model if needed and loads it on the server without predicting. modelName is optional (default: the configured model, or in dynamic mode the Model field). The status ends in Ready (<model>)

Both wait until the node is ready. To see what the server holds, pre-load several models or free them, use the model-manager node.

Output ​

Results are written to msg.<outputField> (msg.inference by default), and the timings to msg.performance.inference.<nodeName>.

One image in, one result out; an array of images in, an array of results out, indexed by input order.

Within one image, detection and segmentation return a list — one entry per instance found, possibly empty. Classification, recognition, OCR, document orientation and anomaly return a single object, because they answer one question about the whole image.

Coordinates ​

Every coordinate is relative to the image, 0–1, rounded to 6 decimals, and area is the fraction of the image covered. This holds for every task, both inference nodes, and both backends, so a downstream rp-crop or rp-add-bbs works the same wherever the result came from and whatever the image size is.

Every result carries all the box formats, derived from the same geometry:

FormatShapeNotes
raw_boxes[[x0,y0], [x1,y1], [x2,y2], [x3,y3]]four corners, clockwise from top-left; keeps rotation
4points{x0, y0, x1, y1, x2, y2, x3, y3}the same corners as flat properties
cwh{x, y, w, h, r}centre, size, rotation in degrees
xywhr{x, y, w, h, r}top-left corner, size, rotation in degrees
2points{xmin, ymin, xmax, ymax}axis-aligned; rotation is lost

For a segmentation or anomaly result the box is the bounding box of the polygons. Picking a format is a downstream concern: nothing has to be configured here, and changing your mind costs no redeploy.

Detection ​

javascript
[
  {
    tag: "bottle",
    confidence: 0.95,
    classId: 1,
    color: { r: 255, g: 0, b: 0 },
    raw_boxes: [[0.1, 0.1], [0.9, 0.1], [0.9, 0.8], [0.1, 0.8]],
    "2points": { xmin: 0.1, ymin: 0.1, xmax: 0.9, ymax: 0.8 }
    // ...plus cwh, xywhr and 4points
  }
]

Segmentation ​

javascript
[
  {
    tag: "person",
    confidence: 0.92,
    classId: 0,
    area: 0.35,
    color: { r: 0, g: 255, b: 0 },
    polygons: [ [[0.1, 0.2], [0.5, 0.2], [0.5, 0.9], [0.1, 0.9]] ],
    "2points": { xmin: 0.1, ymin: 0.2, xmax: 0.5, ymax: 0.9 }
  }
]

polygons is a list of contours, so one instance can have several (a shape with holes). Instances with no contours are dropped.

Classification ​

javascript
{
  tag: "cat",
  confidence: 0.97,
  classId: 3,
  all_tags: [
    { tag: "cat", confidence: 0.97, classId: 3 },
    { tag: "dog", confidence: 0.02, classId: 1 }
  ]
}

Anomaly ​

javascript
{
  tag: "NOK",
  confidence: 0.88,
  classId: 1,
  area: 0.12,
  color: { r: 255, g: 0, b: 0 },
  polygons: [ [[0.3, 0.4], [0.6, 0.4], [0.6, 0.7], [0.3, 0.7]] ],
  "2points": { xmin: 0.3, ymin: 0.4, xmax: 0.6, ymax: 0.7 }
}

tag is OK or NOK, decided by confidence against the model's own threshold — 0.5 for an anomalib export, which is min-max normalized, so 0.5 is the learned threshold. The polygons and the area come from thresholding the anomaly map, not from the verdict, so an OK image can still carry a mask.

Changed. Anomaly used to return a list of one, with polygons in pixels of the model's mask (512×512 for a typical export) rather than relative to the image, and area as a count of those pixels. The same model therefore answered different numbers in this node and in triton-inferencer. Flows doing payload[0], or scaling those coordinates themselves, need updating.

Recognition ​

javascript
{ text: "AB-1234", confidence: 0.94 }

Document orientation ​

javascript
{ angle: 180, orientation_label: "..." }  // label as the model names it

OCR results (text boxes and the text helpers) have the shape described in OCR Inferencer.

Performance ​

javascript
msg.performance.inference["my-inferencer"] = {
  startTime: Date,               // when the node received the message
  endTime: Date,
  milliseconds: 156,             // total time in the node
  node: { preprocessing_ms: 12, transform_result_formats_ms: 8, total_ms: 20 },
  server: {
    image_decode_ms: 5, model_load_ms: 0, inference_ms: 78, proto_serialize_ms: 4,
    debug_image_ms: 0, preprocess_ms: 15, postprocess_ms: 18, manager_overhead_ms: 2,
    dynamic_batch_wait_ms: 0, worker_queue_wait_ms: 0, total_ms: 122
  },
  communication: { request_travel_ms: 8.5, response_travel_ms: 5.3, total_communication_ms: 13.8 }
}

The key is the node's Name, or its id when the name is empty.

Promise Mode ​

With Promise on, the message leaves the node at once, and a promise is appended to the Promises field (msg.promises by default), which the node creates as an array when it is missing. Each prediction appends one promise. The promise resolves to an object with the result under the Output field and the timings under performance; when the prediction fails it resolves, not rejects, to an object with the error text under the Output field.

Resolve the promises downstream with the rp-promise-reader node of @rosepetal/node-red-contrib-utils, which merges them into the message. If the Promises field already holds something that is not an array, the prediction fails with msg.promises must be an array when promise mode is enabled.

Errors ​

A prediction that fails still sends the message: the Output field holds the error text instead of a result, and the node logs Prediction failed: <reason>. Common reasons:

ErrorCause
<name> not readyThe server or the model is still starting
Maximum concurrent predictions limit (N) exceeded.More predictions in progress than Maximum concurrent predictions
The field msg.<field> must be an image or an array of images.Nothing in the Input field
Data length mismatch: ..., ColorSpace mismatch: ..., Unsupported dtype: ...A raw bitmap whose fields do not agree
Failed to process image buffer: <reason>A Buffer that is not a JPEG, PNG or WebP image
Model '<name>' not found locally and no Firebase connection configuredThe model is not in /opt/storage/models and the node has no Firebase connection
Model '<name>' not found in FirebaseNot on the controller and not among the finished models of the project
No model configuredManual mode without a model

If the error says the server is unavailable (UNAVAILABLE, ECONNREFUSED), the node reconnects to the inference server, starting it again if needed, so the next message can succeed.

Node Status ​

StatusMeaning
Checking docker image, Starting inference server, Connecting to inference serverStarting the shared server
yellow Downloading <model>Downloading a Firebase model
yellow Preparing default model <name>Writing the configuration of a default model
yellow ring, text from the serverLoading the model (for example Preparing model, Waiting for inference server…)
green Ready, Ready (<model>)Ready to predict
green Total: Xms | Node: Yms | Server: Zms | Comm: WmsTimings of the last prediction
Reconnecting to inference server, red Restart failed, red Inference server not readyRestart Containers in progress, or failed
red, with the error textStarting, loading the model or a loadModel request failed. A failed prediction does not change the status

The Inference Server ​

  • Container: rosepetal-inference-server (the environment variable INFERENCE_SERVER_NAME of Node-RED changes the name). It is started from the detection image of Rosepetal's Docker registry, tagged with the version of this package (detection:1.4.16 for 1.4.16). If the image is not on the host, the node pulls it with the docker command, so the host must be logged in to that registry.
  • GPU: the container is created with every NVIDIA GPU; if that fails, it is created again without GPU.
  • Reuse: an existing container is reused while it runs the expected image; one created from another version is replaced. It keeps running when the nodes are removed, and serves every inferencer and OCR node.
  • Mounts: /dev/shm, the models folder /opt/storage/models (another host folder with INFERENCE_MODELS_HOST), and an OCR cache, /opt/storage/models/ocr_cache by default (INFERENCE_OCR_MODELS_HOST).
  • Memory budget: the server keeps at most MAX_LOADED_MODELS models and evicts the least recently used one to load another. When the variable is not set, it derives the number from the available RAM and the total VRAM when it starts, between 1 and 12. With MODEL_IDLE_TTL_SEC greater than 0, a model unused for that many seconds is evicted. Both variables are passed to the container from the environment of Node-RED.
  • Release: when the last node using a model is stopped or removed, the model is evicted 10 seconds later (INFERENCE_MODEL_GRACE_MS), unless a node takes it again meanwhile, as during a redeploy.

The model-manager node shows and controls what the server holds.

Models ​

Local models ​

A local model is a folder of /opt/storage/models that holds its weights (.pt, .pth or .onnx) and a JSON configuration file with common.config_type set to "predict". The editor lists the folder under its own name, with the common.task and the framework of common.model_name of that file:

/opt/storage/models/
└── bottle-caps-det/
    ├── inference_config.json   // { "common": { "config_type": "predict", "task": "detection", "model_name": "yolo", ... }, ... }
    └── best.pt

A folder whose JSON file has a pipeline key is a pipeline: its models list names sub-folders, each a model as above. The folders default-models, triton-model-dir, onnx_cache and .tmp are not listed.

Firebase models ​

A model of the platform is downloaded to /opt/storage/models/<model id>/ (its inference_config.json and its weights) the first time a node needs it, and used from there afterwards. Its name in the node is the model id, as list-model shows it.

Default models ​

The catalog has 103 public checkpoints: YOLO (v8, v9, v10, 11 and 26) for detection, segmentation, classification and oriented boxes; RF-DETR for detection and segmentation; PP-OCR v3, v4 and v5 for OCR, text detection and recognition. They are offered in manual mode. When the node starts, it writes the model's configuration to /opt/storage/models/default-models/<id>/; the weights are fetched by the model's framework the first time the model loads.

Examples ​

Detection with a confidence filter ​

[from-dataset] → [inferencer: Model Name bottle-caps-det, Output field detections] → [function]
javascript
// Keep the confident detections; coordinates are relative to the image
msg.payload = msg.detections
  .filter(det => det.confidence > 0.8)
  .map(det => ({ tag: det.tag, box: det["2points"] }));
return msg;

Batch of images ​

javascript
msg.image = [image1, image2, image3];
return msg;
javascript
// msg.inference, for a detection model
[
  [detection1a, detection1b],  // image 1
  [detection2a],               // image 2
  []                           // image 3: nothing found
]

One node, several models ​

javascript
// Model source: Dynamic, Model field: msg.modelName
msg.modelName = msg.topic === "caps" ? "bottle-caps-det" : "labels-det";
return msg;

See Also ​