pytorch_lite
pytorch_lite copied to clipboard
Error using Isolates (Multithreading)
Is it possible to use pytorch_lite in isolates for running inference? I'm trying to split up the work on separate threads to speed up the process.
[ERROR:flutter/runtime/dart_isolate.cc(1097)] Unhandled exception:
Bad state: The BackgroundIsolateBinaryMessenger.instance value is invalid until BackgroundIsolateBinaryMessenger.ensureInitialized is executed.
#0 BackgroundIsolateBinaryMessenger.instance (package:flutter/src/services/_background_isolate_binary_messenger_io.dart:27:7)
#1 _findBinaryMessenger (package:flutter/src/services/platform_channel.dart:145:42)
#2 BasicMessageChannel.binaryMessenger (package:flutter/src/services/platform_channel.dart:192:56)
#3 BasicMessageChannel.send (package:flutter/src/services/platform_channel.dart:206:38)
#4 ModelApi.getImagePredictionListObjectDetection (package:pytorch_lite/pigeon.dart:319:52)
#5 ModelObjectDetection.getImagePredictionList (package:pytorch_lite/pytorch_lite.dart:525:30)
#6 ModelObjectDetection.getImagePrediction (package:pytorch_lite/pytorch_lite.dart:455:52)
#7 _InferencePageState.processImageBatch (package:sharkeye/inference_page.dart:120:38)
#8 _delayEntrypointInvocation.
ChatGPT's response to this error: 'The PytorchLite plugin is attempting to use platform channels (binary messenger) inside an isolate, which is not supported by default in Flutter.'