Pytorch (IRIS)
Running and IRIS dataset classifier through CUSTOM endpoints
Overview
This documentation shows Konduit-Serving can serve a custom model and include post-processing in the pipeline to give a direct output label understood by a human. Iris model is used in this example to deploy on the server as a classifier through custom endpoints.
Adding package to the classpath
First of all we need to add the main package to the classpath so that the notebook can load all the necessary libraries from Konduit-Serving into the Jupyter Notebook kernel.
Classpaths can be considered similar to site-packages in the python ecosystem where each library that's to be imported to your code is loaded from.
We package almost everything you need to get started with the konduit.jar package so you can just start working on the actual code, without having to care about any boilerplate configuration.
%classpath add jar ../../konduit.jarLet's ensure the working directory is correct and list all the file available in the directory.
%%bash
echo "Current directory $(pwd)" && treeYou'll be able to view as the following.
Current directory /root/konduit/demos/1-pytorch-onnx-iris
.
├── dataset
│ └── iris.csv
├── iris.onnx
├── onnx-iris.ipynb
├── onnx.yaml
└── train.py
1 directory, 5 filesMain model script code
We're creating a Pytorch model from scratch here and then converting that into ONNX format.
You'll be able to browse the source code how the training takes places.
Viewing the configuration file
The configuration for the custom endpoint is as follow:
The output shows configurations in YAML, in which you can see two steps in the pipeline, serving a model and post-processing to make it directly understood by a human.
Starting the server
konduit serve can be used together with ID's name (use any name) and configuration file to start the server.
You'll get the following message.
To view the logs of the running server, use konduit logs commands.
You'll be able to see the following from logging.
Sending inputs
Now we can send our inputs through cURL for inference
So, the server will print out the output with a label.
Try once again with --input-type flag.
You'll see the output of the prediction.
Stopping the server
Now after we're done with the server, we can stop it through the konduit stop command
You'll receive this once the server is terminated.
Let's take a look at the following example, where we are going to give an image input and doing pre-processing step before fetching it into the model.
Last updated
Was this helpful?