From d2a810f2aeec6f0abc590706f9e43b8cf1bf74f1 Mon Sep 17 00:00:00 2001 From: turboderp <11859846+turboderp@users.noreply.github.com> Date: Thu, 5 Jun 2025 01:32:36 +0200 Subject: [PATCH] Fix rounding error in Pixtral image preprocessor --- exllamav2/vlm/processor/pixtral.py | 2 +- exllamav2/vlm/util.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/exllamav2/vlm/processor/pixtral.py b/exllamav2/vlm/processor/pixtral.py index 1e8b145..e44a022 100644 --- a/exllamav2/vlm/processor/pixtral.py +++ b/exllamav2/vlm/processor/pixtral.py @@ -19,7 +19,7 @@ def preprocess( assert "longest_edge" in config.vision_size, \ "preprocessing size must specify longest_edge" - patch_size = tuple(config.vision_patch_size[d] for d in ["height", "width"]) + patch_size = tuple(config.vision_patch_size[d] * 2 for d in ["height", "width"]) longest_edge = config.vision_size["longest_edge"] resample = Image.Resampling(config.vision_resample) image_mean = tuple(config.vision_image_mean) diff --git a/exllamav2/vlm/util.py b/exllamav2/vlm/util.py index c1ddc50..5b53e0c 100644 --- a/exllamav2/vlm/util.py +++ b/exllamav2/vlm/util.py @@ -36,7 +36,7 @@ def size_to_longest_edge_and_patch_size( ratio = max(input_size[0] / max_size[0], input_size[1] / max_size[1]) if ratio > 1: - output_size = tuple(int(np.ceil(d / ratio)) for d in input_size) + output_size = tuple(max(1, int(np.floor(d / ratio))) for d in input_size) else: output_size = input_size