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

Issue/update image compression interface #1691

Conversation

MarognaLorenzo
Copy link
Contributor

@MarognaLorenzo MarognaLorenzo commented Apr 27, 2024

New interface

The new interface allow users to set quality_range field and be ready to go. Implementations that are setting quality_upper and quality_lower will raise a DeprecationWarning.

Behaviour

  1. Default uses such as transform_name = A.ImageCompression() won't raise any warning (default values = (99, 100))
  2. transform_name = A.ImageCompression(lower, upper) will raise a Warning
  3. transform_name = A.ImageCompression(quality_lower=lower, quality_upper= upper) will raise a Warning
  4. transform_name = A.ImageCompression(quality_range=[99,100]) won't raise any warning, even if a tuple is passed ( but they need to have a length of 2, both in the [1,100] range and the first one must be lower than the second one
  5. transform_name = A.ImageCompression([99,100])will raise an error because the first 2 expected arguments are quality_lower and quality_upper. This is the drawback for allowing code like at point 2 to raise a warning without failing in existing code.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @MarognaLorenzo - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

albumentations/augmentations/transforms.py Outdated Show resolved Hide resolved
@ternaus
Copy link
Collaborator

ternaus commented Apr 28, 2024

Almost there:

  1. There are a few changes that leverage Pydantic syntax sugar that will simplify the code as some checks and warnings will happen automatically.
  2. You need to install pre-commit hook and make sure that all checks pass before the commit. Details: https://albumentations.ai/docs/CONTRIBUTING/#using-pre-commit-hooks

P.S. Pydantic and pre-commit hooks are very powerful and popular tools in python software development. This commit is a good way to get acquainted to them :)

albumentations/augmentations/transforms.py Show resolved Hide resolved
albumentations/augmentations/transforms.py Outdated Show resolved Hide resolved
albumentations/augmentations/transforms.py Outdated Show resolved Hide resolved
albumentations/augmentations/transforms.py Show resolved Hide resolved
@ternaus
Copy link
Collaborator

ternaus commented May 2, 2024

@MarognaLorenzo to pass code formatting check you need to install pre-commit hook and verify that all checks pass locally.

https://github.com/albumentations-team/albumentations/blob/main/CONTRIBUTING.md#using-pre-commit-hooks

@ternaus ternaus mentioned this pull request May 4, 2024
@ternaus
Copy link
Collaborator

ternaus commented May 4, 2024

There were some issues with CI config,

I created another PR on top of your work and merged it.

All credit goes to you :)

Will mention your contribution in the next releaze.

#1704

@ternaus ternaus closed this May 4, 2024
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.

None yet

2 participants