[codex] add image URL loader#2372
Open
Erol444 wants to merge 10 commits into
Open
Conversation
Borda
reviewed
Jun 29, 2026
Borda
reviewed
Jun 29, 2026
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #2372 +/- ##
=======================================
Coverage 83% 83%
=======================================
Files 69 69
Lines 9616 9675 +59
=======================================
+ Hits 7941 7995 +54
- Misses 1675 1680 +5 🚀 New features to boost your workflow:
|
Borda
reviewed
Jun 29, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new convenience loader for fetching images over HTTP(S) into OpenCV/NumPy (load_image_from_url) and wires it into the public API, along with unit tests and API docs.
Changes:
- Introduces
load_image_from_url()insupervision.utils.image(URL validation, download viarequests, decode via OpenCV, optional on-disk caching). - Adds
prepare_url()helper insupervision.utils.internalfor HTTP(S) URL normalization/validation. - Exports the new helper from
supervision.__init__, and documents/tests the new behavior.
Quality / Testing / Docs (n/5):
- Code quality: 4/5
- Testing: 5/5
- Docs: 3/5
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/utils/test_image.py | Adds focused unit tests for URL loading, caching behavior, and failure modes. |
| src/supervision/utils/internal.py | Adds shared URL normalization/validation helper (prepare_url). |
| src/supervision/utils/image.py | Implements load_image_from_url (download/decode/cache) and related helpers. |
| src/supervision/init.py | Exposes load_image_from_url from the top-level package. |
| docs/utils/image.md | Adds mkdocs API entry for load_image_from_url. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
load_image_from_url()tosupervision.utils.imageand exports it from the top-levelsupervisionpackage. The helper validates and normalizes HTTP(S) URLs, downloads the image withrequests, decodes it through OpenCV, and raises clear errors for invalid URLs, request failures, or undecodable image bytes.Also adds mkdocs API documentation and focused unit tests for successful decoding, invalid image bytes, request failures, and non-HTTP URL rejection.
Validation
uv run --frozen pytest tests/utils/test_image.py tests/utils/test_video.pySKIP=mypy uv run --frozen pre-commit run --files src/supervision/utils/internal.py src/supervision/utils/image.py src/supervision/utils/video.py src/supervision/__init__.py tests/utils/test_image.py tests/utils/test_video.py docs/utils/image.md docs/utils/video.mdgit diff --checkNote: the local mypy hook was skipped because it fails before checking this code due to a NumPy stub syntax issue under the repo's configured Python 3.9 target.