Ver código fonte

Merge branch 'main' into search_improvements

Vishnu Mohandas 1 ano atrás
pai
commit
15905a99f1

+ 1 - 1
lib/l10n/intl_en.arb

@@ -498,7 +498,7 @@
   },
   "remindToEmptyEnteTrash": "Also empty your \"Trash\" to claim the freed up space",
   "sparkleSuccess": "✨ Success",
-  "duplicateFileCountWithStorageSaved": "Your have cleaned up {count, plural, one{{count} duplicate file} other{{count} duplicate files}}, saving ({storageSaved}!)",
+  "duplicateFileCountWithStorageSaved": "You have cleaned up {count, plural, one{{count} duplicate file} other{{count} duplicate files}}, saving ({storageSaved}!)",
   "@duplicateFileCountWithStorageSaved": {
     "description": "The text to display when the user has successfully cleaned up duplicate files",
     "type": "text",

+ 1 - 0
lib/l10n/intl_zh.arb

@@ -409,6 +409,7 @@
   "machineLearning": "机器学习",
   "magicSearch": "魔法搜索",
   "magicSearchDescription": "请使用我们的桌面应用程序来为您库中的待处理项目建立索引。",
+  "loadingModel": "正在下载模型...",
   "status": "状态",
   "indexedItems": "已索引项目",
   "pendingItems": "待处理项目",

+ 6 - 4
lib/services/semantic_search/frameworks/onnx/onnx_image_encoder.dart

@@ -43,9 +43,10 @@ class OnnxImageEncoder {
     for (int y = 0; y < ny; y++) {
       for (int x = 0; x < nx; x++) {
         final int i = 3 * (y * nx + x);
-        inputImage[i] = rgb.getPixel(x, y).r.toDouble();
-        inputImage[i + 1] = rgb.getPixel(x, y).g.toDouble();
-        inputImage[i + 2] = rgb.getPixel(x, y).b.toDouble();
+        final pixel = rgb.getPixel(x, y);
+        inputImage[i] = pixel.r.toDouble();
+        inputImage[i + 1] = pixel.g.toDouble();
+        inputImage[i + 2] = pixel.b.toDouble();
       }
     }
 
@@ -111,8 +112,9 @@ class OnnxImageEncoder {
     for (int i = 0; i < 512; i++) {
       imageNormalization += embedding[i] * embedding[i];
     }
+    final double sqrtImageNormalization = sqrt(imageNormalization);
     for (int i = 0; i < 512; i++) {
-      embedding[i] = embedding[i] / sqrt(imageNormalization);
+      embedding[i] = embedding[i] / sqrtImageNormalization;
     }
     return embedding;
   }

+ 3 - 2
lib/services/semantic_search/frameworks/onnx/onnx_text_encoder.dart

@@ -50,9 +50,10 @@ class OnnxTextEncoder {
     for (int i = 0; i < 512; i++) {
       textNormalization += embedding[i] * embedding[i];
     }
-
+    
+    final double sqrtTextNormalization = sqrt(textNormalization);
     for (int i = 0; i < 512; i++) {
-      embedding[i] = embedding[i] / sqrt(textNormalization);
+      embedding[i] = embedding[i] / sqrtTextNormalization;
     }
 
     return (embedding);