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: .. py:function:: Notebook.from_notebook_id(notebook_id, client) Return the notebook object from the notebook_id. :param notebook_id: notebook_id of the user. :param client: token of the user. :type notebook_id: str :type client: deeplabel.client.BaseClient :return: Notebook object :rtype: 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: .. py:function:: Folder.create(name,project_id, client,type, description, parent_folder_id="project") Create a folder. :param name: name of the folder. :param project_id: project_id in which folder is created. :param parent_folder_id: parent folder id of the folder. :param type: type of the folder. :param description: description of the folder. :param client: token of the user. :type name: str :type project_id: str :type parent_folder_id: str :type type: enum :type description: str :type client: deeplabel.client.BaseClient :return: Folder object :rtype: Folder We can fetch the folder using the folder_id, project_id and from from_search_params. Using the ``Folder.from_folder_id()`` function: .. py:function:: Folder.from_folder_id(folder_id, client) Return the folder object from the folder_id. :param folder_id: folder_id :param client: token of the user. :type folder_id: str :type client: deeplabel.client.BaseClient :return: Folder object :rtype: Folder Using the ``Folder.from_project_id()`` function: .. py:function:: Folder.from_project_id(project_id, client) Return the folder object from the project_id. :param project_id: project_id of the folder. :param client: token of the user. :type project_id: str :type client: deeplabel.client.BaseClient :return: List of Folder object :rtype: List Using the ``Folder.from_search_params()`` function: .. py:function:: Folder.from_search_params(params, client) Return the folder object from the search_params. :param params: search_params for the folder. :param client: token of the user. :type params: dict :type client: deeplabel.client.BaseClient :return: List of Folder object :rtype: 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: .. py:function:: Video.create(input_url, project_id, client, parent_folder_id="project", title=None, vtt_url=None, vtt_type=None) Create a video. :param input_url: url of the video. :param project_id: project_id in which video is created. :param parent_folder_id: parent folder id of the video. :param client: token of the user. :type input_url: str :type project_id: str :type parent_folder_id: str :type client: deeplabel.client.BaseClient :return: Video object :rtype: Video To update a video use the ``Video.update()`` function: .. py:function:: Video.update(video_id, client, title=None, vtt_url=None, vtt_type=None) Update a video. :param video_id: video_id of the video. :param data: dictionary of the data to be updated. :param client: token of the user. :type video_id: str :type data: dict :type client: deeplabel.client.BaseClient :return: Video object :rtype: 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: .. py:function:: Video.from_video_id(video_id, client) Return the video object from the video_id. :param video_id: video_id of the video. :param client: token of the user. :type video_id: str :type client: deeplabel.client.BaseClient :return: Video object :rtype: Video To fetch the video using folder_id use the ``Video.from_folder_id()`` function: .. py:function:: Video.from_folder_id(folder_id, client) Return the video object from the folder_id. :param folder_id: folder_id of the video. :param client: token of the user. :type folder_id: str :type client: deeplabel.client.BaseClient :return: List of Video object :rtype: List To fetch the video using search_params use the ``Video.from_search_params()`` function: .. py:function:: Video.from_search_params(params, client) Return the video object from the search_params. :param params: search_params for the video. :param client: token of the user. :type params: dict :type client: deeplabel.client.BaseClient :return: List of Video object :rtype: 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: .. py:function:: Detection.from_detection_id(detection_id, client) Return the detection object from the detection_id. :param detection_id: detection_id of the detection. :param client: token of the user. :type detection_id: str :type client: deeplabel.client.BaseClient :return: Detection object :rtype: Detection To fetch the detection using video_task_id use the ``Detection.from_video_task_id()`` function: .. py:function:: Detection.from_video_task_id(video_task_id, client) Return the detection object from the video_task_id. :param video_task_id: video_task_id of the detection. :param client: token of the user. :type video_task_id: str :type client: deeplabel.client.BaseClient :return: List of Detection object :rtype: List To fetch the detection using search_params use the ``Detection.from_search_params()`` function: .. py:function:: Detection.from_search_params(params, client) Return the detection object from the search_params. :param params: search_params for the detection. :param client: token of the user. :type params: dict :type client: deeplabel.client.BaseClient :return: List of Detection object :rtype: 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: .. py:function:: VideoTask.from_video_task_id(video_task_id, client) Return the video_task object from the video_task_id. :param video_task_id: video_task_id of the video_task. :param client: token of the user. :type video_task_id: str :type client: deeplabel.client.BaseClient :return: VideoTask object :rtype: VideoTask To fetch the video_task using video_id use the ``VideoTask.from_video_id()`` function: .. py:function:: VideoTask.from_video_id(video_id, client) Return the video_task object from the video_id. :param video_id: video_id of the video_task. :param client: token of the user. :type video_id: str :type client: deeplabel.client.BaseClient :return: List of VideoTask object :rtype: List To fetch the video_task using search_params use the ``VideoTask.from_search_params()`` function: .. py:function:: VideoTask.from_search_params(params, client) Return the video_task object from the search_params. :param params: search_params for the video_task. :param client: token of the user. :type params: dict :type client: deeplabel.client.BaseClient :return: List of VideoTask object :rtype: 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: .. py:function:: VideoGraph.create(video_id, graph_id, mode, client) Create a video graph. :param video_id: video_id of the video. :param graph_id: graph_id of the graph. :param mode: mode of the video graph. :param client: token of the user. :type video_id: str :type graph_id: str :type project_id: str :type mode: enum :type client: deeplabel.client.BaseClient :return: VideoGraph object :rtype: 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: .. py:function:: VideoGraph.from_video_graph_id(video_graph_id, client) Return the video_graph object from the video_graph_id. :param video_graph_id: video_graph_id of the video_graph. :param client: token of the user. :type video_graph_id: str :type client: deeplabel.client.BaseClient :return: VideoGraph object :rtype: VideoGraph To fetch the video_graph using video_id use the ``VideoGraph.from_video_id()`` function: .. py:function:: VideoGraph.from_video_id(video_id, client) Return the video_graph object from the video_id. :param video_id: video_id of the video_graph. :param client: token of the user. :type video_id: str :type client: deeplabel.client.BaseClient :return: List of VideoGraph object :rtype: List To fetch the video_graph using search_params use the ``VideoGraph.from_search_params()`` function: .. py:function:: VideoGraph.from_search_params(params, client) Return the video_graph object from the search_params. :param params: search_params for the video_graph. :param client: token of the user. :type params: dict :type client: deeplabel.client.BaseClient :return: List of VideoGraph object :rtype: List There is a function to update the status and url of the annotated video. .. py:function:: VideoGraph.update_annotated_video(status, url, client) Update the annotated video of the video_graph. :param status: status of the annotated video. :param url: url of the annotated video. :param client: token of the user. :type status: enum :type url: str :type client: deeplabel.client.BaseClient :return: Nothing Gallery ----------------- The Gallery class consists of the following attributes: - gallery_id: str - project_id: str - title: str - parent_folder_id: str It has a property images which fetches all the images present in the gallery. And the gallery_tasks property is used to fetch the gallery tasks. Gallery can be fetched using gallery_id, folder_id and search_params. To create a gallery use the ``Gallery.create()`` function: .. py:function:: Gallery.create(project_id, title, client) Create a gallery. :param project_id: project_id in which gallery is created. :param title: name of the gallery. :param client: token of the user. :type project_id: str :type title: str :type client: deeplabel.client.BaseClient :return: Gallery object :rtype: Gallery To fetch the gallery using gallery_id use the ``Gallery.from_gallery_id()`` function: .. py:function:: Gallery.from_gallery_id(gallery_id, client) Return the gallery object from the gallery_id. :param gallery_id: gallery_id of the gallery. :param client: token of the user. :type gallery_id: str :type client: deeplabel.client.BaseClient :return: Gallery object :rtype: Gallery To fetch the gallery using folder_id use the ``Gallery.from_folder_id()`` function: .. py:function:: Gallery.from_folder_id(folder_id, client) Return the gallery object from the folder_id. :param folder_id: folder_id of the gallery. :param client: token of the user. :type folder_id: str :type client: deeplabel.client.BaseClient :return: List of Gallery object :rtype: List To fetch the gallery using search_params use the ``Gallery.from_search_params()`` function: .. py:function:: Gallery.from_search_params(params, client) Return the gallery object from the search_params. :param params: search_params for the gallery. :param client: token of the user. :type params: dict :type client: deeplabel.client.BaseClient :return: List of Gallery object :rtype: List Gallery Detection ^^^^^^^^^^^^^^^^^^^^ The Detection class consists of the following attributes: - gallery_task_id: str - image_id: str - gallery_id: str - probability: float - graph_node_id: str - type: Enum (IMAGE_BOUNDING_BOX, IMAGE_POLYGON, IMAGE_CLASSIFICATION) - label: str - sequence: Sequence - bounding_box: BoundingBox - polygon: Polygon - sub_class: List[str] The gallery detections can fetched using detection_id, gallery_task_id and search_params. To fetch the detection using detection_id use the ``Detection.from_detection_id()`` function: .. py:function:: Detection.from_detection_id(detection_id, client) Return the detection object from the detection_id. :param detection_id: detection_id of the detection. :param client: token of the user. :type detection_id: str :type client: deeplabel.client.BaseClient :return: Detection object :rtype: Detection To fetch the detection using gallery_task_id use the ``Detection.from_gallery_task_id()`` function: .. py:function:: Detection.from_gallery_task_id(gallery_task_id, client) Return the detection object from the gallery_task_id. :param gallery_task_id: gallery_task_id of the detection. :param client: token of the user. :type gallery_task_id: str :type client: deeplabel.client.BaseClient :return: List of Detection object :rtype: List To fetch the detection using search_params use the ``Detection.from_search_params()`` function: .. py:function:: Detection.from_search_params(params, client) Return the detection object from the search_params. :param params: search_params for the detection. :param client: token of the user. :type params: dict :type client: deeplabel.client.BaseClient :return: List of Detection object :rtype: List GalleryTask ^^^^^^^^^^^^^^^^^^^^ The GalleryTask class consists of the following attributes: - gallery_task_id: str - gallery: {title, gallery_id} - graph_id: str - project_id: str - graph_node: {name, graph_node_id} - is_shown: bool - status: enum (TBD, IN_PROGRESS, SUCCESS, ABORTED, FAILURE, NOT_AVAILABLE) - progress: int - name: str It has a property detections which fetches all the detections of the gallery_task. Gallery Tasks can be fetched from gallery_task_id, gallery_id and search_params. To fetch the gallery_task using gallery_task_id use the ``GalleryTask.from_gallery_task_id()`` function: .. py:function:: GalleryTask.from_gallery_task_id(gallery_task_id, client) Return the gallery_task object from the gallery_task_id. :param gallery_task_id: gallery_task_id of the gallery_task. :param client: token of the user. :type gallery_task_id: str :type client: deeplabel.client.BaseClient :return: GalleryTask object :rtype: GalleryTask To fetch the gallery_task using gallery_id use the ``GalleryTask.from_gallery_id()`` function: .. py:function:: GalleryTask.from_gallery_id(gallery_id, client) Return the gallery_task object from the gallery_id. :param gallery_id: gallery_id of the gallery_task. :param client: token of the user. :type gallery_id: str :type client: deeplabel.client.BaseClient :return: List of GalleryTask object :rtype: List To fetch the gallery_task using search_params use the ``GalleryTask.from_search_params()`` function: .. py:function:: GalleryTask.from_search_params(params, client) Return the gallery_task object from the search_params. :param params: search_params for the gallery_task. :param client: token of the user. :type params: dict :type client: deeplabel.client.BaseClient :return: List of GalleryTask object :rtype: List The gallery tasks also has function insert_detections, insert_detections_to_s3 and get_prev_node_detections_from_s3 which are similar to the video tasks. GalleryGraphs ^^^^^^^^^^^^^^^^^^^^ The GalleryGraph class consists of the following attributes: - gallery_graph_id: str - gallery: {title, gallery_id} - graph_id: str - project_id: str - status: enum (TBD, IN_PROGRESS, SUCCESS, ABORTED, FAILURE, CANCELLED, RETRY) - progress: int - mode: enum (PROD, TEST) - annotated_gallery: {status, url, error_label, error_task, download_count} It has a property gallery_tasks which fetches all the gallery tasks of the gallery graph. To create a gallery graph use the ``GalleryGraph.create()`` function: .. py:function:: GalleryGraph.create(gallery_id, graph_id, mode, client) Create a gallery graph. :param gallery_id: gallery_id of the gallery. :param graph_id: graph_id of the graph. :param mode: mode of the gallery graph. :param client: token of the user. :type gallery_id: str :type graph_id: str :type project_id: str :type mode: enum :type client: deeplabel.client.BaseClient :return: GalleryGraph object :rtype: GalleryGraph The gallery graphs can be fetched using gallery_graph_id, gallery_id and search_params. To fetch the gallery_graph using gallery_graph_id use the ``GalleryGraph.from_gallery_graph_id()`` function: .. py:function:: GalleryGraph.from_gallery_graph_id(gallery_graph_id, client) Return the gallery_graph object from the gallery_graph_id. :param gallery_graph_id: gallery_graph_id of the gallery_graph. :param client: token of the user. :type gallery_graph_id: str :type client: deeplabel.client.BaseClient :return: GalleryGraph object :rtype: GalleryGraph To fetch the gallery_graph using gallery_id use the ``GalleryGraph.from_gallery_id()`` function: .. py:function:: GalleryGraph.from_gallery_id(gallery_id, client) Return the gallery_graph object from the gallery_id. :param gallery_id: gallery_id of the gallery_graph. :param client: token of the user. :type gallery_id: str :type client: deeplabel.client.BaseClient :return: List of GalleryGraph object :rtype: List To fetch the gallery_graph using search_params use the ``GalleryGraph.from_search_params()`` function: .. py:function:: GalleryGraph.from_search_params(params, client) Return the gallery_graph object from the search_params. :param params: search_params for the gallery_graph. :param client: token of the user. :type params: dict :type client: deeplabel.client.BaseClient :return: List of GalleryGraph object :rtype: List There is a function to update the status and url of the annotated gallery. .. py:function:: GalleryGraph.update_annotated_gallery(status, url, client) Update the annotated gallery of the gallery_graph. :param status: status of the annotated gallery. :param url: url of the annotated gallery. :param client: token of the user. :type status: enum :type url: str :type client: deeplabel.client.BaseClient :return: Nothing Images ^^^^^^^^^^^^^^^^^^^^ The Image class consists of the following attributes: - image_id: str - gallery_id: str - image_url: str - project_id: str - name: str - annotation_url: str - parent_folder_id: str - resolution: {height, width} It has a property(download_annotations) to download the annotation to a file. To create a image use the ``Image.create()`` function: .. py:function:: Image.create(image_url, gallery_id, project_id, name, height, width, client) Create a image. :param gallery_id: gallery_id in which image is created. :param image_url: url of the image. :param project_id: project_id in which image is created. :param client: token of the user. :param name: name of the image. :param height: height of the image. :param width: width of the image. :type gallery_id: str :type image_url: str :type project_id: str :type client: deeplabel.client.BaseClient :type name: str :type height: int :type width: int :return: Image object :rtype: Image The images can be fetched using image_id, gallery_and_project_id and search_params. To fetch the image using image_id use the ``Image.from_image_id()`` function: .. py:function:: Image.from_image_id(image_id, client) Return the image object from the image_id. :param image_id: image_id of the image. :param client: token of the user. :type image_id: str :type client: deeplabel.client.BaseClient :return: Image object :rtype: Image To fetch the image using gallery_and_project_id use the ``Image.from_gallery_and_project_id()`` function: .. py:function:: Image.from_gallery_and_project_id(gallery_id, project_id, client) Return the image object from the gallery_and_project_id. :param gallery_id: gallery_id of the image. :param project_id: project_id of the image. :param client: token of the user. :type gallery_id: str :type project_id: str :type client: deeplabel.client.BaseClient :return: List of Image object :rtype: List To fetch the image using search_params use the ``Image.from_search_params()`` function: .. py:function:: Image.from_search_params(params, client) Return the image object from the search_params. :param params: search_params for the image. :param client: token of the user. :type params: dict :type client: deeplabel.client.BaseClient :return: List of Image object :rtype: List 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: .. py:function:: Graph.from_graph_id(graph_id, client) Return the graph object from the graph_id. :param graph_id: graph_id of the graph. :param client: token of the user. :type graph_id: str :type client: deeplabel.client.BaseClient :return: Graph object :rtype: Graph To fetch the graph using search_params use the ``Graph.from_search_params()`` function: .. py:function:: Graph.from_search_params(params, client) Return the graph object from the search_params. :param params: search_params for the graph. :param client: token of the user. :type params: dict :type client: deeplabel.client.BaseClient :return: List of Graph object :rtype: 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: .. py:function:: GraphNode.from_graph_node_id(graph_node_id, client) Return the graph_node object from the graph_node_id. :param graph_node_id: graph_node_id of the graph_node. :param client: token of the user. :type graph_node_id: str :type client: deeplabel.client.BaseClient :return: GraphNode object :rtype: GraphNode To fetch the graph_node using search_params use the ``GraphNode.from_search_params()`` function: .. py:function:: GraphNode.from_search_params(params, client) Return the graph_node object from the search_params. :param params: search_params for the graph_node. :param client: token of the user. :type params: dict :type client: deeplabel.client.BaseClient :return: List of GraphNode object :rtype: 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: .. py:function:: GraphEdge.from_graph_edge_id(graph_edge_id, client) Return the graph_edge object from the graph_edge_id. :param graph_edge_id: graph_edge_id of the graph_edge. :param client: token of the user. :type graph_edge_id: str :type client: deeplabel.client.BaseClient :return: GraphEdge object :rtype: GraphEdge To fetch the graph_edge using target_node_id use the ``GraphEdge.from_target_node_id()`` function: .. py:function:: GraphEdge.from_target_node_id(target_node_id, client) Fetch all GraphEdge that point to given target_graph_node_id :param target_node_id: target_node_id of the graph_edge. :param client: token of the user. :type target_node_id: str :type client: deeplabel.client.BaseClient :return: List of GraphEdge object :rtype: List To fetch the graph_edge using src_node_id use the ``GraphEdge.from_src_node_id()`` function: .. py:function:: GraphEdge.from_src_node_id(src_node_id, client) Fetch all GraphEdge that starts from given src_graph_node_id :param src_node_id: src_node_id of the graph_edge. :param client: token of the user. :type src_node_id: str :type client: deeplabel.client.BaseClient :return: List of GraphEdge object :rtype: List