albumentations-team / albucore

A high-performance image processing library designed to optimize and extend the Albumentations library with specialized functions for advanced image transformations. Perfect for developers working in computer vision who require efficient and scalable image augmentation.
MIT License
12 stars 3 forks source link

More inplace #45

Closed ternaus closed 1 week ago

ternaus commented 1 week ago

Summary by Sourcery

Enhance image processing functions to support in-place operations, improving memory efficiency. Update pre-commit hooks to newer versions and add comprehensive benchmark tests for performance evaluation. Update documentation to reflect these changes and improvements.

Enhancements:

Build:

Documentation:

Tests:

sourcery-ai[bot] commented 1 week ago

Reviewer's Guide by Sourcery

This pull request adds inplace operation support to various image processing functions by modifying the clip function and adding inplace parameters to several operations. The changes primarily affect array operations like add, multiply, and normalize.

Class diagram for updated image processing functions

classDiagram
    class functions {
        +add_weighted_simsimd(np.ndarray img1, float weight1, np.ndarray img2, float weight2)
        +apply_lut(np.ndarray img, ...)
        +multiply(np.ndarray img, ValueType value, bool inplace)
        +add_opencv(np.ndarray img, np.ndarray|float value, bool inplace)
        +add_numpy(np.ndarray img, np.ndarray|float value)
        +add_lut(np.ndarray img, np.ndarray|float value, bool inplace)
        +add_constant(np.ndarray img, float value, bool inplace)
        +add_vector(np.ndarray img, np.ndarray value, bool inplace)
        +add_array(np.ndarray img, np.ndarray value, bool inplace)
        +add(np.ndarray img, ValueType value, bool inplace)
        +normalize_numpy(np.ndarray img, float|np.ndarray mean, float|np.ndarray denominator)
        +add_weighted_numpy(np.ndarray img1, float weight1, np.ndarray img2, float weight2)
        +add_weighted_opencv(np.ndarray img1, float weight1, np.ndarray img2, float weight2)
        +add_weighted_lut(np.ndarray img1, float weight1, np.ndarray img2, float weight2, bool inplace)
        +multiply_add_lut(np.ndarray img, ValueType factor, ValueType value, bool inplace)
        +to_float(np.ndarray img, float|None max_value)
        +from_float_numpy(np.ndarray img, np.dtype target_dtype, float|None max_value)
    }

    class utils {
        +clip(np.ndarray img, Any dtype, bool inplace)
    }

File-Level Changes

Change Details Files
Added inplace operation support to the clip function
  • Added inplace parameter with default value False
  • Modified implementation to use numpy's clip with out parameter when inplace=True
albucore/utils.py
Added inplace parameter support to array operations
  • Added inplace parameter to add_opencv function
  • Modified add_opencv to use destination array when inplace=True
  • Added inplace parameter propagation to add_constant, add_array, and add_vector functions
  • Added inplace parameter to add_weighted_lut function
albucore/functions.py
Updated benchmark results for various operations
  • Updated performance metrics for array operations
  • Added new benchmark results for float32 and uint8 operations with 5 channels
  • Updated version number from 0.0.19 to 0.0.20
benchmark/albucore_benchmark/results/float32_1/*.md
benchmark/albucore_benchmark/results/float32_3/*.md
benchmark/albucore_benchmark/results/float32_5/*.md
benchmark/albucore_benchmark/results/uint8_1/*.md
benchmark/albucore_benchmark/results/uint8_3/*.md
benchmark/albucore_benchmark/results/uint8_5/*.md

Tips and commands #### Interacting with Sourcery - **Trigger a new review:** Comment `@sourcery-ai review` on the pull request. - **Continue discussions:** Reply directly to Sourcery's review comments. - **Generate a GitHub issue from a review comment:** Ask Sourcery to create an issue from a review comment by replying to it. - **Generate a pull request title:** Write `@sourcery-ai` anywhere in the pull request title to generate a title at any time. - **Generate a pull request summary:** Write `@sourcery-ai summary` anywhere in the pull request body to generate a PR summary at any time. You can also use this command to specify where the summary should be inserted. #### Customizing Your Experience Access your [dashboard](https://app.sourcery.ai) to: - Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others. - Change the review language. - Add, remove or edit custom review instructions. - Adjust other review settings. #### Getting Help - [Contact our support team](mailto:support@sourcery.ai) for questions or feedback. - Visit our [documentation](https://docs.sourcery.ai) for detailed guides and information. - Keep in touch with the Sourcery team by following us on [X/Twitter](https://x.com/SourceryAI), [LinkedIn](https://www.linkedin.com/company/sourcery-ai/) or [GitHub](https://github.com/sourcery-ai).
codecov-commenter commented 1 week ago

Codecov Report

Attention: Patch coverage is 91.30435% with 2 lines in your changes missing coverage. Please review.

Please upload report for BASE (main@f5eb6c6). Learn more about missing BASE report.

Files with missing lines Patch % Lines
albucore/functions.py 89.47% 2 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #45 +/- ## ======================================= Coverage ? 57.99% ======================================= Files ? 20 Lines ? 2226 Branches ? 0 ======================================= Hits ? 1291 Misses ? 935 Partials ? 0 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.