JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 51
  • Score
    100M100P100Q75953F
  • License Apache 2.0

A TensorFlow inference library for react native

Package Exports

  • react-native-tensorflow

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-native-tensorflow) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

react-native-tensorflow

A TensorFlow inference library for react native. It follows the android inference api from TensorFlow: https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/android

This library is currently only supporting android

Getting started

$ npm install react-native-tensorflow --save

Mostly automatic installation

$ react-native link react-native-tensorflow

Additional steps for iOS

First you will need CocoaPods.

Create a Podfile in the iOS directory with the following content:

target '<ProjectName>'
       pod 'TensorFlow-experimental'

Then run pod install.

Usage

First you need to put a model in the android/src/main/assets folder for Android and for iOS put the model using XCode in the root of the project. Then you can create an instance providing the file name of the model. Next you will need to feed an image in the form of a number array. Then run the inference and lastly fetch the result.

import TensorFlowInference from 'react-native-tensorflow';


const tensorflowInference = new TensorFlowInference('tensorflow_inception_graph.pb')
tensorflowInference.feed('inputName', [1,2,3,4,...])
tensorflowInference.run('outputNames')
tensorflowInference.fetch('outputName', 10).then(output => console.log(output))

Check the android TensorFlow example for more information on the API: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/android/src/org/tensorflow/demo/TensorFlowImageClassifier.java