Repository navigation
[#22190][fix] Resolve file:// URIs and special characters in load_image - #22193
Conversation
load_image passed a file:// URI to PIL as a literal file name, so it raised FileNotFoundError, and async_load_image took urlparse().path without unquoting, so a percent-encoded name was never found and a bare path containing '#', '?' or ';' was cut at that character. Resolve local sources through _normalize_file_uri in both functions, as ImageMediaIO.load_file and the audio loaders already do. Signed-off-by: sohailshk <[email protected]>
|
No actionable comments were generated in the recent review. WalkthroughThe synchronous and asynchronous image loaders now normalize local paths and ChangesLocal image loading
Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Merge Risk:
|
|
/bot run --disable-fail-fast |
|
PR_Github #85715 [ run ] triggered by Bot. Commit: |
|
PR_Github #85715 [ run ] completed with state |
|
Automatically added "ci: full pre-merge approved" because this PR has satisfied the required GitHub review approvals. Unresolved review conversations and other required checks remain independent merge requirements. |
Dev Engineer Review
tensorrt_llm/inputs/utils.py(+2/-2):load_imageandasync_load_imagenow resolve local andfile:sources with_normalize_file_uribefore loading. The synchronous and asynchronous paths both pass the normalized value as aPath. The async path no longer usesurlparse(...).path, which caused the bug in#22190.#,?, or;should load correctly. The helper's handling of literal%xxtext in bare paths was not verified in the source.QA Engineer Review
tests/unittest/inputs/test_async_media_loading.py(+43 lines). It addsTestLoadImageLocalFile.TestLoadImageLocalFile::test_sync_and_async_load_the_same_file. It covers 6 filenames, each used as a bare path and as afile://URI, for 12 cases acrossload_imageandasync_load_image.#,?, and;.tests/integration/test_lists/test-db/ortests/integration/test_lists/qa/. Whether an existing list entry covers this unit test file is not available.sufficientfor the reported local-file cases. The change does not cover CUDA paths, and the CUDA test suite was not run. Confirm CI results on the current head before merge.Per-File QA Perspective
tensorrt_llm/inputs/utils.py: QA should confirm thatload_imageandasync_load_imageload afile://URI with percent-encoded names. QA should also confirm that bare paths with#,?, or;load in both functions. Test the default multimodal loader with a localfile://image in offline mode.tests/unittest/inputs/test_async_media_loading.py: The new test compares synchronous and asynchronous PIL output against a reference image for each case. It is a unit test and needs no GPU.Description
Fixes #22190.
load_imagepassed afile://URI to PIL as a literal file name, so it raised FileNotFoundError.async_load_imagetookurlparse(...).pathwithout unquoting, so a percent-encoded name was never found, and a bare path containing#,?or;was cut at that character.Both functions now resolve local sources with
_normalize_file_uri, asImageMediaIO.load_fileand the audio loaders already do. Bare paths are returned unchanged by that helper.Test Coverage
tests/unittest/inputs/test_async_media_loading.py::TestLoadImageLocalFile::test_sync_and_async_load_the_same_file(12 cases: bare path andfile://URI, for plain, space,#,?,;and%file names, through bothload_imageandasync_load_image). On the base branch 9 of the 12 fail, with the change all pass; the whole file passes (37 tests).tests/unittest/inputsis already on the l0_cpu list.Run on macOS with a stub package init (no CUDA, no compiled bindings); the CUDA test suite was not run.
PR Checklist
Please review the following before submitting your PR:
PR description clearly explains what and why.
PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.
Test cases are provided for new code paths (see test instructions)
If PR introduces API changes, an appropriate PR label is added - either
api-compatibleorapi-breaking. Forapi-breaking, includeBREAKINGin the PR title.Any new dependencies have been scanned for license and vulnerabilities
CODEOWNERS updated if ownership changes
Documentation updated as needed
Update tava architecture diagram if there is a significant design change in PR.
The reviewers assigned automatically/manually are appropriate for the PR.
Please check this after reviewing the above items as appropriate for this PR.