Skip to content

Commit

Permalink
Add owlvit processor test
Browse files Browse the repository at this point in the history
  • Loading branch information
xenova committed Nov 14, 2023
1 parent d0e6d25 commit 983c502
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/processors.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ describe('Processors', () => {
beit: 'microsoft/beit-base-patch16-224-pt22k-ft22k',
detr: 'facebook/detr-resnet-50',
yolos: 'hustvl/yolos-small-300',
owlvit: 'google/owlvit-base-patch32',
}

const TEST_IMAGES = {
pattern_3x3: 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/pattern_3x3.png',
checkerboard_8x8: 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/checkerboard_8x8.png',
receipt: 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/receipt.png',
tiger: 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/tiger.jpg',
cats: 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/cats.jpg',

// grayscale image
skateboard: 'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/blog/ml-web-games/skateboard.png',
Expand Down Expand Up @@ -236,5 +238,22 @@ describe('Processors', () => {
compare(reshaped_input_sizes, [[888, 1333]]);
}
}, MAX_TEST_EXECUTION_TIME);


// OwlViTFeatureExtractor
it(MODELS.owlvit, async () => {
const processor = await AutoProcessor.from_pretrained(m(MODELS.owlvit))

{
const image = await load_image(TEST_IMAGES.cats);
const { pixel_values, original_sizes, reshaped_input_sizes } = await processor(image);

compare(pixel_values.dims, [1, 3, 768, 768]);
compare(avg(pixel_values.data), 0.250620447910435);

compare(original_sizes, [[480, 640]]);
compare(reshaped_input_sizes, [[768, 768]]);
}
}, MAX_TEST_EXECUTION_TIME);
});
});

0 comments on commit 983c502

Please sign in to comment.