

FXApps: Using tensorflow from a Java application
source link: http://fxapps.blogspot.com/2017/04/using-tensorflow-from-java-application.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Using tensorflow from a Java application
At this point you probably have heard about TensorFlow, the famous Google library for deep learning.
Although the TensorFlow core is C/C++, the most famous API is Python (as you can see in Siraj or sintdex tutorials), but recently TensorFlow released a Java version for the API.
TensorFlow has a small tutorial about the Java API and a single more complex example to classify image. On this small tutorial the link to the tensorflow JAR is broken. I found a working JAR in this URL. The upstream tutorial was already corrected as you can see in github.
There's also the labeled image example, which is very simple as well, but a few additional steps must be taken:
- Download the content from this URL and unzip it. It is the labeled dataset
- Download the LabelImage class from github. When saving it locally remember to remove the package declaration.
- Having the tensorflow JAR you downloaded previously and the native library, you can compile and run the class passing the directory where you unzipped the labeled dataset and a test image.
Maven
A few days ago the tensorflow artifacts was added to maven central repository. To use it you just need the dependency org.tensorflow:tensorflow:1.1.0-rc1. Seriously, no other configuration is required, you just need to add this dependency and everything should work. A test sample maven application can be found at my github.You will find a simple JavaFX Application that allows you to select a file that will be analyzed by the same code used in the LabelImage official example. See some screenshot: To run this application locally you must have maven and Java. Then download the dataset and the labels and modify the PATH_TO_DATA_DIR in App class to the path were you extracted it. Finally, just run:
mvn -q compile exec:java
And it should open the application. All my tests were made on a linux machine, hence I don't know if it would work on Windows.
Conclusion
TensorFlow Java API is very easy to "install" and use. I would say that it is easier than python installation!Recommend
-
11
Creating Fat JARs for JavaFX Applications A FAT JAR is a type of Java application distribution where a single JAR contains all other dependencies, so no additional file is required to run the JAR besides the Java Virtual Machine....
-
11
One of the most fascinating topics in computer science world is Artificial Intelligence. A subset of Artificial intelligence are the algorithms that were created inspired in the...
-
28
Database Query Server using Quarkus We are updating our application to Quarkus and I have this requirement of supporting datasouces that users of our application can create.This is already supported in
-
6
That's exciting. I just finished a post about JArduino and Java and I was supposed to sleep, but I wanted to give it a try with JavaFX, so I did an...
-
12
Control Arduino from Java using JArduino In general when we want to integrate Java with Arduino we can use the serial port for interaction, where arduino will receive commands and also write sensors information. This is greatly e...
-
14
Computer Vision with JavaFX and DJL Computer Vision is not a new topic in Computer Science, but in the recent years it got a boost due the use of Neural Networks for cla...
-
5
Article Deploy a Java application using Helm, Part 1
-
3
Last modified: If you are trading with Kraken or Revolut, then you are going to love
-
6
Deploy a Java application on Red Hat OpenShift using JKube Skip to main content
-
7
Quick Java application setup using Kafka messaging Skip to main content ...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK