Image Classification Demo (Go)#

This client demonstrates how to interact with OpenVINO Model Server prediction endpoints from a Go application. The example shows end-to-end workflow for running classification on JPEG/PNG images using a ResNet50 model. To simplify the environment setup, the demo is run inside a Docker container.

Clone the repository and enter directory:

git clone https://github.com/openvinotoolkit/model_server.git
cd model_server/demos/image_classification/go

Get the model#

To run end to end flow and get correct results, please download resnet-50 model and set preprocessing layers in OVMS. Commands are presented below.

For example:

curl --fail -L --create-dirs https://github.com/onnx/models/raw/main/validated/vision/classification/resnet/model/resnet50-caffe2-v1-9.onnx -o models/resnet/1/resnet50-caffe2-v1-9.onnx
chmod -R 755 models

Build Go client docker image#

Before building the image let’s copy single zebra image, here so it’s included in the docker build context. This way client container will already have a sample to run prediction on:

cp ../../common/static/images/zebra.jpeg .

Then build the docker image and tag it ovmsclient:

docker build . -t ovmsclient

Start OpenVINO Model Server with ResNet model#

Before running the client launch OVMS with prepared ResNet model. You can do that with a command similar to:

docker run -d --rm -p 9000:9000  -v ${PWD}/models:/models openvino/model_server:latest --model_name resnet --model_path /models/resnet --port 9000 --layout NHWC:NCHW --mean "[123.675,116.28,103.53]" --scale "[58.395,57.12,57.375]" --shape "(1,224,224,3)" --color_format BGR:RGB --precision uint8:fp32

Note Layout for downloaded resnet model is changed to NHWC. It ensures that the model will accept binary input generated by the client. See binary inputs doc if you want to learn more about this feature.

Run prediction with Go client#

In order to run prediction on the model served by the OVMS using Go client run the following command:

docker run --net=host --rm ovmsclient --serving-address localhost:9000 zebra.jpeg

Exemplary output:

2026/02/23 14:22:11 Request sent successfully
Predicted class: zebra
Classification confidence: 99.837669%

Command explained:

  • --net=host option is required so the container with the client can access container with the model server via host network (localhost),

  • --serving-address parameter defines the address of the model server gRPC endpoint,

  • the last part in the command is a path to the image that will be send to OVMS for prediction. The image must be accessible from the inside of the container (could be mounted). Single zebra picture - zebra.jpeg - has been embedded in the docker image to simplify the example, so above command would work out of the box. If you wish to use other image you need to provide it to the container and change the path.

You can also choose if the image should be sent as binary input (raw JPG or PNG bytes) or should be converted on the client side to the data array accepted by the model. To send raw bytes just add --binary-input flag like this:

docker run --net=host --rm ovmsclient --serving-address localhost:9000 --binary-input zebra.jpeg

Exemplary output:

2026/02/24 06:44:53 Request sent successfully
Predicted class: zebra
Classification confidence: 99.857803%