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

Bugfixes in textimage #1934

Merged
merged 3 commits into from
Sep 17, 2024
Merged

Bugfixes in textimage #1934

merged 3 commits into from
Sep 17, 2024

Conversation

ternaus
Copy link
Collaborator

@ternaus ternaus commented Sep 17, 2024

Also fixes: #1926

Summary by Sourcery

Fix a bug in fog augmentation by correcting the function call for center calculation. Enhance several image transformation classes with improved functionality, documentation, and examples. Update tests to cover new features and remove redundant tests.

Bug Fixes:

  • Fix incorrect function call for calculating the center of an image in fog augmentation.

Enhancements:

  • Improve the ToRGB transform by adding support for specifying the number of output channels and updating the documentation.
  • Enhance the ToSepia transform with detailed documentation and examples.
  • Refactor the Superpixels transform to improve performance and update documentation.
  • Update the TemplateTransform to handle different types of font colors and improve blending logic.
  • Refactor the UnsharpMask transform to improve edge detection and sharpening logic.

Tests:

  • Add tests for the TextImage augmentation to ensure metadata handling and image transformation.
  • Remove redundant test for TemplateTransform with incorrect size.

Copy link
Contributor

sourcery-ai bot commented Sep 17, 2024

Reviewer's Guide by Sourcery

This pull request implements several bugfixes and improvements in the 'albumentations' library, focusing on the 'textimage' module and other related components. The changes include code refactoring, performance optimizations, and enhanced documentation for various image augmentation transforms.

File-Level Changes

Change Details Files
Refactored and improved the TextImage transform
  • Updated the TextImage class to use a tuple for stopwords instead of a list
  • Modified the preprocess_metadata method to use numpy array for bbox checking
  • Improved error handling and type checking in the draw_text_on_multi_channel_image function
albumentations/augmentations/text/transforms.py
albumentations/augmentations/text/functional.py
Optimized and refactored geometric transformations
  • Moved center and center_bbox functions from functional.py to geometric/functional.py
  • Updated imports and function calls related to geometric transformations in various files
albumentations/augmentations/geometric/functional.py
albumentations/augmentations/geometric/rotate.py
albumentations/augmentations/geometric/transforms.py
albumentations/augmentations/domain_adaptation_functional.py
Enhanced documentation and type hints for various transforms
  • Added detailed docstrings for ToRGB, ToSepia, ToFloat, and Superpixels transforms
  • Improved type hints and parameter descriptions for several transforms
  • Added examples and mathematical formulations to the docstrings
albumentations/augmentations/transforms.py
Refactored and optimized image processing functions
  • Moved bbox_from_mask and mask_from_bbox functions to bbox_utils.py
  • Optimized the superpixels function for better performance
  • Improved the unsharp_mask function to handle single-channel images correctly
albumentations/augmentations/functional.py
albumentations/core/bbox_utils.py
Updated and fixed various test cases
  • Modified test cases to accommodate changes in TextImage and TemplateTransform
  • Updated test cases for geometric transformations
  • Added new test cases for multi-channel image processing
tests/test_transforms.py
tests/test_augmentations.py
tests/test_core.py
tests/functional/test_affine.py
tests/test_text.py

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

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 @ternaus - 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: 5 issues found
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: 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.

tests/test_transforms.py Show resolved Hide resolved
tests/test_transforms.py Show resolved Hide resolved
tests/test_augmentations.py Show resolved Hide resolved
tests/test_text.py Show resolved Hide resolved
tests/test_augmentations.py Show resolved Hide resolved
tests/test_augmentations.py Show resolved Hide resolved
tests/test_augmentations.py Show resolved Hide resolved
tests/test_transforms.py Show resolved Hide resolved
tests/test_transforms.py Show resolved Hide resolved
@ternaus ternaus merged commit 94e7439 into main Sep 17, 2024
17 checks passed
@ternaus ternaus deleted the bugfixes_in_textimage branch September 17, 2024 03:12
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.

TextImage.preprocess_metadata issue in bboxes check
1 participant