ONNX
backends/onnx
Handler file for choosing the correct version of ONNX Runtime, based on the environment. Ideally, we could import the onnxruntime-web
and onnxruntime-node
packages only when needed, but dynamic imports donβt seem to work with the current webpack version and/or configuration. This is possibly due to the experimental nature of top-level await statements. So, we just import both packages, and use the appropriate one based on the environment:
When running in node, we use
onnxruntime-node
.When running in the browser, we use
onnxruntime-web
(onnxruntime-node
is not bundled).
This module is not directly exported, but can be accessed through the environment variables:
Copied
import { env } from '@xenova/transformers';
console.log(env.backends.onnx);
backends/onnx.ONNX : <code> module </code>
The ONNX runtime module.
Kind: static property of backends/onnx
Last updated