Skip to content

Commit

Permalink
deprecate model wrappers mechanism
Browse files Browse the repository at this point in the history
Signed-off-by: Igor Davidyuk <igor.davidyuk@intel.com>
  • Loading branch information
igor-davidyuk committed Apr 24, 2024
1 parent d8dbaa5 commit dca0ca1
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 43 deletions.
41 changes: 0 additions & 41 deletions geti_sdk/deployment/deployed_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@
# See the License for the specific language governing permissions
# and limitations under the License.

import importlib.util
import json
import logging
import os
import shutil
import sys
import tempfile
import time
import zipfile
Expand Down Expand Up @@ -51,7 +49,6 @@

MODEL_DIR_NAME = "model"
PYTHON_DIR_NAME = "python"
WRAPPER_DIR_NAME = "model_wrappers"
REQUIREMENTS_FILE_NAME = "requirements.txt"

LABELS_CONFIG_KEY = "labels"
Expand Down Expand Up @@ -87,7 +84,6 @@ def __attrs_post_init__(self):
self._model_python_path: Optional[str] = None
self._needs_tempdir_deletion: bool = False
self._tempdir_path: Optional[str] = None
self._has_custom_model_wrappers: bool = False
self._label_schema: Optional[LabelSchema] = None

# Attributes related to model explainability
Expand Down Expand Up @@ -143,9 +139,6 @@ def get_data(self, source: Union[str, os.PathLike, GetiSession]):
self._model_data_path = os.path.join(temp_dir, MODEL_DIR_NAME)
self._model_python_path = os.path.join(temp_dir, PYTHON_DIR_NAME)

# Check if the model includes custom model wrappers
if WRAPPER_DIR_NAME in os.listdir(self._model_python_path):
self._has_custom_model_wrappers = True
self.get_data(temp_dir)

elif os.path.isdir(source):
Expand All @@ -166,19 +159,6 @@ def get_data(self, source: Union[str, os.PathLike, GetiSession]):
f"file 'model.xml' and weights file 'model.bin' were not found "
f"at the path specified. "
)
if PYTHON_DIR_NAME in source_contents:
model_python_path = os.path.join(source, PYTHON_DIR_NAME)
else:
model_python_path = os.path.join(
os.path.dirname(source), PYTHON_DIR_NAME
)
python_dir_contents = (
os.listdir(model_python_path)
if os.path.exists(model_python_path)
else []
)
if WRAPPER_DIR_NAME in python_dir_contents:
self._has_custom_model_wrappers = True

self._model_python_path = os.path.join(source, PYTHON_DIR_NAME)

Expand Down Expand Up @@ -288,27 +268,6 @@ def load_inference_model(
)
self._parse_label_schema_from_dict(label_dictionary)

# Create model wrapper with the loaded configuration
# First, add custom wrapper (if any) to path so that we can find it
if self._has_custom_model_wrappers:
wrapper_module_path = os.path.join(
self._model_python_path, WRAPPER_DIR_NAME
)
module_name = WRAPPER_DIR_NAME + "." + model_type.lower().replace(" ", "-")
try:
spec = importlib.util.spec_from_file_location(
module_name, os.path.join(wrapper_module_path, "__init__.py")
)
module = importlib.util.module_from_spec(spec)
sys.modules[module_name] = module
spec.loader.exec_module(module)
except ImportError as ex:
raise ImportError(
f"Unable to load inference model for {self}. A custom model wrapper"
f"is required, but could not be found at path "
f"{wrapper_module_path}."
) from ex

model = model_api_Model.create_model(
model=model_adapter,
model_type=model_type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
- `RotatedRectToPredictionConverter` - class for converting rotated detection results to internal Prediction entities
- `SegmentationToPredictionConverter` - class for converting segmentation results to internal Prediction entities
- `LegacyConverter` - OTX based universal converter for models generated with Geti v1.8 and OTX 1.4
- `ConverterFactory` - factory class for creating the appropriate converter based on the domain of the inference results
"""

Expand Down

0 comments on commit dca0ca1

Please sign in to comment.