feat: Maximum image size for Vlm models (#1802)

* Image scale moved to base vlm options.
Added max_size image limit (options and vlm models).

* DCO Remediation Commit for Shkarupa Alex <shkarupa.alex@gmail.com>

I, Shkarupa Alex <shkarupa.alex@gmail.com>, hereby add my Signed-off-by to this commit: e93602a0d0

Signed-off-by: Shkarupa Alex <shkarupa.alex@gmail.com>

---------

Signed-off-by: Shkarupa Alex <shkarupa.alex@gmail.com>
This commit is contained in:
Shkarupa Alex
2025-06-18 13:57:37 +03:00
committed by GitHub
parent dbab30e92c
commit 215b540f6c
5 changed files with 19 additions and 7 deletions

View File

@@ -253,11 +253,18 @@ class Page(BaseModel):
return []
def get_image(
self, scale: float = 1.0, cropbox: Optional[BoundingBox] = None
self,
scale: float = 1.0,
max_size: Optional[int] = None,
cropbox: Optional[BoundingBox] = None,
) -> Optional[Image]:
if self._backend is None:
return self._image_cache.get(scale, None)
if max_size:
assert self.size is not None
scale = min(scale, max_size / max(self.size.as_tuple()))
if scale not in self._image_cache:
if cropbox is None:
self._image_cache[scale] = self._backend.get_page_image(scale=scale)