Updated PyTorch by using pip install --upgrade torch torchvision torchaudio. After reading this guide (PyTorch vs TensorFlow for Your Python Deep Learning Project) I can see that if I’m targetting Javascript I’m better off with TensorFlow or Keras.

All of these are supported by pip so run ‘pip install tensorfloW’ (it also installs keras).

I tried converting Keras to ONNX with no success but found Keras.js which means that I can skip it altogether.

It has an example that does a great job at detecting numbers too. Onward to Goal #1, round two!

I used the basic script (train with 15 epochs but save and load the resulting model) and got an accuracy of 99.26% and 99.30% for 15 and 30 epochs, respectively. The file size going from 5.8 MB (PyTorch) to 452.2 KB (Keras) is impressive.


Now for Inference Online, I’ll stick to Tensorflow.js.

Rhankfully the MNIST dataset is used in most of these.