Former-commit-id: 13ee1f5cec815590c5d290f0aca264e6d16ddd5d
This commit is contained in:
hiyouga 2024-11-25 00:05:05 +08:00
parent 5a7ff02806
commit 65699c29d4
2 changed files with 3 additions and 3 deletions

View File

@ -113,9 +113,9 @@ class VllmEngine(BaseEngine):
messages[0]["content"] = IMAGE_PLACEHOLDER * len(images) + messages[0]["content"]
if self.template.mm_plugin.__class__.__name__ == "Qwen2vlPlugin": # temporary solution
image_str = "<|vision_start|>" + self.template.mm_plugin.image_token + "<|vision_end|>"
image_str = f"<|vision_start|>{self.template.mm_plugin.image_token}<|vision_end|>"
else:
image_str = self.template.mm_plugin.image_token
image_str = self.template.mm_plugin.image_token or ""
paired_messages = [
{"role": message["role"], "content": message["content"].replace(IMAGE_PLACEHOLDER, image_str)}

View File

@ -82,7 +82,7 @@ class BasePlugin:
Pre-processes a single image.
"""
image_resolution: int = kwargs.get("image_resolution")
if image.width * image.height > image_resolution:
if (image.width * image.height) > image_resolution:
resize_factor = math.sqrt(image_resolution / (image.width * image.height))
width, height = int(image.width * resize_factor), int(image.height * resize_factor)
image = image.resize((width, height), resample=Image.NEAREST)