Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace imgaug with albumentations #1623

Merged
merged 6 commits into from
Mar 17, 2024
Merged

Replace imgaug with albumentations #1623

merged 6 commits into from
Mar 17, 2024

Conversation

talmo
Copy link
Collaborator

@talmo talmo commented Dec 4, 2023

Description

This PR replaces imgaug with albumentations as our library for image augmentation. We're doing this in the hopes of getting rid of our hard dependency on a specific variant of opencv which imgaug (which is no longer maintained) depends on.

Types of changes

  • Bugfix
  • New feature
  • Refactor / Code style update (no logical changes)
  • Build / CI changes
  • Documentation Update
  • Other (explain)

Does this address any currently open issues?

#648

Outside contributors checklist

  • Review the guidelines for contributing to this repository
  • Read and sign the CLA and add yourself to the authors list
  • Make sure you are making a pull request against the develop branch (not main). Also you should start your branch off develop
  • Add tests that prove your fix is effective or that your feature works
  • Add necessary documentation (if appropriate)

Thank you for contributing to SLEAP!

❤️

Summary by CodeRabbit

  • New Features

    • Transitioned from imgaug to albumentations for enhanced image augmentation capabilities.
  • Bug Fixes

    • Adjusted rotation angle parameters to ensure consistency in image transformations.
  • Refactor

    • Updated augmentation-related classes and methods to integrate with the albumentations library.
  • Tests

    • Modified test cases to reflect the new augmentation library usage.

Copy link

coderabbitai bot commented Dec 4, 2023

Important

Auto Review Skipped

Review was skipped due to path filters

Files ignored due to path filters (2)
  • environment_mac.yml is excluded by: !**/*.yml
  • environment_no_cuda.yml is excluded by: !**/*.yml

Walkthrough

The codebase has transitioned from using the imgaug library to albumentations for image augmentation. This shift involves updates to package requirements, alterations in class names, method modifications, and changes in augmentation configurations to integrate the new library across various Python files.

Changes

File Path Change Summary
.conda/meta.yaml
sleap/nn/data/pipelines.py
tests/nn/data/test_augmentation.py
Replaced imgaug with albumentations in package requirements, imports, and usage.
sleap/nn/data/augmentation.py Transitioned from imgaug to albumentations, including import updates, class renaming, and method modifications.
.conda/bld.bat
.conda/build.sh
Modified pip install commands to exclude specific binary packages during installation.
requirements.txt Added the "albumentations" package.

🐇✨
In the land of code, where the pixels play,
imgaug hops out, albumentations here to stay.
With a flip and a twist, images transform with glee,
A rabbit's touch, now all the data's spry and free! 🌟🎩

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link

codecov bot commented Dec 4, 2023

Codecov Report

Attention: Patch coverage is 47.36842% with 10 lines in your changes are missing coverage. Please review.

Project coverage is 73.37%. Comparing base (60a441f) to head (41c9e6d).
Report is 1 commits behind head on develop.

Files Patch % Lines
sleap/nn/data/augmentation.py 23.07% 10 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1623      +/-   ##
===========================================
- Coverage    73.38%   73.37%   -0.01%     
===========================================
  Files          134      134              
  Lines        24064    24063       -1     
===========================================
- Hits         17659    17657       -2     
- Misses        6405     6406       +1     

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

@talmo talmo marked this pull request as ready for review December 4, 2023 19:32
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 2d24296 and 301f289.
Files ignored due to filter (3)
  • environment.yml
  • environment_mac.yml
  • environment_no_cuda.yml
Files selected for processing (4)
  • .conda/meta.yaml (2 hunks)
  • sleap/nn/data/augmentation.py (6 hunks)
  • sleap/nn/data/pipelines.py (8 hunks)
  • tests/nn/data/test_augmentation.py (2 hunks)
Additional comments: 17
.conda/meta.yaml (2)
  • 33-39: The addition of albumentations to the host requirements is consistent with the PR objective to replace imgaug with albumentations. However, ensure that the presence of opencv in the requirements is still necessary, as the PR objective mentioned eliminating the dependency on a specific version of opencv required by imgaug.

  • 61-67: The addition of albumentations to the run requirements is consistent with the PR objective to replace imgaug with albumentations. Similar to the host requirements, verify the necessity of opencv in the run requirements.

sleap/nn/data/augmentation.py (4)
  • 1-11: The import changes from imgaug to albumentations are consistent with the PR objective to replace the image augmentation library.

  • 105-124: The introduction of the AlbumentationsAugmenter class is consistent with the PR objective and the summary provided.

  • 140-202: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [129-202]

