tree: 57fe2116f7cd022977f6e3c3717dd8936679fe58 [path history] [tgz]
  1. convert_to_float_grayscale.py
  2. mnist_test.png
  3. README.md
samples/vision_inference/README.md

Vision Inference Sample

This sample demonstrates how to run a MNIST handwritten digit detection vision model on an image using IREE's command line tools.

Instructions

From this directory:

# Compile the MNIST program.
iree-compile \
    ../models/mnist.mlir \
    --iree-input-type=mhlo \
    --iree-hal-target-backends=cpu \
    -o /tmp/mnist_cpu.vmfb

# Convert the test image to the 1x28x28x1xf32 buffer format the program expects.
cat mnist_test.png | python3 convert_to_float_grayscale.py > /tmp/mnist_test.bin

# Run the program, passing the path to the binary file as a function input.
iree-run-module \
  /tmp/mnist_test.bin \
  --function_input=1x28x28x1xf32=@/tmp/mnist_test.bin

# Observe the results - a list of prediction confidence scores for each digit.