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
d9338f32
"...git@developer.sourcefind.cn:OpenDAS/lmdeploy.git" did not exist on "22e8b2ca2b38ff924ca1cbf82ae7e34b51d1d61a"
Unverified
Commit
d9338f32
authored
Apr 21, 2021
by
harishsdev
Committed by
GitHub
Apr 21, 2021
Browse files
Add more transform examples in gallery
parent
7a464a77
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
0 deletions
+66
-0
gallery/plot_transforms.py
gallery/plot_transforms.py
+66
-0
No files found.
gallery/plot_transforms.py
View file @
d9338f32
...
...
@@ -89,3 +89,69 @@ plot(rotated_img, "Rotated image")
# performs random affine transform on an image.
affined_img
=
T
.
RandomAffine
(
degrees
=
(
30
,
70
),
translate
=
(
0.1
,
0.3
),
scale
=
(
0.5
,
0.75
))(
orig_img
)
plot
(
affined_img
,
"Affine transformed image"
)
####################################
# RandomCrop
# ----------
# The :class:`~torchvision.transforms.RandomCrop` transform
# (see also :func:`~torchvision.transforms.functional.crop`)
# crops an image at a random location.
crop
=
T
.
RandomCrop
(
size
=
(
128
,
128
))(
orig_img
)
plot
(
crop
,
"Random crop"
)
####################################
# RandomResizedCrop
# -----------------
# The :class:`~torchvision.transforms.RandomResizedCrop` transform
# (see also :func:`~torchvision.transforms.functional.resized_crop`)
# crops an image at a random location, and then resizes the crop to a given
# size.
resized_crop
=
T
.
RandomResizedCrop
(
size
=
(
32
,
32
))(
orig_img
)
plot
(
resized_crop
,
"Random resized crop"
)
####################################
# RandomHorizontalFlip
# --------------------
# The :class:`~torchvision.transforms.RandomHorizontalFlip` transform
# (see also :func:`~torchvision.transforms.functional.hflip`)
# performs horizontal flip of an image, with a given probability.
#
# .. note::
# Since the transform is applied randomly, the two images below may actually be
# the same.
random_hflip
=
T
.
RandomHorizontalFlip
(
p
=
0.5
)(
orig_img
)
plot
(
random_hflip
,
"Random horizontal flip"
)
####################################
# RandomVerticalFlip
# ------------------
# The :class:`~torchvision.transforms.RandomVerticalFlip` transform
# (see also :func:`~torchvision.transforms.functional.vflip`)
# performs vertical flip of an image, with a given probability.
#
# .. note::
# Since the transform is applied randomly, the two images below may actually be
# the same.
random_vflip
=
T
.
RandomVerticalFlip
(
p
=
0.5
)(
orig_img
)
plot
(
random_vflip
,
"Random vertical flip"
)
####################################
# RandomApply
# -----------
# The :class:`~torchvision.transforms.RandomApply` transform
# randomly applies a list of transforms, with a given probability
#
# .. note::
# Since the transform is applied randomly, the two images below may actually be
# the same.
random_apply
=
T
.
RandomApply
(
transforms
=
[
T
.
RandomCrop
(
size
=
(
64
,
64
))],
p
=
0.5
)(
orig_img
)
plot
(
random_apply
,
"Random Apply transform"
)
####################################
# GaussianBlur
# ------------
# The :class:`~torchvision.transforms.GaussianBlur` transform
# (see also :func:`~torchvision.transforms.functional.gaussian_blur`)
# 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 Blur of image"
)
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