Skip to content

Relax Albumentations requirement to support 2.x#786

Open
Copilot wants to merge 13 commits intodevelopfrom
copilot/fix-albumentations-version-requirement
Open

Relax Albumentations requirement to support 2.x#786
Copilot wants to merge 13 commits intodevelopfrom
copilot/fix-albumentations-version-requirement

Conversation

Copy link
Contributor

Copilot AI commented Mar 6, 2026

  • Review the new PR feedback and confirm the remaining actionable change
  • Inspect the current RandomSizedCrop normalization logic and recent CI state
  • Refactor _normalize_albu_params to compute the Albumentations API shape once and keep behavior unchanged
  • Run targeted augmentation tests and pre-commit checks
  • Run final review/security checks and reply on the PR comment
Original prompt

This section details on the original issue you should resolve

<issue_title>Version of Albumentations: Is it intentionally required old version 1.4.24 instead of the new 2.0.8?</issue_title>
<issue_description>### Search before asking

  • I have searched the RF-DETR issues and found no similar feature requests.

Description

I trained a detection model with aug_config and meet warning:

UserWarning: A new version of Albumentations is available: 2.0.8 (you have 1.4.24). Upgrade using: pip install -U albumentations. To disable automatic update checks, set the environment variable NO_ALBUMENTATIONS_UPDATE to 1.            2026-03-05 07:36:22.929879: I tensorflow/core/util/port.cc:153] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.     

This is quite annoying and I upgrade the Albumentations to 2.0.8 and seem OK, but i am not sure is there any compatibility issue that the team keep using the old version 1.4.24

Is it intentionally required old version 1.4.24 instead of the new 2.0.8? please advise

Use case

No response

Additional

No response

Are you willing to submit a PR?

  • Yes I'd like to help by submitting a PR!</issue_description>

<agent_instructions>Relax the versions but use only the permissive package, don't install X</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits March 6, 2026 21:54
Co-authored-by: Borda <6035284+Borda@users.noreply.github.com>
Co-authored-by: Borda <6035284+Borda@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix Albumentations version requirement to allow new version Relax Albumentations requirement to support 2.x Mar 6, 2026
Copilot finished work on behalf of Borda March 6, 2026 22:00
@Borda Borda marked this pull request as ready for review March 7, 2026 16:31
Copilot AI review requested due to automatic review settings March 7, 2026 16:31
@codecov
Copy link

codecov bot commented Mar 7, 2026

Codecov Report

❌ Patch coverage is 97.22222% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 66%. Comparing base (fa4b623) to head (f1d1242).

❗ There is a different number of reports uploaded between BASE (fa4b623) and HEAD (f1d1242). Click for more details.

HEAD has 3 uploads less than BASE
Flag BASE (fa4b623) HEAD (f1d1242)
Linux 5 4
py3.12 2 1
gpu 1 0
Additional details and impacted files
@@           Coverage Diff           @@
##           develop   #786    +/-   ##
=======================================
- Coverage       73%    66%    -7%     
=======================================
  Files           69     69            
  Lines         8149   8184    +35     
=======================================
- Hits          5965   5391   -574     
- Misses        2184   2793   +609     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR expands RF-DETR’s Albumentations compatibility to include 2.x by relaxing the dependency constraint and normalizing RandomSizedCrop configuration arguments so the same RF-DETR aug config works across Albumentations 1.x and 2.x.

Changes:

  • Relax Albumentations version constraint to allow 2.x.
  • Normalize RandomSizedCrop params at transform construction time to bridge height/width (1.x) vs size=(h, w) (2.x).
  • Add unit tests for both constructor variants and update augmentation docs to reflect supported versions.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/rfdetr/datasets/transforms.py Normalize RandomSizedCrop params based on the installed Albumentations API signature.
tests/datasets/test_augmentations.py Adds targeted tests for the parameter normalization behavior via monkeypatched RandomSizedCrop.
pyproject.toml Relaxes Albumentations upper bound to <3.0.0.
docs/learn/train/augmentations.md Documents Albumentations 1.4.24+ and 2.x support.

You can also share your feedback on Copilot code review. Take the survey.

Borda and others added 2 commits March 7, 2026 17:52
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Borda
Copy link
Member

Borda commented Mar 7, 2026

@copilot apply changes based on the comments in this thread

Co-authored-by: Borda <6035284+Borda@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 7, 2026

@copilot apply changes based on the comments in this thread

Applied the remaining review-thread change in af0112f: the Albumentations dependency floor is now aligned with the documented support range at >=1.4.24,<3.0.0, and the targeted augmentation tests plus pre-commit checks passed.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.


You can also share your feedback on Copilot code review. Take the survey.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.


You can also share your feedback on Copilot code review. Take the survey.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Borda <6035284+Borda@users.noreply.github.com>
Copilot finished work on behalf of Borda March 8, 2026 06:23
Borda and others added 2 commits March 10, 2026 23:02
… for PR #786

- Add TestRandomSizedCropCompat with 6 new tests:
  - ValueError raised for height-without-width (and vice versa) on 2.x API
  - height/width silently dropped when size is also provided on 2.x API
  - scalar size passes through unchanged on v1 legacy path
- Add comment on unreachable legacy branch (uses_size=False) explaining it
  cannot trigger with albumentations>=1.4.24
- Add troubleshooting note in augmentations.md for height/width auto-adaptation
- Add CHANGELOG entry for version relaxation (>=1.0.0,<2.0.0 → >=1.4.24,<3.0.0)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.


You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +313 to +317
# NOTE: This branch is unreachable when albumentations>=1.4.24 is installed
# (the package constraint since PR #786). albumentations 1.4.24 introduced
# ``size`` to RandomSizedCrop, so _random_sized_crop_uses_size_param() always
# returns True for any conformant installation. The code is kept for
# completeness and is covered only by tests using synthetic fake classes.
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

The NOTE here claims the non-uses_size branch is unreachable for albumentations>=1.4.24, but this file/docstrings (and the new tests) explicitly support a 1.x height/width API path. This comment looks inconsistent with the intended cross-version behavior and could mislead future maintainers; please update or remove it to reflect the actual supported signatures (and/or explain precisely which versions have which signature).

Suggested change
# NOTE: This branch is unreachable when albumentations>=1.4.24 is installed
# (the package constraint since PR #786). albumentations 1.4.24 introduced
# ``size`` to RandomSizedCrop, so _random_sized_crop_uses_size_param() always
# returns True for any conformant installation. The code is kept for
# completeness and is covered only by tests using synthetic fake classes.
# NOTE:
# For the official Albumentations ``RandomSizedCrop`` implementation on
# versions >=1.4.24 (the minimum constrained in this project), the transform
# accepts a ``size`` parameter, so ``_random_sized_crop_uses_size_param()``
# will return True and this ``not uses_size`` branch will not be taken.
# However, this function is intentionally written to also support
# 1.x-style APIs that use ``height``/``width`` (e.g. older Albumentations
# versions, custom transforms, or synthetic classes used in tests). In those
# cases ``uses_size`` can be False and this branch performs the inverse
# normalization from ``size`` -> (height, width).

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Version of Albumentations: Is it intentionally required old version 1.4.24 instead of the new 2.0.8?

3 participants