Skip to content

Commit a9a2d1e

Browse files
committed
Improve the Qwen25VLChatHandler's ability to handle multiple image inputs to avoid the illusion of multiple image inputs
1 parent c0f1cbc commit a9a2d1e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

llama_cpp/llama_chat_format.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3634,7 +3634,7 @@ class Qwen25VLChatHandler(Llava15ChatHandler):
36343634
DEFAULT_SYSTEM_MESSAGE = "You are a helpful assistant."
36353635

36363636
CHAT_FORMAT = (
3637-
#"{% set image_count = namespace(value=0) %}"
3637+
"{% set image_count = namespace(value=0) %}"
36383638
#"{% set video_count = namespace(value=0) %}"
36393639
"{% for message in messages %}"
36403640
"{% if loop.first and message['role'] != 'system' %}"
@@ -3648,11 +3648,12 @@ class Qwen25VLChatHandler(Llava15ChatHandler):
36483648
"{% for content in message['content'] %}"
36493649
"{% if content['type'] == 'image_url' %}"
36503650
"{% if content.image_url is string %}"
3651-
"{{ content.image_url }}"
3651+
"{% set image_count.value = image_count.value + 1 %}"
3652+
"Picture {{ image_count.value }}: <|vision_start|> {{ content.image_url }} <|vision_end|>"
36523653
"{% else %}"
3653-
"{{ content.image_url.url }}"
3654+
"{% set image_count.value = image_count.value + 1 %}"
3655+
"Picture {{ image_count.value }}: <|vision_start|> {{ content.image_url.url }} <|vision_end|>"
36543656
"{% endif %}"
3655-
#"{% set image_count.value = image_count.value + 1 %}"
36563657
"{% elif content['type'] == 'text' %}"
36573658
"{{ content['text'] }}"
36583659
"{% endif %}"

0 commit comments

Comments
 (0)