Create a project

from labelbox import MediaType, Client

client = Client(api_key="<YOUR_API_KEY>")

# Create a new project
project = client.create_project(name="my-test-project",
                                description="a description",

Setting the queueing mode while setting up a project

from labelbox import Client
from labelbox.schema.queue_mode import QueueMode

client = Client(api_key="<YOUR_API_KEY>")

project = client.create_project(name="my-test-project",
                                description="a description",

project = client.create_project(name="my-test-project",
                                description="a description",

Attach Ontology to a project to set up editor

# Get exsiting ontology (you can share an ontology across projects) or create a new one following Ontology section
ontology = client.get_ontology("ONTOLOGY_ID")

# Setup project editor with ontology

Upload labeling instructions

project.upsert_instructions("LOCAL_FILE_PATH (PDF or HTML)")

If using Dataset mode (default) - attach/detach dataset

# Get dataset
dataset = client.get_dataset("DATASET_ID")

#Attach the dataset to the project

#Detach the dataset from the project

If using Batch mode - add a batch to queue


data_rows = [dr.uid for dr in list(dataset.export_data_rows())]

# Randomly select 5 Data Rows
sampled_data_rows = random.sample(data_rows, 5)

batch = project.create_batch(
  "Initial batch", # name of the batch
  sampled_data_rows, # list of Data Rows
  1 # priority between 1-5

# list batches in a project
for batch in project.batches():

Configure project settings

Change Queue mode


Change project resource tag. See more in Organize projects with tags.

tags = project.update_project_resource_tags(["tag1", "tag2"])

Get a project

# Get project by id
project = client.get_project(PROJECT_ID)

# Alternatively you can query by name
projects = client.get_projects(
    where=(( == PROJECT_NAME) &
           (labelbox.Project.description == "new description field")))
project = next(projects, None)

Get project information

ontology = project.ontology()
batches = list(project.batches())

Export data rows queued in a project

data_rows = project.export_queued_data_rows(timeout_seconds=120)

Export labels

labels = project.label_generator()

## Alternatively you can specify date range to export desired labels from a project
labels = project.label_generator(start="2020-01-01", end="2020-01-02")

for label in labels:

Delete a project