Add attachments

Attach supplementary content to an asset.

14811481

Attachments can be used to provide supplementary content to any asset to help provide additional context for the labeling team. For example, your labeler may be able to identify a crop more accurately when provided with additional images of the crop taken from different angles or classify the stage of surgery quicker when provided with a contextual video of the full surgery.

Attachments are applied to individual assets and may be comprised of image, video, text, and/or HTML content. The HTML type can take a text or HTML file and render it in an iframe in the attachments panel. Markdown and HTML can also be used with this type to style the content.

👍

Attachments may be added to any of our supported asset types.

Supported attachment types

Below are the types of attachment data that we support in the Labelbox Editor.

Type

Value

Description

IMAGE

URL of Image (PNG/JPG) (HTTPS or IAM delegated access path)

Labelers can see the attached image(s) while labeling the primary Data Row

VIDEO

URL of Video (MP4) (HTTPS or IAM delegated access path)

Labelers can see the attached video(s) while labeling the primary Data Row

RAW_TEXT

Text string or hyperlink (see below for cloud-hosted text files)

Labelers can see the attached text or hyperlink while labeling the primary Data Row

If passing a hyperlink, we will show a clickable hyperlink. If you want to display text from a URL endpoint, please use the TEXT_URL type.

TEXT_URL

URL of a text file (HTTPS or IAM delegated access path)

Labelers can see the attached text from the linked text URL while labeling the primary Data Row

HTML

URL of an HTML file (HTTPS or IAM delegated access path)

Renders HTML in an iframe as an attachment. Labelers can see and interact with the attached HTML widget while labeling the primary Data Row.

Import attachments

Python SDK

Use the following methods to import attachments to Labelbox using the 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="Data Row attachment 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="RAW_TEXT", attachment_value="IOWA, Zone 2232, June 2022 [Text string]")
data_row.create_attachment(attachment_type="RAW_TEXT", attachment_value="https://storage.googleapis.com/labelbox-sample-datasets/Docs/text_attachment.txt")
data_row.create_attachment(attachment_type="TEXT_URL", attachment_value="https://storage.googleapis.com/labelbox-sample-datasets/Docs/disease_attachment.txt")
data_row.create_attachment(attachment_type="IMAGE", attachment_value="https://storage.googleapis.com/labelbox-sample-datasets/Docs/disease_attachment.jpeg")
data_row.create_attachment(attachment_type="VIDEO", attachment_value="https://storage.googleapis.com/labelbox-sample-datasets/Docs/drone_video.mp4")
data_row.create_attachment(attachment_type="HTML", attachment_value="https://storage.googleapis.com/labelbox-sample-datasets/Docs/windy.html")

JSON format

Use the following format to include attachments in your JSON import file.

