Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob] Add OnnxFlutterPlugin

Neeraj Gupta37519179a138
diff --git a/mobile/lib/nativeplugins/onnx.dart b/mobile/lib/nativeplugins/onnx.dart
index e69de29bb2..58f8bfe7d2 100644
--- a/mobile/lib/nativeplugins/onnx.dart
+++ b/mobile/lib/nativeplugins/onnx.dart
@@ -0,0 +1,41 @@
+import 'package:flutter/services.dart';
+
+class OnnxFlutterPlugin {
+ static const MethodChannel _channel =
+ MethodChannel('ente_onnx_flutter_plugin');
+
+ static Future<bool> init(
+ String modelType,
+ String modelPath, {
+ int sessionsCount = 1,
+ }) async {
+ final bool result = await _channel.invokeMethod('init', {
+ 'modelType': modelType,
+ 'modelPath': modelPath,
+ 'sessionsCount': sessionsCount,
+ });
+ return result;
+ }
+
+ static Future<bool> release(String modelType) async {
+ final bool result =
+ await _channel.invokeMethod('release', {'modelType': modelType});
+ return result;
+ }
+
+ static Future<List<double>> predict(
+ List<double> inputData,
+ String modelType, {
+ int sessionAddress = 0,
+ }) async {
+ final List<dynamic> result = await _channel.invokeMethod(
+ 'predict',
+ {
+ 'sessionAddress': sessionAddress,
+ 'inputData': inputData,
+ 'modelType': modelType,
+ },
+ );
+ return result.cast<double>();
+ }
+}