The from_config method has been correctly updated to use albumentations transformations, aligning with the PR objective.

  • 229-244: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [229-260]

The transform_dataset method has been updated to apply albumentations-based image augmentation, which is in line with the PR objective.

sleap/nn/data/pipelines.py (8)
  • 18-24: The import changes from imgaug to albumentations are consistent with the PR objectives and the summary provided. The AlbumentationsAugmenter is correctly imported and replaces the previous ImgaugAugmenter.

  • 68-74: The TRANSFORMERS tuple has been correctly updated to include AlbumentationsAugmenter instead of ImgaugAugmenter, aligning with the PR objectives and the summary.

  • 406-411: The usage of AlbumentationsAugmenter.from_config is consistent with the PR objectives to replace imgaug with albumentations. The configuration is correctly passed to the from_config method.

  • 550-555: The usage of AlbumentationsAugmenter.from_config within the CentroidConfmapsPipeline class is consistent with the PR objectives and the summary.

  • 713-718: The usage of AlbumentationsAugmenter.from_config within the TopdownConfmapsPipeline class is consistent with the PR objectives and the summary.

  • 863-869: The usage of AlbumentationsAugmenter.from_config within the BottomUpPipeline class is consistent with the PR objectives and the summary.

  • 1028-1034: The usage of AlbumentationsAugmenter.from_config within the BottomUpMultiClassPipeline class is consistent with the PR objectives and the summary.

  • 1186-1192: The usage of AlbumentationsAugmenter.from_config within the TopDownMultiClassPipeline class is consistent with the PR objectives and the summary.

tests/nn/data/test_augmentation.py (3)
  • 17-20: The summary incorrectly states that the rotation angle parameters are adjusted from -90 to 90. The hunk shows that both rotation_min_angle and rotation_max_angle are set to 90, not from -90 to 90. Please correct the summary to accurately reflect the changes made in the code.

  • 14-22: The changes in this hunk correctly reflect the PR's objective of replacing imgaug with albumentations. The AlbumentationsAugmenter is being used with the new configuration as expected.

  • 54-58: The changes in this hunk are also in line with the PR's objective and the summary provided. The ImgaugAugmenter has been replaced with AlbumentationsAugmenter correctly.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 301f289 and 70f2d5a.
Files ignored due to filter (3)
  • environment.yml
  • environment_mac.yml
  • environment_no_cuda.yml
Files selected for processing (6)
  • .conda/bld.bat (1 hunks)
  • .conda/build.sh (1 hunks)
  • .conda/meta.yaml (2 hunks)
  • .conda_mac/build.sh (1 hunks)
  • .conda_mac/meta.yaml (2 hunks)
  • requirements.txt (1 hunks)
Files skipped from review due to trivial changes (3)
  • .conda/meta.yaml
  • .conda_mac/meta.yaml
  • requirements.txt
Additional comments: 2
.conda/build.sh (1)
  • 10-10: The addition of --no-binary qudida,albumentations to the pip install command ensures that these packages are installed from source. This is a good practice when specific binary compatibility is required or when the latest source version is needed. Confirm that this change is compatible with the build environment and that all necessary build tools and dependencies are available to compile these packages from source.
.conda_mac/build.sh (1)
  • 10-10: The addition of --no-binary qudida,albumentations to the pip install command will force these packages to be compiled from source. Ensure that the build environment in the CI and any development setups have the necessary tools and dependencies to compile these packages.

@@ -7,7 +7,7 @@ set PIP_IGNORE_INSTALLED=False

@REM Install the pip dependencies. Note: Using urls to wheels might be better:
@REM https://docs.conda.io/projects/conda-build/en/stable/user-guide/wheel-files.html)
pip install --no-cache-dir -r .\requirements.txt
pip install --no-cache-dir -r .\requirements.txt --no-binary qudida,albumentations
Copy link

Choose a reason for hiding this comment

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

Consider pinning the versions of qudida and albumentations to ensure consistent builds and compatibility with the rest of the codebase.

#!/bin/bash
# Check if the versions of qudida and albumentations are pinned in the requirements.txt file.
rg 'qudida(==|@)' .\requirements.txt
rg 'albumentations(==|@)' .\requirements.txt

@talmo talmo merged commit eb14764 into develop Mar 17, 2024
8 of 9 checks passed
@talmo talmo deleted the talmo/albumentations branch March 17, 2024 02:50
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.

1 participant