A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 13, 13:15 UTC
[Bugfix] Fix max image size for PaddleOCR-VL (#28442)
Signed-off-by: Roger Wang <hey@rogerw.io>
Roger Wang committed
Nov 11, 2025 at 00:07 UTC
4fd4b743a23cc6ccbd832f11be12317a8c2f0fbc
1 file changed
+21
-15
vllm/model_executor/models/paddleocr_vl.py
+21
-15
@@ -198,23 +198,18 @@ class PaddleOCRVLProcessingInfo(BaseProcessingInfo):
198
if image_processor is None:
199
image_processor = self.get_image_processor()
200
201
- do_resize = True
201
hf_config = self.get_hf_config()
202
vision_config = hf_config.vision_config
203
patch_size = vision_config.patch_size
204
merge_size = vision_config.spatial_merge_size
206
-
207
- if do_resize:
208
- resized_height, resized_width = smart_resize(
209
- height=image_height,
210
- width=image_width,
211
- factor=patch_size * merge_size,
212
- min_pixels=image_processor.min_pixels,
213
- max_pixels=image_processor.max_pixels,
214
- )
215
- preprocessed_size = ImageSize(width=resized_width, height=resized_height)
216
- else:
217
- preprocessed_size = ImageSize(width=image_width, height=image_height)
205
+ resized_height, resized_width = smart_resize(
206
+ height=image_height,
207
+ width=image_width,
208
+ factor=patch_size * merge_size,
209
+ min_pixels=image_processor.min_pixels,
210
+ max_pixels=image_processor.max_pixels,
211
+ )
212
+ preprocessed_size = ImageSize(width=resized_width, height=resized_height)
213
214
grid_t = 1
215
grid_h = preprocessed_size.height // patch_size
@@ -227,8 +222,19 @@ class PaddleOCRVLProcessingInfo(BaseProcessingInfo):
222
223
def get_image_size_with_most_features(self) -> ImageSize:
224
hf_config = self.get_hf_config()
230
- image_size = hf_config.vision_config.image_size
231
- return ImageSize(height=image_size, width=image_size)
225
+
226
+ # See `smart_resize` for the calculation of the image size.
227
+ merge_size = hf_config.vision_config.spatial_merge_size
228
+ patch_size = hf_config.vision_config.patch_size
229
+ factor = merge_size * patch_size
230
+ max_num_tokens = self.get_image_processor().max_pixels // (factor**2)
231
+ # Find factors of max_num_tokens close to its square root
232
+ # to create a dummy image with a reasonable aspect ratio.
233
+ h_patches = int(math.sqrt(max_num_tokens))
234
+ while max_num_tokens % h_patches != 0:
235
+ h_patches -= 1
236
+ w_patches = max_num_tokens // h_patches
237
+ return ImageSize(height=h_patches * factor, width=w_patches * factor)
238
239
240
class PaddleOCRVLDummyInputsBuilder(BaseDummyInputsBuilder[PaddleOCRVLProcessingInfo]):