Skip to content

Commit

Permalink
Use AutoImageProcessor for image processors
Browse files Browse the repository at this point in the history
  • Loading branch information
xenova committed Nov 20, 2024
1 parent 155bb9d commit 76c132f
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions tests/processors.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { env, AutoProcessor, RawImage } from "../src/transformers.js";
import { env, AutoProcessor, AutoImageProcessor, RawImage } from "../src/transformers.js";
import { init, MAX_TEST_EXECUTION_TIME } from "./init.js";
import { compare } from "./test_utils.js";

Expand Down Expand Up @@ -75,7 +75,7 @@ describe("Processors", () => {
it(
MODELS.swin2sr,
async () => {
const processor = await AutoProcessor.from_pretrained(MODELS.swin2sr);
const processor = await AutoImageProcessor.from_pretrained(MODELS.swin2sr);

{
// Pad to multiple of 8 (3x3 -> 8x8)
Expand Down Expand Up @@ -103,7 +103,7 @@ describe("Processors", () => {
it(
MODELS.sam,
async () => {
const processor = await AutoProcessor.from_pretrained(MODELS.sam);
const processor = await AutoImageProcessor.from_pretrained(MODELS.sam);

{
// without input points
Expand Down Expand Up @@ -175,7 +175,7 @@ describe("Processors", () => {
it(
MODELS["donut-swin"],
async () => {
const processor = await AutoProcessor.from_pretrained(MODELS["donut-swin"]);
const processor = await AutoImageProcessor.from_pretrained(MODELS["donut-swin"]);

{
const image = await load_image(TEST_IMAGES.receipt);
Expand All @@ -195,7 +195,7 @@ describe("Processors", () => {
it(
MODELS.resnet,
async () => {
const processor = await AutoProcessor.from_pretrained(MODELS.resnet);
const processor = await AutoImageProcessor.from_pretrained(MODELS.resnet);

{
const image = await load_image(TEST_IMAGES.tiger);
Expand All @@ -215,7 +215,7 @@ describe("Processors", () => {
it(
MODELS.vit,
async () => {
const processor = await AutoProcessor.from_pretrained(MODELS.vit);
const processor = await AutoImageProcessor.from_pretrained(MODELS.vit);

{
const image = await load_image(TEST_IMAGES.tiger);
Expand All @@ -235,7 +235,7 @@ describe("Processors", () => {
it(
MODELS.mobilevit,
async () => {
const processor = await AutoProcessor.from_pretrained(MODELS.mobilevit);
const processor = await AutoImageProcessor.from_pretrained(MODELS.mobilevit);

{
const image = await load_image(TEST_IMAGES.tiger);
Expand All @@ -256,7 +256,7 @@ describe("Processors", () => {
it(
MODELS.mobilevit_2,
async () => {
const processor = await AutoProcessor.from_pretrained(MODELS.mobilevit_2);
const processor = await AutoImageProcessor.from_pretrained(MODELS.mobilevit_2);

{
// Tests grayscale image
Expand All @@ -278,7 +278,7 @@ describe("Processors", () => {
it(
MODELS.mobilevit_3,
async () => {
const processor = await AutoProcessor.from_pretrained(MODELS.mobilevit_3);
const processor = await AutoImageProcessor.from_pretrained(MODELS.mobilevit_3);

{
const image = await load_image(TEST_IMAGES.cats);
Expand All @@ -301,7 +301,7 @@ describe("Processors", () => {
it(
MODELS.deit,
async () => {
const processor = await AutoProcessor.from_pretrained(MODELS.deit);
const processor = await AutoImageProcessor.from_pretrained(MODELS.deit);

{
const image = await load_image(TEST_IMAGES.tiger);
Expand All @@ -321,7 +321,7 @@ describe("Processors", () => {
it(
MODELS.beit,
async () => {
const processor = await AutoProcessor.from_pretrained(MODELS.beit);
const processor = await AutoImageProcessor.from_pretrained(MODELS.beit);

{
const image = await load_image(TEST_IMAGES.tiger);
Expand All @@ -341,7 +341,7 @@ describe("Processors", () => {
it(
MODELS.detr,
async () => {
const processor = await AutoProcessor.from_pretrained(MODELS.detr);
const processor = await AutoImageProcessor.from_pretrained(MODELS.detr);

{
const image = await load_image(TEST_IMAGES.tiger);
Expand All @@ -364,7 +364,7 @@ describe("Processors", () => {
it(
MODELS.yolos,
async () => {
const processor = await AutoProcessor.from_pretrained(MODELS.yolos);
const processor = await AutoImageProcessor.from_pretrained(MODELS.yolos);

{
const image = await load_image(TEST_IMAGES.tiger);
Expand All @@ -384,7 +384,7 @@ describe("Processors", () => {
it(
MODELS.dpt,
async () => {
const processor = await AutoProcessor.from_pretrained(MODELS.dpt);
const processor = await AutoImageProcessor.from_pretrained(MODELS.dpt);

{
// Tests grayscale image
Expand All @@ -406,7 +406,7 @@ describe("Processors", () => {
it(
MODELS.glpn,
async () => {
const processor = await AutoProcessor.from_pretrained(MODELS.glpn);
const processor = await AutoImageProcessor.from_pretrained(MODELS.glpn);

{
const image = await load_image(TEST_IMAGES.cats);
Expand Down Expand Up @@ -438,7 +438,7 @@ describe("Processors", () => {
it(
MODELS.nougat,
async () => {
const processor = await AutoProcessor.from_pretrained(MODELS.nougat);
const processor = await AutoImageProcessor.from_pretrained(MODELS.nougat);

{
const image = await load_image(TEST_IMAGES.paper);
Expand All @@ -456,7 +456,7 @@ describe("Processors", () => {

// OwlViTFeatureExtractor
it(MODELS.owlvit, async () => {
const processor = await AutoProcessor.from_pretrained(MODELS.owlvit);
const processor = await AutoImageProcessor.from_pretrained(MODELS.owlvit);
{
const image = await load_image(TEST_IMAGES.cats);
const { pixel_values, original_sizes, reshaped_input_sizes } = await processor(image);
Expand All @@ -474,7 +474,7 @@ describe("Processors", () => {
it(
MODELS.clip,
async () => {
const processor = await AutoProcessor.from_pretrained(MODELS.clip);
const processor = await AutoImageProcessor.from_pretrained(MODELS.clip);

{
const image = await load_image(TEST_IMAGES.tiger);
Expand All @@ -498,7 +498,7 @@ describe("Processors", () => {
it(
MODELS.vitmatte,
async () => {
const processor = await AutoProcessor.from_pretrained(MODELS.vitmatte);
const processor = await AutoImageProcessor.from_pretrained(MODELS.vitmatte);

{
const image = await load_image(TEST_IMAGES.vitmatte_image);
Expand Down Expand Up @@ -545,7 +545,7 @@ describe("Processors", () => {
it(
MODELS.dinov2,
async () => {
const processor = await AutoProcessor.from_pretrained(MODELS.dinov2);
const processor = await AutoImageProcessor.from_pretrained(MODELS.dinov2);

{
const image = await load_image(TEST_IMAGES.tiger);
Expand All @@ -568,7 +568,7 @@ describe("Processors", () => {
it(
MODELS.dpt_2,
async () => {
const processor = await AutoProcessor.from_pretrained(MODELS.dpt_2);
const processor = await AutoImageProcessor.from_pretrained(MODELS.dpt_2);

{
const image = await load_image(TEST_IMAGES.cats);
Expand Down Expand Up @@ -600,7 +600,7 @@ describe("Processors", () => {
// // EfficientNetImageProcessor
// // - tests include_top
// it(MODELS.efficientnet, async () => {
// const processor = await AutoProcessor.from_pretrained(MODELS.efficientnet)
// const processor = await AutoImageProcessor.from_pretrained(MODELS.efficientnet)

// {
// const image = await load_image(TEST_IMAGES.cats);
Expand All @@ -619,7 +619,7 @@ describe("Processors", () => {
it(
MODELS.qwen2_vl,
async () => {
const processor = await AutoProcessor.from_pretrained(MODELS.qwen2_vl);
const processor = await AutoImageProcessor.from_pretrained(MODELS.qwen2_vl);

{
const image = await load_image(TEST_IMAGES.white_image);
Expand Down Expand Up @@ -834,7 +834,7 @@ describe("Processors", () => {
describe(
"FlorenceProcessor",
() => {
/** @type {import('../src/processors.js').Florence2Processor} */
/** @type {import('../src/transformers.js').Florence2Processor} */
let processor;
let images = {};

Expand Down

0 comments on commit 76c132f

Please sign in to comment.