-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdataset_setting.py
35 lines (27 loc) · 1.31 KB
/
dataset_setting.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
import torchtext.vocab as vocab
import torchvision.transforms as transforms
from data_loader import DTDDataLoader, ImageDataLoader
# it is best to pre-calculate mean and std, or normalize at batch.
def get_dtd_train_loader(args, img_size):
transform = transforms.Compose([#transforms.Resize(img_size),
transforms.RandomCrop(img_size),
transforms.RandomHorizontalFlip(),
transforms.ToTensor(),
transforms.Normalize(mean=(0.5, 0.5, 0.5),std=(0.5, 0.5, 0.5))])
dataset_args = [
args.dataset,
args.image_list,
transform
]
return DTDDataLoader(*dataset_args)
def get_train_loader(args, img_size):
transform = transforms.Compose([#transforms.Resize(img_size),
transforms.RandomCrop(img_size),
transforms.RandomHorizontalFlip(),
transforms.ToTensor(),
transforms.Normalize(mean=(0.5, 0.5, 0.5),std=(0.5, 0.5, 0.5))])
dataset_args = [
args.dataset,
transform
]
return ImageDataLoader(*dataset_args)