Infer Module =============================== The infer module contains the classes and function related to inference. Folder ----------------- The folders in anonymization can be of type VIDEO and IMAGE. In anonymization-sdk, we have a root folder (RootFolder) which has attributes: - folder_id: str - type: FolderType - owner_id: str **Enum: FolderType** defines the types of folders supported in the SDK. .. code-block:: python class FolderType(Enum): VIDEO = "VIDEO" IMAGE = "IMAGE" The root folder also has properties: - videos: list of Video objects - images: list of Image objects There is a Folder class which inherits from RootFolder and has the following attributes: - name: str - parent_folder_id: Optional[str] - ancestor_folder_ids: List[str] - description: str To create a folder use the ``Folder.create()`` function: .. py:function:: Folder.create(name,owner_id, client,type, description, parent_folder_id="user") Create a folder. :param name: name of the folder. :param owner_id: owner_id by 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: user client. :type name: str :type owner_id: str :type parent_folder_id: str :type type: enum :type description: str :type client: anonymization.client.BaseClient :return: Folder object :rtype: Folder We can fetch the folder using the folder_id, owner_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: user client. :type folder_id: str :type client: anonymization.client.BaseClient :return: Folder object :rtype: Folder Using the ``Folder.from_owner_id()`` function: .. py:function:: Folder.from_owner_id(owner_id, client) Return the folder object from the owner_id. :param owner_id: owner_id of the folder. :param client: user client :type owner_id: str :type client: anonymization.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: user client :type params: dict :type client: anonymization.client.BaseClient :return: List of Folder object :rtype: List Video ----------------- The video folder in the infer of anonymization-sdk containes all the information related to the inferencing of the videos in anonymization. The video class has the following attributes: - video_id: str - input_url: str - owner_id: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) - remove_audio :bool - status: {download, inference} - log_file: str 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 send a video for blurring using propery called blur. Different methods in the Video class are: To create a video use the ``Video.create()`` function: .. py:function:: Video.create(input_url, client, parent_folder_id=None, remove_audio =False, description=None, title=None,) Create a video. :param input_url: url of the video. :param parent_folder_id: parent folder id of the video. :param client: user client :param remove_audio: Flag to remove or keep video audio :param description: description of video :param title: title of video :type input_url: str :type owner_id: str :type parent_folder_id: str :type remove_audio: bool :type description: str :type title: str :type client: anonymization.client.BaseClient :return: VideoId :rtype: str To update a video use the ``Video.update()`` function: .. py:function:: Video.update(video_id, data:Dict, client) Update a video. :param video_id: video_id of the video. :param data: dictionary of the data to be updated. :param client: user client :type video_id: str :type data: dict :type client: anonymization.client.BaseClient :return: VideoId :rtype: str 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: user client :type video_id: str :type client: anonymization.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: user client :type folder_id: str :type client: anonymization.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: user client :type params: dict :type client: anonymization.client.BaseClient :return: List of Video object :rtype: List .. py:property:: Video.infer This property can be used to send a video for inference/blurring. :return: True/False :rtype: bool To update the video satus ``Video.update_status()`` function: .. py:function:: Video.update_status(inference_status: Optional[_InferenceStatus] = None, download_status: Optional[_DownloadStatus] = None) Updates the video download and inference status. :param inference_status: inference status of video :param download_status: download status of video :type inference_status: anonymization.infer.video._InferenceStatus :type download_status: anonymization.infer.video._DownloadStatus :return: Video :rtype: Video Object Images --------------- The Image class consists of the following attributes: - image_id: str - image_url: str - owner_id: str - name: str - inferred_url: str - parent_folder_id: str - ancestor_folder_ids: List[str] - resolution: {height, width} - status: {download, inference} - log_file: str 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, name, height, width, client, parent_folder_id) Create a image. :param image_url: url of the image. :param name: name of the image. :param height: height of the image. :param width: width of the image. :param client: user client :param parent_folder_id: parent folder id of the video. :type image_id: str :type image_url: str :type owner_id: str :type client: anonymization.client.BaseClient :type name: str :type height: int :type width: int :return: Image object :rtype: Image The images can be fetched using image_id, folder_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: user client :type image_id: str :type client: anonymization.client.BaseClient :return: Image object :rtype: Image To fetch the image using gallery_and_owner_id use the ``Image.from_gallery_and_owner_id()`` function: .. py:function:: Image.from_folder_id(folder_id, client) Return the image object in folder. :param folder_id: folder_id of the image. :param client: user client :type folder_id: str :type client: anonymization.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: user client :type params: dict :type client: anonymization.client.BaseClient :return: List of Image object :rtype: List To update the image satus ``Image.update_status()`` function: .. py:function:: Image.update_status(inference_status: Optional[_InferenceStatus] = None, download_status: Optional[_DownloadStatus] = None) Updates the image download and inference status. :param inference_status: inference status of image :param download_status: download status of image :type inference_status: anonymization.infer.images._InferenceStatus :type download_status: anonymization.infer.images._DownloadStatus :return: Image :rtype: Image Object .. py:property:: Image.infer This property can be used to send an image for inference/blurring. :return: True/False :rtype: bool