/onnx-101

Code for the PyData talk on "But it works on my machine?! ONNX101".

Primary LanguagePythonMIT LicenseMIT

But it works on my machine?! ONNX 101

Repository containing the code for the ONNX 101 tutorial at the PyData Skopje - November 2023 Meetup

Content

  • Example for training a simple classifier using PyTorch for digit recognition on the MNIST dataset and exporting the model to ONNX.
  • Using the ONNX model with ONNX runtime for inference with a simple Express.js server. ort-web-api

Demo 1:

Pre-requisites:

Prepare the environment

poetry shell
poetry install

Obtain the dataset and train the model

python -m onnx_workshop.mnist

Inference with ONNX runtime

python -m onnx_workshop.inference

Demo 2

Pre-requisites:

Start the server

cd ort-web-api
npm install
node index.js

Make a request

curl --request POST \
  --url http://localhost:3000/classify-digit \
  --header 'Content-Type: multipart/form-data' \
  --form digit=examples/3.png