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",
media_type=MediaType.Image)
If you have Workflow enabled and no queue_mode
or quality setting is provided, the project will default to Batch based queuing with benchmark .
Deprecation notice
Dataset mode of queueing will be deprecated starting end of February 2023. Labelbox will communicate to you the dates when your existing projects in dataset mode of queueing will be moved over
Setting the queueing mode & quality settings while setting up a project
from labelbox import Client
from labelbox.schema.queue_mode import QueueMode
client = Client(api_key="<YOUR_API_KEY>")
# Create a batch project with benchmark quality control
benchmark_quality = {
"auto_audit_percentage": 1,
"auto_audit_number_of_labels": 1
}
project = client.create_project(name="benchmark-batch-project",
description="a description",
media_type=MediaType.Image,
queue_mode=QueueMode.Batch,
**benchmark_quality)
# Create a dataset project with consensus quality control.
# In this case, 10% of all data rows need to be annotated by three labelers.
consensus_quality = {
"auto_audit_percentage": 0.1,
"auto_audit_number_of_labels": 3
}
project = client.create_project(name="consensus-dataset-project",
description="a description",
media_type=MediaType.Image,
queue_mode=QueueMode.Dataset,
**consensus_quality)
# And if your organization has access to new paradigm, you can create
# a batch-based project with consensus quality control.
# https://labelbox-group.readme.io/docs/migrating-to-workflows#new-projects
project = client.create_project(name="consensus-batch-project",
description="a description",
media_type=MediaType.Image,
queue_mode=QueueMode.Batch,
**consensus_quality)
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
project.setup_editor(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
project.datasets.connect(dataset)
#Detach the dataset from the project
project.datasets.disconnect(dataset)
If using Batch mode - add a batch to the queue
# Create a batch with data row objects from an existent dataset
# Select a sample of data row objects (optional)
sample = random.sample(list(dataset.export_data_rows()), 3)
batch = project.create_batch(
"Initial batch",
sample, # sample of data row objects
5 # priority between 1(Highest) - 5(lowest)
)
# list batches in a project
for batch in project.batches():
print(batch.name)
Configure project settings
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=((labelbox.Project.name == PROJECT_NAME) &
(labelbox.Project.description == "new description field")))
project = projects.get_one()
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:
print(label.annotations)
Delete a project
project.delete()