Coder Social home page Coder Social logo

tensorflow-java's Introduction

tensorflow-java

Tensorflow Java pipeline and examples. This simple Java pipeline for TensorFlow Java API supports Tensorflow >= 1.4 and it has been tested with TF 1.4.0 and TF 1.6.0.

How To Install

You need to run the jni.sh to install the right Java bindings for your platform and the download.sh script that will download the inception5 model in order to be ready to run a simple examples:

git clone https://github.com/loretoparisi/tensorflow-java.git \
cd tensorflow-java \
sh jni.sh \
sh download.sh \

A simple Hello World example

Create a simple Java class with a main to be executable and import org.tensorflow.TensorFlow

import org.tensorflow.TensorFlow;

public class TensorFlowExample {
  public static void main(String[] args) {
    System.out.println("TensorFlowExample using TensorFlow version: " +  TensorFlow.version());
  }
}

Save it and then from command line compile and run

cd tensorflow-java
javac -cp lib/libtensorflow-1.6.0.jar TensorFlowExample.java
java -cp lib/libtensorflow-1.6.0.jar:. -Djava.library.path=./jni TensorFlowExample

If you get the TensorFlow version as output it worked!

TensorFlowExample using TensorFlow version: 1.0.0-rc2

Real world (Inception) example

We use the LabelImage official Tensorflow example to label an example image with the inception graph model.

$ javac -cp lib/libtensorflow-1.6.0.jar LabelImage.java 
$ java -cp lib/libtensorflow-1.6.0.jar:. -Djava.library.path=./jni LabelImage models/ images/example-400x288.jpg 
BEST MATCH: lakeside (19,00% likely)

Disclaimer

This example is provided as it is and it is based on the official Tensorflow Java JNI wrapper and example available here.

tensorflow-java's People

Contributors

loretoparisi avatar

Watchers

Michael Feng 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.