DL4J Step
Example of applying DL4J Step
This example splits into two parts which are configuring the inference configuration and running the server.
import ai.konduit.serving.examples.utils.Train;
import ai.konduit.serving.models.deeplearning4j.step.DL4JStep;
import ai.konduit.serving.pipeline.impl.pipeline.SequencePipeline;
import ai.konduit.serving.vertx.api.DeployKonduitServing;
import ai.konduit.serving.vertx.config.InferenceConfiguration;
import ai.konduit.serving.vertx.config.InferenceDeploymentResult;
import com.mashape.unirest.http.Unirest;
import com.mashape.unirest.http.exceptions.UnirestException;
import io.vertx.core.DeploymentOptions;
import io.vertx.core.VertxOptions;
import org.json.JSONArray;
import org.json.JSONObject;
import java.util.Arrays;Configure the step
Let's start from the main function by getting the trained model.
//get the file of trained model
Train.ModelTrainResult modelTrainResult = Train.dl4jIrisModel();Create an inference configuration by default.
We'll need to include DL4JStep into the pipeline and bind with the inference configuration. Specify the following:
modelUri: the model file pathinputNames: names for model's input layeroutputNames: names for model's output layer
Deploy the server
Let's deploy the model in the server by calling DeployKonduitServing with the configuration made before. The handler, a callback function, is implemented to capture a successful or failed server deployment state.
Note that we consider only one test input array in this example for inference to show the model's deployment in Konduit-Serving. After execution, the successful server deployment gives below output text.
The complete inference configuration in YAML format is as follows.
Last updated
Was this helpful?