Skip to content

Commit

Permalink
aug
Browse files Browse the repository at this point in the history
  • Loading branch information
pbcquoc committed Nov 29, 2020
1 parent d424594 commit 5e3fb5c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions vietocr/loader/aug.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@

class ImgAugTransform:
def __init__(self):
sometimes = lambda aug: iaa.Sometimes(0.5, aug)
sometimes = lambda aug: iaa.Sometimes(0.3, aug)

self.aug = iaa.Sequential(iaa.SomeOf((1, None),
self.aug = iaa.Sequential(iaa.SomeOf((1, 5),
[
# blur
sometimes(iaa.GaussianBlur(sigma=(0, 1.0))),
sometimes(iaa.MotionBlur(k=3)),

sometimes(iaa.OneOf([iaa.GaussianBlur(sigma=(0, 1.0)),
iaa.MotionBlur(k=3)])),

# color
sometimes(iaa.AddToHueAndSaturation(value=(-10, 10), per_channel=True)),
Expand All @@ -23,13 +24,13 @@ def __init__(self):
sometimes(iaa.Multiply((0.5, 1.5), per_channel=0.5)),
sometimes(iaa.Add((-40, 40), per_channel=0.5)),

sometimes(iaa.JpegCompression(compression=(70, 99))),
sometimes(iaa.JpegCompression(compression=(5, 80))),

# distort
sometimes(iaa.Crop(percent=(0.01, 0.05), sample_independently=True)),
sometimes(iaa.PerspectiveTransform(scale=(0.01, 0.01))),
sometimes(iaa.Affine(scale=(0.7, 1.3), translate_percent=(-0.1, 0.1),
rotate=(-5, 5), shear=(-5, 5),
# rotate=(-5, 5), shear=(-5, 5),
order=[0, 1], cval=(0, 255),
mode=ia.ALL)),
sometimes(iaa.PiecewiseAffine(scale=(0.01, 0.01))),
Expand Down

0 comments on commit 5e3fb5c

Please sign in to comment.