Skip to content
This repository has been archived by the owner on Aug 11, 2023. It is now read-only.

Commit

Permalink
tflite: add edgetpu_lib argument to load_tflite()
Browse files Browse the repository at this point in the history
  • Loading branch information
hhk7734 committed Jan 27, 2021
1 parent be7b930 commit fbc374e
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions py_src/yolov4/tflite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""
import platform

import numpy as np

try:
Expand All @@ -33,6 +35,12 @@

from ..common.base_class import BaseClass

EDGETPU_SHARED_LIB = {
"Linux": "libedgetpu.so.1",
"Darwin": "libedgetpu.1.dylib",
"Windows": "edgetpu.dll",
}[platform.system()]


class YOLOv4(BaseClass):
def __init__(self, tiny: bool = False, tpu: bool = False):
Expand All @@ -46,11 +54,13 @@ def __init__(self, tiny: bool = False, tpu: bool = False):
self.output_index = None
self.output_size = None

def load_tflite(self, tflite_path: str) -> None:
def load_tflite(
self, tflite_path: str, edgetpu_lib: str = EDGETPU_SHARED_LIB
) -> None:
if self.tpu:
self.interpreter = tflite.Interpreter(
model_path=tflite_path,
experimental_delegates=[load_delegate("libedgetpu.so.1")],
experimental_delegates=[load_delegate(edgetpu_lib)],
)
else:
self.interpreter = tflite.Interpreter(model_path=tflite_path)
Expand Down

0 comments on commit fbc374e

Please sign in to comment.