File size: 734 Bytes
ca97aa9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

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,
        });
        // @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,
        });
    }
}