diff --git a/desktop/src/main/ipc.ts b/desktop/src/main/ipc.ts index 1d863b8e9..b6e884818 100644 --- a/desktop/src/main/ipc.ts +++ b/desktop/src/main/ipc.ts @@ -36,13 +36,14 @@ import { updateAndRestart, updateOnNextRestart, } from "./services/app-update"; -import { clipImageEmbedding, clipTextEmbedding } from "./services/ml-clip"; import { runFFmpegCmd } from "./services/ffmpeg"; import { getDirFiles } from "./services/fs"; import { convertToJPEG, generateImageThumbnail, } from "./services/imageProcessor"; +import { clipImageEmbedding, clipTextEmbedding } from "./services/ml-clip"; +import { detectFaces, faceEmbedding } from "./services/ml-face"; import { clearStores, encryptionKey, @@ -146,6 +147,14 @@ export const attachIPCHandlers = () => { clipTextEmbedding(text), ); + ipcMain.handle("detectFaces", (_, imageData: Uint8Array) => + detectFaces(imageData), + ); + + ipcMain.handle("faceEmbedding", (_, input: Float32Array) => + faceEmbedding(input), + ); + // - File selection ipcMain.handle("selectDirectory", () => selectDirectory()); diff --git a/desktop/src/main/services/ml-face.ts b/desktop/src/main/services/ml-face.ts index bf8eea162..066f5406b 100644 --- a/desktop/src/main/services/ml-face.ts +++ b/desktop/src/main/services/ml-face.ts @@ -78,6 +78,16 @@ const faceEmbeddingSession = async () => { return _faceEmbeddingSession; }; +export const detectFaces = async (inputImage: Uint8Array) => { + throw new Error("test"); +}; + +export const faceEmbedding = async (input: Float32Array) => { + throw new Error("test"); +}; + +/* + private async initOnnx() { console.log("start ort"); this.onnxInferenceSession = await ort.InferenceSession.create( @@ -100,7 +110,7 @@ private async getOnnxInferenceSession() { } return this.onnxInferenceSession; } - +*/ // export const clipImageEmbedding = async (jpegImageData: Uint8Array) => { // const tempFilePath = await generateTempFilePath(""); diff --git a/desktop/src/preload.ts b/desktop/src/preload.ts index 07736502b..bea5c9e18 100644 --- a/desktop/src/preload.ts +++ b/desktop/src/preload.ts @@ -143,6 +143,12 @@ const clipImageEmbedding = (jpegImageData: Uint8Array): Promise => const clipTextEmbedding = (text: string): Promise => ipcRenderer.invoke("clipTextEmbedding", text); +const detectFaces = (imageData: Uint8Array): Promise => + ipcRenderer.invoke("detectFaces", imageData); + +const faceEmbedding = (input: Float32Array): Promise => + ipcRenderer.invoke("faceEmbedding", input); + // - File selection // TODO: Deprecated - use dialogs on the renderer process itself @@ -322,6 +328,8 @@ contextBridge.exposeInMainWorld("electron", { // - ML clipImageEmbedding, clipTextEmbedding, + detectFaces, + faceEmbedding, // - File selection selectDirectory,