Skip to content

Commit ee7ad8f

Browse files
authored
Re-submit: Fix: Proper RGBA -> RGB conversion for PIL images. (vllm-project#18569)
Signed-off-by: Chenheli Hua <[email protected]>
1 parent 7268d69 commit ee7ad8f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

datasets.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
TODO: Implement CustomDataset to parse a JSON file and convert its contents into
1414
SampleRequest instances, similar to the approach used in ShareGPT.
1515
"""
16-
1716
import base64
1817
import io
1918
import json
@@ -33,6 +32,7 @@
3332
from vllm.lora.request import LoRARequest
3433
from vllm.lora.utils import get_adapter_absolute_path
3534
from vllm.multimodal import MultiModalDataDict
35+
from vllm.multimodal.image import convert_image_mode
3636
from vllm.transformers_utils.tokenizer import AnyTokenizer, get_lora_tokenizer
3737

3838
logger = logging.getLogger(__name__)
@@ -259,7 +259,7 @@ def process_image(image: Any) -> Mapping[str, Any]:
259259
if isinstance(image, dict) and 'bytes' in image:
260260
image = Image.open(BytesIO(image['bytes']))
261261
if isinstance(image, Image.Image):
262-
image = image.convert("RGB")
262+
image = convert_image_mode(image, "RGB")
263263
with io.BytesIO() as image_data:
264264
image.save(image_data, format="JPEG")
265265
image_base64 = base64.b64encode(

0 commit comments

Comments
 (0)