/tf-lite-unity-sample

TensorFlow Lite Samples on Unity

Primary LanguageC#

TensorFlow Lite for Unity Samples

openupm

Porting of "TensorFlow Lite Examples" to Unity. and some utilities for Unity.

Tested on

  • iOS / Android / macOS / Windows
  • Unity 2019.4.11f1
  • TensorFlow 2.3.0

Samples

  • TensorFlow
    • MNIST
    • SSD Object Detection
    • DeepLab
    • PoseNet
    • Style Transfer
    • Text Classification
    • Bert Question and Answer
  • MediaPipe
    • Hand Tracking
    • Blaze Face
    • Face Mesh
    • Blaze Pose (Upper body)
  • MLKit
    • Blaze Pose (Full body)

Included prebuilt libraries

iOS Android macOS Ubuntu Windows
Core CPU
Metal Delegate - - -
OpenGL Delegate - - - -
NNAPI Delegate - - - -
  • All libraries except iOS are targeted 64bit platform: arm64 or x86_64.

Install TensorFlow Lite for Unity

  • Clone this repository with examples
  • Or core library is available on OpenUPM

Build TensorFlow Lite libraries

Pre-built libraries are included. If you want to build the latest TFLite,

  1. Clone TensorFlow library
  2. Run ./configure in the TensorFlow library
  3. Run ./build_tflite.py (Python3) to build for each platform
# Update iOS, Andoid and macOS
./build_tflte.py --tfpath ../tensorflow -ios -android -macos
  • To build macOS Metal Delegate on TensorFlow v2.3.0 or later, You need to apply following changes the issue

TIPS

[Android] You can see logs from tflite by filtering with "tflite"

# Filtering logcat only Unity and tflite
adb logcat Unity:V tflite:V "*:S"

Show Cases

MNIST
Mnist

SSD Object Detection
SSD

DeepLab Semantic Segmentation
DeepLab

Style Transfer
styletransfter

Hand Tracking
handtracking

BERT
BERT

License

Samples folder Assets/Samples/* is licensed under MIT

Other licenses