mirror of
https://github.com/ente-io/ente.git
synced 2025-08-08 07:28:26 +00:00
[mob][photos] Clip text inference
This commit is contained in:
parent
c26a603901
commit
18a5f4d212
@ -1,5 +1,5 @@
|
||||
import 'dart:async';
|
||||
import "dart:io" show File, Platform;
|
||||
import "dart:io" show File;
|
||||
import 'dart:isolate';
|
||||
import 'dart:typed_data' show Uint8List;
|
||||
|
||||
@ -171,7 +171,6 @@ class MLComputerIsolate {
|
||||
"text": query,
|
||||
"address": clipAddress,
|
||||
"vocabPath": tokenizerVocabPath,
|
||||
"useEntePlugin": Platform.isAndroid,
|
||||
}
|
||||
),
|
||||
) as List<double>;
|
||||
|
@ -36,11 +36,14 @@ class ClipTextEncoder extends MlModel {
|
||||
final text = args["text"];
|
||||
final address = args["address"] as int;
|
||||
final vocabPath = args["vocabPath"] as String;
|
||||
final useEntePlugin = args["useEntePlugin"] ?? false;
|
||||
final List<int> tokenize =
|
||||
await ClipTextTokenizer.instance.tokenize(text, vocabPath);
|
||||
final int32list = Int32List.fromList(tokenize);
|
||||
return _runFFIBasedPredict(int32list, address);
|
||||
if (MlModel.usePlatformPlugin) {
|
||||
return await _runPlatformPlugin(int32list);
|
||||
} else {
|
||||
return _runFFIBasedPredict(int32list, address);
|
||||
}
|
||||
}
|
||||
|
||||
static List<double> _runFFIBasedPredict(
|
||||
@ -65,8 +68,8 @@ class ClipTextEncoder extends MlModel {
|
||||
return embedding;
|
||||
}
|
||||
|
||||
static Future<List<double>> _runEntePlugin(Int32List int32list) async {
|
||||
final w = EnteWatch("ClipTextEncoder._runEntePlugin")..start();
|
||||
static Future<List<double>> _runPlatformPlugin(Int32List int32list) async {
|
||||
final w = EnteWatch("ClipTextEncoder._runPlatformPlugin")..start();
|
||||
final OnnxDart plugin = OnnxDart();
|
||||
final result = await plugin.predictInt(
|
||||
int32list,
|
||||
|
Loading…
x
Reference in New Issue
Block a user