Skip to content

Commit 6452b30

Browse files
committed
adding transforms
1 parent d9b8d00 commit 6452b30

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,31 @@ It has the members:
114114
### Imagenet-12
115115

116116
This is simply implemented with an ImageFolder dataset, after the data is preprocessed [as described here](https://github.com/facebook/fb.resnet.torch/blob/master/INSTALL.md#download-the-imagenet-dataset)
117+
118+
# Transforms
119+
120+
Transforms are common image transforms.
121+
They can be chained together using `transforms.Compose`
122+
123+
- `ToTensor()` - converts PIL Image to Tensor
124+
- `Normalize(mean, std)` - normalizes the image given mean, std (for example: mean = [0.3, 1.2, 2.1])
125+
- `Scale(size, interpolation=Image.BILINEAR)` - Scales the smaller image edge to the given size. Interpolation modes are options from PIL
126+
- `CenterCrop(size)` - center-crops the image to the given size
127+
- `RandomCrop(size)` - Random crops the image to the given size.
128+
- `RandomHorizontalFlip()` - hflip the image with probability 0.5
129+
- `RandomSizedCrop(size, interpolation=Image.BILINEAR)` - Random crop with size 0.08-1 and aspect ratio 3/4 - 4/3 (Inception-style)
130+
131+
### `transforms.Compose`
132+
133+
One can compose several transforms together.
134+
For example.
135+
136+
```python
137+
transform = transforms.Compose([
138+
transforms.RandomSizedCrop(224),
139+
transforms.RandomHorizontalFlip(),
140+
transforms.ToTensor(),
141+
transforms.Normalize(mean = [ 0.485, 0.456, 0.406 ],
142+
std = [ 0.229, 0.224, 0.225 ]),
143+
])
144+
```

0 commit comments

Comments
 (0)