Skip to content

Commit

Permalink
Fix async function not converting image mode
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkLight1337 committed Jul 15, 2024
1 parent 75256e2 commit 4510277
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions vllm/multimodal/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ def get_aiohttp_client(cls) -> aiohttp.ClientSession:
return cls.aiohttp_client

@classmethod
async def fetch_image(cls, image_url: str) -> Image.Image:
async def fetch_image(
cls,
image_url: str,
*,
image_mode: str = "RGB",
) -> Image.Image:
"""
Asynchronously load a PIL image from a HTTP or base64 data URL.
Expand All @@ -99,7 +104,7 @@ async def fetch_image(cls, image_url: str) -> Image.Image:
"Invalid 'image_url': A valid 'image_url' must start "
"with either 'data:image' or 'http'.")

return image
return image.convert(image_mode)


async def async_get_and_parse_image(image_url: str) -> MultiModalDataDict:
Expand Down

0 comments on commit 4510277

Please sign in to comment.