Infer Module

The infer module contains the classes and function related to inference.

Notebook

The Notebook class has the following attributes:
  • notebook_id: str

  • name: str

  • content: str

To get the notebook using notebook_id can use the Notebook.from_notebook_id() function:

Notebook.from_notebook_id(notebook_id, client)

Return the notebook object from the notebook_id.

Parameters:
  • notebook_id (str) – notebook_id of the user.

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

Returns:

Notebook object

Return type:

Notebook

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:
  • name: str

  • parent_folder_id: str

  • ancestor_folder_id: List[str]

  • description: 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 the folder_id, project_id and from from_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

Video

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

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

  • project_id:str

  • input_url: str

  • parent_folder_id: str

  • ancestor_folder_ids: List[str]

  • video_urls: urls of the video, contains url along with resolution, extensopn, fps and file_size

  • video_fps: float

  • duration: float

  • title: str

  • vtt_url: str

  • vtt_type: enum (DEFAULT, AUTO, GCP)

It also contains a property video_url which 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.

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', title=None, vtt_url=None, vtt_type=None)

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.

Returns:

Video object

Return type:

Video

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

Video.update(video_id, client, title=None, vtt_url=None, vtt_type=None)

Update a video.

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

  • data (dict) – dictionary of the data to be updated.

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

Returns:

Video object

Return type:

Video

The videos can be fetched using video_id, folder_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 folder_id use the Video.from_folder_id() function:

Video.from_folder_id(folder_id, client)

Return the video object from the folder_id.

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

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

Returns:

List of Video object

Return type:

List

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

Video Detection

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

  • probability: float

  • time: float

  • type: Enum (BOUNDING_BOX, POLYGON, CLASSIFICATION)

  • label: str

  • sequence: Sequence

  • bounding_box: BoundingBox

  • polygon: Polygon

  • sub_class: List[str]

  • is_deleted:bool

  • is_edited:bool

The detections can be fetched using detection_id, video_task_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_task_id use the Detection.from_video_task_id() function:

Detection.from_video_task_id(video_task_id, client)

Return the detection object from the video_task_id.

Parameters:
  • video_task_id (str) – video_task_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

  • video: {title, video_id}

  • graph_id: str

  • project_id: str

  • graph_node: {name, graph_node_id}

  • is_shown: bool

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

  • progress: int

  • init_time_points: List[{start_time, end_time}]

  • final_time_points: List[{start_time, end_time}]

  • name: str

It has a porperty detections which is used to fetch all the detections of the video_task.

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

There are different functions to insert the detections in db and s3. The insert_detections function is used to insert the detections in db and insert_detections_to_s3 is used to insert the detections in s3. is used to insert the detection in s3. Given detections, this API saves the {videoTaskId}_results.json to S3 insert_detections is only called for tasks with isShown=True to avoid filling up the db.So, S3 provides previous node detections for all the nodes, not DB. For previous nodes in the graph, the detections would have been pushed to s3 using the self.inset_detection_to_s3 here. The function get_prev_node_detections_from_s3 return list of all results.json presigned urls for previous node data.

VideoGraphs

The VideoGraph class has the following attributes:
  • video_graph_id: str

  • video: {title, video_id}

  • graph_id: str

  • project_id: str

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

  • progress: int

  • mode: enum (PROD, TEST)

  • annotated_video: {status, url, error_label, error_task, download_count}

It has a property video_tasks which fetches all the video tasks of the video graph.

To create a video graph use the VideoGraph.create() function:

VideoGraph.create(video_id, graph_id, mode, client)

Create a video graph.

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

  • graph_id (str) – graph_id of the graph.

  • mode (enum) – mode of the video graph.

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

Returns:

VideoGraph object

Return type:

VideoGraph

The video graphs can be fetched using video_graph_id, video_id and search_params.

To fetch the video_graph using video_graph_id use the VideoGraph.from_video_graph_id() function:

VideoGraph.from_video_graph_id(video_graph_id, client)

Return the video_graph object from the video_graph_id.

Parameters:
  • video_graph_id (str) – video_graph_id of the video_graph.

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

