mirror of
https://github.com/hiyouga/LLaMA-Factory.git
synced 2025-10-16 00:28:10 +08:00
add image num check
Former-commit-id: 15201113bf16b748c0a758c7a5b363da8272e0e6
This commit is contained in:
parent
806e1061d4
commit
bae73e676c
@ -210,12 +210,17 @@ class Qwen2vlPlugin(BasePlugin):
|
|||||||
merge_length: int = getattr(image_processor, "merge_size") ** 2
|
merge_length: int = getattr(image_processor, "merge_size") ** 2
|
||||||
if len(images) > 0:
|
if len(images) > 0:
|
||||||
image_grid_thw = _get_mm_inputs(images, processor)["image_grid_thw"]
|
image_grid_thw = _get_mm_inputs(images, processor)["image_grid_thw"]
|
||||||
|
else:
|
||||||
|
image_grid_thw = []
|
||||||
|
|
||||||
num_images = 0
|
num_images = 0
|
||||||
messages = deepcopy(messages)
|
messages = deepcopy(messages)
|
||||||
for message in messages:
|
for message in messages:
|
||||||
content = message["content"]
|
content = message["content"]
|
||||||
while IMAGE_PLACEHOLDER in content:
|
while IMAGE_PLACEHOLDER in content:
|
||||||
|
if num_images >= len(image_grid_thw):
|
||||||
|
raise ValueError("`len(images)` is less than the number of {} tokens.".format(IMAGE_PLACEHOLDER))
|
||||||
|
|
||||||
content = content.replace(
|
content = content.replace(
|
||||||
IMAGE_PLACEHOLDER,
|
IMAGE_PLACEHOLDER,
|
||||||
"<|vision_start|>{}<|vision_end|>".format(
|
"<|vision_start|>{}<|vision_end|>".format(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user