π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Small changes
laurenspriemff5dc490f86f
diff --git a/mobile/lib/services/machine_learning/ml_service.dart b/mobile/lib/services/machine_learning/ml_service.dartindex e9bdd74241..4bfc2e5de1 100644--- a/mobile/lib/services/machine_learning/ml_service.dart+++ b/mobile/lib/services/machine_learning/ml_service.dart@@ -5,7 +5,6 @@ import "dart:isolate";import "dart:math" show min;import "dart:typed_data" show Uint8List, ByteData;-import "package:computer/computer.dart";import "package:dart_ui_isolate/dart_ui_isolate.dart";import "package:flutter/foundation.dart" show debugPrint;import "package:logging/logging.dart";@@ -68,8 +67,6 @@ class FaceMlService {final _functionLock = Lock();final _initIsolateLock = Lock();- final _computer = Computer.shared();-bool _isInitialized = false;bool _isModelsInitialized = false;bool _isIsolateSpawned = false;@@ -132,6 +129,7 @@ class FaceMlService {Future<void> sync() async {await FaceRecognitionService.instance.sync();+ await SemanticSearchService.instance.sync();}Future<void> runAllFaceML({bool force = false}) async {@@ -385,7 +383,8 @@ class FaceMlService {}}- Future<bool> processImage(FileMLInstruction instruction) async { // TODO: clean this function up+ Future<bool> processImage(FileMLInstruction instruction) async {+ // TODO: clean this function up_logger.info("`processImage` start processing image with uploadedFileID: ${instruction.enteFile.uploadedFileID}",);diff --git a/mobile/lib/utils/ml_util.dart b/mobile/lib/utils/ml_util.dartindex fdb578d7d4..301ce40f2c 100644--- a/mobile/lib/utils/ml_util.dart+++ b/mobile/lib/utils/ml_util.dart@@ -52,8 +52,10 @@ Future<List<FileMLInstruction>> getFilesForMlIndexing() async {final List<FileMLInstruction> hiddenFilesToIndex = [];for (final EnteFile enteFile in enteFiles) {final skip = _skipAnalysisEnteFile(enteFile);- final shouldRunFaces = _shouldRunIndexing(enteFile, faceIndexedFileIDs);- final shouldRunClip = _shouldRunIndexing(enteFile, clipIndexedFileIDs);+ final shouldRunFaces =+ _shouldRunIndexing(enteFile, faceIndexedFileIDs, faceMlVersion);+ final shouldRunClip =+ _shouldRunIndexing(enteFile, clipIndexedFileIDs, clipMlVersion);if (skip && !shouldRunFaces && !shouldRunClip) {continue;}@@ -70,8 +72,10 @@ Future<List<FileMLInstruction>> getFilesForMlIndexing() async {}for (final EnteFile enteFile in hiddenFiles) {final skip = _skipAnalysisEnteFile(enteFile);- final shouldRunFaces = _shouldRunIndexing(enteFile, faceIndexedFileIDs);- final shouldRunClip = _shouldRunIndexing(enteFile, clipIndexedFileIDs);+ final shouldRunFaces =+ _shouldRunIndexing(enteFile, faceIndexedFileIDs, faceMlVersion);+ final shouldRunClip =+ _shouldRunIndexing(enteFile, clipIndexedFileIDs, clipMlVersion);if (skip && !shouldRunFaces && !shouldRunClip) {continue;}@@ -100,65 +104,38 @@ Future<Set<int>> getIndexableFileIDs() async {return fileIDs.toSet();}-Future<String> getImagePathForML(- EnteFile enteFile, {- FileDataForML typeOfData = FileDataForML.fileData,-}) async {+Future<String> getImagePathForML(EnteFile enteFile) async {String? imagePath;- switch (typeOfData) {- case FileDataForML.fileData:- final stopwatch = Stopwatch()..start();- File? file;- if (enteFile.fileType == FileType.video) {- try {- file = await getThumbnailForUploadedFile(enteFile);- } on PlatformException catch (e, s) {- _logger.severe(- "Could not get thumbnail for $enteFile due to PlatformException",- e,- s,- );- throw ThumbnailRetrievalException(e.toString(), s);- }- } else {- try {- file = await getFile(enteFile, isOrigin: true);- } catch (e, s) {- _logger.severe(- "Could not get file for $enteFile",- e,- s,- );- }- }- if (file == null) {- _logger.warning(- "Could not get file for $enteFile of type ${enteFile.fileType.toString()}",- );- break;- }- imagePath = file.path;- stopwatch.stop();- _logger.info(- "Getting file data for uploadedFileID ${enteFile.uploadedFileID} took ${stopwatch.elapsedMilliseconds} ms",+ final stopwatch = Stopwatch()..start();+ File? file;+ if (enteFile.fileType == FileType.video) {+ try {+ file = await getThumbnailForUploadedFile(enteFile);+ } on PlatformException catch (e, s) {+ _logger.severe(+ "Could not get thumbnail for $enteFile due to PlatformException",+ e,+ s,);- break;-- case FileDataForML.thumbnailData:- final stopwatch = Stopwatch()..start();- final File? thumbnail = await getThumbnailForUploadedFile(enteFile);- if (thumbnail == null) {- _logger.warning("Could not get thumbnail for $enteFile");- break;- }- imagePath = thumbnail.path;- stopwatch.stop();- _logger.info(- "Getting thumbnail data for uploadedFileID ${enteFile.uploadedFileID} took ${stopwatch.elapsedMilliseconds} ms",+ throw ThumbnailRetrievalException(e.toString(), s);+ }+ } else {+ try {+ file = await getFile(enteFile, isOrigin: true);+ } catch (e, s) {+ _logger.severe(+ "Could not get file for $enteFile",+ e,+ s,);- break;+ }}+ imagePath = file?.path;+ stopwatch.stop();+ _logger.info(+ "Getting file data for uploadedFileID ${enteFile.uploadedFileID} took ${stopwatch.elapsedMilliseconds} ms",+ );if (imagePath == null) {_logger.warning(@@ -182,9 +159,13 @@ bool _skipAnalysisEnteFile(EnteFile enteFile) {return false;}-bool _shouldRunIndexing(EnteFile enteFile, Map<int, int> indexedFileIds) {+bool _shouldRunIndexing(+ EnteFile enteFile,+ Map<int, int> indexedFileIds,+ int newestVersion,+) {final id = enteFile.uploadedFileID!;- return !indexedFileIds.containsKey(id) || indexedFileIds[id]! < faceMlVersion;+ return !indexedFileIds.containsKey(id) || indexedFileIds[id]! < newestVersion;}void normalizeEmbedding(List<double> embedding) {