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

Commit

Permalink
tflite: fix problem of not finding load_delegate()
Browse files Browse the repository at this point in the history
close #48
  • Loading branch information
hhk7734 committed Dec 20, 2020
1 parent b37cc33 commit 5aa8563
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions py_src/yolov4/tflite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,15 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""
import time
from typing import Union

import numpy as np

try:
import tflite_runtime.interpreter as tflite
from tflite_runtime.interpreter import load_delegate
except ModuleNotFoundError:
import tensorflow.lite as tflite
from tensorflow.lite.experimental import load_delegate

from ..common import media, predict
from ..common.base_class import BaseClass


Expand All @@ -47,16 +45,15 @@ def __init__(self, tiny: bool = False, tpu: bool = False):
self.output_index = None
self.output_size = None

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

self.interpreter.allocate_tensors()
input_details = self.interpreter.get_input_details()[0]
# width, height
Expand Down

0 comments on commit 5aa8563

Please sign in to comment.