aeon-toolkit / aeon

A toolkit for machine learning from time series
https://aeon-toolkit.org/
BSD 3-Clause "New" or "Revised" License
989 stars 118 forks source link

[ENH] Support of ONNX format for model persistance and deployment #44

Open aiwalter opened 1 year ago

aiwalter commented 1 year ago

ONNX is a stadardised ML persistance format for deployment e.g. on edge devices. We would have to write a custom ONNX "wrapper" , here is how that works for scikit-learn: https://onnx.ai/sklearn-onnx/

Useful links: https://github.com/onnx/onnxmltools https://github.com/onnx/onnx

Related: https://github.com/sktime/sktime/issues/1240

mbignotti commented 1 year ago

Hi! Apologies for entering the discussion as a complete stranger to the project. But, since this seems to be a very common issue for people who work with numpy/scikit learn (including myself), I just wanted to add a couple of links that could potentially help. Essentially, writing an onnx converter for a custom model, implies having to write the model twice. The creator of sklearn-onnx is aware of this problem, and that's why he wrote a library that tries to simplify writing custom estimators/transformers that are also directly convertible to onnx: https://github.com/sdpython/mlprodict However, I'm not 100% sure that the library is production ready. Also, it is not updated very often.

On the other side, Microsoft took a different approach. You fit your model as usual and then you convert it to a corresponding tensor-based model: https://github.com/microsoft/hummingbird The conversion creates a valid pytorch model, which can then be converted to onnx (or other formats). They don't have an api for writing custom converters yet, but they might be willing to add it, if someone contributes to it.

I'm posting this here because I just wish that the community, soon or late, could come up with a nice solution to the deployment problem of more traditional models, which has been completely neglected in favor of deep learning frameworks.

Thanks a lot for your framework!