Over a million developers have joined DZone.

Building a Custom Processor in Apache NiFi for TensorFlow Using the Java API

DZone's Guide to

Building a Custom Processor in Apache NiFi for TensorFlow Using the Java API

Learn how I used TensorFlow's new Java API with Apache NiFi, which uses a custom processor to perform image recognition.

· AI Zone ·
Free Resource

The most visionary programmers today dream of what a robot could do, just like their counterparts in 1976 dreamed of what personal computers could do. Read more on MistyRobotics.com and enter to win your own Misty. 

TensorFlow has released a Java API, so I decided to write a quick custom processor to run TensorFlow Inception v3.

It's a simple set of dependencies for Maven:

It's easy to add the new processor NiFi. First, build it using mvn install (see my build script), then deploy it:

cp nifi-tensorflow-nar/target/nifi-tensorflow-nar-1.0.nar /Volumes/Transcend/Apps/nifi-1.2.0/lib

Once you restart NiFi, you can add the TensorFlow Processor.

An example flow is to the use the very smart ListFile , which will iterate through a list of files and keep track of the timestamp of files it last accessed. I point to a directory of files and the NiFi processor gets fed a ton of images to very quickly process. This is much faster than my calling out to a script.

I gave it a picture of my RV...

And this is what it guessed. The result of the run is a new attribute, probabilities, which is a string description of what it could be a confidence percentage as text:

Here's the source code.


Robot Development Platforms: What the heck is ROS and are there any frameworks to make coding a robot easier? Read more on MistyRobotics.com

nifi ,tensorflow ,hadoop ,java api ,ai ,image recognition ,tutorial

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}