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

Example file for image augmentation. #112

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions augly/image/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def blur(

@returns: the augmented PIL Image
"""
assert radius > 0, "Radius cannot be negative"
assert radius >= 0, "Radius should be greater than 0"

image = imutils.validate_and_load_image(image)

Expand Down Expand Up @@ -215,7 +215,7 @@ def change_aspect_ratio(

@returns: the augmented PIL Image
"""
assert ratio > 0, "Ratio cannot be negative"
assert ratio >= 0, "Ratio should be greater than 0"

image = imutils.validate_and_load_image(image)

Expand Down Expand Up @@ -1588,7 +1588,7 @@ def pixelization(

@returns: the augmented PIL Image
"""
assert ratio > 0, "Expected 'ratio' to be a positive number"
assert ratio >= 0, "Ratio should be a positive number greater than 0"

Choose a reason for hiding this comment

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

0 is not a positive number so you can just say "XX should be a positive number". Please revise all these accordingly in this file for consistency. Condition is the same for all, so you can use the same message everywhere. Also why did you allow 0 in asserts?


image = imutils.validate_and_load_image(image)

Expand Down Expand Up @@ -1640,6 +1640,8 @@ def random_noise(
assert type(mean) in [float, int], "Mean must be an integer or a float"
assert type(var) in [float, int], "Variance must be an integer or a float"
assert type(seed) == int, "Seed must be an integer"

assert 0.0 <= mean <= 1.0, "mean must be a value in the range [0.0, 1.0]"

image = imutils.validate_and_load_image(image)

Expand Down Expand Up @@ -1845,7 +1847,7 @@ def scale(

@returns: the augmented PIL Image
"""
assert factor > 0, "Expected 'factor' to be a positive number"
assert factor >= 0, "Factor should be a positive number greater than 0"
assert interpolation in [
Image.NEAREST,
Image.BOX,
Expand Down
2,125 changes: 2,032 additions & 93 deletions examples/AugLy_image.ipynb

Large diffs are not rendered by default.