Harden AI Docker runtime imports
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
@@ -14,7 +13,12 @@ class YoloDetectionAdapter:
|
||||
|
||||
@staticmethod
|
||||
def dependencies_available() -> bool:
|
||||
return importlib.util.find_spec("ultralytics") is not None and importlib.util.find_spec("torch") is not None
|
||||
try:
|
||||
import torch # noqa: F401
|
||||
import ultralytics # noqa: F401
|
||||
except Exception:
|
||||
return False
|
||||
return True
|
||||
|
||||
def load_model(self, model_path: Path):
|
||||
if not model_path.exists() or not model_path.is_file():
|
||||
|
||||
Reference in New Issue
Block a user