[
    {
        "externalId": "basic.png",
        "imageUrl": "https://storage.googleapis.com/labelbox-sample-datasets/Docs/basic.jpg",
        "attachments": [
            {
                "type": "RAW_TEXT",
                "value": "IOWA, Zone 2232, June 2022 [Text string]"
            },
            {
                "type": "RAW_TEXT",
                "value": "https://storage.googleapis.com/labelbox-sample-datasets/Docs/text_attachment.txt"
            },
            {
                "type": "TEXT_URL",
                "value": "https://storage.googleapis.com/labelbox-sample-datasets/Docs/text_attachment.txt"
            },
            {
                "type": "IMAGE",
                "value": "https://storage.googleapis.com/labelbox-sample-datasets/Docs/disease_attachment.jpeg"
            },
            {
                "type": "VIDEO",
                "value": "https://storage.googleapis.com/labelbox-sample-datasets/Docs/drone_video.mp4"
            },
            {
                "type": "HTML",
                "value": "https://storage.googleapis.com/labelbox-sample-datasets/Docs/windy.html"
            }
        ]
    }
]
[
     {
         "externalId": "DesigningForGoogleCastVideo.mp4",
         "videoUrl": "https://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/dash/DesigningForGoogleCastVideo.mp4",
         "attachments": [
             {
                 "type": "RAW_TEXT",
                 "value": "Some sample text"
             },
             {
                 "type": "RAW_TEXT",
                 "value": "Some more sample text"
             }
         ]
     }
]
[
     {
         "externalId": "lorem-ipsum.txt",
         "data": "https://storage.googleapis.com/labelbox-sample-datasets/nlp/lorem-ipsum.txt",
         "attachments": [
             {
                 "type": "RAW_TEXT",
                 "value": "Some sample text"
             },
             {
                 "type": "RAW_TEXT",
                 "value": "Some more sample text"
             }
         ]
     }
]
[
    {
        "externalId": "cklidhv7o0zdk0y4z4282dp6o",
        "tileLayerUrl": "https://s3-us-east-2.amazonaws.com/lb-ron/CACI/ron_mctiles/{z}/{x}/{y}.png",
        "bounds": [
            [
                19.405662413477728,
                -99.21052827588443
            ],
            [
                19.400498983095076,
                -99.20534818927473
            ]
        ],
        "minZoom": 12,
        "maxZoom": 20,
        "epsg": "EPSG4326",
        "version": 2,
        "attachments": [
             {
                 "type": "RAW_TEXT",
                 "value": "Some sample text"
             },
             {
                 "type": "RAW_TEXT",
                 "value": "Some more sample text"
             }
         ]
     }
]
[
     {
         "externalId": "ts_bad_blood",
         "audioUrl": "https://labelbox-public-assets.s3.us-west-1.amazonaws.com/bad_blood.mp3",
         "attachments": [
            {
                "type": "IMAGE",
                "value": "https://labelbox-public-assets.s3.us-west-1.amazonaws.com/ts_1989.jpeg"
            },
            {
                "type": "VIDEO",
                "value": "https://labelbox-public-assets.s3.us-west-1.amazonaws.com/ts_music_video.mp4"
            },
            {
                "type": "RAW_TEXT",
                "value": "'Cause baby, now we got bad blood / You know it used to be mad love / So take a look what you've done / 'Cause baby, now we got bad blood"
            }
         ]
     }
]
[
     {
         "externalId": "cat_scan",
         "dicomUrl": "https://storage.googleapis.com/bentz-test/dicom-assets/cat-scan1.dcm",
         "attachments": [
            {
                "type": "IMAGE",
                "value": "https://labelbox-public-assets.s3.us-west-1.amazonaws.com/patient_file_1278.jpeg"
            },
            {
                "type": "RAW_TEXT",
                "value": "ICD-9-CM: 88.38"
            }
         ]
     }
]
[
     {
         "externalId": "utility_bill",
         "pdfUrl": "https://labelbox-public-assets.s3.us-west-1.amazonaws.com/utility_bill.pdf",
         "attachments": [
            {
                "type": "IMAGE",
                "value": "https://labelbox-public-assets.s3.us-west-1.amazonaws.com/18_plain_st_001.jpeg"
            },
            {
                "type": "IMAGE",
                "value": "https://labelbox-public-assets.s3.us-west-1.amazonaws.com/18_plain_st_002.jpeg"
            },
            {
                "type": "IMAGE",
                "value": "https://labelbox-public-assets.s3.us-west-1.amazonaws.com/18_plain_st_003.jpeg"
            }
         ]
     }
]
[
     {
         "externalId": "customer_chat_4739",
         "conversationalUrl": "https://labelbox-public-assets.s3.us-west-1.amazonaws.com/chat_4739.json",
         "attachments": [
            {
                "type": "IMAGE",
                "value": "https://labelbox-public-assets.s3.us-west-1.amazonaws.com/sku_12638326723.jpeg"
            },
            {
                "type": "RAW_TEXT",
                "value": "2017 Mar 03 05:12:41.211 PDT"
            }
         ]
     }
]

Viewing attachments

When any of these attachments have been provided for an asset, labelers will see the Attachment button appear in the top left of the editor.

Clicking on this button or use the hotkey Shift + ? to open the attachments panel.


Did this page help you?