I'm using the onnxruntime-node package to do inferencing in my electron app. I installed the npm package via 'yarn add', and everything works as expected in development.
When I package the electron app, node isn't able to find the onnxruntime-node import.
In an attempt to solve this, I required the prebuild onnx runtime binaries instead.
const ort = require(path.join(`electron-app-dir\\node_modules\\onnxruntime-node\\bin\\napi-v3\\win32\\x64`,'onnxruntime_binding.node'));
This partially solves the problem, as node is able to find the prebuild binary, but I end up with a different error:
'TypeError: ort.InferenceSession.create is not a function'
I'm not sure now to proceed from here. There are some .dlls in the save directory as the onnxruntime_binding.node file. Do these need to be required as well?
Any help figured this out is appreciated!
For reference:
const ort = require(path.join(`electron-app-dir\\node_modules\\onnxruntime-node\\bin\\napi-v3\\win32\\x64`,'onnxruntime_binding.node'));
const modelPath = path.join(__dirname,'model.onnx')
const session = await ort.InferenceSession.create(modelPath);
...
It appears that you can't reference the binaries directly. You always need to reference the node module directory.
I ended up just copying the
onnxruntime-nodemodule into the packaged app resources directory along with the binaries, which works.