Skip to content

Labelbox/labelbox-python

Repository files navigation

Release Notes CI) Downloads Dependency Status Open Issues Changelog License: Apache 2.0 Twitter Follow LinkedIn Follow Supported Python Versions SLSA 3

Labelbox

With Labelbox, enterprises can easily curate and annotate data, generate high-quality human feedback data for computer vision and language models, evaluate and improve model performance, and automate tasks by seamlessly combining AI and human-centric workflows. The academic and research community also relies on Labelbox for cutting-edge AI research and experimentation.

Visit Labelbox for more information.

Table of Contents

Quick Start

Sign Up

If you haven't already, create a free account at Labelbox.

Generate an API key

Log into Labelbox and navigate to Account > API Keys to generate an API key.

Install

To install the SDK, run the following command.

pip install labelbox

If you'd like to install the SDK with enhanced functionality, which additional optional capabilities surrounding data processing, run the following command.

pip install "labelbox[data]"

Please note that if you prefer to build and install your own version of the SDK, it is important to be aware that only tagged commits have been thoroughly tested. Building from the head of develop branch carries some level of risk.

Validate Installation and API Key

After installing the SDK and getting an API Key, it's time to validate them both.

import labelbox as lb

client = lb.Client(API_KEY) # API_KEY = API Key generated from labelbox.com
dataset = client.create_dataset(name="Test Dataset")
data_rows = [{"row_data": "My First Data Row", "global_key": "first-data-row"}]
task = dataset.create_data_rows(data_rows)
task.wait_till_done()

You should be set! Running the snippet above should create a dataset called Test Dataset with its content being My First Data Row. You can log into Labelbox to verify this. If you have any issues please file a Github Issue or contact Labelbox Support directly. For more advanced examples and information on the SDK, see Documentation below.

Contribution Guidelines

We encourage anyone to contribute to this repository to help improve it. Please refer to Contributing Guide for detailed information on how to contribute. This guide also includes instructions for how to build and run the SDK locally.

Documentation

The SDK is well-documented to help developers get started quickly and use the SDK effectively. Here are links to that documentation:

Jupyter Notebooks

We have samples in the examples directory to help you get started with the SDK.

Make sure your notebook will use your source code:

  1. ipython profile create
  2. ipython locate - will show where the config file is. This is the config file used by the Jupyter server, since it runs via ipython
  3. Open the file (this should be ipython_config.py and it is usually located in ~/.ipython/profile_default) and add the following line of code:
c.InteractiveShellApp.exec_lines = [
  'import sys; sys.path.insert(0, "<labelbox-python root folder>")'
]
  1. Go to the root of your project and run jupyter notebook to start the server.

Provenance

To enhance the software supply chain security of Labelbox's users, as of v.3.72.2, every Labelbox SDK release contains a SLSA Level 3 Provenance document.
This document provides detailed information about the build process, including the repository and branch from which the package was generated.

By using the SLSA framework's official verifier, you can verify the provenance document to ensure that the package is from a trusted source. Verifying the provenance helps confirm that the package has not been tampered with and was built in a secure environment.

Example of usage for the v.3.72.2 release wheel:

export VERSION=3.72.2 # sdk release version 
export TAG=v.3.72.2 # github tag
pip download --no-deps labelbox==${VERSION}

curl --location -O \
  https://github.com/Labelbox/labelbox-python/releases/download/${TAG}/multiple.intoto.jsonl

slsa-verifier verify-artifact --source-branch develop --builder-id 'https://github.com/slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@refs/tags/v2.0.0' --source-uri "git+https://github.com/Labelbox/labelbox-python" --provenance-path multiple.intoto.jsonl ./labelbox-${VERSION}-py3-none-any.whl