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 (77%) 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 77% 77%
======================================
Files 102 102
Lines 9032 9038 +6
======================================
+ Hits 6966 6972 +6
Misses 2066 2066 🚀 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.
|
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