Creating your first project
Before you start
Make sure you have completed the installation and authentication steps before continuing to the steps below. Also, to better understand the functionalities described from here on out, take a moment to read Overview & data types.
In order for the following methods to work, make sure the API client is initialized:
from labelbox import Client
client = Client()
Step 1 Build your project's foundation
In the rough hierarchical structure of Labelbox’s data objects, projects and datasets are considered "top-level" objects. They are the foundation upon which your labeling pipeline is structured. Because they are top-level, projects and datasets are created using the Labelbox Client directly.
create_project method to create and name your project. You will be attaching your datasets to your project so name it accordingly.
project = client.create_project(name="<project_name>")
Within your project, use the
create_dataset method to create a dataset, name it, and attach it to your project. The name of the dataset should reflect the nature of the data it contains.
dataset = client.create_dataset(name="<dataset_name>", projects=project)
Step 2 Add data to your project
There are two ways to create data rows within a dataset, in bulk and individually. For details on acceptable file types, see Data import overview.
create_data_row method accepts files individually and is a synchronous operation.
dataset = client.get_dataset("dataset_id")
data_row = dataset.create_data_row(row_data="http://my_site.com/photos/img_01.jpg")
You can also pass a string to a local file.
data_row = dataset.create_data_row(row_data="path/to/file.jpg")
For instructions on how to bulk upload data rows using the
create_data_rows method, see Data Rows.
Step 3 Connect an ontology and specify a label editor
Use this method below to finalize the setup for your newly created project.
project.setup(self, labeling_frontend, labeling_frontend_options)
labeling_frontend argument to specify which editor to use for the project. You can find all of the editors available within your organization by querying for
client.get_labeling_frontends(), which returns a paginated collection.
labeling_frontend_options argument takes in a stringified JSON or dict version of your ontology.
End-to-end python example
from labelbox import Client
import sys, os, json
if __name__ == '__main__':
project = client.create_project(name="Test Project")
dataset = client.create_dataset(name="Test Dataset", projects=project)
frontends = client.get_labeling_frontends()
for frontend in frontends:
# option 1: copy ontology from existing project
ontology = project.labeling_frontend_options()
# option 2: copy + paste ontology directly as stringified JSON
ontology = """
# connecting interface and ontology to finalize project set-up