Namburger / edgetpu-ssdlite-mobiledet-retrain

This repo contains the colab for my ssdlite mobiledet model retrain tutorial
37 stars 7 forks source link

RuntimeError: Encountered unresolved custom op: edgetpu-custom-op.Node number 0 (edgetpu-custom-op) failed to prepare. #10

Closed Awais-commit closed 2 years ago

Awais-commit commented 2 years ago

Hello Namburger thanks for you great tutorial of "EdgeTpu SSDLite Mobiledet Transfer Learning Tutorial".

I tried this tutorial of "face mask detection". It worked perfectly. I successfully train the model on local GPU and convert the model to the "tf_lite" version and compile the model for the "edge_tpu".

The "tflite" version runs on coral dev board. it gives the "2fps" as it runs on the cpu (I guess), but unfortunately the edge_tpu complied version through the error of RuntimeError: Encountered unresolved custom op: edgetpu-custom-op.Node number 0 (edgetpu-custom-op) failed to prepare.

I think the error is same as https://github.com/google-coral/edgetpu/issues/159#issue-648482043 but I dont know how to resolve it. The output of dpkg -l | grep libedgetpu is ii libedgetpu1-std:arm64 16.0 arm64 Support library for Edge TPU and tflite_runtime version is 2.5.0.post1.

The log of tflte complied model for edge tpu are attached. ssdlite_mobiledet_mask_edgetpu.log

The script that I am using for inference is same as in tutorial as update_infer2.zip

Plese tell me how can I run the ssdlite_mobiledet_mask.tflite model to the edge tpu. Where I'm making the mistake? I am pretty new to "Coral Dev Board" so any help would be highly grateful. Thanks.

Namburger commented 2 years ago

@Awais-commit Hello, this tutorial was made a while back so I Imagine the runtime version has changed, I would check to make sure your tflite-runtime package version is up to date with the package uploaded here: https://www.tensorflow.org/lite/guide/python#install_tensorflow_lite_for_python

Also, check libegetpu version:

dpkg -l | grep libedgetpu

For reference I just downloaded the library from here and this is the version I have:

➜  ~ dpkg -l | grep libedgetpu                   
ii  libedgetpu1-std:amd64                      16.0                                  amd64        Support library for Edge TPU

I don't quite remember the mechanism for updating the library in the dev board but I believe an apt update should do!

Awais-commit commented 2 years ago

Thank you @Namburger for your respons. My issue is resolved, I didi two things. 1) make the libedgetpu version same on the coral as on the host machine where I compiled for the "Coral Dev Board"

2) I import from tflite_runtime.interpreter import load_delegate then give the path to model as interpreter = Interpreter(PATH_TO_MODEL , experimental_delegates=[load_delegate('libedgetpu.so.1')])

After that it worked and the inference goes from 2fps to 100+ fps

I am closing the issue and want to thanks for the great tutorial and your help.

On the site note I'm searching for the inference the model using camera and outputting on the "HDMI" and "Streaming" on the port address. I'm able to take the video from the camera an save as video using OpenCV but not able to output it on the HDMI-screen or stream it on the network. if you can guide me on that I would be great-full.

Thanks again

Namburger commented 2 years ago

Here is an old code to run the dev board over hdmi with open cv: https://github.com/Namburger/edgetpu-detection-camera/blob/master/scripts/camera_detector.py

I think there is an issue with the board sometimes not detecting the monitor, a simple restart should fix it

Awais-commit commented 2 years ago

Here is an old code to run the dev board over hdmi with open cv: https://github.com/Namburger/edgetpu-detection-camera/blob/master/scripts/camera_detector.py

I think there is an issue with the board sometimes not detecting the monitor, a simple restart should fix it

@Namburger Sorry I couldn't try it earlier and update. The problem I checked is it wasn't even giving the simple output on the HDMI screen (without running the code).

So I first I update and dist-upgrade the coral Dev board then run this command xhost +SI:localuser:root then reboot it, finally it's showing the output. After that when I run the detection code it was showing the output on the HDMI. Also the script that you provide helped

Thanks a lot for you help and response.