UNPKG

transformers-fork

Version:

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

27 lines (23 loc) • 725 B
import { ImageProcessor, } from "../../base/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, }); 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, }); } }