ML typecast fixes
This commit is contained in:
@@ -52,7 +52,7 @@ abstract class IMLDataDB<T> {
|
||||
Future<void> forceUpdateClusterIds(Map<String, String> faceIDToClusterID);
|
||||
Future<void> removeFaceIdToClusterId(Map<String, String> faceIDToClusterID);
|
||||
Future<void> removePerson(String personID);
|
||||
Future<List<FaceDbInfoForClustering>> getFaceInfoForClustering({
|
||||
Future<List<FaceDbInfoForClustering<T>>> getFaceInfoForClustering({
|
||||
int maxFaces,
|
||||
int offset,
|
||||
int batchSize,
|
||||
|
||||
@@ -721,7 +721,7 @@ class MLDataDB with SqlDbBase implements IMLDataDB<int> {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<FaceDbInfoForClustering>> getFaceInfoForClustering({
|
||||
Future<List<FaceDbInfoForClustering<int>>> getFaceInfoForClustering({
|
||||
int maxFaces = 20000,
|
||||
int offset = 0,
|
||||
int batchSize = 10000,
|
||||
@@ -733,7 +733,7 @@ class MLDataDB with SqlDbBase implements IMLDataDB<int> {
|
||||
);
|
||||
final db = await instance.asyncDB;
|
||||
|
||||
final List<FaceDbInfoForClustering> result = <FaceDbInfoForClustering>[];
|
||||
final List<FaceDbInfoForClustering<int>> result = <FaceDbInfoForClustering<int>>[];
|
||||
while (true) {
|
||||
// Query a batch of rows
|
||||
final List<Map<String, dynamic>> maps = await db.getAll(
|
||||
@@ -753,7 +753,7 @@ class MLDataDB with SqlDbBase implements IMLDataDB<int> {
|
||||
final faceIdToClusterId = await getFaceIdsToClusterIds(faceIds);
|
||||
for (final map in maps) {
|
||||
final faceID = map[faceIDColumn] as String;
|
||||
final faceInfo = FaceDbInfoForClustering(
|
||||
final faceInfo = FaceDbInfoForClustering<int>(
|
||||
faceID: faceID,
|
||||
clusterId: faceIdToClusterId[faceID],
|
||||
embeddingBytes: map[embeddingColumn] as Uint8List,
|
||||
|
||||
@@ -651,7 +651,7 @@ class OfflineMLDataDB with SqlDbBase implements IMLDataDB<String> {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<FaceDbInfoForClustering>> getFaceInfoForClustering({
|
||||
Future<List<FaceDbInfoForClustering<String>>> getFaceInfoForClustering({
|
||||
int maxFaces = 20000,
|
||||
int offset = 0,
|
||||
int batchSize = 10000,
|
||||
@@ -663,7 +663,8 @@ class OfflineMLDataDB with SqlDbBase implements IMLDataDB<String> {
|
||||
);
|
||||
final db = await instance.asyncDB;
|
||||
|
||||
final List<FaceDbInfoForClustering> result = <FaceDbInfoForClustering>[];
|
||||
final List<FaceDbInfoForClustering<String>> result =
|
||||
<FaceDbInfoForClustering<String>>[];
|
||||
while (true) {
|
||||
// Query a batch of rows
|
||||
final List<Map<String, dynamic>> maps = await db.getAll(
|
||||
@@ -683,7 +684,7 @@ class OfflineMLDataDB with SqlDbBase implements IMLDataDB<String> {
|
||||
final faceIdToClusterId = await getFaceIdsToClusterIds(faceIds);
|
||||
for (final map in maps) {
|
||||
final faceID = map[faceIDColumn] as String;
|
||||
final faceInfo = FaceDbInfoForClustering(
|
||||
final faceInfo = FaceDbInfoForClustering<String>(
|
||||
faceID: faceID,
|
||||
clusterId: faceIdToClusterId[faceID],
|
||||
embeddingBytes: map[embeddingColumn] as Uint8List,
|
||||
|
||||
@@ -20,6 +20,9 @@ class FaceDbInfoForClustering<T> {
|
||||
if (T == int) {
|
||||
_fileID = int.parse(faceID.split('_').first) as T;
|
||||
}
|
||||
if (_fileID == null) {
|
||||
throw Exception('Unable to parse fileID from faceID: $faceID');
|
||||
}
|
||||
|
||||
return _fileID!;
|
||||
}
|
||||
|
||||
@@ -123,12 +123,11 @@ class MLService {
|
||||
|
||||
// localMode indicates if the function is called from the offline mode
|
||||
// in such cases, files are pulled from local device & indexes are kept locally
|
||||
Future<void> runAllML({bool force = false, bool localMode = true}) async {
|
||||
Future<void> runAllML({bool force = false, bool localMode = false}) async {
|
||||
try {
|
||||
if (force) {
|
||||
_mlControllerStatus = true;
|
||||
}
|
||||
return;
|
||||
if (!_canRunMLFunction(function: "AllML") && !force) return;
|
||||
if (!force && !computeController.requestCompute(ml: true)) return;
|
||||
_isRunningML = true;
|
||||
@@ -203,7 +202,7 @@ class MLService {
|
||||
|
||||
try {
|
||||
_isIndexingOrClusteringRunning = true;
|
||||
_logger.info('starting image indexing');
|
||||
_logger.info('starting image indexing local: $local');
|
||||
final Stream<List<FileMLInstruction>> instructionStream =
|
||||
fetchEmbeddingsAndInstructions(fileDownloadMlLimit, local);
|
||||
|
||||
@@ -265,8 +264,8 @@ class MLService {
|
||||
bool localMode = false,
|
||||
}) async {
|
||||
final mlDataDB = localMode
|
||||
? OfflineMLDataDB.instance as IMLDataDB
|
||||
: MLDataDB.instance as IMLDataDB;
|
||||
? OfflineMLDataDB.instance as IMLDataDB<T>
|
||||
: MLDataDB.instance as IMLDataDB<T>;
|
||||
if (!_canRunMLFunction(function: "Clustering") && !force) return;
|
||||
if (_clusteringIsHappening) {
|
||||
_logger.info("clusterAllImages() is already running, returning");
|
||||
@@ -304,9 +303,9 @@ class MLService {
|
||||
final result = await mlDataDB.getFaceInfoForClustering(
|
||||
maxFaces: totalFaces,
|
||||
);
|
||||
final Set<int> missingFileIDs = {};
|
||||
final allFaceInfoForClustering = <FaceDbInfoForClustering>[];
|
||||
for (final faceInfo in result) {
|
||||
final Set<T> missingFileIDs = {};
|
||||
final allFaceInfoForClustering = <FaceDbInfoForClustering<T>>[];
|
||||
for (final FaceDbInfoForClustering<T> faceInfo in result) {
|
||||
if (!fileIDToCreationTime.containsKey(faceInfo.fileID)) {
|
||||
missingFileIDs.add(faceInfo.fileID);
|
||||
} else {
|
||||
|
||||
@@ -143,7 +143,8 @@ class SearchService {
|
||||
Future<List<EnteFile>> _getCacheFileFuture() {
|
||||
if (_cachedFilesFuture == null) {
|
||||
_logger.fine("Reading all files from db");
|
||||
_cachedFilesFuture = localDB.getAssets();
|
||||
_cachedFilesFuture =
|
||||
remoteCache.getAllFiles({}, Configuration.instance.getUserID()!);
|
||||
}
|
||||
return _cachedFilesFuture!;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user