Giter Club home page Giter Club logo

flutter_tflite's Introduction

tflite

A Flutter plugin for accessing TensorFlow Lite. Supports both iOS and Android.

Installation

Add tflite as a dependency in your pubspec.yaml file.

Android

In android/app/build.gradle file add the following setting in android block.

    aaptOptions {
        noCompress 'tflite'
    }

iOS

If you get error like "'vector' file not found", please open ios/Runner.xcworkspace in Xcode, click Runner > Tagets > Runner > Build Settings, search Compile Sources As, change the value to Objective-C++;

Usage

  1. Create a assets folder and place your label file and model file in it. In pubspec.yaml add:
  assets:
   - assets/labels.txt
   - assets/mobilenet_v1_1.0_224.tflite
  1. Import the library:
import 'package:tflite/tflite.dart';
  1. Load the model and labels:
String res = await Tflite.loadModel(
  model: "assets/mobilenet_v1_1.0_224.tflite",
  labels: "assets/labels.txt",
);
  1. Run the model on a image file:
var recognitions = await Tflite.runModelOnImage(
  path: filepath,   // required
  inputSize: 224,   // wanted input size, defaults to 224
  numChannels: 3,   // wanted input channels, defaults to 3
  imageMean: 127.5, // defaults to 117.0
  imageStd: 127.5,  // defaults to 1.0
  numResults: 6,    // defaults to 5
  threshold: 0.05,  // defaults to 0.1
  numThreads: 1,    // defaults to 1
);
  1. Release resources:
await Tflite.close();

Demo

Refer to the example.

flutter_tflite's People

Contributors

prakhar1989 avatar shaqian avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.