|
from tensorflow import keras |
|
from tensorflow.keras import layers |
|
size = (image_processor.size["height"], image_processor.size["width"]) |
|
train_data_augmentation = keras.Sequential( |
|
[ |
|
layers.RandomCrop(size[0], size[1]), |
|
layers.Rescaling(scale=1.0 / 127.5, offset=-1), |
|
layers.RandomFlip("horizontal"), |
|
layers.RandomRotation(factor=0.02), |
|
layers.RandomZoom(height_factor=0.2, width_factor=0.2), |
|
], |
|
name="train_data_augmentation", |
|
) |
|
val_data_augmentation = keras.Sequential( |
|
[ |
|
layers.CenterCrop(size[0], size[1]), |
|
layers.Rescaling(scale=1.0 / 127.5, offset=-1), |
|
], |
|
name="val_data_augmentation", |
|
) |
|
|
|
Next, create functions to apply appropriate transformations to a batch of images, instead of one image at a time. |