Unverified Commit 1e2428a2 authored by Baber Abbasi's avatar Baber Abbasi Committed by GitHub
Browse files

[hf-multimodal] pass kwargs to self.processor (#2667)

* add min_pixels, max_pixels

* fix
parent 80a10075
......@@ -45,6 +45,8 @@ class HFMultimodalLM(HFLM):
# TODO: handle whitespace in image placeholder (replacement)
max_images: Optional[int] = 999,
convert_img_format=False,
min_pixels: Optional[int] = None,
max_pixels: Optional[int] = None,
**kwargs,
):
# We initialize using HFLM's init. Sub-methods like _create_model and _create_tokenizer
......@@ -63,6 +65,9 @@ class HFMultimodalLM(HFLM):
self.interleave = interleave
self.max_images = max_images
self.rgb = convert_img_format
self.pixels = ({"min_pixels": min_pixels} if min_pixels else {}) | (
{"max_pixels": max_pixels} if max_pixels else {}
)
# WARNING: improperly set image_token_id can lead to ignored image input or other (potentially silent) errors!
if not image_string:
self.image_token_id = (
......@@ -135,6 +140,7 @@ class HFMultimodalLM(HFLM):
model_name,
revision=revision,
trust_remote_code=trust_remote_code,
**self.pixels,
# use_fast=use_fast_tokenizer,
)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment