Skip to content

Commit 4165c44

Browse files
authored
Merge pull request #6126 from hiyouga/hiyouga/fix_vllm
[inference] fix vllm Former-commit-id: 07059a7
2 parents 7f74e54 + 65699c2 commit 4165c44

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/llamafactory/chat/vllm_engine.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ async def _generate(
113113
messages[0]["content"] = IMAGE_PLACEHOLDER * len(images) + messages[0]["content"]
114114

115115
if self.template.mm_plugin.__class__.__name__ == "Qwen2vlPlugin": # temporary solution
116-
image_str = "<|vision_start|>" + self.template.mm_plugin.image_token + "<|vision_end|>"
116+
image_str = f"<|vision_start|>{self.template.mm_plugin.image_token}<|vision_end|>"
117117
else:
118-
image_str = self.template.mm_plugin.image_token
118+
image_str = self.template.mm_plugin.image_token or ""
119119

120120
paired_messages = [
121121
{"role": message["role"], "content": message["content"].replace(IMAGE_PLACEHOLDER, image_str)}

src/llamafactory/data/mm_plugin.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def _preprocess_image(self, image: "ImageObject", **kwargs) -> "ImageObject":
8282
Pre-processes a single image.
8383
"""
8484
image_resolution: int = kwargs.get("image_resolution")
85-
if image.width * image.height > image_resolution:
85+
if (image.width * image.height) > image_resolution:
8686
resize_factor = math.sqrt(image_resolution / (image.width * image.height))
8787
width, height = int(image.width * resize_factor), int(image.height * resize_factor)
8888
image = image.resize((width, height), resample=Image.NEAREST)

0 commit comments

Comments
 (0)