Skip to content

Dataset Upload Node ​

Overview ​

The Dataset Upload node uploads the images saved in local folders to datasets of the Rosepetal platform. A configuration array says which folder and which camera (the source name in the file name) go to which dataset. Each image is converted to PNG, uploaded to Firebase Storage, registered in Firestore as not labeled, and then deleted from the folder together with its thumbnail.

Key Features ​

  • Batch upload: every image of the configured folders, or only those whose name contains a given timestamp
  • PNG conversion: images are uploaded as PNG with compressionLevel: 9
  • Unlabeled images: stored with labeled: false, ready to be labeled on the platform
  • Suffix: a suffix from the configuration is added to file names that have none
  • 10 uploads at a time, one progress message per image
  • Duplicates skipped: an image whose name already exists in the dataset is not uploaded again
  • Cleanup: uploaded and skipped files are deleted from the folder, with their thumbnail
  • Stoppable: msg.payload = false stops the run

Configuration ​

PropertyDefaultMeaning
Namedataset-uploadLabel of the node
Firebase Confignone (required)The firebase-config node of the project to upload to
Configglobal configTrainingWhere the upload configuration is read: a msg property of the start message, a flow or global context variable, or a JSON value typed in the field

The Create new dataset button below the fields creates an empty dataset in the selected project. It asks for a name and a type (Classification, Segmentation, Anomaly Detection, Object Detection, Oriented Object Detection or OCR) and shows the id of the new dataset, rp-<type prefix>-<name>, which is what the upload configuration needs. The Firebase Config must be deployed and connected for it to work.

Upload Configuration ​

An array with one entry per source:

json
[
  {
    "dataset": "rp-class-bottle-caps",
    "folder": "/opt/storage/images/camera1",
    "sourceName": "cam1",
    "suffix": "a"
  },
  {
    "dataset": "rp-obj-labels",
    "folder": "/opt/storage/images/camera2",
    "sourceName": "cam2"
  }
]
FieldRequiredMeaning
datasetyesId of the target dataset (the Firestore document id, for example rp-class-bottle-caps), not its display name
folderyesFolder to read. A path without a leading slash is taken from the root (opt/storage/images is /opt/storage/images)
sourceNameyesSource name that the file names of this entry carry (see File names)
suffixnoAdded to the file name of images that have no suffix

Several entries can share a folder. An image goes to the entry with its source name and its folder, or, if none, to the first entry with its source name.

Where the configuration comes from ​

With the default Config (global configTraining), set it once, for example from a function node:

javascript
global.set("configTraining", [
  { dataset: "rp-class-bottle-caps", folder: "/opt/storage/images/camera1", sourceName: "cam1", suffix: "a" }
]);

With Config set to msg.uploadConfig, the start message carries it:

javascript
msg.uploadConfig = [
  { dataset: "rp-class-bottle-caps", folder: "/opt/storage/images/camera1", sourceName: "cam1" }
];
msg.payload = true;
return msg;

File Names ​

{timestamp}_{sourceName}_{suffix}.{extension}
  • The source name is the second-to-last part of the name split by _ (1759745408220_cam1_a.jpg → cam1). A name with only two parts, {timestamp}_{sourceName}, takes the last one (1759745408220_cam1.jpg → cam1). A name without _ is rejected with Invalid filename format.
  • If the name has exactly two parts and the entry has a suffix, the image is uploaded as {timestamp}_{sourceName}_{suffix}.
  • Only files with the extensions .png, .jpg, .jpeg, .bmp, .webp, .tiff, .tif, .gif and .avif are read. Sub-folders and names starting with thumbnails are ignored.

What Is Uploaded ​

For each image:

  1. The file is converted to PNG (compressionLevel: 9) and renamed to .png.
  2. If the dataset already has an image with that name (without extension), nothing is uploaded and the output says Image already exists.
  3. Otherwise the node uploads, under upload/nodered/<dataset id>/ in the project's Storage bucket, the PNG, a JPEG copy at quality 80 (<name>-reduced.jpeg) and a JPEG at quality 10 (<name>-lowResolution.jpeg).
  4. It creates the image document in Firestore with labeled: false, set: "PREDETERMINED", the tag 0, and a 300-pixel-wide preview.
  5. It deletes the local file and its thumbnail, <folder>/thumbnails/<name>.jpg. Skipped duplicates are deleted too; files that failed are kept.

Input ​

msg.payloadEffect
trueUploads every image of the configured folders
a string, for example "1759745408220"Uploads only the images whose file name contains that string
falseStops the run: uploads already started finish and report, the rest are not started and send nothing
anything elseWarning Invalid payload.

A start message while a run is in progress is ignored with the warning Upload already in progress. With Config of type msg, the configuration is read from the start message.

Output ​

One message per image handled:

javascript
{
  payload: "1759745408220_cam1_a.jpg",  // local file name
  done: true,                            // false if the image failed
  message: "",                           // "", "Image already exists" or the error
  imagesDone: 5,                         // images handled so far, this one included
  imagesLeft: 15                         // images still to handle in this run
}
messagedoneMeaning
""trueUploaded
Image already existstrueSkipped, the dataset has it already
Invalid filename formatfalseThe name has no _
No config found for sourceName: <name>falseNo entry has that source name
Dataset not found: <id>falseThe entry's dataset is not a dataset of the project
other textfalseThe error of the conversion or of the upload

At the end the node counts the image files still in the folders, writes the number to the global context variable trainingCount, and warns Upload complete. Remaining files: <n>.

Status and Errors ​

The status is set when the node starts:

StatusMeaning
yellow ring waiting for firebaseWaiting for the Firebase connection
green dot ready (<projectId>)Ready to upload to that project
red ring firebase not connectedThe Firebase Config could not connect
red ring missing firebase-configNo Firebase Config selected
red ring no Firebase projectIdThe Firebase Config gives no project id

Errors that stop a run before any upload:

  • configTraining is empty or not found in <type>.<property>
  • Invalid or missing folder for config entry with sourceName: <name> (that entry is skipped)
  • No valid config entries with folders found in configTraining
  • Error reading directory <folder>: <reason> (that folder is skipped)
  • Firebase configuration not ready. Ensure the firebase-config node is connected.
  • No images found with timestamp: <string> (warning)

Example ​

Upload the images of one inspection cycle once its images are saved: a function node builds the start message with the cycle's timestamp.

javascript
// msg.timestamp was set by the node that saved the images
msg.payload = String(msg.timestamp);
return msg;

Wire it to dataset-upload, and its output to a function node that reports progress:

javascript
if (!msg.done) node.warn(`${msg.payload}: ${msg.message}`);
node.status({ text: `${msg.imagesDone} done, ${msg.imagesLeft} left` });
return null;

See Also ​