DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
Building Scalable Real-Time Apps with AstraDB and Vaadin
Register Now

Trending

  • MLOps: Definition, Importance, and Implementation
  • Tomorrow’s Cloud Today: Unpacking the Future of Cloud Computing
  • Structured Logging
  • Integrating AWS With Salesforce Using Terraform

Trending

  • MLOps: Definition, Importance, and Implementation
  • Tomorrow’s Cloud Today: Unpacking the Future of Cloud Computing
  • Structured Logging
  • Integrating AWS With Salesforce Using Terraform
  1. DZone
  2. Data Engineering
  3. AI/ML
  4. Combining DJL.AI With Apache NiFi for Deep Learning Workflows

Combining DJL.AI With Apache NiFi for Deep Learning Workflows

In this article, see how to use deep learning in Apache NiFi with a tutorial of how to build your own custom processor for deep learning.

Tim Spann user avatar by
Tim Spann
CORE ·
Dec. 20, 19 · Tutorial
Like (3)
Save
Tweet
Share
9.52K Views

Join the DZone community and get the full member experience.

Join For Free

Person deep under water with several small fish

NiFi + DJL.AI = A Merry Deep Learning Christmas


Happy Mmm...FLaNK Day!

I have been experimenting with the awesome new Apache 2.0 licensed Java Deep Learning Library, DJL. In NiFi, I was trying to figure out a quick use case and demo. So I used my Web Camera processor to grab a still shot from my Powerbook webcam and send it to the processor. The results are sent to slack.

Since it's the holidays, I think of my favorite holiday movies: The Matrix and Blade Runner. So I thought a Voight-Kampf test would be fun. Since I don't have a deep learning QA piece built yet, let's start by seeing if you look human. We'll call them 'person'. I am testing to see if I am a replicant. Sometimes it's hard to tell. Let's see if DJL thinks I am human.

See: http://nautil.us/blog/-the-science-behind-blade-runners-voight_kampff-test

Okay, so at least it thinks I am a person. The classification of a Christmas tree is vaguely accurate. So we can see how easy and powerful Deep Learning is in Java, adding it to NiFi makes it even easier.

It did not identify my giant french bread.

You might also be interested in:  Using Apache Spark and Apache NiFi to Run TensorFlow

Building a New Custom Processor for Deep Learning

The hardest part was a good NiFi Integration test. The DJL team provides some great examples, and it's really easy to plug into their models.

Java
xxxxxxxxxx
1
 
1
ZooModel<BufferedImage, DetectedObjects> model =
2
 
          
3
                     MxModelZoo.SSD.loadModel(criteria, new ProgressBar())
4
 
          
5
Predictor<BufferedImage, DetectedObjects> predictor = model.newPredictor()
6
 
          
7
DetectedObjects detection = predictor.predict(img);


All the sources are on GitHub and reference the below DJL sites and repos.

Using a New Custom Processor as Part of a Real-time Holiday Flow

We first add the DeepLearningProcessor to our canvas.

An example flow:

  • GetWebCameraProcessor: grab an image from an attached webcamera
  • UpdateAttribute: Add media type for image
  • DeepLearningProcessor: Run our DJL deep learning model from a zoo
  • PutSlack: Put DJL results in a text window in slack
  • PostSlack: Send our DJL altered image to slack
  • Funnel: Send all failures to Valhalla

If we example the provenance, we can see how long it took to run and some other interesting attributes.

We place the results of our image analysis in attributes while we return a new image that has a bounding box on the found object(s).

We now a full classification workflow for real-time deep learning analysis on images, could be used for Santa watching, Security, Memes and other important business purposes.

The initial release is available here: https://github.com/tspannhw/nifi-djl-processor/releases/tag/v1.0

Using library and example code from the Deep Java Library (https://djl.ai/).

  • https://github.com/awslabs/djl#getting-started
  • https://djl.ai/mxnet/mxnet-model-zoo/
  • https://github.com/awslabs/djl/blob/master/examples/pom.xml
  • https://github.com/tspannhw/djl/blob/master/examples/src/main/java/ai/djl/examples/inference/ObjectDetection.java
  • https://github.com/aws-samples/djl-demo
  • https://github.com/awslabs/djl/blob/master/jupyter/BERTQA.ipynb
  • https://github.com/awslabs/djl/blob/master/examples/src/main/java/ai/djl/examples/inference/BertQaInference.java

Source Code: https://github.com/tspannhw/nifi-djl-processor/

Further Reading

Exploring Apache NiFi 1.10: Parameters and Stateless Engine

Apache NiFi Overview

Deep learning Apache NiFi

Opinions expressed by DZone contributors are their own.

Trending

  • MLOps: Definition, Importance, and Implementation
  • Tomorrow’s Cloud Today: Unpacking the Future of Cloud Computing
  • Structured Logging
  • Integrating AWS With Salesforce Using Terraform

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: