[Bugfix] Emit a valid media type from encode_{audio,image,video}_url (#49056)
Signed-off-by: Vineeth Sai <vineethsai4444@gmail.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
import pytest
|
||||
import torch
|
||||
from PIL import Image
|
||||
|
||||
from vllm.multimodal.inputs import (
|
||||
MultiModalBatchedField,
|
||||
@@ -10,7 +11,11 @@ from vllm.multimodal.inputs import (
|
||||
MultiModalSharedField,
|
||||
PlaceholderRange,
|
||||
)
|
||||
from vllm.multimodal.utils import argsort_mm_positions, group_and_batch_mm_items
|
||||
from vllm.multimodal.utils import (
|
||||
argsort_mm_positions,
|
||||
encode_image_url,
|
||||
group_and_batch_mm_items,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -224,6 +229,16 @@ def test_group_and_batch_mm_items_splits_shared_data_by_dtype():
|
||||
assert [num_items for num_items, _ in res] == [1, 1, 1]
|
||||
|
||||
|
||||
def test_encode_image_url_uncommon_format_has_valid_mimetype():
|
||||
"""A format missing from mimetypes.types_map must still produce a
|
||||
well-formed type/subtype media type, not a bare 'image'."""
|
||||
# ".tga" is not registered in mimetypes.types_map, so it exercises the
|
||||
# fallback path; Pillow can still encode it.
|
||||
url = encode_image_url(Image.new("RGB", (2, 2)), format="TGA")
|
||||
mimetype = url.removeprefix("data:").split(";", 1)[0]
|
||||
assert mimetype == "image/tga"
|
||||
|
||||
|
||||
def test_group_and_batch_mm_items_split_by_shared_data():
|
||||
elem1 = MultiModalFieldElem(
|
||||
data=torch.zeros(1, dtype=torch.uint8),
|
||||
|
||||
Reference in New Issue
Block a user