Skip to content

armgit / ente

Public Imported from GitHub
0

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

tsc

Manav Rathi8fbcef42218c
diff --git a/web/packages/new/photos/services/ml/clip.ts b/web/packages/new/photos/services/ml/clip.ts
index 21794431ba..5f5df66713 100644
--- a/web/packages/new/photos/services/ml/clip.ts
+++ b/web/packages/new/photos/services/ml/clip.ts
@@ -197,10 +197,10 @@ export const clipMatches = async (
searchPhrase: string,
electron: Electron,
): Promise<Map<number, number> | undefined> => {
- const textEmbedding = await electron
- .computeCLIPTextEmbeddingIfAvailable(searchPhrase)
- .then((e) => (e ? normalizedEmbedding(e) : e));
- if (!textEmbedding) return undefined;
+ const t = await electron.computeCLIPTextEmbeddingIfAvailable(searchPhrase);
+ if (!t) return undefined;
+
+ const textEmbedding = normalizedEmbedding(t);
return new Map(
(await clipIndexes())
@@ -215,11 +215,12 @@ export const clipMatches = async (
const clipMatchScore = (imageEmbedding: number[], textEmbedding: number[]) => {
if (imageEmbedding.length != textEmbedding.length)
throw Error(
- `CLIP image embeddings (${imageEmbedding.length}) and text embeddings (${textEmbedding.length}) length mismatch`,
+ `CLIP image embedding (${imageEmbedding.length}) and text embedding (${textEmbedding.length}) length mismatch`,
);
let score = 0;
for (let i = 0; i < imageEmbedding.length; i++) {
+ // We checked the length above.
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
score += imageEmbedding[i]! * textEmbedding[i]!;
}