Skip to content

Commit

Permalink
Add image-to-image unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xenova committed Nov 8, 2023
1 parent eb25c5f commit 6d80ba2
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/pipelines.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1326,6 +1326,44 @@ describe('Pipelines', () => {
}, MAX_TEST_EXECUTION_TIME);
});

describe('Image-to-image', () => {

// List all models which will be tested
const models = [
'caidas/swin2SR-classical-sr-x2-64',
];

it(models[0], async () => {
let upscaler = await pipeline('image-to-image', m(models[0]));

// Input is 3x3 => padded to 8x8 => upscaled to 16x16
let url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/pattern_3x3.png';

// single
{
let outputs = await upscaler(url);
expect(outputs.width).toEqual(16);
expect(outputs.height).toEqual(16);
expect(outputs.channels).toEqual(3);
expect(outputs.data).toHaveLength(768);
}

// batched
{
let outputs = await upscaler([url, url]);
expect(outputs).toHaveLength(2);
for (let output of outputs) {
expect(output.width).toEqual(16);
expect(output.height).toEqual(16);
expect(output.channels).toEqual(3);
expect(output.data).toHaveLength(768);
}
}

await upscaler.dispose();
}, MAX_TEST_EXECUTION_TIME);
});

describe('Document question answering', () => {

// List all models which will be tested
Expand Down

0 comments on commit 6d80ba2

Please sign in to comment.