All Projects → VeriSilicon → tflite-vx-delegate

VeriSilicon / tflite-vx-delegate

Licence: MIT license
Tensorflow Lite external delegate based on TIM-VX

Programming Languages

C++
36643 projects - #6 most used programming language
python
139335 projects - #7 most used programming language
CMake
9771 projects
shell
77523 projects
Starlark
911 projects

Projects that are alternatives of or similar to tflite-vx-delegate

glDelegateBenchmark
quick and dirty benchmark for TFLite gles delegate on iOS
Stars: ✭ 13 (-53.57%)
Mutual labels:  tflite, tflite-delegate
glDelegateBench
quick and dirty inference time benchmark for TFLite gles delegate
Stars: ✭ 17 (-39.29%)
Mutual labels:  tflite, tflite-delegate
E2E-tfKeras-TFLite-Android
End to end training MNIST image classifier with tf.Keras, convert to TFLite and deploy to Android
Stars: ✭ 17 (-39.29%)
Mutual labels:  tflite
react-native-camera-tflite
Real time image classification with React Native and Tensorflow lite.
Stars: ✭ 52 (+85.71%)
Mutual labels:  tflite
Aidlearning Framework
🔥🔥AidLearning is a powerful mobile development platform, AidLearning builds a linux env supporting GUI, deep learning and visual IDE on Android...Now Aid supports OpenCL (GPU+NPU) for high performance acceleration...Linux on Android or HarmonyOS
Stars: ✭ 4,537 (+16103.57%)
Mutual labels:  tflite
LIGHT-SERNET
Light-SERNet: A lightweight fully convolutional neural network for speech emotion recognition
Stars: ✭ 20 (-28.57%)
Mutual labels:  tflite
Yolov5
YOLOv5 🚀 in PyTorch > ONNX > CoreML > TFLite
Stars: ✭ 19,914 (+71021.43%)
Mutual labels:  tflite
YOLOv5-Lite
🍅🍅🍅YOLOv5-Lite: lighter, faster and easier to deploy. Evolved from yolov5 and the size of model is only 930+kb (int8) and 1.7M (fp16). It can reach 10+ FPS on the Raspberry Pi 4B when the input size is 320×320~
Stars: ✭ 1,230 (+4292.86%)
Mutual labels:  tflite
tflite native
A Dart interface to TensorFlow Lite (tflite) through dart:ffi
Stars: ✭ 127 (+353.57%)
Mutual labels:  tflite
TFLite-Object-Detection-with-TFLite-Model-Maker
Custom object detection with the TFLite Model Maker
Stars: ✭ 13 (-53.57%)
Mutual labels:  tflite
TF2DeepFloorplan
TF2 Deep FloorPlan Recognition using a Multi-task Network with Room-boundary-Guided Attention. Enable tensorboard, quantization, flask, tflite, docker, github actions and google colab.
Stars: ✭ 98 (+250%)
Mutual labels:  tflite
Tensorflow-lite-kotlin-samples
📌This repo contains the kotlin implementation of TensorflowLite Example Android Apps🚀
Stars: ✭ 17 (-39.29%)
Mutual labels:  tflite
TFLite-Mobile-Generic-Object-Localizer
Python TFLite scripts for detecting objects of any class in an image without knowing their label.
Stars: ✭ 42 (+50%)
Mutual labels:  tflite
Tensorflow Yolov4 Tflite
YOLOv4, YOLOv4-tiny, YOLOv3, YOLOv3-tiny Implemented in Tensorflow 2.0, Android. Convert YOLO v4 .weights tensorflow, tensorrt and tflite
Stars: ✭ 1,881 (+6617.86%)
Mutual labels:  tflite
Selfie2Anime-with-TFLite
How to create Selfie2Anime from tflite model to Android.
Stars: ✭ 70 (+150%)
Mutual labels:  tflite
CFU-Playground
Want a faster ML processor? Do it yourself! -- A framework for playing with custom opcodes to accelerate TensorFlow Lite for Microcontrollers (TFLM). . . . . . Online tutorial: https://google.github.io/CFU-Playground/ For reference docs, see the link below.
Stars: ✭ 361 (+1189.29%)
Mutual labels:  tflite
Yolov3
YOLOv3 in PyTorch > ONNX > CoreML > TFLite
Stars: ✭ 8,159 (+29039.29%)
Mutual labels:  tflite
MobileQA
离线端阅读理解应用 QA for mobile, Android & iPhone
Stars: ✭ 49 (+75%)
Mutual labels:  tflite
Food-Ordering-Application-with-Review-Analyzer
A food ordering android application with feedback analyzer to improve food suggestions to customer.
Stars: ✭ 67 (+139.29%)
Mutual labels:  tflite
E2E-Object-Detection-in-TFLite
This repository shows how to train a custom detection model with the TFOD API, optimize it with TFLite, and perform inference with the optimized model.
Stars: ✭ 28 (+0%)
Mutual labels:  tflite

