Skip to content

Commit

Permalink
perf(sharp): fix lazy load sharp
Browse files Browse the repository at this point in the history
  • Loading branch information
j-mendez committed Aug 5, 2023
1 parent b489b20 commit 57d634f
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 857 deletions.
29 changes: 0 additions & 29 deletions __tests__/classify.test.ts

This file was deleted.

20 changes: 5 additions & 15 deletions __tests__/convert.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import { convertAsync } from "../src/convert-async";
import { SAMPLE } from "../__mocks__/sample";
import { ready, setBackend } from "@tensorflow/tfjs-core";

beforeAll(async () => {
await setBackend("wasm"); // set tensorflow wasm backend
await ready();
});

describe("convert base64 to tensor", () => {
test("use pure js", async () => {
await setBackend("wasm"); // set tensorflow wasm backend
await ready();

const tensor = convert(SAMPLE);

expect(tensor).toEqual({
Expand All @@ -27,9 +29,6 @@ describe("convert base64 to tensor", () => {
});

test("use sharp", async () => {
await setBackend("wasm"); // set tensorflow wasm backend
await ready();

const tensor = await convertAsync(SAMPLE);

expect(tensor).toEqual({
Expand All @@ -48,25 +47,16 @@ describe("convert base64 to tensor", () => {
});

test("handle missing jpeg data sync", async () => {
await setBackend("wasm"); // set tensorflow wasm backend
await ready();

const tensor = convert("");

expect(tensor).toEqual(null);
});
test("handle missing jpeg data async", async () => {
await setBackend("wasm"); // set tensorflow wasm backend
await ready();

const tensor = await convertAsync("");

expect(tensor).toEqual(null);
});
test("handle missing jpeg data error async", async () => {
await setBackend("wasm"); // set tensorflow wasm backend
await ready();

return expect(convertAsync("dqdw")).rejects.toEqual(
new Error("Input Buffer is empty")
);
Expand Down
Loading

0 comments on commit 57d634f

Please sign in to comment.