π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
download model on mobile in offline mode
laurenspriemcf61fdbbc60c
diff --git a/mobile/apps/photos/lib/services/machine_learning/ml_indexing_isolate.dart b/mobile/apps/photos/lib/services/machine_learning/ml_indexing_isolate.dartindex a098a00272..ec0952fe31 100644--- a/mobile/apps/photos/lib/services/machine_learning/ml_indexing_isolate.dart+++ b/mobile/apps/photos/lib/services/machine_learning/ml_indexing_isolate.dart@@ -167,10 +167,10 @@ class MLIndexingIsolate extends SuperIsolate {if (areModelsDownloaded) {return;}- final goodInternet = await canUseHighBandwidth();+ final goodInternet = isOfflineMode || await canUseHighBandwidth();if (!goodInternet) {_logger.info(- "Cannot download models because user is not connected to wifi",+ "Cannot download models because user is not connected to wifi and is in online mode",);return;}diff --git a/mobile/apps/photos/lib/services/machine_learning/ml_model.dart b/mobile/apps/photos/lib/services/machine_learning/ml_model.dartindex cb874756e2..a44b454aed 100644--- a/mobile/apps/photos/lib/services/machine_learning/ml_model.dart+++ b/mobile/apps/photos/lib/services/machine_learning/ml_model.dart@@ -3,6 +3,7 @@ import "dart:io" show File, Platform;import "package:logging/logging.dart";import "package:onnx_dart/onnx_dart.dart";import "package:onnxruntime/onnxruntime.dart";+import "package:photos/service_locator.dart" show isOfflineMode;import "package:photos/services/machine_learning/onnx_env.dart";import "package:photos/services/remote_assets_service.dart";import "package:photos/utils/network_util.dart";@@ -46,7 +47,7 @@ abstract class MlModel {if (await RemoteAssetsService.instance.hasAsset(modelRemotePath)) {return await RemoteAssetsService.instance.getAssetPath(modelRemotePath);} else {- if (await canUseHighBandwidth()) {+ if (isOfflineMode || await canUseHighBandwidth()) {return await downloadModel();} else {logger.warning(diff --git a/mobile/apps/photos/lib/services/machine_learning/ml_service.dart b/mobile/apps/photos/lib/services/machine_learning/ml_service.dartindex 1e73bde7f2..aa833142bd 100644--- a/mobile/apps/photos/lib/services/machine_learning/ml_service.dart+++ b/mobile/apps/photos/lib/services/machine_learning/ml_service.dart@@ -288,14 +288,15 @@ class MLService {}await MLIndexingIsolate.instance.cleanupLocalIndexingModels();continue;- } else if (!await canUseHighBandwidth()) {+ } else if (!(isOfflineMode || await canUseHighBandwidth())) {_logger.info(- 'stopping indexing because user is not connected to wifi',+ 'stopping indexing because user is not connected to wifi and in online mode',);break stream;} else {await MLIndexingIsolate.instance.ensureDownloadedModels();- if ((flagService.useRustForML || isOfflineMode) && !rustRuntimePrepared) {+ if ((flagService.useRustForML || isOfflineMode) &&+ !rustRuntimePrepared) {await MLIndexingIsolate.instance.prepareRustRuntime();rustRuntimePrepared = true;}diff --git a/mobile/apps/photos/lib/ui/settings/ml/machine_learning_settings_page.dart b/mobile/apps/photos/lib/ui/settings/ml/machine_learning_settings_page.dartindex 9f67a371c9..fdd658552e 100644--- a/mobile/apps/photos/lib/ui/settings/ml/machine_learning_settings_page.dart+++ b/mobile/apps/photos/lib/ui/settings/ml/machine_learning_settings_page.dart@@ -441,7 +441,7 @@ class _ModelLoadingStateState extends State<ModelLoadingState> {MenuSectionTitle(title: AppLocalizations.of(context).status),const SizedBox(height: 8),FutureBuilder(- future: canUseHighBandwidth(),+ future: canUseHighBandwidth().then((v) => isOfflineMode || v),builder: (context, snapshot) {String title = "";if (snapshot.hasData) {diff --git a/mobile/apps/photos/lib/utils/ml_util.dart b/mobile/apps/photos/lib/utils/ml_util.dartindex d3f09552e4..a02cc0a976 100644--- a/mobile/apps/photos/lib/utils/ml_util.dart+++ b/mobile/apps/photos/lib/utils/ml_util.dart@@ -80,7 +80,7 @@ Future<IndexStatus> getIndexStatus() async {final showPendingFiles = math.max(indexableFiles - indexedFiles, 0);final hasWifiEnabled = await canUseHighBandwidth();_logger.info(- "Shown IndexStatus: indexedFiles: $showIndexedFiles, pendingFiles: $showPendingFiles, hasWifiEnabled: $hasWifiEnabled. Real values: indexedFiles: $indexedFiles (faces: $facesIndexedFiles, clip: $clipIndexedFiles), indexableFiles: $indexableFiles",+ "Shown IndexStatus: indexedFiles: $showIndexedFiles, pendingFiles: $showPendingFiles, hasWifiEnabled: $hasWifiEnabled, ifOffline: $isOfflineMode. Real values: indexedFiles: $indexedFiles (faces: $facesIndexedFiles, clip: $clipIndexedFiles), indexableFiles: $indexableFiles",);return IndexStatus(showIndexedFiles, showPendingFiles, hasWifiEnabled);} catch (e, s) {