Table of Contents

Creating your first project

Alex Cota Updated by Alex Cota

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()

Project setup

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.

Use the 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.

The 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="")

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)

Use the 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.

The 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 = """
"tools": [],
"classifications": []

# option 1: (v2.4) connect interface and ontology
project.setup(list(frontend_list)[1], ontology)

# option 2: (v2.3 and older) first, connect frontend interface
# then, connect the ontology
project.setup(list(frontend_list)[1], ontology)

Next Steps

Now that you have set up your first project, explore Projects, Datasets, Data Rows, and Labels pages to learn how to do more with the Python SDK.

Was this page helpful?

Getting started

Project setup script