Reputation: 121
I have a running application using which I can recognize faces. In that, .tflite model is working perfectly on Android.
I am facing issues on iOS, in which the application is perfectly running in debug mode, but it is not working in release mode.
Refer to the following code snippet:
Future loadModel() async {
final options = InterpreterOptions();
tempDir = await getApplicationDocumentsDirectory();
print("load");
try {
options.addDelegate(GpuDelegate());
interpreter = await tfl.Interpreter.fromAsset('mobilefacenet.tflite',
options: options);
setState(() {
faceModel = "loaded successfully";
});
} on Exception {
setState(() {
faceModel = "failed to load";
});
print('Failed to load model.');
}
}
ERROR Return:
Unhandled Exception: Invalid argument(s): Failed to lookup symbol 'TFLGpuDelegateCreate': dlsym(RTLD_DEFAULT, TFLGpuDelegateCreate):
The above code is running perfectly on iPhone in Debug mode, but when running it using flutter run --release, the command app is not loading the tflite model.
Upvotes: 3
Views: 569
Reputation: 11
Note: TFLite may not work in the iOS simulator. It's recommended that you test with a physical device.
When creating a release archive (IPA), the symbols are stripped by Xcode, so the command flutter build ipa may throw a Failed to lookup symbol ... symbol not found error. To work around this:
Step 1: In Xcode, go to Target Runner > Build Settings > Strip Style Step 2: Change from All Symbols to Non-Global Symbols
Upvotes: 1