Upload pre-annotated tasks

Step 1: Format your annotation data

Let's get started. First, you need to ensure that your annotation data format is compatible with Sama's format.

Step 2: Use the API

All you need to do is to call the "Create task" endpoint. If you want to take a closer look at the endpoints and how they work you can go here and check the documentation.

Here is an example of a python script that shows how you can call the API.

url = f"https://api.sama.com/v2/projects/{project_id}/batches.json?access_key={client_access_key}"

sama_data = [
    {
        "data": {}
    }

]
payload = {"tasks": sama_data}

headers = {
    "Accept": "application/json",
    "Content-Type": "application/json"
}

# POST request
response = requests.request("POST", url, json=payload, headers=headers)
print(response.text)

API end-to-end tutorial

Format a dataset from scratch and upload it to the Sama Platform using the API on this tutorial

Examples for pre-annotation

Use this section as a reference to check examples of pre-annotations formats on different vector types.

JSON format for pre-annotations

Don’t feel overwhelmed by the JSON format. We are going to walk you through the different sections inside the JSON

  • The data: This section lists the inputs as they are defined in the project settings. If you don’t know how to see your inputs, go here and follow the tutorial.
    If you already know your inputs you can start getting the corresponding data, follow this tutorial if you are not sure about the process.
  • The output: This section consists of a dictionary of the outputs defined in the project settings, but in the JSON this name comes with the prefix output_ (e.g "output_YOUR_OUTPUT_NAME").
    Inside this section, you can have some other nested inputs depending on the annotation type you are working with.

Rectangle

This annotation corresponds to the following output

Are you struggling while formatting your shape points?

Is normal to have different representations of coordinates. The Sama Platform draws the shapes using ordered pairs (x,y) for each vertex.

Some formats represent the shapes by a list like [x, y, weight, height], if this is your case use the following script to get [[x1,y1], [x1, y2], [x2, y1], [x2,y2]] witch is how Sama Platform draws a rectangle.

def _from_bbox_to_rectangle(bbox):
    x1 = int(bbox[0])
    y1 = int(bbox[1])
    width = int(bbox[2])
    height = int(bbox[3])

    y2 = y1 + height
    x2 = x1 + width

    return [[x1,y1], [x1, y2], [x2, y1], [x2,y2]]

Polygon

This annotation corresponds to the following output

Point

This annotation corresponds to the following output

Arrow

This annotation corresponds to the following output

Key points

This annotation corresponds to the following output

Cuboid

This annotation corresponds to the following output

Slide rectangle

This annotation corresponds to the following output

Create your JSON and upload a vector pre-annotation following this tutorial

Importing raster pre-annotations

This is an example of how pre-annotations look for raster.

This annotation corresponds to the following output

Create your JSON and upload a raster pre-annotation following this tutorial


Importing video pre-annotations

This is an example of how a pre-annotation looks for a video. You need to update the "data" inside your JSON

This annotation corresponds to the following output

Create your JSON and upload a video pre-annotation following this tutorial


Importing 3D Point Cloud pre-annotations

This is an example of how a pre-annotation looks for 3D Point-Cloud.

This annotation corresponds to the following output

📘

Important aspect about some nested inputs inside "key_locations"

Even though "position_center", "direction" and "dimensions" come inside "key_locations" when you download the delivery format JSON are not taking on count when uploading pre-annotated tasks.


Create your JSON and upload a 3D Point Cloud pre-annotation following this tutorial


📘

Note

Sama Platform also supports pre-annotations on CSV format. If you are interested in this format reach out your project manager for more information.