improve image transforms

This commit is contained in:
hobogalaxy committed 2020-11-18 01:56:15 +01:00
1 parent fcef1b6f71
commit a4bf41296f
1 file changed
+5 -3
+5 -3
View File
@@ -3,14 +3,16 @@ from torchvision import transforms
data_augmentation_transformations = [ data_augmentation_transformations = [
transforms.RandomAffine((-15, 15), translate=(0.2, 0.2)), transforms.RandomAffine((-15, 15), translate=(0.2, 0.2)),
transforms.RandomHorizontalFlip(p=0.8), transforms.RandomHorizontalFlip(p=0.65),
transforms.RandomRotation((-15, 15)), transforms.RandomRotation((-15, 15)),
transforms.ColorJitter(hue=.05, saturation=.05),
] ]
efficient_net_train_preprocess = transforms.Compose([ efficient_net_train_preprocess = transforms.Compose([
transforms.Resize((224, 224)), transforms.Resize((256, 256)), # the correct size for eff net b1 is 224x224 but we random crop it later
transforms.RandomApply(data_augmentation_transformations, 0.8), transforms.RandomCrop(224),
transforms.ToTensor(), transforms.ToTensor(),
transforms.RandomApply(data_augmentation_transformations, 0.8),
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]), transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
]) ])