-
Notifications
You must be signed in to change notification settings - Fork 45
/
preview_dataset.py
39 lines (28 loc) · 1.2 KB
/
preview_dataset.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import torch
import torchvision
def main():
train_loader = torch.utils.data.DataLoader(
torchvision.datasets.MNIST(
'data', train=True, download=True,
transform=torchvision.transforms.Compose([
# torchvision.transforms.RandomAffine(
# degrees=30),
# torchvision.transforms.RandomAffine(
# degrees=0, translate=(0.0, 0.5)),
# torchvision.transforms.RandomAffine(
# degrees=0, translate=(0.5, 0.5)),
# torchvision.transforms.RandomAffine(
# degrees=0, scale=(0.25, 1)),
# torchvision.transforms.RandomAffine(
# degrees=0, shear=(-30, 30, -30, 30)),
torchvision.transforms.RandomAffine(
degrees=30, translate=(0.5, 0.5), scale=(0.25, 1),
shear=(-30, 30, -30, 30)),
torchvision.transforms.ToTensor(),
])),
batch_size=800)
inputs_batch, labels_batch = next(iter(train_loader))
grid = torchvision.utils.make_grid(inputs_batch, nrow=40, pad_value=1)
torchvision.utils.save_image(grid, 'inputs_batch_preview.png')
if __name__ == '__main__':
main()