As a data protection lawyer, I am very aware of the privacy implications when it comes to model deployment. That’s what got me thinking: Could you train a model in fastai and run it in the browser? Turns out you can!
All the pieces were already in place, but it was somewhat difficult to connect that dots. So I open-sourced my pet project and wrote a short blog post documenting the findings.
If you find any mistakes that I made, please let me know! I want to thank everybody in the fastai community, which is the most helpful community I have ever encountered.
Turns out onnx.js 0.1.7 somehow doesn’t like the nn.BatchNorm1d layer. The workaround I found was to disable the input check in onnx.min.js (I had to pretty-print it first using Chrome dev tools, and we’re looking at lines 19789-19790):
if (!(t = e.op).checkInputs(h))
throw new Error("invalid inputs detected; op: " + e.node.name);
If you comment these two out and add the below line instead, it works again: