I tried the onnx.js (Getting Started example) from their git repository and it worked as expected.
Now I'm trying the same thing with node.js and webpack, but I'm getting a weird error when loading the model.
onnx.min.js:14 Uncaught (in promise) TypeError: Cannot read property 'webgl' of undefined
the code
import { Tensor, InferenceSession } from "onnxjs";
const init = async ()=>{
const session = new InferenceSession({ backendHint: 'webgl'});
await session.loadModel("./models/onnx/squeeze_net.onnx")
...
}
init();
The model path is correct, loaded successfully with Axios.
The same error is returned with backendHint
set to cpu
or wasm
onnx.min.js:14 Uncaught (in promise) TypeError: Cannot read property 'cpu' of undefined
onnx.min.js:14 Uncaught (in promise) TypeError: Cannot read property 'wasm' of undefined