UNPKG

@huggingface/transformers

Version:

State-of-the-art Machine Learning for the web. Run 🤗 Transformers directly in your browser, with no need for a server!

25 lines (22 loc) • 726 B
import { ImageProcessor } from '../../image_processors_utils.js'; export class VLMImageProcessor extends ImageProcessor { constructor(config) { super({ do_pad: true, pad_size: { width: config.image_size, height: config.image_size, }, ...config, }); // @ts-expect-error TS2339 this.constant_values = this.config.background_color.map((x) => x * this.rescale_factor); } pad_image(pixelData, imgDims, padSize, options) { return super.pad_image(pixelData, imgDims, padSize, { constant_values: this.constant_values, center: true, ...options, }); } }