[mob][photos] Functions to get embeddings of specific files
This commit is contained in:
@@ -17,6 +17,21 @@ extension ClipDB on MLDataDB {
|
||||
return _convertToVectors(results);
|
||||
}
|
||||
|
||||
Future<Map<int, EmbeddingVector>> getClipVectorsForFileIDs(
|
||||
Iterable<int> fileIDs,
|
||||
) async {
|
||||
final db = await MLDataDB.instance.asyncDB;
|
||||
final results = await db.getAll(
|
||||
'SELECT * FROM $clipTable WHERE $fileIDColumn IN (${fileIDs.join(", ")})',
|
||||
);
|
||||
final Map<int, EmbeddingVector> embeddings = {};
|
||||
for (final result in results) {
|
||||
final embedding = _getVectorFromRow(result);
|
||||
embeddings[embedding.fileID] = embedding;
|
||||
}
|
||||
return embeddings;
|
||||
}
|
||||
|
||||
// Get indexed FileIDs
|
||||
Future<Map<int, int>> clipIndexedFileWithVersion() async {
|
||||
final db = await MLDataDB.instance.asyncDB;
|
||||
|
||||
@@ -400,6 +400,28 @@ class MLDataDB {
|
||||
return maps.map((e) => mapRowToFace(e)).toList();
|
||||
}
|
||||
|
||||
Future<Map<int, List<Face>>> getFacesForFileIDs(
|
||||
Iterable<int> fileUploadIDs,
|
||||
) async {
|
||||
final db = await instance.asyncDB;
|
||||
final List<Map<String, dynamic>> maps = await db.getAll(
|
||||
'''
|
||||
SELECT * FROM $facesTable
|
||||
WHERE $fileIDColumn IN (${fileUploadIDs.map((id) => "'$id'").join(",")})
|
||||
''',
|
||||
);
|
||||
if (maps.isEmpty) {
|
||||
return {};
|
||||
}
|
||||
final result = <int, List<Face>>{};
|
||||
for (final map in maps) {
|
||||
final face = mapRowToFace(map);
|
||||
final fileID = map[fileIDColumn] as int;
|
||||
result.putIfAbsent(fileID, () => <Face>[]).add(face);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<Map<String, Iterable<String>>> getClusterToFaceIDs(
|
||||
Set<String> clusterIDs,
|
||||
) async {
|
||||
|
||||
Reference in New Issue
Block a user