Spaces:
Sleeping
Sleeping
File size: 1,092 Bytes
1cd0545 | 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 | from torchvision import transforms
def get_train_transform():
"""
Transform dùng cho tập train.
Có augmentation nhẹ để tăng độ đa dạng dữ liệu.
"""
return transforms.Compose([
transforms.Resize((112, 112)),
transforms.RandomHorizontalFlip(p=0.5),
transforms.ColorJitter(
brightness=0.3,
contrast=0.3,
saturation=0.2
),
transforms.GaussianBlur(
kernel_size=3
),
transforms.ToTensor(),
transforms.Normalize(
mean=[0.5, 0.5, 0.5],
std=[0.5, 0.5, 0.5]
),
transforms.RandomErasing(
p=0.5,
scale=(0.02, 0.15)
)
])
def get_val_transform():
"""
Transform dùng cho validation/test.
Không augmentation để đánh giá ổn định.
"""
return transforms.Compose([
transforms.Resize((112, 112)),
transforms.ToTensor(),
transforms.Normalize(
mean=[0.5, 0.5, 0.5],
std=[0.5, 0.5, 0.5]
)
]) |