All Projects → heigeo → Cordova Plugin Tensorflow

heigeo / Cordova Plugin Tensorflow

Licence: mit
On-device image recognition via TensorFlow/Inception. For Cordova/PhoneGap.

Projects that are alternatives of or similar to Cordova Plugin Tensorflow

ionic-multi-camera
Take multiple photos one after another
Stars: ✭ 12 (-76.47%)
Mutual labels:  cordova, phonegap
Corber
CLI for building hybrid apps with Ember/Vue/Glimmer/Cordova
Stars: ✭ 327 (+541.18%)
Mutual labels:  phonegap, cordova
Awesome Cordova
📱 A curated list of amazingly awesome Cordova libraries, resources and shiny things.
Stars: ✭ 269 (+427.45%)
Mutual labels:  phonegap, cordova
cordova-plugin-flurryanalytics
Adds support for all that Flurry Analytics flavored goodness to your Cordova based apps
Stars: ✭ 23 (-54.9%)
Mutual labels:  cordova, phonegap
Cordova Admob Pro
🔥 Cordova Plugin for Google AdMob, DFP, ADX. Easy monetization using mobile Ad, with single line of JavaScript. Compatible with Cordova CLI, Inoic, PhoneGap Build, etc.
Stars: ✭ 690 (+1252.94%)
Mutual labels:  phonegap, cordova
daftarkaryaku
daftar beragam karyaku . . .
Stars: ✭ 26 (-49.02%)
Mutual labels:  cordova, phonegap
Framework7
Full featured HTML framework for building iOS & Android apps
Stars: ✭ 16,560 (+32370.59%)
Mutual labels:  phonegap, cordova
phonegap-template-vue-f7-split-panel
A Split View PhoneGap template using Vue.js and Framework7 that degrades to a Panel View on smaller devices
Stars: ✭ 17 (-66.67%)
Mutual labels:  cordova, phonegap
Cordova Template Framework7 Vue Webpack
Framework7 - Vue - Webpack Cordova Template with Webpack Dev Server and Hot Module Replacement
Stars: ✭ 630 (+1135.29%)
Mutual labels:  phonegap, cordova
Cordova Plugin Googleplus
➕ Cordova plugin to login with Google Sign-In on iOS and Android
Stars: ✭ 537 (+952.94%)
Mutual labels:  phonegap, cordova
cordova-swift3-plugin-example
Swift 3 Cordova plugin example to support blog post.
Stars: ✭ 23 (-54.9%)
Mutual labels:  cordova, phonegap
Cordova Plugin Linkedin
Cordova plugin for LinkedIn
Stars: ✭ 17 (-66.67%)
Mutual labels:  phonegap, cordova
vuetify-cordova
App template for hybrid apps using Vue.js / Vuetify / Cordova
Stars: ✭ 32 (-37.25%)
Mutual labels:  cordova, phonegap
ionic4-angular6-crud-example
Building CRUD Mobile App using Ionic 4, Angular 6 and Cordova
Stars: ✭ 50 (-1.96%)
Mutual labels:  cordova, phonegap
framework7-template-single-view
Deprecated! Framework7 single view starter app template
Stars: ✭ 34 (-33.33%)
Mutual labels:  cordova, phonegap
Cordova Plugin Native Keyboard
🎹 Add a Slack / WhatsApp - style chat keyboard to your Cordova app!
Stars: ✭ 271 (+431.37%)
Mutual labels:  phonegap, cordova
phonegap
PushBots' official module for Phonegap
Stars: ✭ 21 (-58.82%)
Mutual labels:  cordova, phonegap
cordova-plugin-zeep
Zip compression/decompression for the cordova/phonegap platform
Stars: ✭ 27 (-47.06%)
Mutual labels:  cordova, phonegap
Toast Phonegap Plugin
🍻 A Toast popup plugin for your fancy Cordova app
Stars: ✭ 503 (+886.27%)
Mutual labels:  phonegap, cordova
Hiapp
A simple and interesting hybrid app. React Native version: http://t.cn/R5LqqLz Demo:
Stars: ✭ 791 (+1450.98%)
Mutual labels:  phonegap, cordova

