Commit Graph

152 Commits

Author SHA1 Message Date
Jirka Borovec bcbe8de1e4
chore(pre-commit): remove unnecessary exclude rule for changelog... (#2452)
* chore(pre-commit): remove unnecessary exclude rule for changelog and deprecated docs
* docs(changelog): reformat code blocks for consistency and clarity
* docs(changelog): reformat and align code blocks for consistent indentation and readability
* chore(pre-commit): update mdformat hooks to include gfm and frontmatter extensions
* chore(pre-commit): split mdformat hook into gfm and mkdocs variants
* docs(changelog): fix nested code fences breaking mdformat-mkdocs
* fix(pre_commit): 🎨 auto format pre-commit hooks

---------

Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-07-21 19:33:35 +02:00
Jirka Borovec 16814acff3
feat(utils): add `TkImageWindow` to unblock switch to `opencv-python-headless` (#2320)
- Added `sv.ImageWindow`, a Tkinter/Pillow-based desktop image viewer with BGR, grayscale, and BGRA support, keyboard polling, left-click callbacks, context-manager usage, window-state checks, and clean close handling
- Added responsive image resizing with optional aspect-ratio preservation and correctly mapped mouse coordinates after scaling or letterboxing
- Updated compatible runnable examples to use `sv.ImageWindow`, while retaining OpenCV display APIs for worker-thread streaming examples that are incompatible with Tkinter
- Improved `sv.cv2_to_pillow` to support grayscale and BGRA images
- Updated webcam guidance to clarify capture ownership and explicit `VideoCapture` cleanup
- Fixed image-window event handling to prevent stale keypresses, ghost windows, close-time races, and blocked waits after the window closes

---------

Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-07-15 15:06:55 +02:00
Jirka Borovec 3ecd5d0744
Optimize mask annotation ROI blending (#2368)
- Improved MaskAnnotator performance by blending mask overlays only within the affected ROI while preserving dense mask and CompactMask rendering behavior
- Fixed all-false masks to skip unnecessary ROI blending
- Updated compact-mask benchmark output to clarify annotation speedup reporting

---------

Co-authored-by: Codex <codex@openai.com>
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
2026-07-01 15:55:21 +02:00
Jirka Borovec beb047095f
feat: add compact RLE mask ingestion (#2367)
- Added compact COCO RLE mask ingestion with a `CompactMask` representation and optional compact mask parsing during inference for substantially lower memory usage on sparse segmentation results.
- Added `Detections.to_compact_masks()` to convert existing dense masks into compact masks while preserving detection and collection metadata.
- Improved compact mask decoding performance with cropped RLE processing, batched decoding on the fast path, vectorized decoding for small images, optimized RLE traversal, and faster delta decoding.
- Improved mask metrics to operate directly on `CompactMask` instances, preserving the compact representation while producing results equivalent to dense masks.
- Fixed mixed-modality inference handling by keeping detections and masks aligned, isolating malformed RLE failures to individual predictions where possible, and falling back safely when decoding cannot be completed.
- Fixed compact mask conversion and parsing to preserve dense-mask pixel content across public parsing and slicing paths, while correctly documenting and applying the intended bbox-cropping behavior for compact COCO RLE masks.
- Improved COCO RLE validation with checks for malformed payloads, invalid dimensions, count overflows, image size limits, count-sum mismatches, bounding-box mismatches, and safe fallback behavior for incompatible mask sizes.
- Added inference benchmarks and documentation demonstrating the memory and inference-time characteristics of compact masks, including guidance on their performance tradeoffs and behavior.

---------

Co-authored-by: Codex <codex@openai.com>
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-07-01 12:50:40 +02:00
Jirka Borovec 0a95bae8a8
chore: bump minimum Python to 3.10 (#2260)
- Drop Python 3.9 from CI test matrix
- requires-python = ">=3.10" in pyproject.toml
- ruff target-version py39 → py310
- mypy python_version 3.9 → 3.10
- Remove Python 3.9 classifier

---------

Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-06-29 14:45:30 +02:00
Jirka Borovec 09b21992c5
chore: port example typing refinements (#2358)
Co-authored-by: Codex <codex@openai.com>
2026-06-27 09:08:54 +02:00
Jirka Borovec 9faa4f6133
chore: update `mdformat` hook arguments to disable wrapping (#2307)
* chore: update `mdformat` hook arguments to disable wrapping
* fix(pre_commit): 🎨 auto format pre-commit hooks
* Apply suggestions from code review

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-06-09 16:15:05 +02:00
Madhav-C 4b856f1c04
docs(examples): fix outdated CLI flag names in `heatmap_and_track` README (#2266)
The README listed `--track_threshold` and `--match_threshold`, but
script.py exposes `--track_activation_threshold` and
`--minimum_matching_threshold` (the CLI surface is derived from the
main() signature by jsonargparse.auto_cli). Following the README as
written produced "unknown argument" errors.

Aligns the README with the actual CLI surface.
2026-05-22 20:00:30 +02:00
Jirka Borovec 153cde5854
feat(compact_mask): add `resize()` method and benchmark stage (#2227)
* feat: add resize() method and benchmark stage
* perf: optimise resize() — vectorised coords, L3 direct RLE
* refactor: split _rle_resize and extract _resize_crop
* test: expand resize() tests for scaling and edge cases
* refactor: switch resize helpers to F-order (column-major) RLE
* fix: merge True/True RLE junctions in _rle_join_cols
* perf: vectorize _rle_scale_col RLE re-encoding
* test: add density-dispatch and parallel-path resize tests
* refactor: harden resize() threading and RLE invariants
* fix: accurate resize timing and exact nearest-neighbour parity
* type: add explicit numpy typing to ndarray declarations

---------

Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-04-22 15:34:12 +02:00
Jirka Borovec 5a59dcdec6
refactor(masks): switch CompactMask RLE to F-order (#2228)
* refactor(masks): switch CompactMask RLE to F-order
* docs(masks): update _rle_area docstring example to F-order RLE
* test(masks): verify _rle_encode produces COCO-compatible F-order RLE

---------

Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-04-22 08:12:00 +02:00
abritton2002 51dd062407
fix: VideoInfo.fps returns float instead of truncated int (#2210)
* VideoInfo.fps returns float instead of int

Truncating the raw CAP_PROP_FPS value with int() causes timing drift for
non-integer frame rates (23.976, 29.97, 59.94). Over a long video this
accumulates into noticeable sync errors — e.g. 23 vs 23.976 drifts ~1s
per minute of footage.

Changes:
- VideoInfo.fps type annotation: int -> float
- from_video_path: int(video.get(CAP_PROP_FPS)) -> float(...)
- ByteTrack.frame_rate type annotation: int -> float (already converts
  to int internally via max_time_lost = int(frame_rate / 30.0 * buffer))
- Tests: assert fps is float, add float_fps_video_path fixture at 23.976

* fix: update examples to cast float fps to int where required
* fix: wrap long docstring line in FPSBasedTimer (ruff E501)
* test: remove unused float_fps_video_path fixture

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Jirka Borovec <6035284+Borda@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-04-13 20:05:19 +02:00
Jirka Borovec 9b7099d3fc
feat: add CompactMask for memory-efficient crop-RLE mask storage (#2159)
Dense (N, H, W) bool masks cause OOM for aerial imagery (1000 objects x
4K image ~ 8.3 GB). CompactMask encodes each mask as a run-length
sequence of its bounding-box crop, reducing typical usage to ~2 MB.

* fix: correct bounding box coordinates in CompactMask doctests
* feat: implement memory-efficient IoU and NMS with CompactMask integration
* test: add extensive tests for CompactMask IoU, NMS, and InferenceSlicer integration
* feat(examples): add CompactMask demo and benchmark
* feat(examples): expand CompactMask benchmark with new stages and metrics
* feat(tests): add detailed CompactMask tests for NMM, centroids, holes, and segments
* feat(compact_mask): add repack(), fix merge perf, and add parity tests
* fix(masks): handle empty crops by defaulting centroid to (0, 0)
* feat(compact_mask): add `bbox_xyxy` property and improve type annotations
* feat(compact_mask): enhance `with_offset` for clipping and add tests
* docs(compact_mask): unwrap prose and add per-operation speedup analysis
* perf(compact_mask): fast path in with_offset avoids decode/re-encode
* fix(benchmark): count NMS mismatches and explain exact-vs-resize difference
* test(compact_mask): add 121 parametrised random-scenario parity tests
* refactor: rename single-char variables to descriptive names
* fix(nms): remove resize-to-640 approximation from mask_non_max_suppression
* docs(compact_mask): update README with fresh benchmark results
* refactor(benchmark): improve summary table logic, add CSV export
* docs(compact_mask): update README with revised benchmark speedups and cleanup

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-04-13 11:10:12 +02:00
Jirka Borovec c67d977682
example/time_in_zone: Update requirements for inference package 2026-02-04 19:59:08 +09:00
Piotr Skalski a897905955
fix "time in zone" demo and make it use RF-DETR (#1922)
* migrate YT video file download script to use `yt_dlp`; old script didn't work anymore
* RF-DETR file example works
* ultralytics stream example migrated to new inference
* migrate inference scripts to use RF-DETR-Medium
* RF-DETR naive stream example
* RF-DETR stream example
* updated README.md

* fix(pre_commit): 🎨 auto format pre-commit hooks

* Migrate `time_in_zone` examples to use `jsonargparse` and update `--classes` argument format to accept lists
* Add licensing details for `ultralytics` and `supervision` in `README.md`

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: jirka <6035284+Borda@users.noreply.github.com>
2026-02-03 15:57:36 +01:00
Jirka Borovec d925cdf666
Standardize examples and error messages with `uv` CLI for virtual env. and dependency installation (#2129) 2026-02-03 13:59:35 +01:00
Jirka Borovec 66c49b2e80
examples/traffic_analysis: improve CLI argument handling (#2059)
* refactor(traffic_analysis): improve CLI argument handling
* fix(pre_commit): 🎨 auto format pre-commit hooks

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-02-03 12:56:56 +01:00
Jirka Borovec 0efb55ec19
examples/tracking: improve CLI argument parsing (#2058)
* refactor(tracking): improve CLI argument parsing
* Apply suggestions from code review
* fix(pre_commit): 🎨 auto format pre-commit hooks

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-03 12:52:50 +01:00
Jirka Borovec 11f483b75e
examples/time_in_zone: improve CLI argument handling (#2057)
* refactor(time_in_zone): improve CLI argument handling
* Refactor examples with `jsonargparse` for improved CLI, rename `confidence` and `iou` arguments for consistency, and update documentation and requirements.
* fix(pre_commit): 🎨 auto format pre-commit hook

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-02-03 12:49:55 +01:00
Jirka Borovec 1688e71ed9
examples/speed_estimation: improve CLI argument parsing (#2056)
* refactor(speed_estimation): improve CLI argument parsing
* fix(pre_commit): 🎨 auto format pre-commit hooks
* Apply suggestions from code review

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-03 12:02:22 +01:00
Jirka Borovec 45aedbda7e
examples/heatmap_and_track: improve CLI argument parsing (#2055)
* refactor(heatmap_and_track): improve CLI argument parsing
* fix(pre_commit): 🎨 auto format pre-commit hooks
* Make `source_video_path` optional with default fallback to `download_video`; update defaults for `target_video_path`.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-03 11:52:25 +01:00
Jirka Borovec 6a1b2b8eb4
examples/count_people_in_zone: resolve IoU threshold & improve CLI (#2054)
* refactor(count_people_in_zone): resolve IoU threshold & improve CLI
* fix(pre_commit): 🎨 auto format pre-commit hooks
* Apply suggestions from code review

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-03 11:35:09 +01:00
Jirka Borovec a5b51a11e5
Chore CI by adding checks for links and references (#2113)
* Chore CI by adding checks for links and references
* Potential fix for code scanning alert no. 6: Workflow does not contain permissions
* Fix markdown image formatting in metrics documentation
* Update all `docs` links to use absolute URLs and fix broken references in documentation and workflows.
* Fix broken `albumentations` links in dataset processing documentation
* lycheeVersion: v0.22.0
* Refactor CI link check workflow to use lychee config file for cleaner argument management
* add TODOs for future file type support
* Fix header formatting for example plots across metric files

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-02 17:01:19 +01:00
pre-commit-ci[bot] 3abb6245c1
chore(pre_commit): ⬆ pre_commit autoupdate (#2075)
* chore(pre_commit): ⬆ pre_commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.14.10 → v0.14.11](https://github.com/astral-sh/ruff-pre-commit/compare/v0.14.10...v0.14.11)
- [github.com/executablebooks/mdformat: 0.7.17 → 1.0.0](https://github.com/executablebooks/mdformat/compare/0.7.17...1.0.0)

* fix(pre_commit): 🎨 auto format pre-commit hooks
* Apply suggestions from code review

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Jirka Borovec <6035284+Borda@users.noreply.github.com>
Co-authored-by: jirka <jirka.borovec@seznam.cz>
2026-01-12 20:15:27 +01:00
Jirka Borovec d570366fb4
chore(pre_commit): convert bandit into Ruff's S rule & add TODOs for security improvements (#2039) 2026-01-12 08:08:19 +01:00
SkalskiP 036a956473 fix for #1911 2025-07-26 17:46:04 +02:00
Onuralp SEZER 212e69b5a4
refactor: 🧪 type hints to use the new union syntax for optional types
- Updated type hints across multiple files to replace `Optional[X]` with `X | None` for better readability and consistency.
- Added `from __future__ import annotations` to files to enable postponed evaluation of type annotations.
- Adjusted function signatures and variable types in various modules including `polygon_zone.py`, `smoother.py`, `transformers.py`, `vlm.py`, and others.
- Ensured compatibility with Python 3.10+ type hinting features.

Signed-off-by: Onuralp SEZER <thunderbirdtr@gmail.com>
2025-07-15 16:36:01 +03:00
Onuralp SEZER b792db72fd
chore: 🧹 update requirements.txt to remove version constraints for dependencies 2025-07-15 12:29:47 +02:00
pre-commit-ci[bot] f68a6bc362 fix(pre_commit): 🎨 auto format pre-commit hooks 2025-07-15 10:16:29 +00:00
Onuralp SEZER 2adb64b949
chore: 🧹 update requirements files to remove version constraints 2025-07-15 12:15:55 +02:00
Onuralp SEZER 1d3e887fca
chore: 🧹 update requirements and change default weights file in ultralytics_example.py for count people example 2025-07-15 00:58:35 +03:00
Onuralp SEZER 00fab37e58
feat: 🚀 dropping python 3.8 support and upgrade all codes to python3.9 syntax style as min
Signed-off-by: Onuralp SEZER <thunderbirdtr@gmail.com>
2025-07-14 20:12:11 +03:00
pre-commit-ci[bot] e804a01e85 fix(pre_commit): 🎨 auto format pre-commit hooks 2025-02-18 11:52:48 +00:00
SkalskiP 7e19c633a6 merge 0.26.0 deprecation changes 2025-02-18 10:04:38 +01:00
LinasKo f3d27d8381 Cap ultralytics version 2024-12-05 17:23:05 +02:00
Onuralp SEZER a57f4f22ae
docs: 📝 git clone examples with single branch and single depth added into example docs
Signed-off-by: Onuralp SEZER <thunderbirdtr@gmail.com>
2024-11-19 17:59:58 +03:00
Onuralp SEZER 78f17cba2e
chore: 🧹 clean up documentation and improve formatting
Signed-off-by: Onuralp SEZER <thunderbirdtr@gmail.com>
2024-09-27 14:18:26 +03:00
Onuralp SEZER 1f0c278c4e
refactor: ruff rules enabled and fixed and code refactor made
Signed-off-by: Onuralp SEZER <thunderbirdtr@gmail.com>
2024-09-19 10:35:30 +03:00
LinasKo a7ecc57432 Remove deprecations, make changelog 2024-08-27 17:01:04 +03:00
LinasKo 2012ec7bcb Unify how optional values are marked in docstings
* No longer means 'has default value'. Removed where it meant that.
* `Optional[datatype]` is now used instead of `datatype, optional`
* Fixed a handful of incorrect type annotations
2024-08-14 12:46:16 +03:00
LinasKo 28f83b18f9 Deprecate BoundingBoxAnnotator, rename to BoxAnnotator 2024-07-12 18:18:50 +03:00
LinasKo 084926ded3 Deprecations, changelog, notebook cleanup, 'new' markers 2024-07-11 03:21:41 +03:00
Piotr Skalski d7b6af84e6
Update README.md
fix errors in example commands
2024-05-07 12:25:41 +02:00
Manzar Iqbal Malik aaf5df2f6a
Update README.md
Aligned draw zones file name for both examples, fixed file name for ultralytics example
2024-05-06 12:15:38 +01:00
dependabot[bot] f72d06b05e
Bump tqdm from 4.66.1 to 4.66.3 in /examples/speed_estimation
Bumps [tqdm](https://github.com/tqdm/tqdm) from 4.66.1 to 4.66.3.
- [Release notes](https://github.com/tqdm/tqdm/releases)
- [Commits](https://github.com/tqdm/tqdm/compare/v4.66.1...v4.66.3)

---
updated-dependencies:
- dependency-name: tqdm
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-03 21:51:32 +00:00
SkalskiP ffda94b1e5 pin inference version to 0.9.17 2024-04-30 16:06:02 +02:00
SkalskiP d4b1375db7 pin inference version 2024-04-29 21:46:07 +02:00
SkalskiP ba2d30d110 `calculate_dynamic_line_thickness` -> `calculate_optimal_line_thickness`
`calculate_dynamic_text_scale` -> `calculate_optimal_text_scale`
2024-04-26 17:36:50 +02:00
SkalskiP a45341ce63 final cleanup; setting `supervision>=0.20.0` in `requirements.txt` and refactoring stream processing scripts 2024-04-24 22:41:59 +02:00
pre-commit-ci[bot] d531c59f85 fix(pre_commit): 🎨 auto format pre-commit hooks 2024-04-13 05:39:05 +00:00
Jeslin P James 15b1473c2f Updated examples to remove frame_resolution_wh from PolygonZone 2024-04-13 10:28:11 +05:30