Uploading Predictions

After Prediction objects, you just need to upload them to your Nucleus dataset by associating them with a model. This can be accomplished with a single call to Dataset.upload_predictions. See example usage below.

We recommend setting asynchronous=True to drastically speed up the upload. This will also allow you to check on the job's status in the dashboard or via the API (see our docs on Async Jobs).

import nucleus

# construct various predictions
box_pred_1 = nucleus.BoxPrediction(...)
box_pred_2 = nucleus.BoxPrediction(...)
polygon_pred = nucleus.PolygonPrediction(...)
line_pred = nucleus.LinePrediction(...)
cuboid_pred = nucleus.CuboidPrediction(...)
segmentation_pred = nucleus.SegmentationPrediction(...)

# fetch dataset and model
client = nucleus.NucleusClient("YOUR_SCALE_API_KEY")
dataset = client.get_dataset("YOUR_DATASET_ID")
model = client.get_model("YOUR_MODEL_ID")

# upload predictions to dataset
job = dataset.upload_predictions(
    predictions=[box_pred_1, box_pred_2, polygon_pred, line_pred, cuboid_pred, segmentation_pred],