|
55 | 55 | from lib.core.enums import ProjectType |
56 | 56 | from lib.core.enums import ClassTypeEnum |
57 | 57 | from lib.core.exceptions import AppException |
58 | | -from lib.core.types import MLModel |
59 | 58 | from lib.core.types import PriorityScoreEntity |
60 | 59 | from lib.core.types import Project |
61 | 60 | from lib.core.pydantic_v1 import ValidationError |
@@ -1923,27 +1922,6 @@ def upload_image_annotations( |
1923 | 1922 | if response.errors and not response.errors == constants.INVALID_JSON_MESSAGE: |
1924 | 1923 | raise AppException(response.errors) |
1925 | 1924 |
|
1926 | | - def download_model(self, model: MLModel, output_dir: Union[str, Path]): |
1927 | | - """Downloads the neural network and related files |
1928 | | - which are the <model_name>.pth/pkl. <model_name>.json, <model_name>.yaml, classes_mapper.json |
1929 | | -
|
1930 | | - :param model: the model that needs to be downloaded |
1931 | | - :type model: dict |
1932 | | -
|
1933 | | - :param output_dir: the directory in which the files will be saved |
1934 | | - :type output_dir: str |
1935 | | -
|
1936 | | - :return: the metadata of the model |
1937 | | - :rtype: dict |
1938 | | - """ |
1939 | | - res = self.controller.models.download( |
1940 | | - model_data=model.dict(), download_path=output_dir |
1941 | | - ) |
1942 | | - if res.errors: |
1943 | | - logger.error("\n".join([str(error) for error in res.errors])) |
1944 | | - else: |
1945 | | - return BaseSerializer(res.data).serialize() |
1946 | | - |
1947 | 1925 | def consensus( |
1948 | 1926 | self, |
1949 | 1927 | project: NotEmptyStr, |
@@ -1983,48 +1961,6 @@ def consensus( |
1983 | 1961 | raise AppException(response.errors) |
1984 | 1962 | return response.data |
1985 | 1963 |
|
1986 | | - def run_prediction( |
1987 | | - self, |
1988 | | - project: Union[NotEmptyStr, dict], |
1989 | | - images_list: List[NotEmptyStr], |
1990 | | - model: Union[NotEmptyStr, dict], |
1991 | | - ): |
1992 | | - """This function runs smart prediction on given list of images from a given project |
1993 | | - using the neural network of your choice |
1994 | | -
|
1995 | | - :param project: the project in which the target images are uploaded. |
1996 | | - :type project: str or dict |
1997 | | -
|
1998 | | - :param images_list: the list of image names on which smart prediction has to be run |
1999 | | - :type images_list: list of str |
2000 | | -
|
2001 | | - :param model: the name of the model that should be used for running smart prediction |
2002 | | - :type model: str or dict |
2003 | | -
|
2004 | | - :return: tuple of two lists, list of images on which the prediction has succeeded and failed respectively |
2005 | | - :rtype: tuple |
2006 | | - """ |
2007 | | - project_name = None |
2008 | | - folder_name = None |
2009 | | - if isinstance(project, dict): |
2010 | | - project_name = project["name"] |
2011 | | - if isinstance(project, str): |
2012 | | - project_name, folder_name = extract_project_folder(project) |
2013 | | - |
2014 | | - model_name = model |
2015 | | - if isinstance(model, dict): |
2016 | | - model_name = model["name"] |
2017 | | - project, folder = self.controller.get_project_folder(project_name, folder_name) |
2018 | | - response = self.controller.models.run_prediction( |
2019 | | - project=project, |
2020 | | - folder=folder, |
2021 | | - items_list=images_list, |
2022 | | - model_name=model_name, |
2023 | | - ) |
2024 | | - if response.errors: |
2025 | | - raise AppException(response.errors) |
2026 | | - return response.data |
2027 | | - |
2028 | 1964 | def upload_image_to_project( |
2029 | 1965 | self, |
2030 | 1966 | project: NotEmptyStr, |
@@ -2073,49 +2009,6 @@ def upload_image_to_project( |
2073 | 2009 | if response.errors: |
2074 | 2010 | raise AppException(response.errors) |
2075 | 2011 |
|
2076 | | - def search_models( |
2077 | | - self, |
2078 | | - name: Optional[NotEmptyStr] = None, |
2079 | | - type_: Optional[NotEmptyStr] = None, # noqa |
2080 | | - project_id: Optional[int] = None, |
2081 | | - task: Optional[NotEmptyStr] = None, |
2082 | | - include_global: Optional[bool] = True, |
2083 | | - ): |
2084 | | - r"""Search for ML models. |
2085 | | -
|
2086 | | - :param name: search string |
2087 | | - :type name: str |
2088 | | -
|
2089 | | - :param type\_: ml model type string |
2090 | | - :type type\_: str |
2091 | | -
|
2092 | | - :param project_id: project id |
2093 | | - :type project_id: int |
2094 | | -
|
2095 | | - :param task: training task |
2096 | | - :type task: str |
2097 | | -
|
2098 | | - :param include_global: include global ml models |
2099 | | - :type include_global: bool |
2100 | | -
|
2101 | | - :return: ml model metadata |
2102 | | - :rtype: list of dicts |
2103 | | - """ |
2104 | | - condition = EmptyCondition() |
2105 | | - if name: |
2106 | | - condition &= Condition("name", name, EQ) |
2107 | | - if type_: |
2108 | | - condition &= Condition("type", type_, EQ) |
2109 | | - if project_id: |
2110 | | - condition &= Condition("project_id", project_id, EQ) |
2111 | | - if task: |
2112 | | - condition &= Condition("task", task, EQ) |
2113 | | - if include_global: |
2114 | | - condition &= Condition("include_global", include_global, EQ) |
2115 | | - |
2116 | | - res = self.controller.models.list(condition) |
2117 | | - return res.data |
2118 | | - |
2119 | 2012 | def upload_images_to_project( |
2120 | 2013 | self, |
2121 | 2014 | project: NotEmptyStr, |
|
0 commit comments