Creating Objects

Updated 2 weeks ago by Florijan Stamenkovic

Top-level Object Creation

Please take a look at Overview & Data Types to see which data (object) types are available in Labelbox.

Object types such as Project and Dataset are "top-level" objects in the sense that they don't belong to an object of a different tyle. For that reason they are created using the Labelbox Client directly.

>>> from labelbox import Client

>>> client = Client()
>>> project = client.create_project(name="MyProject")
>>> dataset = client.create_dataset(name="MyDataset")

Creation functions accept only named arguments. Names correspond to field names for the object type being created. For an exhaustive list of object types and their fields consult Labelbox Object Types.

Bulk DataRow Creation

DataRows can be added to a Dataset using a bulk-upload. This is typically faster and avoids API limit issues.

The Dataset.create_data_rows method accepts a list of items. For exact info on how items items should be formatted, consult the Python client API documentation.

Bulk DataRow creation is asynchronous. This means that your code continues before the bulk creation is fully finished on the server side. You can (but don't have to) wait for bulk creation to finish before continuing with other tasks (or even terminating the client Python process).

>>> task = dataset.create_data_rows([{DataRow.row_data: "http://site/image.jpg"}, "path/to/local/file.png"])
>>> task.wait_till_done()


How did we do?