TfLite-vx-delegate

TfLite-vx-delegate constructed with TIM-VX as an openvx delegate for tensorflow lite. Before vx-delegate, you may have nnapi-linux version from Verisilicon, we suggest you move to this new delegate because:

1. without nnapi, it's flexible to enable more AI operators.
2. vx-delegate is opensourced, and will promised compatible with latest tensorflow release(currently v2.9.0).

Use tflite-vx-delegate

Prepare source code

mkdir wksp && cd wksp
# tim-vx is optional, it will be downloaded by CMake automatically for none-cross build
# if you want to do cross build with cmake, you have to build tim-vx firstly
git clone https://github.com/VeriSilicon/TIM-VX.git tim-vx
git clone https://github.com/VeriSilicon/tflite-vx-delegate.git
# tensorflow is optional, it will be downloaded automatically if not present
git clone https://github.com/tensorflow/tensorflow.git

Build from source with cmake

# default built for x86-64 simulator
cd tflite-vx-delegate
mkdir build && cd build
cmake ..
make vx_delegate -j12

# benchmark_model
make benchmark_model -j12
# label_image
make lable_image -j12

If you would like to build with your own vivante driver sdk and tim-vx build, you need do cross-build as

cd tim-vx
mkdir build && cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=<toolchain.cmake> -DEXTERNAL_VIV_SDK=<sdk_root>
# we can also build from a specific ovxlib instead of use default one by set
# TIM_VX_USE_EXTERNAL_OVXLIB=ON
# OVXLIB_INC=<direct_to_ovxlib_include>
# OVXLIB_LIB=<full_patch_to_libovxlib.so>

If you would like to build using local version of tensorflow, you can use FETCHCONTENT_SOURCE_DIR_TENSORFLOW cmake variable. Point this variable to your tensorflow tree. For additional details on this variable please see the official cmake documentation

cmake -DFETCHCONTENT_SOURCE_DIR_TENSORFLOW=/my/copy/of/tensorflow \
    -DOTHER_CMAKE_DEFINES...\
    ..

After cmake execution completes, build and run as usual. Beware that cmake process will apply a patch to your tensorflow tree. The patch is requred to enable the external delegate support and the NBG support.

Enable external delegate support in benchmark_model/label_image

For tensorflow v2.8.0, addtional patch pwd/patches/0001-TensorFlow-V280-Enable-External-Delegate.patch requred to enable enable external delegate in benchmark_model/label_image. If tensorflow source code downloaded by cmake, you can find it in <build_output_dir>/_deps/tensorflow-src

The patch get merged into Tensorflow master branch, no patch required for master branch.

benchmark_model/Label_image compatible with Tflite+NBG

With our Acuity Toolkit, you can generate tflite file with compiled NBG(Network Binary Graph) as a custom operator. To support this special format, you should build benchmark_model/label_image from our delegate repo not use the offical one.

Run

# For default x86 build, you can find prebuilt sdk from tim-vx
# export VSIMULATOR_CONFIG=<your_target_npu_id> for x86-simulator
export VIVANTE_SDK_DIR=<direct_to_sdk_root>
# Please copy libtim-vx.so to drivers/ directory
export LD_LIBRARY_PATH=${VIVANTE_SDK_DIR}/drivers:$LD_LIBRARY_PATH # the "drivers" maybe named as lib
./benchmark_model --external_delegate_path=<patch_to_libvx_delegate.so> --graph=<tflite_model.tflite>
# If you would like to use cache mode which save and load binary graph in local disk
./benchmark_model --external_delegate_path=<patch_to_libvx_delegate.so> \
                  --external_delegate_options='allowed_cache_mode:true;cache_file_path:<cache_file>' \
                  --graph=<tflite_model.tflite>

Test

Introduced unit test with tensorflow keras api and convert it to tflite with quantized or none-quantized model, Golden generated from CPU implementation of tflite Details for run test

Model verification script to compare NPU result with CPU result

Examples

examples/python/label_image.py modified based on offical label_image

1. build tensorflow-lite runtime python package follow by [offical build instruction](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/lite/tools/pip_package#readme)
2. Added "-e" option to provide external provider, [Offical Label Image Instruction](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/examples/python/README.md)

examples/minimal modified based on offical minimal

minimal <patch_to_libvx_delegate.so> <tflite_model.tflite>
# If you would like to use cache mode which save and load binary graph in local disk
minimal <patch_to_libvx_delegate.so> <tflite_model.tflite> use_cache_mode <cache_file>
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].