Skip to content

Commit

Permalink
add prob for ra (PaddlePaddle#2194)
Browse files Browse the repository at this point in the history
* add prob for ra

* add prob for ra
  • Loading branch information
littletomatodonkey authored Mar 9, 2021
1 parent 1a08799 commit 0e332fb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ppocr/data/imaug/randaugment.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,16 @@ def __call__(self, img):
class RandAugment(RawRandAugment):
""" RandAugment wrapper to auto fit different img types """

def __init__(self, *args, **kwargs):
def __init__(self, prob=0.5, *args, **kwargs):
self.prob = prob
if six.PY2:
super(RandAugment, self).__init__(*args, **kwargs)
else:
super().__init__(*args, **kwargs)

def __call__(self, data):
if np.random.rand() > self.prob:
return data
img = data['image']
if not isinstance(img, Image.Image):
img = np.ascontiguousarray(img)
Expand Down

0 comments on commit 0e332fb

Please sign in to comment.