-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathdata_augmentation.py
More file actions
26 lines (20 loc) · 986 Bytes
/
data_augmentation.py
File metadata and controls
26 lines (20 loc) · 986 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import nutszebra_data_augmentation_picture
from functools import wraps
da = nutszebra_data_augmentation_picture.DataAugmentationPicture()
def reset(func):
@wraps(func)
def wrapper(self, *args, **kwargs):
da()
return func(self, *args, **kwargs)
return wrapper
class DataAugmentationNormalizeBigger(object):
@staticmethod
@reset
def train(img):
da.load_picture(img).resize_image_randomly(1.0, size_range=(224, 288)).scale_to_one(1.0, constant=255.).fixed_normalization(1.0, each_rgb=True).crop_picture_randomly(1.0, sizes=(224, 224)).horizontal_flipping(0.5).convert_to_chainer_format(1.0)
return da.x, da.info
@staticmethod
@reset
def test(img):
da.load_picture(img).resize_image_randomly(1.0, size_range=(256, 256), interpolation='bicubic').scale_to_one(1.0, constant=255.).fixed_normalization(1.0, each_rgb=True).crop_center(sizes=(224, 224)).convert_to_chainer_format(1.0)
return da.x, da.info