mirror of
https://github.com/hiyouga/LLaMA-Factory.git
synced 2025-10-15 16:18:10 +08:00
[misc] update mm plugin (#6691)
Former-commit-id: 00303338d6927b1fda58b23340a31a8fa009f706
This commit is contained in:
parent
332f637592
commit
5baa3add8c
@ -91,7 +91,7 @@ class BasePlugin:
|
|||||||
if (image.width * image.height) > image_resolution:
|
if (image.width * image.height) > image_resolution:
|
||||||
resize_factor = math.sqrt(image_resolution / (image.width * image.height))
|
resize_factor = math.sqrt(image_resolution / (image.width * image.height))
|
||||||
width, height = int(image.width * resize_factor), int(image.height * resize_factor)
|
width, height = int(image.width * resize_factor), int(image.height * resize_factor)
|
||||||
image = image.resize((width, height), resample=Image.NEAREST)
|
image = image.resize((width, height), resample=Image.Resampling.NEAREST)
|
||||||
|
|
||||||
if image.mode != "RGB":
|
if image.mode != "RGB":
|
||||||
image = image.convert("RGB")
|
image = image.convert("RGB")
|
||||||
@ -780,15 +780,15 @@ class Qwen2vlPlugin(BasePlugin):
|
|||||||
image = super()._preprocess_image(image, **kwargs)
|
image = super()._preprocess_image(image, **kwargs)
|
||||||
if min(image.width, image.height) < 28:
|
if min(image.width, image.height) < 28:
|
||||||
width, height = max(image.width, 28), max(image.height, 28)
|
width, height = max(image.width, 28), max(image.height, 28)
|
||||||
image = image.resize((width, height), resample=Image.NEAREST)
|
image = image.resize((width, height), resample=Image.Resampling.NEAREST)
|
||||||
|
|
||||||
if image.width / image.height > 200:
|
if image.width / image.height > 200:
|
||||||
width, height = image.height * 180, image.height
|
width, height = image.height * 180, image.height
|
||||||
image = image.resize((width, height), resample=Image.NEAREST)
|
image = image.resize((width, height), resample=Image.Resampling.NEAREST)
|
||||||
|
|
||||||
if image.height / image.width > 200:
|
if image.height / image.width > 200:
|
||||||
width, height = image.width, image.width * 180
|
width, height = image.width, image.width * 180
|
||||||
image = image.resize((width, height), resample=Image.NEAREST)
|
image = image.resize((width, height), resample=Image.Resampling.NEAREST)
|
||||||
|
|
||||||
return image
|
return image
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user