Skip to main content

Labelbox Python API

Project description

Labelbox Python SDK

Release Notes CI Downloads Dependency Status Open Issues Changelog License: Apache 2.0 Twitter Follow LinkedIn Follow

Labelbox is a cloud-based data-centric AI platform designed to help teams create high-quality training data for their AI models. It provides a suite of tools and features that streamline the process of data curation, labeling, model output evaluation for computer vision and large language models. Visit Labelbox for more information.

The Python SDK provides a convenient way to interact with Labelbox programmatically, offering advantages over REST or GraphQL APIs:

  • Simplified interactions: The SDK abstracts away the complexities of API calls, making it easier to work with Labelbox.
  • Object-oriented approach: The SDK provides an object-oriented interface, allowing you to interact with Labelbox entities (projects, datasets, labels, etc.) as Python objects.
  • Extensibility: The SDK can be extended to support custom data formats and operations.

Table of Contents

Installation

Supported python versions

Welcome to the quick start guide for integrating Labelbox into your Python projects. Whether you're looking to incorporate advanced data labeling into your workflow or simply explore the capabilities of the Labelbox Python SDK, this guide will walk you through the two main methods of setting up Labelbox in your environment: via a package manager and by building it locally.

Install using pip

To get started with the least amount of hassle, follow these simple steps to install the Labelbox Python SDK using pip, Python's package manager.

  1. Ensure pip is installed: First, make sure you have pip installed on your system. It's the tool we'll use to install the SDK.

  2. Sign up for Labelbox: If you haven't already, create a free account at Labelbox to access its features.

  3. Generate your API key: Log into Labelbox and navigate to Account > API Keys to generate an API key. You'll need this for programmatic access to Labelbox.

  4. Install the SDK: Open your terminal or command prompt and run the following command to install the Labelbox Python SDK:

    pip install labelbox
    
  5. Install optional dependencies: For enhanced functionality, such as data processing, you can install additional dependencies with:

    pip install "labelbox[data]"
    

    This includes essential libraries like Shapely, GeoJSON, NumPy, Pillow, and OpenCV-Python, enabling you to handle a wide range of data types and perform complex operations.

Building and installing locally

For those who prefer or require a more hands-on approach, such as contributing to the SDK or integrating it into a complex project, building the SDK locally is the way to go.

Steps for local installation

  1. Clone the SDK repository: First, clone the Labelbox SDK repository from GitHub to your local machine.

  2. Install required dependencies: To ensure all dependencies are met, run:

    pip install -r requirements.txt
    
  3. Install the SDK locally: Navigate to the root directory of the cloned repository and run:

    pip install -e .
    

    For additional data processing capabilities, remember to install the data extra as mentioned in the easy installation section.

Code architecture

The Labelbox Python SDK is designed to provide a clean and intuitive interface for interacting with the Labelbox API. It primarily uses GraphQL for communication, with some REST API calls for specific functionalities. The SDK wraps the GraphQL API calls and provides object-oriented representations of Labelbox entities like projects, datasets, and labels. This allows developers to interact with Labelbox in a more Pythonic way, making code easier to read and maintain.

Key files and classes include:

  • labelbox/client.py: Contains the Client class, which provides methods for interacting with the Labelbox API.
  • labelbox/orm/model.py: Defines the data model for Labelbox entities like projects, datasets, and labels.
  • labelbox/schema/*.py: Contains classes representing specific Labelbox entities and their attributes.
  • labelbox/data/annotation_types/*.py: Defines classes for different annotation types, such as bounding boxes, polygons, and classifications.
  • labelbox/data/serialization/*.py: Provides converters for different data formats.

The SDK wraps the GraphQL APIs and provides a Pythonic interface for interacting with Labelbox.

Contribution guidelines

We encourage developers to contribute to the Labelbox Python SDK and help improve its functionality and usability. Please refer to the CONTRIB.md file in the root folder of the repository for detailed information on how to contribute.

Develop with AI assistance

Use the codebase as context for large language models

Using the GPT repository loader, we have created lbx_prompt.txt that contains data from all .py and .md files. The file has about 730k tokens. We recommend using Gemini 1.5 Pro with 1 million context length window.

Documentation

The Labelbox Python SDK is well-documented to help developers get started quickly and use the SDK effectively. Here are some resources:

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

labelbox-3.66.0.tar.gz (186.0 kB view hashes)

Uploaded Source

Built Distribution

labelbox-3.66.0-py3-none-any.whl (237.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page