浏览代码

Wire together

Manav Rathi 1 年之前
父节点
当前提交
41f7b30ca0
共有 3 个文件被更改,包括 29 次插入2 次删除
  1. 10 1
      desktop/src/main/ipc.ts
  2. 11 1
      desktop/src/main/services/ml-face.ts
  3. 8 0
      desktop/src/preload.ts

+ 10 - 1
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());

+ 11 - 1
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("");

+ 8 - 0
desktop/src/preload.ts

@@ -143,6 +143,12 @@ const clipImageEmbedding = (jpegImageData: Uint8Array): Promise<Float32Array> =>
 const clipTextEmbedding = (text: string): Promise<Float32Array> =>
     ipcRenderer.invoke("clipTextEmbedding", text);
 
+const detectFaces = (imageData: Uint8Array): Promise<Float32Array> =>
+    ipcRenderer.invoke("detectFaces", imageData);
+
+const faceEmbedding = (input: Float32Array): Promise<Float32Array> =>
+    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,