Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
vision
Commits
d4aa0111
Unverified
Commit
d4aa0111
authored
Apr 28, 2021
by
Aditya Oke
Committed by
GitHub
Apr 27, 2021
Browse files
Add illustrations for AutoAugment in gallery example (#3727)
Co-authored-by:
Nicolas Hug
<
nicolashug@fb.com
>
parent
c2b8575c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
10 deletions
+23
-10
gallery/plot_transforms.py
gallery/plot_transforms.py
+23
-0
torchvision/transforms/autoaugment.py
torchvision/transforms/autoaugment.py
+0
-10
No files found.
gallery/plot_transforms.py
View file @
d4aa0111
...
...
@@ -178,3 +178,26 @@ plot(random_apply_img, "Random Apply transformed Image")
# performs gaussianblur transform on an image.
gaus_blur_img
=
T
.
GaussianBlur
(
kernel_size
=
(
5
,
9
),
sigma
=
(
0.4
,
3.0
))(
orig_img
)
plot
(
gaus_blur_img
,
"Gaussian Blurred Image"
)
####################################
# AutoAugment
# -----------
# The :class:`~torchvision.transforms.AutoAugment` transform
# automatically augments data based on a given auto-augmentation policy.
# See :class:`~torchvision.transforms.AutoAugmentPolicy` for the available policies.
policies
=
[
T
.
AutoAugmentPolicy
.
CIFAR10
,
T
.
AutoAugmentPolicy
.
IMAGENET
,
T
.
AutoAugmentPolicy
.
SVHN
]
num_cols
=
5
fig
,
axs
=
plt
.
subplots
(
nrows
=
len
(
policies
),
ncols
=
num_cols
)
fig
.
suptitle
(
"Auto-augmented images with different policies"
)
for
pol_idx
,
policy
in
enumerate
(
policies
):
auto_augmenter
=
T
.
AutoAugment
(
policy
)
for
col
in
range
(
num_cols
):
augmented_img
=
auto_augmenter
(
orig_img
)
ax
=
axs
[
pol_idx
,
col
]
ax
.
imshow
(
np
.
asarray
(
augmented_img
))
ax
.
set
(
xticklabels
=
[],
yticklabels
=
[],
xticks
=
[],
yticks
=
[])
if
col
==
0
:
ax
.
set
(
ylabel
=
str
(
policy
).
split
(
'.'
)[
-
1
])
torchvision/transforms/autoaugment.py
View file @
d4aa0111
...
...
@@ -142,16 +142,6 @@ class AutoAugment(torch.nn.Module):
If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` are supported.
fill (sequence or number, optional): Pixel fill value for the area outside the transformed
image. If given a number, the value is used for all bands respectively.
If input is PIL Image, the options is only available for ``Pillow>=5.0.0``.
Example:
>>> t = transforms.AutoAugment()
>>> transformed = t(image)
>>> transform=transforms.Compose([
>>> transforms.Resize(256),
>>> transforms.AutoAugment(),
>>> transforms.ToTensor()])
"""
def
__init__
(
self
,
policy
:
AutoAugmentPolicy
=
AutoAugmentPolicy
.
IMAGENET
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment