Skip to content

Replace Albumentations with Kornia#1230

Merged
bw4sz merged 2 commits into
weecology:mainfrom
jveitchmichaelis:kornia-ab
Dec 13, 2025
Merged

Replace Albumentations with Kornia#1230
bw4sz merged 2 commits into
weecology:mainfrom
jveitchmichaelis:kornia-ab

Conversation

@jveitchmichaelis
Copy link
Copy Markdown
Collaborator

@jveitchmichaelis jveitchmichaelis commented Dec 11, 2025

Supersedes #1169

Seems like a lot of changes, but a good chunk is new docs + re-implementations of some augmentations that kornia doesn't support out of the box.

Fully replaces albumentations with kornia. On the user end, very little changes except to removing RandomSizedBBoxSafeCrop, but we have a mostly equivalent crop operation and we can handle empty training inputs.

One gotcha is kornia doesn't do any output filtering after transforming. It composes its pipeline into a transformation that's applied to all geometries, but we need to check if those lie within the image or not. There's a new dataset function to do this, though perhaps in the future could be rolled into the recent box validation function instead (we need to return to filter and not just flag).

I also put some notes about zoom transforms, as DownScale is poorly named in Albumentations, with some guidelines for reproducing the effect through a double Rescale if it's important.

transforms

Example transformations included in the commit.

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 11, 2025

Codecov Report

❌ Patch coverage is 90.14085% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.66%. Comparing base (059eaa3) to head (a88ad05).
⚠️ Report is 61 commits behind head on main.

Files with missing lines Patch % Lines
src/deepforest/datasets/training.py 82.60% 4 Missing ⚠️
src/deepforest/augmentations.py 93.75% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1230      +/-   ##
==========================================
+ Coverage   87.57%   87.66%   +0.08%     
==========================================
  Files          20       20              
  Lines        2608     2699      +91     
==========================================
+ Hits         2284     2366      +82     
- Misses        324      333       +9     
Flag Coverage Δ
unittests 87.66% <90.14%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jveitchmichaelis
Copy link
Copy Markdown
Collaborator Author

jveitchmichaelis commented Dec 11, 2025

re. codecov:

  • We can ignore the diff in augmentations as it refers to an inverse transform which I copied from the relevant kornia class, but I don't think we use it. I also think the existing one may be wrong/useless given the comments in their code.
  • I can add some tests for when all boxes are removed, just to check that training doesn't outright fail

Copy link
Copy Markdown
Collaborator

@bw4sz bw4sz left a comment

Choose a reason for hiding this comment

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

Great. I'm not concerned too much about the code coverage. I am merging and I going to be explore the zoom default settings with the CropModel BOEM classifier issues we discussed on thursday. I will add a PR if I think different defaults are useful.

@bw4sz bw4sz merged commit 6cbf151 into weecology:main Dec 13, 2025
7 checks passed
bw4sz pushed a commit that referenced this pull request Jan 16, 2026
Integrate Kornia to replace Albumentations. Add zoom augmentations and a custom box checker. 

---------

Co-authored-by: henrykironde <henrykironde@gmail.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.

3 participants