-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransform.py
51 lines (38 loc) · 1.22 KB
/
transform.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import numpy as np
import pandas as pd
import os
import cv2
import albumentations
from albumentations.pytorch.transforms import ToTensorV2
import torch
import torch.nn.functional as F
from torch import nn
import math
from configuration import *
def get_train_transforms():
return albumentations.Compose(
[
albumentations.Resize(Config.IMG_SIZE, Config.IMG_SIZE, always_apply=True),
albumentations.HorizontalFlip(p=0.5),
albumentations.VerticalFlip(p=0.5),
albumentations.Rotate(limit=120, p=0.8),
albumentations.RandomBrightness(limit=(0.09, 0.6), p=0.5),
albumentations.Normalize(mean = Config.MEAN, std = Config.STD),
ToTensorV2(p=1.0),
])
def get_valid_transforms():
return albumentations.Compose(
[
albumentations.Resize(Config.IMG_SIZE, Config.IMG_SIZE,always_apply=True),
albumentations.Normalize(),
ToTensorV2(p=1.0)
]
)
def get_test_transforms():
return albumentations.Compose(
[
albumentations.Resize(Config.IMG_SIZE, Config.IMG_SIZE,always_apply=True),
albumentations.Normalize(),
ToTensorV2(p=1.0)
]
)