Skip to content

[codex] add image URL loader#2372

Open
Erol444 wants to merge 10 commits into
developfrom
codex/add-image-url-loader
Open

[codex] add image URL loader#2372
Erol444 wants to merge 10 commits into
developfrom
codex/add-image-url-loader

Conversation

@Erol444

@Erol444 Erol444 commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds load_image_from_url() to supervision.utils.image and exports it from the top-level supervision package. The helper validates and normalizes HTTP(S) URLs, downloads the image with requests, 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.py
  • SKIP=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.md
  • git diff --check

Note: 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.

Comment thread src/supervision/utils/image.py
Comment thread src/supervision/utils/image.py Outdated
@codecov

codecov Bot commented Jun 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.52542% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 83%. Comparing base (934da12) to head (60b0cb2).

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:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Erol444 Erol444 requested a review from Borda June 29, 2026 11:58
@Erol444 Erol444 marked this pull request as ready for review June 29, 2026 11:58
@Erol444 Erol444 requested a review from SkalskiP as a code owner June 29, 2026 11:58
Comment thread src/supervision/utils/image.py

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() in supervision.utils.image (URL validation, download via requests, decode via OpenCV, optional on-disk caching).
  • Adds prepare_url() helper in supervision.utils.internal for 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.

Comment thread src/supervision/utils/image.py
Comment thread src/supervision/utils/internal.py Outdated
@Borda Borda added the enhancement New feature or request label Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants