Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Update refs

Manav Rathiac8a5b491d0f
diff --git a/desktop/src/main/services/ml-worker.ts b/desktop/src/main/services/ml-worker.ts
index 68a8eb8349..cd9a3e0404 100644
--- a/desktop/src/main/services/ml-worker.ts
+++ b/desktop/src/main/services/ml-worker.ts
@@ -209,7 +209,7 @@ const cachedCLIPImageSession = makeCachedInferenceSession(
/**
* Compute CLIP embeddings for an image.
*
- * The embeddings are computed using ONNX runtime, with CLIP as the model.
+ * The embeddings are computed using ONNX runtime, with MobileCLIP as the model.
*/
export const computeCLIPImageEmbedding = async (input: Float32Array) => {
const session = await cachedCLIPImageSession();
@@ -237,7 +237,7 @@ const getTokenizer = () => {
/**
* Compute CLIP embeddings for an text snippet.
*
- * The embeddings are computed using ONNX runtime, with CLIP as the model.
+ * The embeddings are computed using ONNX runtime, with MobileCLIP as the model.
*/
export const computeCLIPTextEmbeddingIfAvailable = async (text: string) => {
const sessionOrSkip = await Promise.race([
diff --git a/web/packages/new/photos/services/ml/clip.ts b/web/packages/new/photos/services/ml/clip.ts
index e0d1211fbe..b226ef10cb 100644
--- a/web/packages/new/photos/services/ml/clip.ts
+++ b/web/packages/new/photos/services/ml/clip.ts
@@ -39,8 +39,9 @@ export const clipIndexingVersion = 1;
* initial launch of this feature using the GGML runtime.
*
* Since the initial launch, we've switched over to another runtime,
- * [ONNX](https://onnxruntime.ai) and have made other implementation changes,
- * but the overall gist remains the same.
+ * [ONNX](https://onnxruntime.ai), started using Apple's
+ * [MobileCLIP](https://github.com/apple/ml-mobileclip/) as the model and have
+ * made other implementation changes, but the overall gist remains the same.
*
* Note that we don't train the neural network - we only use one of the publicly
* available pre-trained neural networks for inference. These neural networks
@@ -117,16 +118,11 @@ const computeEmbedding = async (
};
/**
- * Convert {@link imageData} into the format that the CLIP model expects.
+ * Convert {@link imageData} into the format that the MobileCLIP model expects.
*/
const convertToCLIPInput = (imageData: ImageData) => {
const [requiredWidth, requiredHeight] = [256, 256];
- // const mean = [0.48145466, 0.4578275, 0.40821073] as const;
- const mean = [0, 0, 0] as const;
- // const std = [0.26862954, 0.26130258, 0.27577711] as const;
- const std = [1, 1, 1] as const;
-
const { width, height, data: pixelData } = imageData;
// Maintain aspect ratio.
@@ -152,9 +148,9 @@ const convertToCLIPInput = (imageData: ImageData) => {
width,
height,
);
- clipInput[pi] = (r / 255.0 - mean[0]) / std[0];
- clipInput[pi + cOffsetG] = (g / 255.0 - mean[1]) / std[1];
- clipInput[pi + cOffsetB] = (b / 255.0 - mean[2]) / std[2];
+ clipInput[pi] = r / 255.0;
+ clipInput[pi + cOffsetG] = g / 255.0;
+ clipInput[pi + cOffsetB] = b / 255.0;
pi++;
}
}