Add image layers

Attach alternative views to an image.

14811481

Image layers can be used to provide labelers with additional view options for the image being labeled. For example, if you have additional cameras capturing images of your subject matter in different formats (greyscale, thermal, etc.), you may want to provide these images as contextual layers to the primary image to supplement labeling.

Only images may be attached as layers to an image asset. Layers are applied to individual images, and a maximum of 10 layers may be added per image. (If more than 10 layers are needed, please reach out to support.) Image layers are a visualization tool designed to help you view the asset to be labeled in different ways. You may change visual settings on the image layers (e.g., transparency, brightness) and still create annotations on the data row..

Importing layers

Image layers are imported as attachments to a data row. You must include the following information for each image layer.

ParameterRequiredValue
typeYesIMAGE_OVERLAY
valueYesURL of Image (PNG/JPG) (HTTPS or IAM delegated access path)
nameNoString

Python SDK

import labelbox 

#Enter your API key
API_KEY = ""
client = labelbox.Client(api_key=API_KEY)

#create a new dataset
dataset = client.create_dataset(name="Image layer example")

#create a data row with external ID
data_row = dataset.create_data_row(row_data="https://storage.googleapis.com/labelbox-sample-datasets/Docs/basic.jpg",
                        external_id="base_image")

#Create multiple attachments
data_row.create_attachment(attachment_type="IMAGE_OVERLAY", attachment_value="https://storage.googleapis.com/labelbox-sample-datasets/Docs/rgb.jpg", attachment_name="RGB")
data_row.create_attachment(attachment_type="IMAGE_OVERLAY", attachment_value="https://storage.googleapis.com/labelbox-sample-datasets/Docs/cir.jpg", attachment_name="CIR")
data_row.create_attachment(attachment_type="IMAGE_OVERLAY", attachment_value="https://storage.googleapis.com/labelbox-sample-datasets/Docs/weeds.jpg", attachment_name="Weeds")

JSON format

[
    {
      "row_data": "https://lb-test-data.s3.us-west-1.amazonaws.com/image-samples/sample-image-1.jpg",
      "global_key": "https://lb-test-data.s3.us-west-1.amazonaws.com/image-samples/sample-image-1.jpg",
      "media_type": "IMAGE",
      "metadata_fields": [{"schema_id": "cko8s9r5v0001h2dk9elqdidh", "value": "tag_string"}],
      "attachments": [
            {
                "type": "IMAGE_OVERLAY",
                "value": "https://storage.googleapis.com/labelbox-sample-datasets/Docs/rgb.jpg",
                "name": "RGB"
            },
            {
                "type": "IMAGE_OVERLAY",
                "value": "https://storage.googleapis.com/labelbox-sample-datasets/Docs/cir.jpg",
                "name": "CIR"
            },
            {
                "type": "IMAGE_OVERLAY",
                "value": "https://storage.googleapis.com/labelbox-sample-datasets/Docs/weeds.jpg",
                "name": "Weeds"
            }
        ]
    }
]

Viewing image layers

When layers have been provided for an image, labelers will see the Image overlay button appear in the top bar of the editor, to the left of the zoom menu.

Clicking on this button opens a dropdown menu where alternative layers may be selected. Labelers can additionally use the keyboard shortcut (Option/Alt key + Layer #) to quickly switch between layers.