Skip to content

Open In Colab

How to import segmentation pre-annotations

In this tutorial, we will show you how to import prediction labels into your Kili project.

You will see these predictions as pre-annotations in your labeling interface, and you will be able to modify or validate them.

We will discover this feature on a segmentation project that is used to work with images or videos with pixel-level annotations.

The data used in this tutorial is from the COCO dataset.

Import an image into your Kili project

Let's first inspect what our annotated image looks like in the COCO dataset.

Raw image With the annotations
image.png image.png

Before starting, we install the requirements:

%pip install matplotlib Pillow kili opencv-python
%matplotlib inline

import urllib.request
from random import randint

import cv2
import matplotlib.pyplot as plt

from kili.client import Kili

Let's authenticate to Kili:

kili = Kili(
    # api_endpoint="",
    # the line above can be uncommented and changed if you are working with an on-premise version of Kili

Let's create an image project in Kili where we can annotate images with a semantic tool and two classes: HUMAN and MOTORCYCLE at pixel level.

We create the image project with its ontology (json_interface):

json_interface = {
    "jobs": {
        "JOB_0": {
            "mlTask": "OBJECT_DETECTION",
            "tools": ["semantic"],
            "instruction": None,
            "required": 1,
            "isChild": False,
            "content": {
                "categories": {
                    "MOTORCYCLE": {"name": "Motorcycle", "children": [], "color": "#0755FF"},
                    "HUMAN": {"name": "Human", "children": [], "color": "#EEBA00"},
                "input": "radio",
project = kili.create_project(
    description="COCO dataset",
    title="[Kili SDK Notebook]: Motorcycle annotation segmentation project",

project_id = project["id"]

Then, we upload the image to the project:

external_id = "moto"
content = ""


You should now be able to visualize your asset in Kili: