ZoneMinder / mlapi

An easy to use/extend object recognition API you can locally install. Python+Flask. Also works with ZMES!
Other
58 stars 34 forks source link

installing python3-edgetpu breaks the coral detection #21

Closed hugalafutro closed 3 years ago

hugalafutro commented 3 years ago

Hi, I've previously installed mlapi+coral in vm, for one reason or another I've ended up not using it, now I'm planning to use it again and installing it on a physical computer it appears some thing changed in regards to python3-edgetpu as installing it breaks the coral detection test.

I've installed all the prerequisites and got the coral detection working doing the parrot test:

$ 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
----INFERENCE TIME----
Note: The first inference on Edge TPU is slow because it includes loading the model into Edge TPU memory.
12.4ms
3.8ms
3.8ms
3.9ms
3.9ms
-------RESULTS--------
Ara macao (Scarlet Macaw): 0.77734

then when installing python3-edgetpu I've noticed it removed libedgetpu1-std and replaced it and spat out a warning:

$ sudo apt-get install python3-edgetpu
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  libedgetpu1-legacy-std
The following packages will be REMOVED:
  libedgetpu1-std
The following NEW packages will be installed:
  libedgetpu1-legacy-std python3-edgetpu
0 upgraded, 2 newly installed, 1 to remove and 0 not upgraded.
Need to get 0 B/3,374 kB of archives.
After this operation, 11.2 MB of additional disk space will be used.
Do you want to continue? [Y/n]
(Reading database ... 126795 files and directories currently installed.)
Removing libedgetpu1-std:amd64 (15.0) ...
Selecting previously unselected package libedgetpu1-legacy-std:amd64.
(Reading database ... 126789 files and directories currently installed.)
Preparing to unpack .../libedgetpu1-legacy-std_15.0_amd64.deb ...
Unpacking libedgetpu1-legacy-std:amd64 (15.0) ...
Selecting previously unselected package python3-edgetpu.
Preparing to unpack .../python3-edgetpu_15.0_amd64.deb ...
Unpacking python3-edgetpu (15.0) ...
Setting up libedgetpu1-legacy-std:amd64 (15.0) ...
Setting up python3-edgetpu (15.0) ...

      =========WARNING========
      python3-edgetpu package is deprecated. In order to maintain compatibility
      with libedgetpu, we've created a legacy version that will not receive any
      future updates; it exists only to support python3-edgetpu. At this moment,
      python3-edgetpu depends on libedgetpu1-legacy-std, which runs the
      Edge TPU at its reduced operating frequency; if you want to use
      the Edge TPU at its max operating frequency, you can do:
      sudo apt install libedgetpu1-legacy-max
      For more information, see g.co/coral/python3-edgetpu.
      =========================
Processing triggers for libc-bin (2.31-0ubuntu9.1) ...

after which the parrot test breaks:

$ 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 <module>
    main()
  File "classify_image.py", line 100, in main
    interpreter.allocate_tensors()
  File "/home/sammael/.local/lib/python3.8/site-packages/tflite_runtime/interpreter.py", line 259, in allocate_tensors
    return self._interpreter.AllocateTensors()
RuntimeError: Internal: Unsupported data type in custom op handler: 45494944Node number 1 (EdgeTpuDelegateForCustomOp) failed to prepare.

If I install libedgetpu1-std the parrot test works again, but doing so removes python3-edgetpu

I'm unsure how to proceed now. Do I ignore the broken parrot test and proceed with compiling opencv and installing mlapi?

pliablepixels commented 3 years ago

Do I ignore the broken parrot test and proceed with compiling opencv and installing mlapi?

Yes, ignore the coral tests. I think their libraries have upgraded - when I developed it, I aligned it with python3-edgetpu which I think relies on an older version.

fennec622 commented 3 years ago

Hi can you adapt with pycoral ?

/usr/local/lib/python3.8/dist-packages/pyzm/ml/coral_edgetpu.py

Traceback (most recent call last): File "mlapi.py", line 219, in <module> od_obj = ObjectDetect.Object(options=g.config) File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/object.py", line 30, in __init__ import pyzm.ml.coral_edgetpu as tpu File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/coral_edgetpu.py", line 14, in <module> from edgetpu.detection.engine import DetectionEngine ModuleNotFoundError: No module named 'edgetpu'

Do I ignore the broken parrot test and proceed with compiling opencv and installing mlapi?

Yes, ignore the coral tests. I think their libraries have upgraded - when I developed it, I aligned it with python3-edgetpu which I think relies on an older version.

pliablepixels commented 3 years ago

Closing as this is done