Label Module

The label module contains the classes and function related to labelling.

DetectionLabel

The DetectionLabel class is used to store the information of a label. It contains the following attributes:
  • color: str

  • name: str

  • type: enum (OBJECT, ACTION)

  • category: enum (DETECTION, CLASSIFICATION)

  • id: str

  • label_id: str

  • is_deleted: bool

To create a DetectionLabel object, you can use the DetectionLabel.create() function:

DetectionLabel.create(name, type, category, description, client, color)

Create a DetectionLabel

Parameters:
  • name (str) – name of the label

  • type (enum (OBJECT, ACTION)) – type of the label

  • category (enum (DETECTION, CLASSIFICATION)) – category of the label

  • description (str) – description of the label

  • client (deeplabel.client.BaseClient) – token of the user.

  • color (str) – color of the label

Returns:

DetectionLabel object

Return type:

DetectionLabel

The labels can be retrieved using the DetectionLabel.from_search_params() function:

DetectionLabel.from_search_params(params, client)

Retrieve a list of DetectionLabel objects

Parameters:
  • params – search parameters

  • client (deeplabel.client.BaseClient) – token of the user.

Returns:

list of DetectionLabel objects

Return type:

list of DetectionLabel

LabelMap

The LabelMap class is used to store the information of detection label. It contains the following attributes:
  • label_id: str

  • label: DetectionLabel

  • name_lower: str

  • project_id: str

To add labels to a project, we can use the LabelMap.add_labels_to_project() function:

LabelMap.add_labels_to_project(project_id, label_ids, client)

Add labels to a project

Parameters:
  • project_id (str) – id of the project

  • label_ids (list of str) – list of label ids

  • client (deeplabel.client.BaseClient) – token of the user.

Returns:

list of LabelMap objects

Return type:

list of LabelMap

To get the label maps we can use the LabelMap.from_search_params() function:

LabelMap.from_search_params(params, client)

Retrieve a list of LabelMap objects

Parameters:
  • params – search parameters

  • client (deeplabel.client.BaseClient) – token of the user.

Returns:

list of LabelMap objects

Return type:

list of LabelMap

Folder

The folders in deeplabel can be of type VIDEO and GALLERY. In deeplabel-sdk, we have a root folder (RootFolder) which has attributes:
  • folder_id: str

  • type: enum

  • project_id: str

The root folder also has properties:
  • folders: list of Folder objects

  • videos: list of Video objects

  • galleries: list of Gallery objects

There is a Folder class which inherits from RootFolder and has the following attributes:
  • folder_id: str

  • description: str

  • name: str

  • parent_folder_id: str

  • ancestor_folder_id: List[str]

To create a folder use the Folder.create() function:

Folder.create(name, project_id, client, type, description, parent_folder_id='project')

Create a folder.

Parameters:
  • name (str :type project_id: str) – name of the folder.

  • project_id – project_id in which folder is created.

  • parent_folder_id (str) – parent folder id of the folder.

  • type (enum) – type of the folder.

  • description (str) – description of the folder.

  • client (deeplabel.client.BaseClient) – token of the user.

Returns:

Folder object

Return type:

Folder

We can fetch the folder using folder_id, project_id and search_params.

Using the Folder.from_folder_id() function:

Folder.from_folder_id(folder_id, client)

Return the folder object from the folder_id.

Parameters:
  • folder_id (str) – folder_id

  • client (deeplabel.client.BaseClient) – token of the user.

Returns:

Folder object

Return type:

Folder

Using the Folder.from_project_id() function:

Folder.from_project_id(project_id, client)

Return the folder object from the project_id.

Parameters:
  • project_id (str) – project_id of the folder.

  • client (deeplabel.client.BaseClient) – token of the user.

Returns:

List of Folder object

Return type:

List

Using the Folder.from_search_params() function:

Folder.from_search_params(params, client)

Return the folder object from the search_params.

Parameters:
  • params (dict) – search_params for the folder.

  • client (deeplabel.client.BaseClient) – token of the user.

Returns:

List of Folder object

Return type:

List

DlModels

The DlModel class contains the information regarding the DlModel. It has following attributes:

  • dl_model_id: str

  • url: str

  • description: str

  • sequence: SequenceInfo (length, sampling_rate)

  • status:

  • name: str

  • architecture: str

  • category: enum (DETECTION, CLASSIFICATION, ACTION-RECOGNITION)

  • type: enum (OBJECT, ACTION)

