Coverage for src/bob/bio/face/pytorch/preprocessing.py: 100%
5 statements
« prev ^ index » next coverage.py v7.6.0, created at 2024-07-13 00:04 +0200
« prev ^ index » next coverage.py v7.6.0, created at 2024-07-13 00:04 +0200
1#!/usr/bin/env python
2# vim: set fileencoding=utf-8 :
3# Tiago de Freitas Pereira <tiago.pereira@idiap.ch>
5import torchvision.transforms as transforms
7import bob.io.image
10def get_standard_data_augmentation():
11 """
12 Standard data augmentation used on my experiments
13 """
14 transform = transforms.Compose(
15 [
16 lambda x: bob.io.image.to_matplotlib(x),
17 lambda x: x.astype("uint8"),
18 transforms.ToPILImage(),
19 transforms.RandomHorizontalFlip(p=0.5),
20 transforms.RandomRotation(degrees=(-3, 3)),
21 transforms.RandomAutocontrast(p=0.1),
22 transforms.PILToTensor(),
23 lambda x: (x - 127.5) / 128.0,
24 ]
25 )
26 return transform