Skip to content

load_image fails on file:// URIs and async_load_image mishandles percent-encoded paths and #, ?, ; in file names #22190

Closed

Description

@sohailshk

System Info

Any platform; found on current main (e3c25b0). Pure Python path, no GPU needed.

Who can help?

Multimodal input loading / OpenAI-compatible serving (code owners of the touched files).

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

import asyncio, tempfile, pathlib
from PIL import Image
from tensorrt_llm.inputs.utils import load_image, async_load_image

d = pathlib.Path(tempfile.mkdtemp())
Image.new("RGB", (6, 4)).save(d / "with space.png")
uri = (d / "with space.png").as_uri() # file:///.../with%20space.png

load_image(uri, format="pil") # FileNotFoundError: 'file:///.../with%20space.png'
asyncio.run(async_load_image(uri, format="pil")) # FileNotFoundError: '.../with%20space.png'

Image.new("RGB", (6, 4)).save(d / "a#b.png")
asyncio.run(async_load_image(str(d / "a#b.png"), format="pil")) # FileNotFoundError: '.../a'

the same happens for "a?b.png" and "a;b.png"

Expected behavior

Both functions load the file. ImageMediaIO.load_file and load_audio / async_load_audio already resolve local sources with _normalize_file_uri (strip file://, unquote). The cosmos3 action code (_torch/visual_gen/models/cosmos3/action.py, comment at lines 349-351) also relies on load_image handling file:// URIs.

actual behavior

FileNotFoundError as shown. load_image hands the raw URI string to PIL; async_load_image uses urlparse(...).path without unquoting, which also cuts a bare path at #, ? or ;. default_multimodal_input_loader calls load_image for local image strings, so an offline request with a file:// image fails.

additional notes

A fix with a unit test is ready; PR to follow. No existing issue or PR found (searched load_image, _normalize_file_uri, file:// URI). Open PR #17168 touches the data-URI branch of the same file but not these lines.

Before submitting a new issue...

  • Make sure you already searched for relevant issues, and checked the documentation and examples for answers to frequently asked questions.

Activity

  1. added
    bug
    on Nov 12, 2026
  2. added
    Multimodal
    on Nov 12, 2026
  3. added a commit that references this issue on Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Multimodalbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions