Skip to content

Commit

Permalink
Add integration test for upscaling a rank 4 tensor (#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Scott authored Feb 4, 2022
1 parent 66c041a commit f488078
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/upscalerjs/jestconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"coveragePathIgnorePatterns": [
"node_modules",
".generated.ts"
],
],
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json", "node"]
}
17 changes: 17 additions & 0 deletions test/integration/browser/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,23 @@ describe('Image Format Integration Tests', () => {
checkImage(upscaledSrc, "upscaled-4x-pixelator.png", 'diff.png');
});

it("upscales a rank 4 tensor", async () => {
const upscaledSrc = await driver.executeScript(() => new Promise(resolve => {
const upscaler = new window['Upscaler']({
model: '/pixelator/pixelator.json',
scale: 4,
});
const img = new Image();
img.src = window['flower'];
img.crossOrigin = 'anonymous';
img.onload = function () {
const tensor = window['tf'].browser.fromPixels(img).expandDims(0);
upscaler.upscale(tensor).then(resolve);
}
}));
checkImage(upscaledSrc, "upscaled-4x-pixelator.png", 'diff.png');
});

it("upscales a base64 png path", async () => {
const data = fs.readFileSync(path.resolve(__dirname, "../../__fixtures__", 'flower-small.png')).toString('base64');
const originalImage = `data:image/png;base64,${data}`;
Expand Down

0 comments on commit f488078

Please sign in to comment.