Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update image-augmentation.md #1356

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions chapter_computer-vision/image-augmentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ from d2l import torch as d2l
import torch
import torchvision
from torch import nn
from torchvision import transforms
```

```{.python .input}
Expand Down Expand Up @@ -75,7 +76,7 @@ apply(img, gluon.data.vision.transforms.RandomFlipLeftRight())

```{.python .input}
#@tab pytorch
apply(img, torchvision.transforms.RandomHorizontalFlip())
apply(img, transforms.RandomHorizontalFlip())
```

```{.python .input}
Expand All @@ -91,7 +92,7 @@ apply(img, gluon.data.vision.transforms.RandomFlipTopBottom())

```{.python .input}
#@tab pytorch
apply(img, torchvision.transforms.RandomVerticalFlip())
apply(img, transforms.RandomVerticalFlip())
```

```{.python .input}
Expand All @@ -116,7 +117,7 @@ apply(img, shape_aug)

```{.python .input}
#@tab pytorch
shape_aug = torchvision.transforms.RandomResizedCrop(
shape_aug = transforms.RandomResizedCrop(
(200, 200), scale=(0.1, 1), ratio=(0.5, 2))
apply(img, shape_aug)
```
Expand All @@ -140,7 +141,7 @@ apply(img, gluon.data.vision.transforms.RandomBrightness(0.5))

```{.python .input}
#@tab pytorch
apply(img, torchvision.transforms.ColorJitter(
apply(img, transforms.ColorJitter(
brightness=0.5, contrast=0, saturation=0, hue=0))
```

Expand All @@ -158,7 +159,7 @@ apply(img, gluon.data.vision.transforms.RandomHue(0.5))

```{.python .input}
#@tab pytorch
apply(img, torchvision.transforms.ColorJitter(
apply(img, transforms.ColorJitter(
brightness=0, contrast=0, saturation=0, hue=0.5))
```

Expand All @@ -178,7 +179,7 @@ apply(img, color_aug)

```{.python .input}
#@tab pytorch
color_aug = torchvision.transforms.ColorJitter(
color_aug = transforms.ColorJitter(
brightness=0.5, contrast=0.5, saturation=0.5, hue=0.5)
apply(img, color_aug)
```
Expand All @@ -202,8 +203,8 @@ apply(img, augs)

```{.python .input}
#@tab pytorch
augs = torchvision.transforms.Compose([
torchvision.transforms.RandomHorizontalFlip(), color_aug, shape_aug])
augs = transforms.Compose([
transforms.RandomHorizontalFlip(), color_aug, shape_aug])
apply(img, augs)
```

Expand Down Expand Up @@ -255,12 +256,12 @@ test_augs = gluon.data.vision.transforms.Compose([

```{.python .input}
#@tab pytorch
train_augs = torchvision.transforms.Compose([
torchvision.transforms.RandomHorizontalFlip(),
torchvision.transforms.ToTensor()])
train_augs = transforms.Compose([
transforms.RandomHorizontalFlip(),
transforms.ToTensor()])

test_augs = torchvision.transforms.Compose([
torchvision.transforms.ToTensor()])
test_augs = transforms.Compose([
transforms.ToTensor()])
```

```{.python .input}
Expand Down
Loading