Skip to content

armgit / ente

Public Imported from GitHub
0

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

update computeTextEmbedding to accept model prop

Abhinav31e88f9925f7
diff --git a/src/api/clip.ts b/src/api/clip.ts
index 2bc675c95c..731551e2b0 100644
--- a/src/api/clip.ts
+++ b/src/api/clip.ts
@@ -34,11 +34,13 @@ export async function computeImageEmbedding(
}
export async function computeTextEmbedding(
+ model: Model,
text: string
): Promise<Float32Array> {
try {
const embedding = await ipcRenderer.invoke(
'compute-text-embedding',
+ model,
text
);
return embedding;
diff --git a/src/services/clipService.ts b/src/services/clipService.ts
index 487531fcf6..c77721cbdc 100644
--- a/src/services/clipService.ts
+++ b/src/services/clipService.ts
@@ -274,16 +274,14 @@ export async function computeONNXImageEmbedding(
}
export async function computeTextEmbedding(
+ model: Model,
inputFilePath: string
): Promise<Float32Array> {
- const ggmlTextEmbedding = await computeGGMLTextEmbedding(inputFilePath);
- const onnxTextEmbedding = await computeONNXTextEmbedding(inputFilePath);
- const score = await computeClipMatchScore(
- ggmlTextEmbedding,
- onnxTextEmbedding
- );
- log.info('textEmbeddingScore', score);
- return onnxTextEmbedding;
+ if (model === Model.GGML_CLIP) {
+ return await computeGGMLTextEmbedding(inputFilePath);
+ } else {
+ return await computeONNXTextEmbedding(inputFilePath);
+ }
}
export async function computeGGMLTextEmbedding(
diff --git a/src/utils/ipcComms.ts b/src/utils/ipcComms.ts
index ac7a51502b..d17e7e3564 100644
--- a/src/utils/ipcComms.ts
+++ b/src/utils/ipcComms.ts
@@ -178,8 +178,8 @@ export default function setupIpcComs(
ipcMain.handle('compute-image-embedding', (_, model, inputFilePath) => {
return computeImageEmbedding(model, inputFilePath);
});
- ipcMain.handle('compute-text-embedding', (_, text) => {
- return computeTextEmbedding(text);
+ ipcMain.handle('compute-text-embedding', (_, model, text) => {
+ return computeTextEmbedding(model, text);
});
ipcMain.handle('get-platform', () => {
return getPlatform();