asus4 / tf-lite-unity-sample

TensorFlow Lite Samples on Unity
834 stars 249 forks source link

Add NN Api Delegate #270

Closed asus4 closed 1 year ago

asus4 commented 1 year ago

Android Neural Networks API has been supported as an useNNAPI option in the InterpreterOptions.cs. But there was no way to configure options in the NNAPI.

This PR allows configuring all options supported in the original TFLite CAPI.

Please take a look at SsdSample.cs for an example of usage.

asus4 commented 1 year ago

How to test the new NNAPI delegate

  1. Open the SSD sample scene
  2. Change the Accelerator option to NNPAI
  3. Build and run it on your Android
  4. See log in the logcat

The first time you start the app, you'll see the following warning.

12-27 14:03:58.261 17049 17138 W Unity   : TFLite Warning: File /storage/emulated/0/Android/data/com.asus4.tfliteunitysample/files/ssd-token_5504566449498313531.bin couldn't be opened for reading: No such file or directory

From the second time onwards, you won't see such a warning.