From bb7f8a5eef9f793e9e2197b4566218e774b22a4d Mon Sep 17 00:00:00 2001 From: laurenspriem Date: Fri, 9 May 2025 15:59:46 +0530 Subject: [PATCH] More testing --- .../debug/ml_debug_section_widget.dart | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/mobile/lib/ui/settings/debug/ml_debug_section_widget.dart b/mobile/lib/ui/settings/debug/ml_debug_section_widget.dart index c2c3406bc5..7ccdd26f56 100644 --- a/mobile/lib/ui/settings/debug/ml_debug_section_widget.dart +++ b/mobile/lib/ui/settings/debug/ml_debug_section_widget.dart @@ -147,9 +147,13 @@ class _MLDebugSectionWidgetState extends State { onTap: () async { try { final allClip = await MLDataDB.instance.getAllClipVectors(); + final allClipSmall = allClip.sublist(0, 15000); + showShortToast(context, "Got all embeddings"); + logger.info("Got all embeddings"); final clipVectorDB = ClipVectorDB.instance; await clipVectorDB.deleteAllEmbeddings(); + logger.info("Clean vector DB"); final stats = await clipVectorDB.getIndexStats(); logger.info("ClipVectorDB stats: size: ${stats.$1}, " "capacity: ${stats.$2}, dimensions: ${stats.$3}"); @@ -158,10 +162,13 @@ class _MLDebugSectionWidgetState extends State { "ClipVectorDB stats: size: ${stats.$1}, " "capacity: ${stats.$2}, dimensions: ${stats.$3}"); - final fileIDs = allClip.map((e) => e.fileID).toList(); - final embeddings = allClip + final fileIDs = allClipSmall.map((e) => e.fileID).toList(); + final embeddings = allClipSmall .map((e) => Float32List.fromList(e.vector.toList())) .toList(); + showShortToast(context, "Reshaped embeddings data"); + logger.info("Reshaped embeddings data"); + final now = DateTime.now(); await clipVectorDB.bulkInsertEmbeddings( fileIDs: fileIDs, @@ -185,6 +192,24 @@ class _MLDebugSectionWidgetState extends State { }, ), sectionOptionSpacing, + MenuItemWidget( + captionedTextWidget: const CaptionedTextWidget( + title: "Migrate to ClipVectorDB", + ), + pressedColor: getEnteColorScheme(context).fillFaint, + trailingIcon: Icons.chevron_right_outlined, + trailingIconIsMuted: true, + onTap: () async { + try { + await MLDataDB.instance.migrateFillClipVectorDB(); + showShortToast(context, "Migration done!"); + } catch (e, s) { + logger.warning('ClipVectorDB migration failed ', e, s); + await showGenericErrorDialog(context: context, error: e); + } + }, + ), + sectionOptionSpacing, MenuItemWidget( captionedTextWidget: const CaptionedTextWidget( title: "Show ClipVectorDB stats",