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

Fix random fog #1981

Merged
merged 3 commits into from
Oct 8, 2024
Merged

Fix random fog #1981

merged 3 commits into from
Oct 8, 2024

Conversation

ternaus
Copy link
Collaborator

@ternaus ternaus commented Oct 8, 2024

Fixes: #1952

Summary by Sourcery

Fix the random fog effect by adjusting the fog radius and color calculations and enhance the randomness control by using a random state object instead of a random seed.

Bug Fixes:

  • Fix the calculation of fog radius and color in the fog augmentation function to ensure correct fog rendering.

Enhancements:

  • Replace the use of a random seed with a random state object for better control over randomness in fog augmentation.

Copy link
Contributor

sourcery-ai bot commented Oct 8, 2024

Reviewer's Guide by Sourcery

This pull request addresses an issue with random fog generation in the Albumentations library. The changes improve the robustness of the fog effect by adjusting the fog radius calculation, ensuring compatibility with different image types, and refactoring the random state handling.

Updated class diagram for fog augmentation functions

classDiagram
    class Functional {
        +add_fog(img, intensity, alpha_coef, particle_positions, random_state)
    }
    class Transforms {
        +apply(img, particle_positions, intensity, random_state)
        +get_params_dependent_on_data(params, data)
        +get_transform_init_args_names()
    }
    Functional <|-- Transforms
    note for Functional "Updated fog radius calculation and random state handling"
    note for Transforms "Refactored random state handling"
Loading

File-Level Changes

Change Details Files
Improved fog radius calculation
  • Added a minimum fog radius of 2 pixels
  • Ensured the minimum radius is at least 1 pixel
  • Modified the random radius selection to use the new minimum radius
albumentations/augmentations/functional.py
Enhanced compatibility with different image types
  • Replaced hardcoded 255 value with MAX_VALUES_BY_DTYPE[np.uint8]
  • Used max_value instead of 255 for color and alpha calculations
albumentations/augmentations/functional.py
Refactored random state handling
  • Changed random_seed parameter to random_state in the apply method
  • Updated the get_params_dependent_on_data method to use random_state instead of random_seed
albumentations/augmentations/transforms.py

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 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

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: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 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 and I'll use the feedback to improve your reviews.

@ternaus ternaus merged commit 2345cdd into main Oct 8, 2024
17 checks passed
@ternaus ternaus deleted the fix_random_fog branch October 8, 2024 20:54
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.

ValueError: high <= 0
1 participant