initialize method
Implementation
Future initialize() async {
late Delegate delegate;
try {
if (Platform.isAndroid) {
// print("android");
delegate = GpuDelegateV2(
options: GpuDelegateOptionsV2(
isPrecisionLossAllowed: false,
inferencePreference: TfLiteGpuInferenceUsage.fastSingleAnswer,
inferencePriority1: TfLiteGpuInferencePriority.minLatency,
inferencePriority2: TfLiteGpuInferencePriority.auto,
inferencePriority3: TfLiteGpuInferencePriority.auto,
),
);
// print("android12");
} else if (Platform.isIOS) {
delegate = GpuDelegate(
options: GpuDelegateOptions(
allowPrecisionLoss: true,
waitType: TFLGpuDelegateWaitType.active),
);
}
var interpreterOptions = InterpreterOptions()..addDelegate(delegate);
_interpreter = await Interpreter.fromAsset('mobilefacenet.tflite',
options: interpreterOptions);
} catch (e) {
// print('Failed to load model.');
// print(e);
}
}