It also has different properties:
  • generate_zip_url: Generates the presigned url for the model if the model zip file is present in s3.

  • name: List of labels from the model.names file.

  • name_filter: Get dlmodel labels from model.names.filter or model.names.include file.

The DlModel can be fetched using the dl_model_id and search_params.

Using the DlModel.from_dl_model_id() function:

DlModel.from_dl_model_id(dl_model_id, client)

Return the DlModel object from the dl_model_id.

Parameters:
  • dl_model_id (str) – dl_model_id

  • client (deeplabel.client.BaseClient) – token of the user.

Returns:

DlModel object

Return type:

DlModel

Using the DlModel.from_search_params() function:

DlModel.from_search_params(params, client)

Return the DlModel object from the search_params.

Parameters:
  • params (dict) – search_params for the DlModel.

  • client (deeplabel.client.BaseClient) – token of the user.

Returns:

List of DlModel object

Return type:

List

Video

The video folder in the label of deeplabel-sdk containes all the information related to the labelling of the videos in deeplabel.

The video class has the following attributes:
  • video_id: str

  • title: str

  • project_id:str

  • input_url: str

  • thumbnail_url: str

  • status: The labelling is done in different steps. Each step has its own status. The Differnt stags of labelling are:
    • download

    • assign_resources

    • extraction

    • frames_extraction

    • inference

    • label

    • review

    • labelling

    Each of these steps can have the following status along with start_time and end_time: - TBD - IN_PROGRESS - SUCCESS - FAILURE - CANCELLED - ABORTED - HOLD - RETRY - REDO

  • extraction_points: List of ExtractionPoints (labelling_fps, start_time, end_time)

  • duration: float

  • video_fps: float

  • labelling_fps: int

  • is_feedback: bool

It also contains following properties:
  • video_url: It is used to generate a new presigned url for the video if the current url has expired. We can also fetch all the video_graph and video_task of the video using the property video_graphs and video_tasks respectively.

  • ext: Extenion of the video, deduced from path/name

  • detections: detections of the video

  • frames: frames of the video

  • tasks: tasks of the video

Different methods in the Video class are:

To create a video use the Video.create() function:

Video.create(input_url, project_id, client, parent_folder_id='project', is_feedback=False)

Create a video.

Parameters:
  • input_url (str) – url of the video.

  • project_id (str) – project_id in which video is created.

  • parent_folder_id (str) – parent folder id of the video.

  • client (deeplabel.client.BaseClient) – token of the user. :param is_feedback: Is it a feedback.

Returns:

Video object

Return type:

Video

The videos can be fetched using video_id and search_params.

To fetch the video using video_id use the Video.from_video_id() function:

Video.from_video_id(video_id, client)

Return the video object from the video_id.

Parameters:
  • video_id (str) – video_id of the video.

  • client (deeplabel.client.BaseClient) – token of the user.

Returns:

Video object

Return type:

Video

To fetch the video using search_params use the Video.from_search_params() function:

Video.from_search_params(params, client)

Return the video object from the search_params.

Parameters:
  • params (dict) – search_params for the video.

  • client (deeplabel.client.BaseClient) – token of the user.

Returns:

List of Video object

Return type:

List

We can insert the extraction time points if the video has an extraction task using the Video.set_extraction_points() function:

Video.set_extraction_points(extraction_timepoints, client)

Set the extraction points for the video.

Parameters:
  • extraction_timepoints – extraction_ptimeoints for the video.

  • client (deeplabel.client.BaseClient) – token of the user.

Returns:

Video object

Return type:

Video

Video Detection

Inferred videos detections can be fetched using the Detection class. The Detection class has the following attributes:
  • is_reviewed: bool

  • type: Enum (BOUNDING_BOX, POLYGON, CLASSIFICATION)

  • bounding_box: BoundingBox

  • polygon: Polygon

  • label: DetectionLabel

  • detection_id: str

  • video_id: str

  • frame_id: str

  • sequence_id: str

The detections can be fetched using detection_id, video_id_and_project_id and search_params.

To fetch the detection using detection_id use the Detection.from_detection_id() function:

