diff --git a/src/env.js b/src/env.js index 55ff234ce..b00b19136 100644 --- a/src/env.js +++ b/src/env.js @@ -1,6 +1,6 @@ -import fs from 'fs'; -import path from 'path'; -import { fileURLToPath } from 'url'; +import fs from 'node:fs'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; import { ONNX } from './backends/onnx.js'; const { env: onnx_env } = ONNX; diff --git a/src/image_utils.js b/src/image_utils.js index ebf57cf34..deeba0419 100644 --- a/src/image_utils.js +++ b/src/image_utils.js @@ -1,5 +1,5 @@ -import fs from 'fs'; +import fs from 'node:fs'; import { getFile, isString } from './utils.js'; import { env } from './env.js'; @@ -8,7 +8,7 @@ let ImageClass = typeof Image !== 'undefined' ? Image : null; let ImageDataClass; let loadImageFunction; -if (typeof self !== 'undefined') { +if (typeof OffscreenCanvas !== 'undefined') { CanvasClass = OffscreenCanvas; loadImageFunction = self.createImageBitmap; ImageDataClass = ImageData; @@ -18,6 +18,7 @@ if (typeof self !== 'undefined') { CanvasClass = Canvas; loadImageFunction = async (/**@type {Blob}*/ b) => await loadImage(Buffer.from(await b.arrayBuffer())); ImageDataClass = ImageData; + // @ts-ignore ImageClass = Image; } diff --git a/src/transformers.js b/src/transformers.js index 99e99017d..1626f8f14 100644 --- a/src/transformers.js +++ b/src/transformers.js @@ -29,9 +29,8 @@ export { // environment variables export { env } from './env.js'; - // other export { pipeline } from './pipelines.js'; -export { Tensor } from './tensor_utils.js'; +export { Tensor } from './tensor_utils.js'; \ No newline at end of file diff --git a/src/utils.js b/src/utils.js index dca41ecb7..e6dee777a 100644 --- a/src/utils.js +++ b/src/utils.js @@ -1,5 +1,5 @@ -import { existsSync, statSync, promises } from 'fs'; +import { existsSync, statSync, promises } from 'node:fs'; import { env } from './env.js';