Future<void> loadModel() async {
try {
final options = InterpreterOptions();
if (useGpu) {
try {
if (useXNNPack) {
if (Platform.isAndroid) {
options.addDelegate(XNNPackDelegate());
}
}
if (Platform.isIOS) {
options.addDelegate(GpuDelegate());
}
} catch (e) {
print('GPU delegate not available: $e');
}
}
if (!useGpu) {
options.threads = 4;
}
_interpreter = await Interpreter.fromAsset(
modelPath,
options: options,
);
} catch (e) {
debugPrint('Error loading model: $e');
}
}
I got an error when loading the .tflite model in Flutter. Could you please help? Thank you!