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

Add scale param to brightness and fix some docs #300

Merged
merged 1 commit into from Jun 12, 2020

Conversation

Smankusors
Copy link
Contributor

@Smankusors Smankusors commented Jun 8, 2020

Summary

This add an option to not scale the image (to 0 - 255) when doing random_brightness. This also might fixes #114.

Code example :

brightness_range = [0.5, 2]
image = random_brightness(image, brightness_range, True) #for enable scale
image = random_brightness(image, brightness_range, False) #for disable scale

#or alternatively
image = random_brightness(image, brightness_range, scale=True)
image = random_brightness(image, brightness_range, scale=False)

#or call the apply_brightness_shift directly
image = apply_brightness_shift(image, 0.5, scale=True)

Related Issues

There's no documentation about this on keras.io...

PR Overview

  • This PR requires new unit tests [n] (make sure tests are included)
  • This PR requires to update the documentation [?] (make sure the docs are up-to-date)
  • This PR is backwards compatible [y]
  • This PR changes the current API [n] (all API changes need to be approved by fchollet)

@Dref360
Copy link
Contributor

Dref360 commented Jun 8, 2020

Hello, thanks for the PR,
Could you add some tests that check that the new behavior is respected?

@Smankusors
Copy link
Contributor Author

Smankusors commented Jun 9, 2020

Hello, thanks for the PR,
Could you add some tests that check that the new behavior is respected?

hmm currently I'm on Windows. But I have trouble running tests. I got

E   ModuleNotFoundError: No module named 'resource'

I think I will need to use Linux to run tests? I already tried pip3 install resource but still module not found 😢

@Smankusors
Copy link
Contributor Author

Smankusors commented Jun 9, 2020

anyway, what do you think about this?

def test_random_brightness_scale():
    img = np.ones((1, 1, 3)) * 128
    zeros = np.zeros((1, 1, 3))
    assert np.array_equal(img, affine_transformations.random_brightness(img, [1, 1], scale=False))
    assert np.array_equal(zeros, affine_transformations.random_brightness(img, [1, 1], scale=True))

@Dref360
Copy link
Contributor

Dref360 commented Jun 9, 2020

Yeah looks good.
Yup you need UNIX to run the rest. We should probably change that.

* also fix some docs; and
* add random_brightness_scale test
@Smankusors
Copy link
Contributor Author

Smankusors commented Jun 10, 2020

alright, I run the tests on the Google Colab 🤣

And I made little changes so the tests can run successfully.

@Dref360 Dref360 merged commit 422f890 into keras-team:master Jun 12, 2020
1 check passed
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.

2 participants