Konduit Serving works by defining a series of steps. These include operations such as
Pre- or post-processing steps
One or more machine learning models
Transforming the output in a way that can be understood by humans
If deploying your model does not require pre- nor post-processing, only one step - a machine learning model - is required. This configuration is defined using a single ModelStep.
A reference Java project is provided in the Example repository ( https://github.com/KonduitAI/konduit-serving-examples ) with a Maven pom.xml dependencies file. If using the IntelliJ IDEA IDE, open the java folder as a Maven project and run the main function of the InferenceModelStepDL4J class.
Configure the step
Define the DL4J configuration as a ModelConfig object.
tensorDataTypesConfig: The ModelConfig object requires a HashMap input_data_types. Its keys should represent column names, and the values should represent data types as strings, e.g. "INT32", "FLOAT",etc,. See here for a list of supported data types.
modelConfigType: This argument requires a ModelConfigType object. In the Java program above, we recognised that SimpleCNN is configured as a MultiLayerNetwork, in contrast with the ComputationGraph class, which is used for more complex networks. Specify modelType as MULTI_LAYER_NETWORK, and modelLoadingPath to point to the location of DL4J weights saved in the ZIP file format.
Accepted input and output data formats are as follows:
Input: JSON, ARROW, IMAGE, ND4J (not yet implemented) and NUMPY.
Output: NUMPY, JSON, ND4J (not yet implemented) and ARROW.
The inferenceConfiguration is stored as a JSON File. Set the KonduitServingMainArgs with the saved config.json file path as configPath and other necessary server configuration arguments.
Start server by calling KonduitServingMain with the configurations mentioned in the KonduitServingMainArgs using Callback Function(as per the code mentioned in the Inference Section below)
Inference
We generate a (3, 224, 224) array of random numbers between 0 and 255 as input to the model for prediction.
Before requesting for a prediction, we normalize the image to be between 0 and 1:
To configure the client, set the required URL to connect server and specify any port number that is not reserved (as used in server configuration).
A Callback Function onSuccess is implemented in order to post the Client request and get the HttpResponse, only after the successful run of the KonduitServingMain Server.
Accepted input and output data formats are as follows:
Input: JSON, ARROW, IMAGE, ND4J (not yet implemented) and NUMPY.
Output: NUMPY, JSON, ND4J (not yet implemented) and ARROW.