Model Adapters

    Adapters are the bridge between OpenEye and ML model backends. Each adapter implements loading and inference for a specific model type.

    ModelAdapter ABC

    All adapters extend openeye_ai.adapters.base.ModelAdapter:

    openeye_ai/adapters/base.py
    class ModelAdapter(ABC):
        _loaded: bool = False
    
        def load(self, model_dir: Path) -> None:
            self._do_load(model_dir)
            self._loaded = True
    
        @abstractmethod
        def _do_load(self, model_dir: Path) -> None:
            """Load model weights from disk."""
    
        def predict(self, image: Image.Image) -> dict[str, Any]:
            if not self._loaded:
                raise ModelNotLoadedError(...)
            return self._do_predict(image)
    
        @abstractmethod
        def _do_predict(self, image: Image.Image) -> dict[str, Any]:
            """Run inference. Return dict with 'objects' and/or 'depth_map'."""
    
        @abstractmethod
        def pull(self, model_dir: Path) -> None:
            """Download model weights."""

    Built-in Adapters

    AdapterModuleModels
    yolov8openeye_ai.adapters.yolov8YOLOv8 (ultralytics)
    yolo26openeye_ai.adapters.yolo26YOLOv26
    depth_anythingopeneye_ai.adapters.depth_anythingDepth Anything V2
    grounding_dinoopeneye_ai.adapters.grounding_dinoGrounding DINO
    rfdetropeneye_ai.adapters.rfdetrRF-DETR
    sam2openeye_ai.adapters.sam2Segment Anything 2
    smolvlaopeneye_ai.adapters.smolvlaSmolVLA
    yolov8:onnxopeneye_ai.adapters.yolov8_onnxYOLOv8 ONNX
    onnx_genericopeneye_ai.adapters.onnx_runtimeGeneric ONNX
    yolov8:tensorrtopeneye_ai.adapters.tensorrt_runtimeYOLOv8 TensorRT
    tensorrt_genericopeneye_ai.adapters.tensorrt_runtimeGeneric TensorRT

    Lifecycle

    • pull(model_dir) — Download weights to the model directory
    • load(model_dir) — Load weights into memory
    • predict(image) — Run inference on a PIL Image
    • Return dict must include inference_ms and either objects or depth_map