Components
Describes the components that make up Konduit-Serving
Components
Konduit-Serving has many internal components that work together to achieve the desired result. Following are the main concepts and components that make up Konduit-Serving:
CLI
Jar Package
Pipelines
Pipeline Step
Inference Configuration
This page will go through each one of them and explain what they are used for.
CLI Interface
Konduit-Serving comes with a CLI interface (with a konduit
alias) that's responsible for taking care of most aspects of the application. The help command will describe most of what we are able to do with Konduit-Serving. Executing konduit --help
command will show us the following output:
Each command describes its shorthand description right in front of it. If you want to look at an individual command in detail, you can use the corresponding --help command with them. For example, the help menu for the logs command can be seen by executing, konduit logs --help:
As can be seen, the --help command for an individual help command describes its functionality in detail along with some explicit examples and use cases. It also describes each individual optional/non-optional argument that can be used with it. This can come in very handy while learning about konduit-serving for the first time and is a useful starting place to play around with a specific command. You can do the same for the rest of the commands. Which are:
build
config
inspect
list
logs
predict
metrics
profile
pythonpaths
serve
stop
version
Jar File Package
Each Konduit-Serving distribution whether it is for Windows, Linux or MacOS comes contained in a JAR file. So, you'll need a Java Virtual Machine present in the system where you're using Konduit-Serving as a Model Pipeline Server. The CLI itself is linked with the jar file and utilizes a java runtime internally to interact with the Konduit-Serving package. If you look at the konduit serving distribution, you'll see the following folder architecture in the root folder:
The main CLI logic is places under bin/konduit file, which contains the following content:
As you can see, it uses the java command which is available through a Java runtime environment. The java command itself uses the konduit.jar file which is the main application package inside a Konduit-Serving distribution.
This JAR file will be used as a Java application dependency while creating custom endpoints logic for a Konduit-Serving pipeline. We'll get to how we can do that later in this notebook.
Introduction to Pipelines
Throughout this document the term "Model Serving Pipeline" has been used. This refers to how Machine Learning or Deep Learning models get served on an application server. Machine/Deep Learning models work on n-dimensional arrays (also known as ND-Arrays). They don't know how to convert a JPEG or PNG image into numbers directly. Instead, they expect pre-processed data in the form of a multidimensional array. Also, any other form of data, be it text, audio or video, gets converted into numbers ND-Arrays before getting fed into a machine learning model.
The process during which the data is converted from one form to another is called pre-processing and is done just before it's fed as a model input. So, in a sense you can see this as being Lego blocks fitting into each other. One part takes input in a specific form and outputs it into another form, which in turn gets fed into the next part. This chaining of processes creates a series of steps which have specific jobs to perform before the next step and the end result is a machine learning Pipeline. The typical flow of the pipeline looks like the following:
A pipeline can also be in the form of a directed acyclic graph or DAG where data can flow into the graph and can give multiple outputs. In Konduit-Serving a Pipeline graph can also contain optional graph branches and can also concatenate outputs from multiple graph nodes. For the sake of the current goal (BMI Model Serving) we'll stick to a Sequential Pipeline which only has one input and one output.
Pipeline Steps
Inside Konduit-Serving, a pipeline can be broken down into steps, where each step is responsible for performing a specific function. A pipeline step is the smallest component of a whole pipeline and can be used for a whole list of operations. To see the list of available pipeline steps you can use the config command in Konduit-Serving CLI.
config command can take a pipeline pattern string and creates a pipeline configuration as well as server configuration. The server configuration combined with pipeline step configuration is collectively called Inference Configuration in Konduit-Serving. This is the final output from the config command.
The following pipeline step types can be used to configure a pipeline configuration.
# | Pipeline Step Type Name | Description |
01 | CROP_GRID | A pipeline step that crops sub images out of a larger image, based on a grid. |
02 | CROP_FIXED_GRID | This step is similar to CROP_GRID with the difference that the x/y location values are hardcoded into the configuration, instead of coming dynamically from the input Data instance. |
03 | DL4J | A model pipelinestep that serves a DL4J model. |
04 | KERAS | A model pipeline step that serves a Keras model. |
05 | DRAW_BOUNDING_BOX | A pipeline step that configures how to draw a bounding box onto an image. The bounding box data, that's to be drawn, is taken from the previous step's data instance. |
06 | DRAW_GRID | Draw a grid on the specified image, based on the x/y coordinates of the corners, and the number of segments within the grid in both directions. |
07 | DRAW_FIXED_GRID | A pipeline step that draws a grid on an image. This is similar to DRAW_GRID but the corner x/y location values are hardcoded into the configuration (via points), instead of coming dynamically from the input Data instance. |
08 | DRAW_SEGMENTATION | A pipeline step that configures how to draw a segmentation mask, optionally on an image. |
09 | EXTRACT_BOUNDING_BOX | A pipeline step that extracts sub-images from an input image, based on the locations of input bounding boxes. |
10 | CAMERA_FRAME_CAPTURE | A pipeline step that specifies an input that's taken from a camera feed. |
11 | VIDEO_FRAME_CAPTURE | A pipeline step that configures how to extract a single frame from a video each time inference is called. The video path is hardcoded, mainly used for testing/demo purposes. |
12 | IMAGE_TO_NDARRAY | A PipelineStep for converting images to n-dimensional arrays. |
13 | LOGGING | A step that logs the key and value pairs coming from the previous steps. |
14 | SSD_TO_BOUNDING_BOX | A pipeline step that configures extraction of bounding boxes from an SSD model output. |
15 | SAMEDIFF | A model pipeline step that serves a SameDiff model. |
16 | SHOW_IMAGE | A pipeline step that configures how to show/render an image from a previous step in an application frame. Usually only used for testing and debugging locally, not when serving from HTTP/GRPC etc endpoints. |
17 | TENSORFLOW | A model pipeline step that serves a TensorFlow model using Tensorflow Java API. This is packaged into Konduit-Serving through JavaCPP. |
18 | ND4JTENSORFLOW | A pipeline step that configures a TensorFlow model that is to be executed based on an ND4J graph runner. This has performance benefits over native TensorFlow Java distribution. |
19 | PYTHON | This pipeline step can take an arbitrary python script and serve that through Konduit-Serving. |
20 | ONNX | A model pipeline step that serves a ONNX model. |
Inference Configuration
Inference configuration contains all the details about how the pipeline server should be setup, which protocol it’s supposed to use for sending in/out data, whether we have a sequential or graph pipeline and finally how the pipeline is configured. The config command outputs inference configuration for us that can be directly used with a serve command after necessary changes are made. An Example of inference configuration through config command is as follows:
The above command creates a yaml configuration for a logging pipeline step. Logging pipeline step just takes in an input from the previous pipeline step and outputs (and logs on console) the same information. This is useful for debugging issues in the running servers.
This configuration can be saved inside a file by executing the following:
Afterwards, this configuration can be used with the serve command to start a Konduit-Serving server. Example is following:
Last updated