From da293e16b6466e18f1f1d4dd350ea0e9e84c873c Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sat, 5 Feb 2022 15:45:44 +0100 Subject: [PATCH] Edge TPU TF imports fix (#6542) * Edge TPU TF imports fix Fix for https://github.com/ultralytics/yolov5/issues/6535#issuecomment-1030631526 * Update common.py --- models/common.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/models/common.py b/models/common.py index 4da698811669..07f57c66b215 100644 --- a/models/common.py +++ b/models/common.py @@ -374,11 +374,11 @@ def wrap_frozen_graph(gd, inputs, outputs): graph_def.ParseFromString(open(w, 'rb').read()) frozen_func = wrap_frozen_graph(gd=graph_def, inputs="x:0", outputs="Identity:0") elif tflite: # https://www.tensorflow.org/lite/guide/python#install_tensorflow_lite_for_python - try: # prefer tflite_runtime if installed + try: # https://coral.ai/docs/edgetpu/tflite-python/#update-existing-tf-lite-code-for-the-edge-tpu from tflite_runtime.interpreter import Interpreter, load_delegate except ImportError: - import tensorflow.lite.experimental.load_delegate as load_delegate - import tensorflow.lite.Interpreter as Interpreter + import tensorflow as tf + Interpreter, load_delegate = tf.lite.Interpreter, tf.lite.experimental.load_delegate, if 'edgetpu' in w.lower(): # Edge TPU https://coral.ai/software/#edgetpu-runtime LOGGER.info(f'Loading {w} for TensorFlow Lite Edge TPU inference...') delegate = {'Linux': 'libedgetpu.so.1',