Conversation
| Args: | ||
| img (~numpy.ndarray): An image array. This is in CHW format. | ||
| prob (float): Erasing probability. | ||
| scale_ratio_interval (tuple of two floats): Determines |
There was a problem hiding this comment.
In the arguments, scale_ratio_range is used.
| prob (float): Erasing probability. | ||
| scale_ratio_interval (tuple of two floats): Determines | ||
| the distribution from which a scale ratio is sampled. | ||
| aspect_ratio_interval (tuple of two floats): Determines |
There was a problem hiding this comment.
In the arguments, aspect_ratio_range is used.
| scale_ratio_interval (tuple of two floats): Determines | ||
| the distribution from which a scale ratio is sampled. | ||
| aspect_ratio_interval (tuple of two floats): Determines | ||
| the distribution from which an aspect ratio is sampled. |
| * **aspect_ratio** (float): :math:`a` in the description. | ||
|
|
||
| """ | ||
| if random.randint(0, 1) > prob: |
There was a problem hiding this comment.
randint(0, 1) returns 0 or 1. When 0 < prob < 1, this condition means 50% regardless of prob.
|
I think the following code is more simple. if np.random.unifrom() < prob:
random_sized_crop(img, ...)[:] = mean
return img |
…kitotakeki/chainercv into akitotakeki-add-random-erasing
| * **aspect_ratio** (float): :math:`a` in the description. | ||
|
|
||
| """ | ||
| if random.uniform(0.0, 1.0) > prob: |
| crop, params = random_sized_crop(img, scale_ratio_range, | ||
| aspect_ratio_range, return_param=True) | ||
| if random_value: | ||
| crop[:] = np.random.random(crop.shape) * scale |
There was a problem hiding this comment.
This line modifies the input image.
This reverts commit 6bf2ef6.
| the distribution from which an aspect ratio is sampled. | ||
| random_value (bool): Fill the rectangle region with random values. | ||
| scale (float): Pixel value scale. | ||
| fixed_value (~numpy.ndarray): Determines pixel values |
There was a problem hiding this comment.
For the consistency with other functions, how about using fill?
There was a problem hiding this comment.
How about using random value when fill='random'? We can remove scale and random_value.
There was a problem hiding this comment.
Changing from fixed_value to fill is fine.
However, if scale is deleted, the range of random values can not be defined.
There was a problem hiding this comment.
Do we need to specify the range of random value? The range of pixel is always [0, 255] in ChainerCV
There was a problem hiding this comment.
I understood the situation. I'll fix the point.
However, the pixel range is always [0, 255] in ChainerCV, but in Chainer, it seems to be [0, 1].
https://github.com/chainer/chainer/blob/master/chainer/datasets/mnist.py
https://github.com/chainer/chainer/blob/master/chainer/datasets/svhn.py
https://github.com/chainer/chainer/blob/master/chainer/datasets/fashion_mnist.py
The difference seems inconvenient when using Chainer and ChainerCV at the same time.
There was a problem hiding this comment.
in Chainer, it seems to be [0, 1].
This is not true. Chainer sometimes uses [0, 255]. For example, ResNet in Chainer assumes the input range is [0, 255].
https://github.com/chainer/chainer/blob/master/chainer/links/model/vision/resnet.py#L547-L548
There was a problem hiding this comment.
Mismatch of the pixel range in Chainer seems awkward.
However, this has nothing to do with ChainerCV, so I will follow your suggestion.
| scale_ratio_range=(0.02, 0.4), | ||
| aspect_ratio_range=(0.3, 1 / 0.3), | ||
| random_value=True, | ||
| scale=1.0, |
There was a problem hiding this comment.
This should be 255 since we use [0, 255] as the default range of images.
There was a problem hiding this comment.
I think we can remove this option.
…kitotakeki/chainercv into akitotakeki-add-random-erasing
This PR is the implementation of Random Erasing (https://arxiv.org/abs/1708.04896).
Random Erasing is a new data augmentation method for training the convolutional neural network (CNN).
Please merge after #432.