Init API for communicating with Supervisely Instance. First, we load environment variables with credentials:
Get your IDs and username from environment
Prepare project for Labeling Job
Function will populate project meta with classes: "kiwi", "lemon", and tags: "size", "origin".
Labeling jobs automation
Step 1. Create and add annotators to the team, before creating Labeling Job
Create accounts for annotators with restrictions.
Note: Creating users requires admin permission.
Labelers will be able to login only after being added to at least one team
Note: Adding users to the Team requires admin permission.
Step 2. Define project and datasets for labeling job
Output:
Output:
Step 3. Create Labeling Jobs
Create labeling job for labeler 1, and assign class lemon to label.
Output:
You can stop Labeling Job if you need. Job will become unavailable for labeler.
Create labeling job for labeler 2, and assign class kiwi to label, and also tags "size" and "origin", with objects and tags limit. You can also specify which images to label by providing images ids.
List all images in dataset and get their IDs. As an example we will select only half of images in the dataset.
Output:
Created Labeling Jobs
Get all labeling jobs in a team
Output:
Labeling Jobs filtering
List of available filters:
created_by_id
assigned_to_id
project_id
dataset_id
Note: filters can be used in various combinations
Get all labeling jobs that were created by user 'my_username'
Note: Getting UserInfo by login requires admin permission.
Output
Get all labeling jobs that were created by user "my_username" and were assigned to labeler 2
Output:
Get all active labeling jobs in a team
Output:
Labeling Jobs Statuses
api.labeling_job.Status.PENDING - labeling job is created, labeler still has not started api.labeling_job.Status.IN_PROGRESS - labeler started, but not finished api.labeling_job.Status.ON_REVIEW - labeler finished his job, reviewer is in progress api.labeling_job.Status.COMPLETED - reviewer completed job api.labeling_job.Status.STOPPED - job was stopped at some stage
Output
Output:
If you want to change Labeling Job status you can use api.labeling_job.set_status() method
Output:
The following methods will wait until labeling job will change status to the given expected status:
Labeler has finished annotating
Reviewer has finished his annotation review
Archive Labeling Job
Archive Labeling job by ID. Data can be retrieved after archiving.
labeler_1 = api.user.get_info_by_login(login='labeler_1')
if labeler_1 is None:
labeler_1 = api.user.create(login='labeler_1', password='11111abc', is_restricted=True)
labeler_2 = api.user.get_info_by_login(login='labeler_2')
if labeler_2 is None:
labeler_2 = api.user.create(login='labeler_2', password='22222abc', is_restricted=True)
if api.user.get_team_role(labeler_1.id, TEAM_ID) is None:
api.user.add_to_team(labeler_1.id, TEAM_ID, api.role.DefaultRole.ANNOTATOR)
if api.user.get_team_role(labeler_2.id, TEAM_ID) is None:
api.user.add_to_team(labeler_2.id, TEAM_ID, api.role.DefaultRole.ANNOTATOR)
created_jobs = api.labeling_job.create(name='labeler1_lemons_task',
dataset_id=datasets[0].id,
user_ids=[labeler_1.id],
readme='annotation manual for fruits in markdown format here (optional)',
description='short description is here (optional)',
classes_to_label=["lemon"])
print(created_jobs)
dataset_images_infos = api.image.get_list(dataset_id=datasets[0].id)
dataset_images_ids = [image_info.id for image_info in dataset_images_infos]
selected_images_ids = dataset_images_ids[:len(dataset_images_ids) // 2]
created_jobs = api.labeling_job.create(
name='labeler2_kiwi_task_with_complex_settings',
dataset_id=datasets[0].id,
user_ids=[labeler_2.id],
readme='annotation manual for fruits in markdown format here (optional)',
description='short description is here (optional)',
classes_to_label=["kiwi"],
objects_limit_per_image=10,
tags_to_label=["size", "origin"],
tags_limit_per_image=20,
images_ids=selected_images_ids
)
print(created_jobs)