-
Notifications
You must be signed in to change notification settings - Fork 442
channel_shift_range not affecting images? #223
Comments
I think there was a mistake with the code. If you input some large value like 200.0, it will produce real channel shifts like mentioned here under "Old Channel_Shift Images(cifar10)": #17 However, it should be using a float between 0 and 1 rather than a large absolute value. |
Actually it used to work with that workaround in a previous version of keras, but not anymore. I looked through the code:
And tried using the apply_channel_shift on two different simple arrays:
which results in:
or
No matter what channel_axis I use as a parameter |
This will be added to the list of issues needed to be fixed when we will work on the refactoring. (See keras-team/governance#10 for updates) |
It looks like 'channel_shift_range` adds/subtracts the same intensity from all channels in the image. So because of that the image just becomes brighter or darker instead of changing color. I imagine the expected behavior would be to change color too, no? In that case, we need to add different intensity to different channels.
|
I am still observing the same behavior. keras-team/governance#10 is merged. Is someone looking into this? For reference: The code mazatov cited is found here keras-preprocessing/keras_preprocessing/image/affine_transformations.py Lines 159 to 180 in 0494094
I am not familiar with some of the numpy methods, but I could look into finding a fix. |
A fix should probably also address issue #170. |
It works in a [0.0,255.0] range but instead of random channel shift i.e. r+20, g-10, b+3, it just applies random brightness: r+5, g+5,b+5 (shifting all channels by the same value). |
I put a fix on a fork. Still needs to be tested before I add a pull request. |
Has this problem solved yet? I checked @BSVogler 's fork mentioned before, but there's error about the np.random.uniform() function in the code (Line 206 in affine_transformations.py). Seems there's no parameters named channel anymore now. Have you re-wrote the np.random.uniform function? how you write it? |
I am sorry, I kinda forgot about this one. My fork needs to resolve the conflicts and probably update the usage of numpy since it has been more than a year. |
So, I've decided adding random channel shift would be an important image augmentation for my training set. But when I test the output, I'm not seeing any changes no matter if I set channel_shift_range to 0.1 or 0.9. Am I misunderstanding how this augmentation works? I thought it was supposed to shift the colors around so the model would be robust to variances in color?
Here's my code:
Environment:
Jupyter Lab
Python 3.6.6
Keras==2.2.4
Keras-Applications==1.0.7
Keras-Preprocessing==1.0.9
tensorboard==1.9.0
tensorflow-gpu==1.9.0
Thanks in advance for the help!
The text was updated successfully, but these errors were encountered: