Skip to content

From Dataset Node ​

Overview ​

The From Dataset node reads images from a dataset of the Rosepetal platform, through a firebase-config node, and puts them in a message as raw pixels, ready for the inference nodes. It works in one of three retrieval modes:

Retrieval modeEach input messageUse it to
Fetch on demand (default)Downloads one random image that matches the filters and adds it to the messageTest a flow with fresh images from a large dataset
Pre-download imagesAdds one random image from a pool downloaded when the node startsSend images fast and often, from a small fixed set
Stream entire datasetIs a command (start, pause, stop); after start the node sends every matching image, one per intervalRun a model over a whole dataset

Key Features ​

  • Tag and set filters: one tag, or all; one set (Train, Validation, Test, Predetermined), or all
  • Message overrides: in Fetch on demand and Stream entire dataset modes the dataset, tag and set can come from msg, flow or global context
  • Buffered streaming: images are downloaded ahead of time, as many as the measured download time and the interval require
  • Raw output: pixels as a Buffer with width, height, channels and color space (RGB or BGR)
  • Survives disconnections: messages that arrive while Firebase reconnects are queued and processed afterwards

Configuration ​

PropertyDefaultMeaning
Namefrom-datasetLabel of the node
Firebase configurationnone (required)The firebase-config node of the project. The other fields are enabled once it is connected
Retrieval modeFetch on demandFetch on demand, Pre-download images or Stream entire dataset
Use msg propertiesoffFetch on demand and Stream entire dataset only. Reads the dataset, tag and set from the fields below instead of the dropdowns
DatasetnoneDataset to read. The dropdown lists the datasets of the project and stores the dataset id
TagAll tagsOnly images of this tag. The dropdown shows the number of images of each tag
SetAll setsAll sets, Train, Validation, Test or Predetermined
Filtered count-Read only. Number of images that match the selected tag and set
Interval (ms)1000Stream entire dataset only. Time between two images: a number, or a msg, flow or global property that holds one. Values below 100 are raised to 100
Dataset field / Tag field / Set fieldemptyWith Use msg properties. msg, flow or global property that holds the dataset (id or name), the tag id and the set (for example TRAIN). The dataset field is required; an empty tag or set field means all tags or all sets
Number of cached images10Pre-download images only. Size of the pool, from 1 to 50
BGRoffSwaps the red and blue channels: the image comes out as BGR or BGRA instead of RGB or RGBA
Output fieldimagemsg property that receives the image

Retrieval Modes ​

Fetch on demand ​

Every input message gets one image, chosen at random among the images that match the dataset, tag and set. To keep reads low, the node draws from a pool of matching images that it reads from Firestore 200 at a time and keeps for 5 minutes, or until a dataset changes. The message is passed on with the image in the Output field.

With Use msg properties, each message says which dataset, tag and set to use:

javascript
// Dataset field: msg.payload.dataset, Tag field: msg.payload.tag, Set field: msg.payload.set
msg.payload = { dataset: "rp-class-bottle_caps", tag: "SCRATCH", set: "TRAIN" };
return msg;

Pre-download images ​

When the node starts it downloads Number of cached images random images that match the dataset, tag and set, and keeps them in a folder of the system's temporary directory (node-red-rosepetal-vp-cache/from-dataset/<node id>). Every input message gets one image picked at random from that pool, with no download. The pool is reused after a restart or a redeploy as long as the dataset, tag, set and number do not change; it is deleted when the node is deleted. Message overrides are not available in this mode.

Stream entire dataset ​

The node sends every image that matches the dataset, tag and set, newest first, one every Interval (ms). The input messages are commands, in msg.payload:

msg.payloadCommand
"start", true, { "command": "start" }, or no payloadStart, or resume after a pause
"pause", { "command": "pause" }Pause and remember the position
"stop", false, { "command": "stop" }Stop and go back to the first image

Any other payload is rejected with the warning Unsupported payload for all dataset mode command. An inject node with its default timestamp payload is rejected: set its payload to the string start or to true.

  • start after a pause resumes where it stopped if the dataset, tag and set are the same; otherwise, and when a stream is running, it starts again from the first image.
  • The interval and, with Use msg properties, the dataset, tag and set are read from the start message.
  • Before the first image the node downloads one image to measure the download time, then fills a buffer of ceil(download time / (interval × 0.2)) images, at least 2 and at most 50, waiting at most 30 seconds.
  • An image that cannot be downloaded is retried twice, after 1 and 2 seconds. An image that cannot be decoded is skipped with the error Error processing image <index>: <reason>.
  • After the last image the status shows Complete: N/N and the next start begins again from the first image.

Output ​

The image is written to the Output field (msg.image by default):

javascript
{
  data: Buffer,        // pixels, row by row, channels interleaved
  width: 1920,
  height: 1080,
  channels: 3,         // 1, 3 or 4
  colorSpace: "RGB",   // "GRAY", "RGB", "RGBA", "BGR" or "BGRA"
  dtype: "uint8",
  name: "1759745408220_cam1_a"  // name of the image in the dataset
}

Grayscale images keep one channel (GRAY); images with alpha keep four. BMP files that the image library cannot read are decoded by the node itself (24 and 32 bits, uncompressed).

In Fetch on demand and Pre-download images modes the rest of the input message is passed on unchanged. In Stream entire dataset mode every image is sent in a copy of the start message, with these properties added:

PropertyMeaning
imageIndexPosition of the image in the stream, from 1
totalImagesNumber of images that match the filters
datasetName of the dataset
tagTag filter, ALL_TAGS when none
setSet filter, ALL_SETS when none

Fetch Limit and Disconnections ​

Every image downloaded counts toward the fetch limit of the firebase-config node (5000 a day). The images of a pool count when the pool is downloaded, not when they are sent.

  • Fetch on demand: while the limit is reached, input messages are dropped and the status shows Fetch limit reached — reset firebase-config.
  • Stream entire dataset: start fails with Firebase fetch limit reached. Reset in firebase-config node., and a running stream stops with the status Fetch limit reached — stream stopped. After Restart limit, send start again.
  • Pre-download images: after Restart limit, a pool that could not be downloaded is downloaded again by itself.

When the Firebase connection is lost, a running stream is paused, and up to 50 input messages are queued (more are dropped with a warning). They are processed in order when the connection returns. A paused stream is not resumed by itself: send start.

Node Status ​

StatusMeaning
Loading datasetStarting
green Ready (fetch on demand: <dataset>), Ready (fetch: msg props required)Fetch on demand mode is ready
green Dataset loaded (cached)The pool is ready
green Ready (stream: <dataset>), Ready (stream: msg props required)Stream mode is ready for a start
blue Measuring download speed..., Initializing buffer..., Loading buffer: n/mPreparing a stream
blue Streaming: i/N (buf: b, dl: d)Sending image i of N, b images buffered, d downloading
yellow Waiting: i/N (buf: b, dl: d)The next image is still downloading
yellow Paused at i/N, blue Resuming at i/NPaused, resumed
green Complete: N/N (avg: X ms)The stream ended; average download time
grey StoppedStopped by a stop command
yellow No images match filtersNothing to stream
yellow ring Firebase disconnected - queuing messages, Disconnected - queued N msg(s), Reconnecting - queued N msg(s)Waiting for the Firebase connection
green Reconnected - processing queued messagesConnection back
red Firebase config not set, Firebase config not readyNo firebase-config, or it could not connect
red Dataset not found, Dataset not configured, Dataset required (msg or config)The dataset is missing or does not exist in the project
red No images found in dataset / tag / set selectedThe pool could not be filled

Errors ​

ErrorCause
<name> not readyA message arrived before the node finished starting, or after it failed to start
Dataset not found: <dataset>The dataset of the configuration or of the message is not in the project
Dataset field is required when using message propertiesUse msg properties is on and the message has no dataset
No images found in dataset / tag / set selectedNo image matches the filters
No cached images availablePre-download mode without a pool
Predownload failed: <reason>The pool could not be downloaded
Error processing image: <reason>The download or the decoding failed

Examples ​

Run a model on random images ​

[inject every 2 s] → [from-dataset: Fetch on demand, Tag OK] → [inferencer] → [debug]

Set the inferencer to read its image from msg.image, the default Output field of from-dataset.

Run a model over a whole dataset ​

[inject: payload "start"] ─┐
[inject: payload "pause"] ─┼→ [from-dataset: Stream entire dataset, Interval 500] → [inferencer] → [function]
[inject: payload "stop"]  ─┘

The function node can record each result with the index of its image:

javascript
flow.set(`result_${msg.imageIndex}`, msg.payload);
node.status({ text: `${msg.imageIndex}/${msg.totalImages}` });
return null;

See Also ​