-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata.py
More file actions
59 lines (54 loc) · 2.15 KB
/
data.py
File metadata and controls
59 lines (54 loc) · 2.15 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import torchvision.transforms as transforms
# once the images are loaded, how do we pre-process them before being passed into the network
# by default, we resize the images to 64 x 64 in size
# and normalize them to mean = 0 and standard-deviation = 1 based on statistics collected from ImageNet
data_transforms ={ 'train' : transforms.Compose(
[
transforms.Resize((64, 64)),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
]
),
'val' : transforms.Compose(
[
transforms.Resize((64, 64)),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
]
),
}
data_transforms_2 ={ 'train' : transforms.Compose(
[
transforms.Resize((224, 224)),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
]
),
'val' : transforms.Compose(
[
transforms.Resize((224, 224)),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
]
),
}
data_transforms_plus = {
'train': transforms.Compose([
transforms.RandomResizedCrop(224), # Randomly resize and crop to 224x224
transforms.RandomHorizontalFlip(), # Random horizontal flip
transforms.ToTensor(), # Convert image to tensor
transforms.Normalize( # Normalize using ImageNet stats
mean=[0.485, 0.456, 0.406], # Mean of ImageNet RGB channels
std=[0.229, 0.224, 0.225] # Std dev of ImageNet RGB channels
),
]),
'val': transforms.Compose([
transforms.Resize(256), # Resize image to 256x256
transforms.CenterCrop(224), # Crop to center 224x224
transforms.ToTensor(), # Convert image to tensor
transforms.Normalize( # Normalize using ImageNet stats
mean=[0.485, 0.456, 0.406], # Mean of ImageNet RGB channels
std=[0.229, 0.224, 0.225] # Std dev of ImageNet RGB channels
),
]),
}