Render model loading status

This commit is contained in:
vishnukvmd 2024-01-05 18:08:23 +05:30
parent 4edebb9501
commit 529ad88a70
5 changed files with 57 additions and 6 deletions

View file

@ -832,6 +832,8 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("Loading gallery..."),
"loadingMessage":
MessageLookupByLibrary.simpleMessage("Loading your photos..."),
"loadingModel":
MessageLookupByLibrary.simpleMessage("Downloading models..."),
"localGallery": MessageLookupByLibrary.simpleMessage("Local gallery"),
"location": MessageLookupByLibrary.simpleMessage("Location"),
"locationName": MessageLookupByLibrary.simpleMessage("Location name"),

View file

@ -2876,6 +2876,16 @@ class S {
);
}
/// `Downloading models...`
String get loadingModel {
return Intl.message(
'Downloading models...',
name: 'loadingModel',
desc: '',
args: [],
);
}
/// `Status`
String get status {
return Intl.message(

View file

@ -409,6 +409,7 @@
"machineLearning": "Machine learning",
"magicSearch": "Magic search",
"magicSearchDescription": "Please note that this will result in a higher bandwidth and battery usage until all items are indexed.",
"loadingModel": "Downloading models...",
"status": "Status",
"indexedItems": "Indexed items",
"pendingItems": "Pending items",
@ -704,7 +705,7 @@
"deleteAlbumsDialogBody": "This will delete all empty albums. This is useful when you want to reduce the clutter in your album list.",
"deleteProgress": "Deleting {currentlyDeleting} / {totalCount}",
"genericProgress": "Processing {currentlyProcessing} / {totalCount}",
"@genericProgress" : {
"@genericProgress": {
"description": "Generic progress text to display when processing multiple items",
"type": "text",
"placeholders": {
@ -718,7 +719,6 @@
}
}
},
"permanentlyDelete": "Permanently delete",
"canOnlyCreateLinkForFilesOwnedByYou": "Can only create link for files owned by you",
"publicLinkCreated": "Public link created",

View file

@ -38,7 +38,7 @@ class SemanticSearchService {
final _logger = Logger("SemanticSearchService");
final _queue = Queue<EnteFile>();
final _mlFramework = kCurrentModel == Model.onnxClip ? ONNX() : GGML();
final _frameworkInitialization = Completer<void>();
final _frameworkInitialization = Completer<bool>();
final _embeddingLoaderDebouncer =
Debouncer(kDebounceDuration, executionInterval: kDebounceDuration);
@ -141,6 +141,10 @@ class SemanticSearchService {
);
}
Future<bool> getFrameworkInitializationStatus() {
return _frameworkInitialization.future;
}
Future<void> clearIndexes() async {
await EmbeddingsDB.instance.deleteAllForModel(kCurrentModel);
_logger.info("Indexes cleared for $kCurrentModel");
@ -232,7 +236,7 @@ class SemanticSearchService {
_logger.info("Initializing ML framework");
try {
await _mlFramework.init();
_frameworkInitialization.complete();
_frameworkInitialization.complete(true);
} catch (e, s) {
_logger.severe("ML framework initialization failed", e, s);
}

View file

@ -115,7 +115,17 @@ class _MachineLearningSettingsPageState
hasEnabled
? Column(
children: [
const MagicSearchIndexStatsWidget(),
FutureBuilder(
future: SemanticSearchService.instance
.getFrameworkInitializationStatus(),
builder: (BuildContext context, AsyncSnapshot snapshot) {
if (snapshot.hasData) {
return const MagicSearchIndexStatsWidget();
} else {
return const ModelLoadingState();
}
},
),
const SizedBox(
height: 12,
),
@ -144,6 +154,31 @@ class _MachineLearningSettingsPageState
}
}
class ModelLoadingState extends StatelessWidget {
const ModelLoadingState({super.key});
@override
Widget build(BuildContext context) {
return Column(
children: [
MenuSectionTitle(title: S.of(context).status),
MenuItemWidget(
captionedTextWidget: CaptionedTextWidget(
title: S.of(context).loadingModel,
),
trailingWidget: EnteLoadingWidget(
size: 12,
color: getEnteColorScheme(context).fillMuted,
),
singleBorderRadius: 8,
alignCaptionedTextToLeft: true,
isGestureDetectorDisabled: true,
),
],
);
}
}
class MagicSearchIndexStatsWidget extends StatefulWidget {
const MagicSearchIndexStatsWidget({
super.key,