gtbluesky / onnxruntime_flutter

A flutter plugin for OnnxRuntime provides an easy, flexible, and fast Dart API to integrate Onnx models in flutter apps across mobile and desktop platforms.
MIT License
68 stars 12 forks source link

vad iterator bounded with Widget #2

Closed ty1135 closed 9 months ago

ty1135 commented 11 months ago

one thing that i don't understand is that :

in example/main.dart, if move the creation of VadIterator into the function 'infer', everything just went crash.

ty1135 commented 11 months ago

I/flutter (30738): onnx provider=OrtProvider.nnapi I/flutter (30738): onnx provider=OrtProvider.xnnpack I/flutter (30738): onnx provider=OrtProvider.cpu W/libc (30738): Access denied finding property "ro.mediatek.platform" W/onnxruntime(30738): [W:onnxruntime:, graph.cc:3543 CleanUnusedInitializersAndNodeArgs] Removing initializer '628'. It is not used by any node and should be removed from the model. W/onnxruntime(30738): [W:onnxruntime:, graph.cc:3543 CleanUnusedInitializersAndNodeArgs] Removing initializer '629'. It is not used by any node and should be removed from the model. W/onnxruntime(30738): [W:onnxruntime:, graph.cc:3543 CleanUnusedInitializersAndNodeArgs] Removing initializer '623'. It is not used by any node and should be removed from the model.

ty1135 commented 11 months ago

E/flutter ( 3544): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: LateInitializationError: Field '_newIsolateSendPort@335028358' has not been initialized. E/flutter ( 3544): #0 OrtIsolateSession._newIsolateSendPort (package:onnxruntime/src/ort_isolate_session.dart) E/flutter ( 3544): #1 OrtIsolateSession.run (package:onnxruntime/src/ort_isolate_session.dart:82:5) E/flutter ( 3544): #2 OrtSession.runAsync (package:onnxruntime/src/ort_session.dart:226:28) E/flutter ( 3544): #3 VadIterator.predict (package:vad/vad_iterator.dart:80:37) E/flutter ( 3544): #4 _MyAppState.infer (package:vad/main.dart:78:25)

ty1135 commented 11 months ago

manually solved now by adding "await Future.delayed(Duration(seconds: 2));" after "vadIterator.initModel();"

the reason is that OrtIsolateSession._init() is not awaited. I tried to fix, but I failed.

flutter-painter commented 11 months ago

Why not create a branch for this fix So that others can also look ? Did you catch any exception ?