loading...
Cover image for DJL - Deep Java Library

DJL - Deep Java Library

dhruvesh_patel profile image Dhruvesh Patel ・2 min read

Want to get hands dirty with Machine Learning / Deep Learning, but have got Java background and do not know where to start? Then read on, this post is about using existing Java skillset and ramp-up your journey to start building deep learning models.

What is DJL?

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 this 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". Developer can develop model using DJL and run it on an engine of your choice - MXNet, Pytorch, TensorFlow.

DJL Example for Object Detection

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 available here.

Local software setup

  • Install JDK 8 (DJL has some known issues with JDK 11)
  • Install IntelliJ a IDE
  • Import DJL project using IntelliJ

Refer setup related more details here.

For Java source code for ObjectDetection.java class, which is using DJL can be found here.

Run the Object Detection Example:

  • Input image is used as below.

DJL - Input Image

  • Build the project and run Use the following command to run the project:

Build project

  • Output should look like the following:

DJL Output

An output image with bounding box will be saved as build/output/detected-dog_bike_car.png:

DJL - Output

Conclusion

Within Deep learning landscape, there are lots of resources for Python users like NumPy for data analysis or frameworks such as MXNet, TensorFlow. But, the very few sources for Java. Thanks to AWS team, DJL provides open source tools to train and serve Deep learning models in Java and makes it easy to start deep learning journey.

Enjoy building machine learning applications with power of DJL !

Please like, share and comment your views/ opinion.

Disclaimer - This post is my personal opinion and does not reflect those of any of my past, present or future employers or affiliations.

Discussion

pic
Editor guide
Collapse
shreya1310 profile image
Shreya1310

Nicely explained!!! DJL is good way to start deep learning journey for Java techie...

Collapse
dhruvesh_patel profile image
Dhruvesh Patel Author

Yup, it is...Puts your skills to use and lets you jump start deep learning.

Collapse
prabhat36539454 profile image
Prabhat Kumar

Nicely explained

Collapse
dhruvesh_patel profile image
Dhruvesh Patel Author

Thanks for kind words.

Collapse
siy profile image
Sergiy Yevtushenko

I'd say it's the DJL has problems with Java 11 (rather than vice versa), but otherwise interesting article.

Collapse
dhruvesh_patel profile image
Dhruvesh Patel Author

Hi Sergiy, Good point. I have revised wording to have correct inference. Glad that you liked reading article.

Collapse
chiragks profile image
Chirag Shah

Amazing used of Java Tech. , Please keep share article like this.

Collapse
dhruvesh_patel profile image
Dhruvesh Patel Author

Thanks for kind words.

Collapse
hennalyons profile image
Henna Lyons

nice DJL Example for Object Detection

Collapse
dhruvesh_patel profile image
Dhruvesh Patel Author

Thanks for the feedback.

Collapse
amandahopkins profile image
AmandaHopkins

very nice article..

Collapse
dhruvesh_patel profile image
Dhruvesh Patel Author

Thanks for the feedback.

Collapse
phyllisroberts profile image
PhyllisRoberts

Nice Share

Collapse
dhruvesh_patel profile image
Dhruvesh Patel Author

Thanks for your comment, glad that you liked reading the article.

Collapse
luciolangworth profile image
LucioLangworth

Man, It's perfect details information..

Collapse
dhruvesh_patel profile image
Dhruvesh Patel Author

Thank you for kind words.