cordova-plugin-tensorflow

Integrate the TensorFlow inference library into your PhoneGap/Cordova application!

var tf = new TensorFlow('inception-v1');
var imgData = "/9j/4AAQSkZJRgABAQEAYABgAAD//gBGRm ...";

tf.classify(imgData).then(function(results) {
    results.forEach(function(result) {
        console.log(result.title + " " + result.confidence);
    });
});

/* Output:
military uniform 0.647296
suit 0.0477196
academic gown 0.0232411
*/

Installation

Cordova

cordova plugin add https://github.com/heigeo/cordova-plugin-tensorflow

PhoneGap Build

<!-- config.xml -->
<plugin spec="https://github.com/heigeo/cordova-plugin-tensorflow.git" />

Supported Platforms

  • Android
  • iOS

API

The plugin provides a TensorFlow class that can be used to initialize graphs and run the inference algorithm.

Initialization

// Use the Inception model (will be downloaded on first use)
var tf = new TensorFlow('inception-v1');

// Use a custom retrained model
var tf = new TensorFlow('custom-model', {
    'label': 'My Custom Model',
    'model_path': "https://example.com/graphs/custom-model-2017.zip#rounded_graph.pb",
    'label_path': "https://example.com/graphs/custom-model-2017.zip#retrained_labels.txt",
    'input_size': 299,
    'image_mean': 128,
    'image_std': 128,
    'input_name': 'Mul',
    'output_name': 'final_result'
})

To use a custom model, follow the steps to retrain the model and optimize it for mobile use. Put the .pb and .txt files in a HTTP-accessible zip file, which will be downloaded via the FileTransfer plugin. If you use the generic Inception model it will be downloaded from the TensorFlow website on first use.

Methods

Each method returns a Promise (if available) and also accepts a callback and errorCallback.

classify(image[, callback, errorCallback])

Classifies an image with TensorFlow's inference algorithm and the registered model. Will automatically download and initialize the model if necessary, but it is recommended to call load() explicitly for the best user experience.

Note that the image must be provided as base64 encoded JPEG or PNG data. Support for file paths may be added in a future release.

var tf = new TensorFlow(...);
var imgData = "/9j/4AAQSkZJRgABAQEAYABgAAD//gBGRm ...";
tf.classify(imgData).then(function(results) {
    results.forEach(function(result) {
        console.log(result.title + " " + result.confidence);
    });
});

load()

Downloads the referenced model files and loads the graph into TensorFlow.

var tf = new TensorFlow(...);
tf.load().then(function() {
    console.log("Model loaded");
});

Downloading the model files can take some time. If you would like to provide a progress indicator, you can do that with an onprogress event:

var tf = new TensorFlow(...);
tf.onprogress = function(evt) {
    if (evt['status'] == 'downloading')
        console.log("Downloading model files...");
        console.log(evt.label);
        if (evt.detail) {
            // evt.detail is from the FileTransfer API
            var $elem = $('progress');
            $elem.attr('max', evt.detail.total);
            $elem.attr('value', evt.detail.loaded);
        }
    } else if (evt['status'] == 'unzipping') {
        console.log("Extracting contents...");
    } else if (evt['status'] == 'initializing') {
        console.log("Initializing TensorFlow");
    }
};
tf.load().then(...);

checkCached()

Checks whether the requisite model files have already been downloaded. This is useful if you want to provide an interface for downloading and managing TensorFlow graphs that is separate from the classification interface.

var tf = new TensorFlow(...);
tf.checkCached().then(function(isCached) {
    if (isCached) {
        $('button#download').hide();
    }
});

References

This plugin is made possible by the following libraries and tutorials:

Source Files
TensorFlow Android Inference Interface libtensorflow_inference.so,
libandroid_tensorflow_inference_java.jar
TensorFlow Android Demo Classifer.java,
TensorFlowImageClassifier.java (modified)
TensorflowPod Referenced via podspec
TensorFlow iOS Examples ios_image_load.mm (modified),
tensorflow_utils.mm (+ RunModelViewController.mm)
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].