π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob] store sideways face boolean in local face table
laurenspriem01aecb974291
diff --git a/mobile/lib/face/db.dart b/mobile/lib/face/db.dartindex 95aced5a5a..e45ea42523 100644--- a/mobile/lib/face/db.dart+++ b/mobile/lib/face/db.dart@@ -1,5 +1,4 @@import 'dart:async';-import "dart:convert" show json;import "dart:io" show Directory;import "dart:math";@@ -11,7 +10,6 @@ import 'package:path_provider/path_provider.dart';import "package:photos/extensions/stop_watch.dart";import 'package:photos/face/db_fields.dart';import "package:photos/face/db_model_mappers.dart";-import "package:photos/face/model/detection.dart";import "package:photos/face/model/face.dart";import "package:photos/models/file/file.dart";import "package:photos/services/machine_learning/face_ml/face_clustering/face_info_for_clustering.dart";@@ -455,31 +453,6 @@ class FaceMLDataDB {);}- // TODO: remove this method and replace by correct logic during indexing- Future<Map<String, bool>> getFaceIdsToIsSidewaysFaceTEMP() async {- final db = await instance.sqliteAsyncDB;- final List<Map<String, dynamic>> maps = await db.getAll(- 'SELECT $faceIDColumn, $faceDetectionColumn FROM $facesTable',- );-- final time = DateTime.now();- final Map<String, bool> result = {};- for (final map in maps) {- final faceID = map[faceIDColumn] as String;- final detection =- Detection.fromJson(json.decode(map[faceDetectionColumn] as String));- result[faceID] = detection.faceIsSideways();- }- _logger.info(- 'decoding detections and calculating face sideways bools took ${DateTime.now().difference(time).inMilliseconds} ms',- );- final double sidewaysRatio =- result.values.where((e) => e).length / result.length;- _logger.info('sideways face ratio: $sidewaysRatio');-- return result;- }-Future<Set<FaceInfoForClustering>> getFaceInfoForClustering({double minScore = kMinimumQualityFaceScore,int minClarity = kLaplacianHardThreshold,@@ -493,14 +466,11 @@ class FaceMLDataDB {);final db = await instance.sqliteAsyncDB;- final Map<String, bool> faceIdsToIsSideways =- await getFaceIdsToIsSidewaysFaceTEMP();-final Set<FaceInfoForClustering> result = {};while (true) {// Query a batch of rowsfinal List<Map<String, dynamic>> maps = await db.getAll(- 'SELECT $faceIDColumn, $faceEmbeddingBlob, $faceScore, $faceBlur FROM $facesTable'+ 'SELECT $faceIDColumn, $faceEmbeddingBlob, $faceScore, $faceBlur, $isSideways FROM $facesTable'' WHERE $faceScore > $minScore AND $faceBlur > $minClarity'' ORDER BY $faceIDColumn'' DESC LIMIT $batchSize OFFSET $offset',@@ -522,7 +492,7 @@ class FaceMLDataDB {embeddingBytes: map[faceEmbeddingBlob] as Uint8List,faceScore: map[faceScore] as double,blurValue: map[faceBlur] as double,- isSideways: faceIdsToIsSideways[faceID] ?? false,+ isSideways: (map[isSideways] as int) == 1,);result.add(faceInfo);}diff --git a/mobile/lib/face/db_fields.dart b/mobile/lib/face/db_fields.dartindex 206806e0ca..c7d0c703c4 100644--- a/mobile/lib/face/db_fields.dart+++ b/mobile/lib/face/db_fields.dart@@ -8,6 +8,7 @@ const faceDetectionColumn = 'detection';const faceEmbeddingBlob = 'eBlob';const faceScore = 'score';const faceBlur = 'blur';+const isSideways = 'is_sideways';const imageWidth = 'width';const imageHeight = 'height';const faceClusterId = 'cluster_id';@@ -20,6 +21,7 @@ const createFacesTable = '''CREATE TABLE IF NOT EXISTS $facesTable ($faceEmbeddingBlob BLOB NOT NULL,$faceScore REAL NOT NULL,$faceBlur REAL NOT NULL DEFAULT $kLapacianDefault,+ $isSideways INTEGER NOT NULL DEFAULT 0,$imageHeight INTEGER NOT NULL DEFAULT 0,$imageWidth INTEGER NOT NULL DEFAULT 0,$mlVersionColumn INTEGER NOT NULL DEFAULT -1,diff --git a/mobile/lib/face/db_model_mappers.dart b/mobile/lib/face/db_model_mappers.dartindex 683281e93d..70dc779157 100644--- a/mobile/lib/face/db_model_mappers.dart+++ b/mobile/lib/face/db_model_mappers.dart@@ -34,6 +34,7 @@ Map<String, dynamic> mapRemoteToFaceDB(Face face) {).writeToBuffer(),faceScore: face.score,faceBlur: face.blur,+ isSideways: face.detection.faceIsSideways() ? 1 : 0,mlVersionColumn: faceMlVersion,imageWidth: face.fileInfo?.imageWidth ?? 0,imageHeight: face.fileInfo?.imageHeight ?? 0,