Returns:

VideoGraph object

Return type:

VideoGraph

To fetch the video_graph using video_id use the VideoGraph.from_video_id() function:

VideoGraph.from_video_id(video_id, client)

Return the video_graph object from the video_id.

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

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

Returns:

List of VideoGraph object

Return type:

List

To fetch the video_graph using search_params use the VideoGraph.from_search_params() function:

VideoGraph.from_search_params(params, client)

Return the video_graph object from the search_params.

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

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

Returns:

List of VideoGraph object

Return type:

List

There is a function to update the status and url of the annotated video.

VideoGraph.update_annotated_video(status, url, client)

Update the annotated video of the video_graph.

Parameters:
  • status (enum) – status of the annotated video.

  • url (str) – url of the annotated video.

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

Returns:

Nothing

Graphs

The Graph class has following attributes:

  • graph_id: str

  • name: str

  • project_id: str

It has a property nodes which fetches all the nodes of the graph and a property edges which fetches all the edges of the graph.

The graph can be fetched using graph_id and search_params.

To fetch the graph using graph_id use the Graph.from_graph_id() function:

Graph.from_graph_id(graph_id, client)

Return the graph object from the graph_id.

Parameters:
  • graph_id (str) – graph_id of the graph.

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

Returns:

Graph object

Return type:

Graph

To fetch the graph using search_params use the Graph.from_search_params() function:

Graph.from_search_params(params, client)

Return the graph object from the search_params.

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

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

Returns:

List of Graph object

Return type:

List

GraphNodes

The GraphNode class has the following attributes:

  • graph_node_id: str

  • name: str

  • notebook_id: str

  • type: enum (DLMODEL, SCRIPT, NOTEBOOK, VIDEOWRITE, VIDEO_CONVERSION)

  • dl_model_id: str

  • is_head: bool

  • is_shown: bool

  • graph_id: str

It has a property graph which fetches the graph of the graph node, prev_nodes which fetches all the previous nodes of the graph node and next_nodes which fetches all the next nodes of the graph node and next_nodes which fetches all the next nodes of the graph node.

The graph nodes can be fetched using graph_node_id and search_params.

To fetch the graph_node using graph_node_id use the GraphNode.from_graph_node_id() function:

GraphNode.from_graph_node_id(graph_node_id, client)

Return the graph_node object from the graph_node_id.

Parameters:
  • graph_node_id (str) – graph_node_id of the graph_node.

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

Returns:

GraphNode object

Return type:

GraphNode

To fetch the graph_node using search_params use the GraphNode.from_search_params() function:

GraphNode.from_search_params(params, client)

Return the graph_node object from the search_params.

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

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

Returns:

List of GraphNode object

Return type:

List

GraphEdges

The GraphEdge class has the following attributes:

  • graph_id: str

  • graph_edge_id: str

  • src_graph_node_id: str

  • target_graph_node_id: str

The graph edges can be fetched using graph_edge_id, target_node_id, src_node_id and search_params.

To fetch the graph_edge using graph_edge_id use the GraphEdge.from_graph_edge_id() function:

GraphEdge.from_graph_edge_id(graph_edge_id, client)

Return the graph_edge object from the graph_edge_id.

Parameters:
  • graph_edge_id (str) – graph_edge_id of the graph_edge.

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

Returns:

GraphEdge object

Return type:

GraphEdge

To fetch the graph_edge using target_node_id use the GraphEdge.from_target_node_id() function:

GraphEdge.from_target_node_id(target_node_id, client)

Fetch all GraphEdge that point to given target_graph_node_id

Parameters:
  • target_node_id (str) – target_node_id of the graph_edge.

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

Returns:

List of GraphEdge object

Return type:

List

To fetch the graph_edge using src_node_id use the GraphEdge.from_src_node_id() function:

GraphEdge.from_src_node_id(src_node_id, client)

Fetch all GraphEdge that starts from given src_graph_node_id

Parameters:
  • src_node_id (str) – src_node_id of the graph_edge.

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

Returns:

List of GraphEdge object

Return type:

List