Closed fogelton closed 3 years ago
On coral dev board?
pc + usb coral
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
if self.tpu:
self.interpreter = tflite.Interpreter(
model_path=tflite_path,
experimental_delegates=[load_delegate("libedgetpu.so.1")],
)
else:
self.interpreter = tflite.Interpreter(model_path=tflite_path)
How about this? If you can test, please test and make pull request :)
I just updated the package to the latest version and I get an import error for the load_delegate I do not know why.. i have tensorflow2.4 python3.8 when I execute python3 and only the given commands, the results:
import tensorflow.lite as tflite 2021-01-05 16:27:54.947757: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory 2021-01-05 16:27:54.947782: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine. from tensorflow.lite.experimental import load_delegate Traceback (most recent call last): File "
", line 1, in ImportError: cannot import name 'load_delegate' from 'tensorflow.lite.experimental'
when I execute the commands in python with tflite_runtime installed
import tflite_runtime.interpreter as tflite from tflite_runtime.interpreter import load_delegate
the load_delegate is imported successfully, this is very weird and above my knowledge
I'm sorry. There seemed to be no problem, so I committed without testing. :(
Could you test the code below?
try:
import tflite_runtime.interpreter as tflite
from tflite_runtime.interpreter import load_delegate
except ModuleNotFoundError:
import tensorflow.lite as tflite
load_delegate = tflite.experimental.load_delegate
it works, thanks
in tflite/init bool variable can be added
and later
to prevent the error, but maybe there is more elegant way :)