Tf Lite Unity Sample Save

TensorFlow Lite Samples on Unity

Project README

TensorFlow Lite for Unity Samples

npm

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

Tested on

  • iOS / Android / macOS / Windows / Linux
  • Unity 2022.3.22f1
  • TensorFlow 2.16.1

Included examples:

  • TensorFlow
    • MNIST
    • SSD Object Detection
    • DeepLab
    • PoseNet
    • Style Transfer
    • Text Classification
    • Bert Question and Answer
    • Super Resolution
    • Audio Classification
  • MediaPipe
    • Hand Tracking
    • Blaze Face
    • Face Mesh
    • Blaze Pose (Full body)
    • Selfie Segmentation

Included prebuilt libraries:

iOS Android macOS Ubuntu Windows
Core CPU
Metal Delegate - - -
GPU Delegate - - ✅ Experimental -
NNAPI Delegate - - - -
  • You need to install OpenGL ES and OpenCL to run GPU Delegate on Linux. See MediaPipe for details.

Install TensorFlow Lite for Unity

[!IMPORTANT]
You need to install Git-LFS.

  • If you want to try all examples, clone this repository with Git-LFS.
  • If you just need TensorFlow Lite libraries via UPM, open the file Packages/manifest.json and add following lines into scopedRegistries and dependencies section.
{
  "scopedRegistries": [
    {
      "name": "package.openupm.com",
      "url": "https://package.openupm.com",
      "scopes": [
        "com.cysharp.unitask"
      ]
    },
    {
      "name": "npm",
      "url": "https://registry.npmjs.com",
      "scopes": [
        "com.github.asus4"
      ]
    }
  ],
  "dependencies": {
    // Core TensorFlow Lite libraries
    "com.github.asus4.tflite": "2.16.1",
    // Utilities for TFLite
    "com.github.asus4.tflite.common": "2.16.1",
    // Utilities for MediaPipe
    "com.github.asus4.mediapipe": "2.16.1",
    ...// other dependencies
  }
}

Build TensorFlow Lite libraries yourself

Pre-built libraries are included in the UPM package. Also, you can find TFLite libraries at tflite-runtime-builder from TFLite v2.14.0 or later.

If you want to build the latest TFLite yourself, Follow the below instructions:

  1. Clone TensorFlow library
  2. Run ./configure in the TensorFlow library
  3. Run ./build_tflite.py (Python3) to build for each platform
# Update iOS, Android and macOS
./build_tflite.py --tfpath ../tensorflow -ios -android -macos

# Build with XNNPACK
./build_tflite.py --tfpath ../tensorflow -macos -xnnpack

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

MIT License

Copyright (c) 2024 Koki Ibukuro

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Other Licenses

Model Licenses

📌 : Each TensorFlow Lite model might have a different license. Please check the license of the model you use.

Open Source Agenda is not affiliated with "Tf Lite Unity Sample" Project. README Source: asus4/tf-lite-unity-sample
Stars
804
Open Issues
2
Last Commit
3 weeks ago

Open Source Agenda Badge

Open Source Agenda Rating