this is slowly becoming actually useful

This commit is contained in:
hobogalaxy committed 2020-11-24 18:15:52 +01:00
1 parent d518ddb63d
commit 8628600ea3
15 files changed
+190 -176

No files matched your search

@@ -1,2 +1 @@
from .lightning_module import LitModel
from .transforms import *
@@ -1,5 +1,5 @@
from models.transfer_learning_img_classifier.lightning_module import LitModel
from models.transfer_learning_img_classifier import transforms
from lightning_modules.data_modules import transforms
from PIL import Image
@@ -23,7 +23,7 @@ def predict():
img = Image.open("../../example_img.png").convert("RGB")
# preprocess
img = transforms.test_preprocess(img)
img = transforms.imagenet_test_preprocess(img)
img = img.reshape((1, *img.size())) # reshape to form batch of size 1
# inference
@@ -1,30 +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.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)),
])