createInferenceSession method
Creates an inference session using onnxruntime-web
Implementation
Future<JSObject> createInferenceSession(String modelPath, JSObject options) async {
final completer = Completer<JSObject>();
try {
// Get the InferenceSession class from onnxruntime-web
final inferenceSession = _ort.getProperty('InferenceSession'.toJS) as JSObject;
// Use the create method to create a session - async operation
final createPromise = callMethod(inferenceSession, 'create', [modelPath, options]);
// Convert Promise to Future
final session = await promiseToFuture<JSObject>(createPromise);
completer.complete(session);
} catch (e) {
completer.completeError('Failed to create inference session: $e');
}
return completer.future;
}