I am struggling to load a locally hosted Onnyxruntime model in ReactNative.
Imports:
import { Asset } from 'expo-asset';
import { InferenceSession } from "onnxruntime-react-native";
Here is what I am doing and the error this gives me.
const startOnnxRuntimeSession = async () => {
//path to model:
const model = require('../assets/model.ort');
const asset = Asset.fromModule(model);
if (!asset.localUri) {
await asset.downloadAsync();
}
// load a model
if (onnxSession !== null) {
const session: InferenceSession = await InferenceSession.create(asset.localUri);
setOnnxSession(session);
console.log("Onnx session started successfully");
}
}
The error that I am getting is that the model is null
Error: Can't load a model: null is not an object (evaluating '(0, _classPrivateFieldLooseBase2.default)(this, _inferenceSession)[_inferenceSession].loadModel')
I also tried just passing the path '../assets/model.ort' to the InferenceSession
const session: InferenceSession = await InferenceSession.create('../assets/model.ort');
This gives the same error "Null"