Skip to content

Files

Latest commit

c2544e6 · Jul 27, 2024

History

History
This branch is 2 commits behind yalue/onnxruntime_go_examples:master.

mnist

onnxruntime_go: MNIST Example

This example makes use of the pre-trained MNIST network, obtained from the official ONNX models repository. Specifically, the included mnist.onnx is MNIST-12 from the above link.

This example uses the network to analyze single image files specified on the command line.

Example Usage

Run the program with -help to see all command-line flags. In general, you will need to supply it with an input image.

./mnist -image_path ./eight.png
./mnist -image_path ./tiny_5.png

# There's an additional flag if you want to invert the image colors. The
# network is trained on images with black backgrounds, so you may want to
# invert images with white backgrounds.
./mnist -image_path ./seven.png -invert_image

Note that the program will also create postprocessed_input_image.png in the current directory, showing the image that was passed to the neural network after resizing and converting to grayscale.