Client
Create a project
When creating a project, specify amedia_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 eitherglobal_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
Theproject.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 DataRow
objects 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 theproject.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 attributeaccess_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 theDataRow
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
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
Withproject.get_overview(details)
you can obtain some of the data from the Project Overview tab.
Output
The boolean parameterdetails
will change the output to display the distribution of data rows between the queues.
When details
is to false:
Attribute | Description | Name in the Overview tab |
---|---|---|
to_label | Number of data rows that are yet to be labeled | To Label |
in_review | Number of data rows to be reviewed | In Review |
in_rework | Number of data rows to be reworked | In Rework |
skipped | Number of skipped data rows | Skipped |
done | Number of data rows marked as Done | Done |
issues | Number of data rows with associated issues | Issues |
labeled | Number of data rows with one or more labels | - |
total_data_rows | Total number of data rows in the project | - |
details
is set to true, the output will be the same as before, except for the following:
Attribute | Description |
---|---|
in_review | data : List of task queues in review with the associated number of data rowstotal : Number of data rows to be reviewed |
in_rework | data : List of task queues in rework with the associated number of data rowstotal : Number of data rows to be reworked |
Equivalences
The following are equal:Attribute | Sum of attributes |
---|---|
overview.labeled | overview.in_review + overview.in_rework + overview.done |
overview.total_data_rows | overview.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
TheMALPredictionImport.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
Useproject.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
Useproject.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 theclient.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, asource_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
-
Defaults to
-
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.
-
param batch_priority
- The priority of the batch.