Skip to content
This repository was archived by the owner on Sep 18, 2024. It is now read-only.

Conversation

@Smankusors
Copy link
Contributor

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

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

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

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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

random_brightness shifts the image normalization

2 participants