A seasoned Cloud Solution Architect and hands-on Cloud-native backend developer
Want to get your hands dirty with Machine Learning / Deep Learning, but have a Java background and not sure where to start? Then read on! This article is about using an existing Java skillset and ramp-up your journey to start building deep learning models.
DJL is an open-source library to build and deploy deep learning in Java. DJL is built by AWS and is open source.
DJL provides a native Java development experience and functions like any other regular Java library & expedite machine learning and deep learning journey. Developers can use their existing IDE (Eclipse/ IntelliJ) to build, train and deploy models and DJL makes it easy to integrate these models with Java Apps.
The simple APIs abstract away the complexity involved in developing Deep learning models. With the bundled set of pre-trained models from ModelZoo, users can immediately start integrating Deep learning into their Java applications.
DJL is engine-agnostic and goes with Java fundamental "Write once, run anywhere". A developer can develop a model using DJL and run it on an engine of your choice - MXNet, Pytorch, TensorFlow.
Object detection is a computer vision technique for locating instances of objects in images or videos.
In this example, we will learn how to implement inference code with a ModelZoo model to detect dogs in an image. Source code for this model is here.
Local Software Setup
For more details: https://docs.djl.ai/docs/development/setup.html
For Java source code for ObjectDetection.java class, which is using DJL can be found here.
Input image is used as below:
Build the project and run
Use the following command to run the project:
cd examples ./gradlew run -Dmain=ai.djl.examples.inference.ObjectDetection
Output should look like the following:
[INFO ] - Detected objects image has been saved in: build/output/detected-dog_bike_car.png [INFO ] - [ class: "car", probability: 0.99991, bounds: [x=0.611, y=0.137, width=0.293, height=0.160] class: "bicycle", probability: 0.95385, bounds: [x=0.162, y=0.207, width=0.594, height=0.588] class: "dog", probability: 0.93752, bounds: [x=0.168, y=0.350, width=0.274, height=0.593] ]
An output image with bounding box will be saved as build/output/detected-dog_bike_car.png:
Within Deep learning landscape, there are lots of resources for Python users like NumPy for data analysis or frameworks such as MXNet, TensorFlow. But very few sources for Java. Thanks to the AWS team, DJL provides open-source tools to train and serve Deep learning models in Java and make it easy to start your deep learning journey.
Please like, share and comment with your views/opinions.
Disclaimer: This post is my personal opinion and does not reflect those of any of my past, present or future employers or affiliations.
Create your free account to unlock your custom reading experience.