03/12/2019 AWS has announced the Deep Java Library for developing and deploying machine learning models in Java.
It's just a little, but I've touched it so I'll introduce it. As for prior knowledge, I usually use Java, but my knowledge of ML / DL is almost zero.
here,
Announcing DJL, an open source library for developing deep learning models in Java. DJL provides a user-friendly API for training, testing, and deploying deep learning models. If you are a Java user interested in deep learning, DJL is a great starting point. For Java developers working on deep learning models, DJL makes it easy to train and execute predictions.
So I'm hoping to touch it.
The official page is below, but the Amazon / AWS colors are not very visible. https://djl.ai/
Try
Anyway, let's move it according to the tutorial.
https://github.com/awslabs/djl.git
It seems good to clone from and move the example and below.
#Run in a suitable folder
git clone https://github.com/awslabs/djl/
After cloning, go to the example folder and take a look at the README.md there.
There are various kinds of examples as below, so let's try the first one first.
Let's do a Single-shot Object Detection example.
First of all, you are asked to set it up, but since it is only used with Java 11+, environment variables, and IntelliJ as an option, it seems that people who usually do Java can proceed without reading too much.
In this example, we use a pre-prepared ZooModel, hit an image against it to express what animal is reflected in it, and make an image with the recognized part surrounded by a square. It becomes an example.
Suddenly, you can check the operation below. (Quoted from object_detection.md)
cd examples ./gradlew run -Dmain=ai.djl.examples.inference.ObjectDetection
The following is displayed as the execution result. It will take some time for the first time to download the library, but it will take about 10 seconds after the second time.
$ ./gradlew run -Dmain=ai.djl.examples.inference.ObjectDetection
> Task :run
Loading: 100% |████████████████████████████████████████|
[22:02:10] src/nnvm/legacy_json_util.cc:209: Loading symbol saved by previous version v1.5.0. Attempting to upgrade...
[22:02:10] src/nnvm/legacy_json_util.cc:217: Symbol successfully upgraded!
[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]
]
BUILD SUCCESSFUL in 11s
3 actionable tasks: 1 executed, 2 up-to-date
The result is that a car, a bicycle and a dog are shown.
Although it will be a retrofit, [ai.djl.examples.inference.ObjectDetection](https://github.com/awslabs/djl/blob/master/examples/src/main/java/ai/djl/examples/inference/ If you look at the ObjectDetection.java) class
Path imageFile = Paths.get("src/test/resources/dog_bike_car.jpg ");
You can see that this image is Input.
After execution, the output image is in build / output / detected-dog_bike_car.png
. (Implemented in the same class)
You can do it properly.
By replacing the Input image, it seems that Object Detection can be performed with another image.
again ai.djl.examples.inference.ObjectDetection If you look at it, you can see that even myself, who only understands Java, is doing something. The logger settings are familiar and give you a sense of familiarity.
I read the general flow as follows.
--Logger settings --Reading the input image --Setting of various parameters to be passed to the model --Pass parameters and images to a pre-prepared model called MxModelZoo (MxNet based model) --Implementation of forecast --Reflect the prediction result on the image --Output the prediction result to the standard output
It's like that. It is necessary to confirm in detail what each parameter means, but I honestly thought that Object Detection using the prepared model is a low hurdle.
The dependent library of the project that included the example looked like the following. There seems to be no duplication with the Spring system, so it seems that it can be used together without conflicts.
For the time being, I tried only one example using DJL.
I used to think about touching DeepLearning4J, but I was stumbling around the environment construction and shelving it, but this time it was smooth.
All ML / DL systems in Java! I could not reach the feeling, but when using ML / DL for only one function of a general Web system, I thought that it might be good to try using this with a small start. ..
Recommended Posts