Detection.from_detection_id(detection_id, client)

Return the detection object from the detection_id.

Parameters:
  • detection_id (str) – detection_id of the detection.

  • client (deeplabel.client.BaseClient) – token of the user.

Returns:

Detection object

Return type:

Detection

To fetch the detection using video_id_and_project_id use the Detection.from_video_id_and_project_id() function:

Detection.from_video_id_and_project_id(video_id, project_id, client)

Return the detection object from the video_id_and_project_id

Parameters:
  • video_id (str) – video_id of the detection.

  • project_id (str) – project_id of the detection.

  • client (deeplabel.client.BaseClient) – token of the user.

Returns:

List of Detection object

Return type:

List

To fetch the detection using search_params use the Detection.from_search_params() function:

Detection.from_search_params(params, client)

Return the detection object from the search_params.

Parameters:
  • params (dict) – search_params for the detection.

  • client (deeplabel.client.BaseClient) – token of the user.

Returns:

List of Detection object

Return type:

List

VideoTask

The VideoTask class has the following attributes:
  • video_task_id: str

  • timestamp: {created_at, modified_at}

  • video: {title, video_id}

  • project: {title, project_id}

  • status: enum (TBD, IN_PROGRESS, SUCCESS, ABORTED, FAILURE)

  • assignee: {name, user_id}

  • is_deleted: bool

  • name: str

Video Tasks can be fetched from video_task_id, video_id and search_params.

To fetch the video_task using video_task_id use the VideoTask.from_video_task_id() function:

VideoTask.from_video_task_id(video_task_id, client)

Return the video_task object from the video_task_id.

Parameters:
  • video_task_id (str) – video_task_id of the video_task.

  • client (deeplabel.client.BaseClient) – token of the user.

Returns:

VideoTask object

Return type:

VideoTask

To fetch the video_task using video_id use the VideoTask.from_video_id() function:

VideoTask.from_video_id(video_id, client)

Return the video_task object from the video_id.

Parameters:
  • video_id (str) – video_id of the video_task.

  • client (deeplabel.client.BaseClient) – token of the user.

Returns:

List of VideoTask object

Return type:

List

To fetch the video_task using search_params use the VideoTask.from_search_params() function:

VideoTask.from_search_params(params, client)

Return the video_task object from the search_params.

Parameters:
  • params (dict) – search_params for the video_task.

  • client (deeplabel.client.BaseClient) – token of the user.

Returns:

List of VideoTask object

Return type:

List

To update the status of the video_task use the VideoTask.update_status() function:

VideoTask.update_status(status, client)

Update the status of the video_task.

Parameters:
  • status (enum) – status of the video_task.

  • client (deeplabel.client.BaseClient) – token of the user.

Returns:

VideoTask object

Return type:

VideoTask

Video Frame

The frame class has the following attributes:
  • displayed: bool

  • review_comment: str

  • name: str

  • number: int

  • is_deleted: bool

  • parent_folder_id: str

  • resolution: {width, height}

  • frame_id: str

  • video_id: str

  • frame_url: str

  • frame_number: int

  • point_in_time: float

  • detections: List of Detection objects

  • assignee: str

The frames can be fetched from frame_id, video_id_and_project_id and search_params.

To fetch the frame using frame_id use the Frame.from_frame_id() function:

Frame.from_frame_id(frame_id, client)

Return the frame object from the frame_id.

Parameters:
  • frame_id (str) – frame_id of the frame.

  • client (deeplabel.client.BaseClient) – token of the user.

Returns:

Frame object

Return type:

Frame

To fetch the frame using video_id_and_project_id use the Frame.from_video_id_and_project_id() function:

Frame.from_video_id_and_project_id(video_id, project_id, client)

Return the frame object from the video_id_and_project_id

Parameters:
  • video_id (str) – video_id of the frame.

  • project_id (str) – project_id of the frame.

  • client (deeplabel.client.BaseClient) – token of the user.

Returns:

List of Frame object

Return type:

List

To fetch the frame using search_params use the Frame.from_search_params() function:

Frame.from_search_params(params, client)

Return the frame object from the search_params.

Parameters:
  • params (dict) – search_params for the frame.

  • client (deeplabel.client.BaseClient) – token of the user.

Returns:

List of Frame object

Return type:

List