- read

Updates to TensorFlow Lite Flutter Support Suite

Amish Garg 60

Last year we published tflite_flutter and tflite_flutter_helper packages to empower Flutter Developers for creating performant flutter ML apps using the TensorFlow Lite without compromising on advantages offered by native TensorFlow APIs.

We have introduced some updates this year to help you build for more use-cases without hassle.

TFLite Flutter Plugin

TensorFlow Lite Flutter plugin provides a flexible and fast solution for accessing TensorFlow Lite interpreter and performing inference. The API is similar to the TFLite Java and Swift APIs. It directly binds to TFLite C API making it efficient (low-latency). Offers acceleration support using NNAPI, GPU delegates on Android, Metal and CoreML delegates on iOS, and XNNPack delegate on Desktop platforms.

Key Features:

  • Multi-platform Support for Android, iOS, Windows, Mac, Linux.
  • Flexibility to use any TFLite Model.
  • Acceleration using multi-threading and delegate support.
  • Support for Select TensorFlow Ops using Flex Delegate.
  • Similar structure as TensorFlow Lite Java API.
  • Inference speeds close to native Android Apps built using the Java API.
  • You can choose to use any TensorFlow version by building binaries locally.
  • Run inference in different isolates to prevent jank on UI thread.

TFLite Flutter Helper Library

TFLite Flutter Helper Library brings TFLite Support Library and TFLite Support Task Library to Flutter and helps users to develop ML apps and deploy TFLite models to mobile devices quickly. The documentation for the helper library is available here.

Helper Library

The helper library helps to process and input and output of TensorFlow Lite models and makes the TensorFlow lite interpreter easier to use. It provides APIs to assist developers with Vision and Audio use-cases. Please have a look at this guide to get started with the support library.

Helper Task Library

A flexible and ready-to-use library for common machine learning model types, such as classification and detection. Using the task library developers can integrate the supported models into their flutter apps with just 5 lines of code.

Currently, Text based models like NLClassifier, BertNLClassifier and BertQuestionAnswerer are available to use with the Flutter Task Library. Please have a look at this guide to get started.

Example Apps

We have made available a couple of example Flutter ML apps to help you better understand the usage of above tools and APIs.

Text Classification

Demonstrates the use of Interpreter and Task Library. (blog)

Text Classification Dem

Audio Classification

Real-time audio classification, using TensorAudio API from TFLite Flutter Support Library. (code)

Audio Classification Demo

Real-time Object Detection

Demonstrates usage of Isolates with tflite_flutter_plugin to achieve performance equivalent to native Android and iOS apps. (code, blog)

Object Detection demo

Image Classification

Demonstrates the usage of Image Processing APIs from the Helper Library. (code).

Image Classification Demo

BERT Question and Answer

Demonstrates the usage of Flutter Task Library. (code).

Bert QA demo

PlaneStrike Flutter

Thanks to Wayne Wei. Plane Strike is a small game that can be played on both Android/iOS/desktop. (code, blog).

PlaneStrike Flutter Demo

Style Transfer

Thanks to PuzzleLeaf. Demonstrates Artistic Style Transfer using the TFLite Flutter Plugin. (code, video).