Skip to content

armgit / ente

Public Imported from GitHub
0

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

Import onnxruntime with TypeScript types

Manav Rathi500022d4b997
diff --git a/desktop/src/main/services/clip.ts b/desktop/src/main/services/clip.ts
index 0ef6053183..525e613424 100644
--- a/desktop/src/main/services/clip.ts
+++ b/desktop/src/main/services/clip.ts
@@ -14,13 +14,13 @@ import { existsSync } from "fs";
import jpeg from "jpeg-js";
import fs from "node:fs/promises";
import path from "node:path";
-import { CustomErrors } from "../../types/ipc";
+import * as ort from "onnxruntime-node";
import Tokenizer from "../../thirdparty/clip-bpe-ts/mod";
+import { CustomErrors } from "../../types/ipc";
import { writeStream } from "../fs";
import log from "../log";
import { generateTempFilePath } from "../temp";
import { deleteTempFile } from "./ffmpeg";
-const ort = require("onnxruntime-node");
const textModelName = "clip-text-vit-32-uint8.onnx";
const textModelByteSize = 64173509; // 61.2 MB
diff --git a/desktop/src/main/types/onnx-runtime.d.ts b/desktop/src/main/types/onnx-runtime.d.ts
new file mode 100644
index 0000000000..85fc00ab6f
--- /dev/null
+++ b/desktop/src/main/types/onnx-runtime.d.ts
@@ -0,0 +1,9 @@
+/**
+ * Types for [onnxruntime-node](https://onnxruntime.ai/docs/api/js/index.html).
+ *
+ * Note: these are not the official types but are based on a temporary
+ * [workaround](https://github.com/microsoft/onnxruntime/issues/17979).
+ */
+declare module "onnxruntime-node" {
+ export * from "onnxruntime-common";
+}