From 6100f0e76eb6667521ebf423ae7750e1cbe6dbf5 Mon Sep 17 00:00:00 2001 From: Kinar R <42828719+kinaryml@users.noreply.github.com> Date: Thu, 18 May 2023 18:09:39 +0530 Subject: [PATCH] Update base_options.py --- mediapipe/tasks/python/core/base_options.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/mediapipe/tasks/python/core/base_options.py b/mediapipe/tasks/python/core/base_options.py index 8247f15bd..2d74b16eb 100644 --- a/mediapipe/tasks/python/core/base_options.py +++ b/mediapipe/tasks/python/core/base_options.py @@ -16,6 +16,7 @@ import dataclasses import enum import os +import platform from typing import Any, Optional from mediapipe.calculators.tensor import inference_calculator_pb2 @@ -63,10 +64,22 @@ class BaseOptions: else: full_path = None - if self.delegate == BaseOptions.Delegate.GPU: - acceleration_proto = _AccelerationProto(gpu=_DelegateProto.Gpu()) + platform = platform.system() + + if self.delegate is not None: + if platform == "Linux": + if self.delegate == BaseOptions.Delegate.GPU: + acceleration_proto = _AccelerationProto(gpu=_DelegateProto.Gpu()) + else: + acceleration_proto = _AccelerationProto(tflite=_DelegateProto.TfLite()) + elif platform == "Windows": + raise Exception("Delegate is unsupported for Windows.") + elif platform == "Darwin": + raise Exception("Delegate is unsupported for MacOS.") + else: + raise Exception("Unidentified system") else: - acceleration_proto = _AccelerationProto(tflite=_DelegateProto.TfLite()) + acceleration_proto = None return _BaseOptionsProto( model_asset=_ExternalFileProto(