add transforms to datamodule parameters

This commit is contained in:
hobogalaxy committed 2020-11-24 14:22:42 +01:00
1 parent ea525da14a
commit b6dc1f0af6
13 files changed
+62 -47

No files matched your search

@@ -1 +1,2 @@
from .lightning_module import LitModel
from .transforms import *
@@ -2,9 +2,7 @@ from torchvision import transforms
img_augmentation_transformations = [
transforms.RandomAffine((-4, 4), translate=(0.2, 0.2)),
transforms.RandomHorizontalFlip(p=0.65),
transforms.RandomRotation((-20, 20)),
transforms.RandomRotation((-10, 10)),
]
train_preprocess = transforms.Compose([
@@ -1,18 +0,0 @@
from torchvision import transforms
img_augmentation_transformations = [
transforms.RandomAffine((-15, 15), translate=(0.2, 0.2)),
transforms.RandomHorizontalFlip(p=0.65),
transforms.RandomRotation((-15, 15)),
transforms.ColorJitter(hue=.05, saturation=.05),
]
train_preprocess = transforms.Compose([
transforms.ToTensor(),
transforms.RandomApply(img_augmentation_transformations, 0.5)
])
test_preprocess = transforms.Compose([
transforms.ToTensor()
])
@@ -1 +1,2 @@
from .lightning_module import LitModel
from .transforms import *
@@ -4,7 +4,7 @@ import torch.nn.functional as F
import torch
# custom models
from models.transfer_learning_cifar10_classifier.models import *
from models.transfer_learning_img_classifier.models import *
class LitModel(pl.LightningModule):
@@ -1,5 +1,5 @@
from models.transfer_learning_cifar10_classifier.lightning_module import LitModel
from models.transfer_learning_cifar10_classifier import transforms
from models.transfer_learning_img_classifier.lightning_module import LitModel
from models.transfer_learning_img_classifier import transforms
from PIL import Image
@@ -0,0 +1,30 @@
from torchvision import transforms
img_augmentation_transformations = [
transforms.RandomAffine((-15, 15), translate=(0.2, 0.2)),
transforms.RandomHorizontalFlip(p=0.65),
transforms.RandomRotation((-15, 15)),
transforms.ColorJitter(hue=.05, saturation=.05),
]
train_preprocess = transforms.Compose([
transforms.Resize((256, 256)), # the correct size for eff net b1 is 224x224 but we random crop it later
transforms.RandomCrop(224),
transforms.ToTensor(),
transforms.RandomApply(img_augmentation_transformations, 0.8),
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
])
test_preprocess = transforms.Compose([
transforms.Resize((224, 224)),
transforms.ToTensor(),
transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),
])
cifar10_train_preprocess = transforms.Compose([
transforms.ToTensor(),
transforms.RandomHorizontalFlip(p=0.5),
# transforms.RandomRotation((-15, 15)),
])