use search with keys in ml computer
This commit is contained in:
@@ -50,6 +50,24 @@ class MLComputer extends SuperIsolate {
|
||||
}
|
||||
}
|
||||
|
||||
Future<(Uint64List, List<Uint64List>, List<Float32List>)>
|
||||
bulkVectorSearchWithKeys(
|
||||
Uint64List potentialKeys,
|
||||
bool exact,
|
||||
) async {
|
||||
try {
|
||||
final result =
|
||||
await runInIsolate(IsolateOperation.bulkVectorSearchWithKeys, {
|
||||
"potentialKeys": potentialKeys,
|
||||
"exact": exact,
|
||||
});
|
||||
return result;
|
||||
} catch (e, s) {
|
||||
_logger.severe("Could not run bulk vector search in MLComputer", e, s);
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<double>> runClipText(String query) async {
|
||||
try {
|
||||
await _ensureLoadedClipTextModel();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'dart:typed_data' show Uint8List, Float32List;
|
||||
|
||||
import "package:flutter_rust_bridge/flutter_rust_bridge.dart" show Uint64List;
|
||||
import "package:ml_linalg/linalg.dart";
|
||||
import "package:photos/db/ml/clip_vector_db.dart";
|
||||
import "package:photos/models/ml/face/box.dart";
|
||||
@@ -45,6 +46,9 @@ enum IsolateOperation {
|
||||
/// [MLComputer]
|
||||
bulkVectorSearch,
|
||||
|
||||
/// [MLComputer]
|
||||
bulkVectorSearchWithKeys,
|
||||
|
||||
/// [FaceClusteringService]
|
||||
linearIncrementalClustering,
|
||||
|
||||
@@ -62,6 +66,17 @@ Future<dynamic> isolateFunction(
|
||||
Map<String, dynamic> args,
|
||||
) async {
|
||||
switch (function) {
|
||||
case IsolateOperation.bulkVectorSearchWithKeys:
|
||||
await _ensureRustLoaded();
|
||||
final potentialKeys = args["potentialKeys"] as Uint64List;
|
||||
final exact = args["exact"] as bool;
|
||||
|
||||
return ClipVectorDB.instance.bulkSearchWithKeys(
|
||||
potentialKeys,
|
||||
BigInt.from(100),
|
||||
exact: exact,
|
||||
);
|
||||
|
||||
case IsolateOperation.bulkVectorSearch:
|
||||
await _ensureRustLoaded();
|
||||
final clipFloat32 = args["clipFloat32"] as List<Float32List>;
|
||||
|
||||
Reference in New Issue
Block a user