-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransforms.py
34 lines (30 loc) · 1.01 KB
/
transforms.py
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
27
28
29
30
31
32
33
34
import albumentations as A
from albumentations.pytorch.transforms import ToTensorV2
def train_transforms(transform_params):
return A.Compose([
A.Resize(transform_params['image_size'],
transform_params['image_size']),
A.Transpose(p=0.5),
A.HorizontalFlip(p=0.5),
A.VerticalFlip(p=0.5),
A.RandomRotate90(p=0.25),
A.RandomBrightnessContrast(
brightness_limit=(-0.1, 0.1),
contrast_limit=(-0.1, 0.1), p=0.25
),
A.Normalize(
mean=transform_params['normalize_mean'],
std=transform_params['normalize_std'], p=1.,
),
ToTensorV2(p=1.),
], p=1.)
def test_transforms(transform_params):
return A.Compose([
A.Resize(transform_params['image_size'],
transform_params['image_size']),
A.Normalize(
mean=transform_params['normalize_mean'],
std=transform_params['normalize_std'], p=1.,
),
ToTensorV2(p=1.),
], p=1.)