Uploading predictions
In this example, we'll walk you through how to upload predictions using our API into an already existing dataset.
Before you begin: See Prerequisites and learn about the The prediction format.
Create a new python file and import the following libraries:
You can either access the tool and copy the UUID following dataset/ in the URL, or utilize the datasets endpoint to get the uuid of the dataset:
In order to upload predictions, a prediction group needs to exist. Predictions can be organized into groups for any purpose imaginable. The UUID of an existing prediction group can be found in the URL after predictions/ or by using the endpoint
For datasets not containing segmentation tasks, a new prediction group can be creaited either by clicking in the app (Manage Predictions in the upper right corner and then + Create predictions group), or by using the following code snippet
Special case: Segmentation datasets
Predictions groups connected to segmentation datasets mus be created using the code snippet, and requires also one extra parameter called classMapping. The mapping is used when calculating disagreement between predictions and annotations and will impact the sorting as well as how disagreements appear in the gallery. The classMapping parameter is a list of dictionaries, where each dictionary contains the keys annotated and predicted. The annotated key is the class name in the annotations, and the predicted key is the class name in the predictions. {"annotated": "oak", "predicted": "tree"} if you have annotated different species of trees, but only predict wether it is a tree or not.
All class names in the predictions and the annotations must be present in the class mappings, even if they don't need to be mapped. In the annotations, non-segmented areas are labeled with the class name _background.
For a small amount of predictions, synchronous calls might work
For larger amounts of predictions, asynchronous calls are recommended. The following example uses the async client from the kognic-auth library to make 100 asynchronous calls:
Setting MAX_CONNECTIONS to something bigger than 10 might not work and is not recommended.