Skip to content

Commit

Permalink
Fix openvino import issue
Browse files Browse the repository at this point in the history
Signed-off-by: Samet Akcay <samet.akcay@intel.com>
  • Loading branch information
samet-akcay committed Oct 22, 2024
1 parent 1465b05 commit f7a853b
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/anomalib/deploy/inferencers/openvino_inferencer.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,6 @@

logger = logging.getLogger("anomalib")

if find_spec("openvino") is not None:
import openvino as ov

if TYPE_CHECKING:
from openvino import CompiledModel
else:
logger.warning("OpenVINO is not installed. Please install OpenVINO to use OpenVINOInferencer.")


class OpenVINOInferencer(Inferencer):
"""OpenVINO implementation for the inference.
Expand Down Expand Up @@ -102,6 +94,11 @@ def __init__(
task: str | None = None,
config: dict | None = None,
) -> None:
try:
import openvino as ov
except ImportError:
logger.warning("OpenVINO is not installed. Please install OpenVINO to use OpenVINOInferencer.")
raise
self.device = device

self.config = config
Expand All @@ -121,6 +118,8 @@ def load_model(self, path: str | Path | tuple[bytes, bytes]) -> tuple[Any, Any,
[tuple[str, str, ExecutableNetwork]]: Input and Output blob names
together with the Executable network.
"""
import openvino as ov

core = ov.Core()
# If tuple of bytes is passed
if isinstance(path, tuple):
Expand Down

0 comments on commit f7a853b

Please sign in to comment.