microsoft / microsoft/onnxruntime
[Feature Request] Support for running onnxruntime in Pyodide
- Dominant language
- C++
- Stars
- 21.9k
- Forks
- 4.2k
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 184
Description
### Describe the feature request
Would you consider supporting the [Pyodide](https://pyodide.com/) Python distribution in `onnxruntime`?
> Pyodide brings Python to the browser using WebAssembly, enabling you to run Python code without a server. It includes popular libraries like NumPy, Pandas, and Matplotlib, supports package installation via micropip, and bridges Python with JavaScript for interactive web apps and scientific computing.
Some previous discussion around this topic can be found in https://github.com/pyodide/pyodide-recipes/issues/272 and in https://github.com/microsoft/onnxruntime/issues/18036
To achieve this it would be possible to [check if the code is running under pyodide](https://pyodide.org/en/stable/usage/faq.html#how-to-detect-that-code-is-run-with-pyodide). If this is the case, the `js` package can be used to proxy calls to the wasm implementation of `onnxruntime`. This could look something like what has been done here: https://github.com/pyodide/pyodide-recipes/issues/272#issuecomment-3966515588
### Describe scenario use case
Adding this would benefit all use cases where people are running Pyodide and would like to run inference with the `onnxruntime` Python API. This includes projects like [Jupyter Lite](https://jupyterlite.readthedocs.io/en/stable/).
Of course, once `onnxruntime` is supported in Pyodide, it opens the door to creating Pyodide "recipes" for many different machine learning packages. For me specifically, the `gliner` and `gliner2` packages would be relevant.
Contributor guide
Research direction
The issue names no files or tests; start by reviewing the linked Pyodide recipe discussion and prior onnxruntime issue, then inspect the WebAssembly implementation and Python API entry points referenced there. Done means the onnxruntime Python API can run under Pyodide for the described inference use case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, python, wasm
- Domain
- machine-learning, web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100