Implemented headless install support#999
Conversation
Co-authored-by: Jirka Borovec <6035284+Borda@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds a supported “headless” installation path for RF-DETR so inference environments (e.g., Linux servers/Docker) can avoid GUI OpenCV system-library requirements, while keeping default installs unchanged.
Changes:
- Introduces
rfdetr[headless]extra (OpenCV headless + pinned Supervision line) and sets coresupervision>=0.20.0. - Adds a small compatibility helper in
RFDETR.predict()to attachsource_imagemetadata whensv.Detectionslacks.metadata. - Documents headless installation and adds tests covering the new extra constraints and legacy metadata behavior.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
pyproject.toml |
Adds headless extra (opencv-python-headless + supervision>=0.20.0,<0.21.0) and constrains core supervision to >=0.20.0. |
src/rfdetr/detr.py |
Adds _attach_detection_metadata() and uses it in predict() to support older Supervision Detections objects without .metadata. |
tests/models/test_predict.py |
Adds a regression test for legacy detections metadata attachment via _attach_detection_metadata(). |
tests/cli/test_optional_dependencies.py |
Refactors extras reader + adds tests ensuring headless extra uses headless OpenCV and pins Supervision below 0.21. |
README.md |
Documents pip install "rfdetr[headless]" for headless inference environments. |
docs/learn/install.md |
Adds a “Headless” install tab with pip and uv commands. |
AGENTS.md |
Notes the new [headless] extra and the “clean environment” recommendation to avoid multiple cv2 providers. |
Codecov Report✅ All modified and coverable lines are covered by tests. ❌ Your project check has failed because the head coverage (81%) is below the target coverage (95%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## develop #999 +/- ##
=======================================
Coverage 81% 81%
=======================================
Files 106 107 +1
Lines 11046 11083 +37
=======================================
+ Hits 8956 8992 +36
- Misses 2090 2091 +1 🚀 New features to boost your workflow:
|
|
|
@Borda I guess that ideally |
# Conflicts: # tests/cli/test_optional_dependencies.py
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
| headless = [ | ||
| "opencv-python-headless", # OpenCV without GUI system libraries for Linux server images | ||
| "supervision>=0.20.0,<0.21.0", # TODO: last Supervision line that depends on opencv-python-headless | ||
| ] |
…dless >=4.8,<5 - Remove supervision>=0.20.0,<0.21.0 from headless extra — conflicted with base supervision==0.29.0rc0 (empty intersection → ResolutionImpossible) - Pin opencv-python-headless>=4.8,<5 for API stability - Resolves DEP-001 (critical) and NIT-004 from /review of PR roboflow#999 --- Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
…rectness fixes - Create src/rfdetr/compat/supervision.py — relocates _attach_detection_metadata, _make_keypoints, _empty_keypoints_is_empty out of detr.py (ARCH-001) - Replace try/except string-match TypeError detection with inspect.signature check via module-level _KEYPOINTS_ACCEPTS_NEW_API flag (CORR-003, PERF-001) - Guard xy.ndim != 3 with ValueError before constructor call (CORR-002) - Add None guard to _attach_detection_metadata, raises ValueError (CORR-006) - Add instance-level comment on is_empty assignment (NIT-001) - Update detr.py to import from rfdetr.compat.supervision --- Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
…ta tests - Fix import: _attach_detection_metadata now from rfdetr.compat.supervision (CORR-005) - Add TestAttachDetectionMetadata class — parametrized (NIT-005) covering: no-metadata creation, existing-key preservation, overwrite, None→ValueError (COV-001) - Add TestMakeKeypoints: new-API path, flag assertion, 2D-xy ValueError, fallback path via monkeypatch (CORR-001), empty-detections is_empty override (CORR-004) - Add TestEmptyKeypointsIsEmpty (NIT-002) --- Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
…requirements - Add CI step: uv pip install --dry-run .[headless] on Linux — catches future dep conflicts before user reports (CI-001) - README: replace vague clean environment with explicit conflict scenario + scope note; confirm detection/seg/keypoints all supported (DOC-001) - AGENTS.md: replace ambiguous clean environment with explicit venv requirement and conflict explanation (DOC-002) - docs/getting-started/install.md: same clean-environment + scope callout (DOC-004) --- Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
|
HI @Borda need anything else from me to get this over the line? |
What does this PR do?
Added tests for the new extra and legacy metadata behavior.
Address #531
Type of Change
Testing
uvx pre-commit run --all-files
optional dependency tests passed
pip and uv dry-runs for .[headless] resolve opencv-python-headless and not opencv-python
focused predict metadata tests passed under both current Supervision and supervision==0.20.0
I have tested this change locally
I have added/updated tests for this change
Checklist
Additional Context
To be utilised by torchgeo/torchgeo#3625