Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Es6 rewrite #91

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/env.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
5 changes: 3 additions & 2 deletions src/image_utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import fs from 'fs';
import fs from 'node:fs';
import { getFile, isString } from './utils.js';
import { env } from './env.js';

Expand All @@ -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;
Expand All @@ -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;
}

Expand Down
3 changes: 1 addition & 2 deletions src/transformers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
2 changes: 1 addition & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import { existsSync, statSync, promises } from 'fs';
import { existsSync, statSync, promises } from 'node:fs';

import { env } from './env.js';

Expand Down