google-coral / tflite

Examples using TensorFlow Lite API to run inference on Coral devices
https://coral.withgoogle.com
Apache License 2.0
181 stars 67 forks source link

AttributeError: 'Delegate' object has no attribute '_library' #62

Closed jukomol closed 1 year ago

jukomol commented 1 year ago

Description

I am trying coral dev board micro. So, I tried this example. It produces the above error. I followed the instructions properly and tried everything I found on Google, but I am unsure what is occurring with this issue.

Click to expand! ### Issue Type Support ### Operating System Ubuntu ### Coral Device Dev Board Micro ### Other Devices _No response_ ### Programming Language Python 3.6 ### Relevant Log Output ```shell System information -ubuntu 18.04.6 lts -tflite-runtime installed from Source, Using 'sudo apt-get install python3-tflite-runtime' [version: 2.5.0] -Python Verison: 3.6 -edgetpu-compiler 16 amd64 Logs: syncx@syncx:~/cubesatnet_improvised/tflite/python/examples/classification$ python3 classify_image.py \ --model models/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite --labels models/inat_bird_labels.txt --input images/parrot.jpg Traceback (most recent call last): File "classify_image.py", line 122, in main() File "classify_image.py", line 99, in main interpreter = make_interpreter(args.model) File "classify_image.py", line 73, in make_interpreter {'device': device[0]} if device else {}) File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 160, in load_delegate delegate = Delegate(library, options) File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 89, in init self._library = ctypes.pydll.LoadLibrary(library) File "/usr/lib/python3.6/ctypes/init.py", line 426, in LoadLibrary return self._dlltype(name) File "/usr/lib/python3.6/ctypes/init.py", line 348, in init self._handle = _dlopen(self._name, mode) OSError: libedgetpu.so.1: cannot open shared object file: No such file or directory Exception ignored in: > Traceback (most recent call last): File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 124, in del if self._library is not None: AttributeError: 'Delegate' object has no attribute '_library' Standalone code to reproduce the issue python3 classify_image.py --model models/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite --labels models/inat_bird_labels.txt --input images/parrot.jpg ```
jukomol commented 1 year ago

So, I reinstalled the pycoral and edgetpu. After installing, I tried to rerun the example, and it gave the below error. I followed this link. But no solution worked for me.


Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 160, in load_delegate
    delegate = Delegate(library, options)
  File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 119, in __init__
    raise ValueError(capture.message)
ValueError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "classify_image.py", line 122, in <module>
    main()
  File "classify_image.py", line 99, in main
    interpreter = make_interpreter(args.model)
  File "classify_image.py", line 73, in make_interpreter
    {'device': device[0]} if device else {})
  File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 163, in load_delegate
    library, str(e)))
ValueError: Failed to load delegate from libedgetpu.so.1```
hjonnala commented 1 year ago

Hi @jukomol If you are working with Dev Board Micro, please follow the docuemntation at: https://coral.ai/docs/dev-board-micro/arduino/

The eaxmples in this repo does not work with Dev Board Micro. Thanks!!

jukomol commented 1 year ago

Can you please assist me, how to run image classification model on Dev Board Micro? I got my tflite quantizatio file. But I am not sure how to run it on the dev board micro.

hjonnala commented 1 year ago

Please try the classify_example with the below steps:

git clone --recurse-submodules -j8 https://github.com/google-coral/coralmicro

cd coralmicro && bash setup.sh

bash build.sh

python3 scripts/flashtool.py -e classify_images

If it works, feel free to change the model path with you tflite model path at: https://github.com/google-coral/coralmicro/blob/main/examples/classify_images/classify_images.cc#L66

google-coral-bot[bot] commented 1 year ago

Are you satisfied with the resolution of your issue? Yes No