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 = falsestops the run
Configuration
| Property | Default | Meaning |
|---|---|---|
| Name | dataset-upload | Label of the node |
| Firebase Config | none (required) | The firebase-config node of the project to upload to |
| Config | global configTraining | Where 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:
[
{
"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"
}
]| Field | Required | Meaning |
|---|---|---|
dataset | yes | Id of the target dataset (the Firestore document id, for example rp-class-bottle-caps), not its display name |
folder | yes | Folder to read. A path without a leading slash is taken from the root (opt/storage/images is /opt/storage/images) |
sourceName | yes | Source name that the file names of this entry carry (see File names) |
suffix | no | Added 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:
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:
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 withInvalid 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,.gifand.avifare read. Sub-folders and names starting withthumbnailsare ignored.
What Is Uploaded
For each image:
- The file is converted to PNG (
compressionLevel: 9) and renamed to.png. - If the dataset already has an image with that name (without extension), nothing is uploaded and the output says
Image already exists. - 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). - It creates the image document in Firestore with
labeled: false,set: "PREDETERMINED", the tag0, and a 300-pixel-wide preview. - It deletes the local file and its thumbnail,
<folder>/thumbnails/<name>.jpg. Skipped duplicates are deleted too; files that failed are kept.
Input
msg.payload | Effect |
|---|---|
true | Uploads every image of the configured folders |
a string, for example "1759745408220" | Uploads only the images whose file name contains that string |
false | Stops the run: uploads already started finish and report, the rest are not started and send nothing |
| anything else | Warning 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:
{
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
}message | done | Meaning |
|---|---|---|
"" | true | Uploaded |
Image already exists | true | Skipped, the dataset has it already |
Invalid filename format | false | The name has no _ |
No config found for sourceName: <name> | false | No entry has that source name |
Dataset not found: <id> | false | The entry's dataset is not a dataset of the project |
| other text | false | The 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:
| Status | Meaning |
|---|---|
yellow ring waiting for firebase | Waiting for the Firebase connection |
green dot ready (<projectId>) | Ready to upload to that project |
red ring firebase not connected | The Firebase Config could not connect |
red ring missing firebase-config | No Firebase Config selected |
red ring no Firebase projectId | The 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 configTrainingError 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.
// 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:
if (!msg.done) node.warn(`${msg.payload}: ${msg.message}`);
node.status({ text: `${msg.imagesDone} done, ${msg.imagesLeft} left` });
return null;See Also
- Firebase Config - Required configuration node
- List Dataset - Ids, types and tags of the datasets
- From Dataset - Read the images back from a dataset