Skip to content

Commit 9a17396

Browse files
committed
Use min_pixels and max_pixels from config
1 parent f045ec8 commit 9a17396

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/base/image_processors_utils.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,10 @@ export class ImageProcessor extends Callable {
619619
this.pad_size = config.pad_size;
620620
// @ts-expect-error TS2339
621621
this.do_pad = config.do_pad;
622+
// @ts-expect-error TS2339
623+
this.min_pixels = config.min_pixels;
624+
// @ts-expect-error TS2339
625+
this.max_pixels = config.max_pixels;
622626

623627
if (this.do_pad && !this.pad_size && this.size && this.size.width !== undefined && this.size.height !== undefined) {
624628
// Should pad, but no pad size specified
@@ -892,12 +896,11 @@ export class ImageProcessor extends Callable {
892896

893897
} else if (this.size_divisibility !== undefined) {
894898
return enforce_size_divisibility([srcWidth, srcHeight], this.size_divisibility);
895-
} else if (size.min_pixels !== undefined && size.max_pixels !== undefined) {
899+
} else if (this.min_pixels !== undefined && this.max_pixels !== undefined) {
896900
// Custom resize logic for Qwen2-VL models
897-
const { min_pixels, max_pixels } = size;
898901
// @ts-expect-error TS2339
899902
const factor = this.config.patch_size * this.config.merge_size;
900-
return smart_resize(srcHeight, srcWidth, factor, min_pixels, max_pixels);
903+
return smart_resize(srcHeight, srcWidth, factor, this.min_pixels, this.max_pixels);
901904
} else {
902905
throw new Error(`Could not resize image due to unsupported \`this.size\` option in config: ${JSON.stringify(size)}`);
903906
}

0 commit comments

Comments
 (0)