Predictions

Create prediction

POST

If you have predictions generated for your dataset from a model, either as pre-annotated tasks or pre-labeled tasks, you can import the predictions with your dataset into Label Studio for review and correction.

To import predicted labels into Label Studio, you must use the Basic Label Studio JSON format and set up your tasks with the predictions JSON key. The Label Studio ML backend also outputs tasks in this format.

JSON format for predictions

Label Studio JSON format for pre-annotations must contain two sections:

  • A data object which references the source of the data that the pre-annotations apply to. This can be a URL to an audio file, a pre-signed cloud storage link to an image, plain text, a reference to a CSV file stored in Label Studio, or something else.
  • A predictions array that contains the pre-annotation results for the different types of labeling. See how to add results to the predictions array.

For more information, see the JSON format reference in the Label Studio documentation

Request

This endpoint expects an object.
task
integerOptional
Task ID for which the prediction is created
result
list of maps from strings to anyOptional
score
doubleOptional
Prediction score. Can be used in Data Manager to sort task by model confidence. Task with the lowest score will be shown first.
model_version
stringOptional
Model version - tag for predictions that can be used to filter tasks in Data Manager, as well as select specific model version for showing preannotations in the labeling interface

Response

This endpoint returns an object
result
list of maps from strings to any
List of prediction results for the task
task
integer
id
integerOptional
model_version
stringOptional
Model version - tag for predictions that can be used to filter tasks in Data Manager, as well as select specific model version for showing preannotations in the labeling interface
created_ago
stringOptionalDefaults to
Delta time from creation time
score
doubleOptional
Prediction score
cluster
integerOptional
Cluster for the current prediction
neighbors
map from strings to anyOptional
Array of task IDs of the closest neighbors
mislabeling
doubleOptional
Related task mislabeling score
created_at
datetimeOptional
updated_at
datetimeOptional
model
integerOptional
An ML Backend instance that created the prediction.
model_run
integerOptional
A run of a ModelVersion that created the prediction.
project
integerOptional
POST
1curl -X POST http://localhost:8080/api/predictions/ \
2 -H "Authorization: Token <api_key>" \
3 -H "Content-Type: application/json" \
4 -d '{
5 "result": [
6 {
7 "original_width": 1920,
8 "original_height": 1080,
9 "image_rotation": 0,
10 "from_name": "bboxes",
11 "to_name": "image",
12 "type": "rectanglelabels",
13 "value": {
14 "x": 20,
15 "y": 30,
16 "width": 50,
17 "height": 60,
18 "rotation": 0,
19 "values": {
20 "rectanglelabels": {
21 "0": "Person"
22 }
23 }
24 }
25 }
26 ],
27 "score": 0.95,
28 "model_version": "yolo-v8"
29}'
200Successful
1{
2 "result": [
3 {
4 "original_width": 1920,
5 "original_height": 1080,
6 "image_rotation": 0,
7 "from_name": "bboxes",
8 "to_name": "image",
9 "type": "rectanglelabels",
10 "value": {
11 "x": 20,
12 "y": 30,
13 "width": 50,
14 "height": 60,
15 "rotation": 0,
16 "values": {
17 "rectanglelabels": {
18 "0": "Person"
19 }
20 }
21 }
22 }
23 ],
24 "task": 1,
25 "id": 1,
26 "model_version": "yolo-v8",
27 "created_ago": "created_ago",
28 "score": 0.95,
29 "cluster": 1,
30 "neighbors": {
31 "neighbors": {
32 "key": "value"
33 }
34 },
35 "mislabeling": 1.1,
36 "created_at": "2024-01-15T09:30:00Z",
37 "updated_at": "2024-01-15T09:30:00Z",
38 "model": 1,
39 "model_run": 1,
40 "project": 1
41}