Skip to main content

Open in Colab

GitHub

Client

Create a project

When creating a project, specify a media_type using one of the following values:
  • lb.MediaType.Audio
  • lb.MediaType.Conversational
  • lb.MediaType.Document
  • lb.MediaType.Geospatial_Tile
  • lb.MediaType.Html
  • lb.MediaType.Image
  • lb.MediaType.Simple_Tile
  • lb.MediaType.Text
  • lb.MediaType.Video

Get a project

Methods

Create a batch

When creating a batch to send to a project, one of either global_keys or data_rows must be supplied as an argument. If using the data_rows argument, you can supply either a list of data row IDs or a list of DataRow class objects. Optionally, you can supply a priority, ranging from 1 (highest) to 5 (lowest), for which the batch should be labeled. This will determine the order in which the included data rows appear in the labeling queue compared to other batches. If no value is provided, the batch will assume the lowest priority. For more details, see Batch.

Create multiple batches

The project.create_batches() method accepts up to 1 million data rows. Batches are chunked into groups of 100k data rows (if necessary), which is the maximum batch size. This method takes in a list of either data row IDs or DataRowobjects into a data_rows argument or global keys into a global_keys argument, but both approaches cannot be used in the same method. Batches will be created with the specified name_prefix argument and a unique suffix to ensure unique batch names. The suffix will be a 4-digit number starting at 0000. For example, if the name prefix is demo-create-batches- and three batches are created, the names will be demo-create-batches-0000, demo-create-batches-0001, and demo-create-batches-0002. This method will throw an error if a batch with the same name already exists.

Create batches from a dataset

If you wish to create batches in a project using all the data rows of a dataset, instead of gathering global keys or IDs and iterating over subsets of data rows, you can use the project.create_batches_from_dataset() method. This method takes in a dataset ID and creates a batch (or batches if there are more than 100k data rows) comprised of all data rows not already in the project. The same logic applies to the name_prefix argument and the naming of batches as described in the section immediately above.

Get the batches

Get a batch

You can retrieve the batch of a particular project withclient.get_batch().

Connect an ontology

Get the members and their roles

The scope of a member is provided by the attribute access_from from the class ProjectMember. It can have one of the following values:
  • ORGANIZATION: project membership is derived from the organization role
  • PROJECT_MEMBERSHIP: access is given specifically to the project
  • USER_GROUP: access is given via a group

Upload labeling instructions

Note that if the ontology connected to your project is connected to other projects, calling this method will attach the instructions to those projects as well.

Get the workflow tasks

Move data rows to a workflow task

Note that data rows need labels attached before being moved to a different workflow task. They can not be moved from “Initial Labeling.”

Modify data row priority

Once a batch has been added to a project, you can set the priority of its data rows. To do so, define a list of label parameter overrides (LPOs), which are tuples that set the priority for individual data rows. Each override has three values: an object of the DataRow class or a DataRowIdentifier object, the new priority. All values must be integers that match the range of the list. The priority is an integer between -2,147,483,648 to 2,147,483,647. The lowest value has the highest priority. Override lists are limited to 1,000 items; larger lists trigger an error. Once the override list is defined, pass it to project.set_labeling_parameter_overrides to change the priority of the corresponding data rows. Use project.labeling_parameter_overrides to get a list of data row priorities and project.update_data_row_labeling_priority to update existing data row priority.

Set data row priority

Update data row priority

Add project tags

Get project tags

The tags variable is a list where each element is an object of type ResourceTag with the attributes, uid, color(ex: “008856”) andtext.

Get the project overview

With project.get_overview(details)you can obtain some of the data from the Project Overview tab.

Output

The boolean parameter details will change the output to display the distribution of data rows between the queues. When details is to false:
AttributeDescriptionName in the Overview tab
to_labelNumber of data rows that are yet to be labeledTo Label
in_reviewNumber of data rows to be reviewedIn Review
in_reworkNumber of data rows to be reworkedIn Rework
skippedNumber of skipped data rowsSkipped
doneNumber of data rows marked as DoneDone
issuesNumber of data rows with associated issuesIssues
labeledNumber of data rows with one or more labels-
total_data_rowsTotal number of data rows in the project-
When details is set to true, the output will be the same as before, except for the following:
AttributeDescription
in_reviewdata: List of task queues in review with the associated number of data rows
total: Number of data rows to be reviewed
in_reworkdata: List of task queues in rework with the associated number of data rows
total: Number of data rows to be reworked

Equivalences

The following are equal:
AttributeSum of attributes
overview.labeledoverview.in_review + overview.in_rework + overview.done
overview.total_data_rowsoverview.to_label + overview.in_review + overview.in_rework + overview.done

Example project overview

Manage bulk imports

Use the following methods to manage bulk imports:
  • project.get_mal_prediction_imports() to retrieve the list of MAL import jobs.
  • project.get_label_imports() to to retrieve the list of ground-truth import jobs.
  • MALPredictionImport.delete() to delete a MAL import.

Delete label imports

The MALPredictionImport.delete() method can only delete MAL imports. To delete a ground-truth label, use the Data Rows tab on the web platform. Deleting an import is permanent and can’t be undone.

Export a project

For complete details, see Export overview.

Export issues and comments

Duplicate a project

See the section Duplicate a project for the scope of this method.

Update a project

Delete a project

Deleting a project cannot be undoneThis method deletes the project along with all labels made in the project. This action cannot be reverted.

Attributes

Get the basics

Get the ontology

Get the benchmarks

Get the webhooks

Get data row priority

Use project.labeling_parameter_overrides to get a list of labeling parameter overrides (LPOs), which define the priority for each label in the override list. Use set_labeling_parameter_overrides and update_data_row_labeling_priority to modify data row priority.

Get the number of labels

Use project.get_label_count() to return the sum of labels in the different task queues of a project.

Copy data rows and labels

To copy our data rows and labels to a different project from a source project, use the client.send_to_annotate_from_catalog method with our Labelbox client. Send to Annotate does not currently support consensus projects.

Parameters

When you send data rows with labels to our destination project, you may choose to include or exclude certain parameters inside a Python dictionary, at a minimum, a source_project_id will need to be provided:
  • source_project_id
    • The id of the project where our data rows with labels will originate.
  • annotation_ontology_mapping
    • A dictionary containing the mapping of the source project’s ontology feature schema IDs to the destination project’s ontology feature schema IDs. If left empty, only the data rows with no labels will be sent to our destination project.
    • {"<source_feature_schema_id>" : "<destination_feature_schema_id>"}
  • exclude_data_rows_in_project
    • Excludes data rows that are already in the project.
  • override_existing_annotations_rule
    • The strategy defines how to handle conflicts in classifications between the data rows that already exist in the project and incoming labels from the source project.
      • Defaults to ConflictResolutionStrategy.KeepExisting
      • Options include:
        • ConflictResolutionStrategy.KeepExisting
        • ConflictResolutionStrategy.OverrideWithPredictions
        • ConflictResolutionStrategy.OverrideWithAnnotations
  • param batch_priority
    • The priority of the batch.