π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Fix reshape order for image tensor
NullPointer883363fcc069
diff --git a/lib/services/semantic_search/frameworks/onnx/onnx_image_encoder.dart b/lib/services/semantic_search/frameworks/onnx/onnx_image_encoder.dartindex 2336ba0c10..9d6dc325ff 100644--- a/lib/services/semantic_search/frameworks/onnx/onnx_image_encoder.dart+++ b/lib/services/semantic_search/frameworks/onnx/onnx_image_encoder.dart@@ -34,64 +34,6 @@ class OnnxImageEncoder {//Check the existence of imagePath locallyfinal rgb = img.decodeImage(File(args["imagePath"]).readAsBytesSync())!;- // dynamic inputImage;- // if (rgb.height >= rgb.width) {- // inputImage = img.copyResize(- // rgb,- // width: 224,- // interpolation: img.Interpolation.linear,- // );- // inputImage = img.copyCrop(- // inputImage,- // x: 0,- // y: (inputImage.height - 224) ~/ 2,- // width: 224,- // height: 224,- // );- // } else {- // inputImage = img.copyResize(- // rgb,- // height: 224,- // interpolation: img.Interpolation.linear,- // );- // inputImage = img.copyCrop(- // inputImage,- // x: (inputImage.width - 224) ~/ 2,- // y: 0,- // width: 224,- // height: 224,- // );- // }-- // final mean = [0.48145466, 0.4578275, 0.40821073];- // final std = [0.26862954, 0.26130258, 0.27577711];- // //final processedImage = imageToByteListFloat32(rgb, 224, mean, std);- // final rgbData = [[], [], []]; // [1, 3, 224, 224- // rgbData[0] = List.filled(224, List.filled(224, 0.0));- // rgbData[1] = List.filled(224, List.filled(224, 0.0));- // rgbData[2] = List.filled(224, List.filled(224, 0.0));-- // // [3, 224*224] -> [3, 224, 224]- // for (int i = 0; i < 224; i++) {- // for (int j = 0; j < 224; j++) {- // rgbData[0][i][j] = (inputImage.getPixel(i, j).r / 255 - mean[0]) / std[0];- // rgbData[1][i][j] = (inputImage.getPixel(i, j).g / 255 - mean[1]) / std[1];- // rgbData[2][i][j] = (inputImage.getPixel(i, j).g / 255 - mean[2]) / std[2];- // }- // }-- // final flattenedList = [- // for (final subList in rgbData)- // for (final innerList in subList)- // for (final element in innerList)- // element,- // ];-- // final floatList = Float32List(flattenedList.length);- // for (int i = 0; i < flattenedList.length; i++) {- // floatList[i] = flattenedList[i];- // }-final int nx = rgb.width;final int ny = rgb.height;final int inputSize = 3 * nx * ny;@@ -153,7 +95,8 @@ class OnnxImageEncoder {final int v2 = min(max(v.round(), 0), 255);- final int i = 3 * (y * nx3 + x) + c;+ // createTensorWithDataList is dump compared to reshape and hence has to be given with one channel after another+ final int i = (y * nx3 + x) + (c % 3) * 224 * 224;result[i] = ((v2 / 255) - mean[c]) / std[c];}