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
f524cd3a
Unverified
Commit
f524cd3a
authored
Aug 01, 2023
by
Nicolas Hug
Committed by
GitHub
Aug 01, 2023
Browse files
Fix docs (#7789)
parent
3e4e353d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
gallery/plot_cutmix_mixup.py
gallery/plot_cutmix_mixup.py
+5
-5
No files found.
gallery/plot_cutmix_mixup.py
View file @
f524cd3a
...
...
@@ -4,8 +4,8 @@
How to use CutMix and MixUp
===========================
:class:`~torchvision.transforms.v2.Cut
m
ix` and
:class:`~torchvision.transforms.v2.Mix
u
p` are popular augmentation strategies
:class:`~torchvision.transforms.v2.Cut
M
ix` and
:class:`~torchvision.transforms.v2.Mix
U
p` are popular augmentation strategies
that can improve classification accuracy.
These transforms are slightly different from the rest of the Torchvision
...
...
@@ -79,8 +79,8 @@ for images, labels in dataloader:
dataloader
=
DataLoader
(
dataset
,
batch_size
=
4
,
shuffle
=
True
)
cutmix
=
v2
.
Cut
m
ix
(
num_classes
=
NUM_CLASSES
)
mixup
=
v2
.
Mix
u
p
(
num_classes
=
NUM_CLASSES
)
cutmix
=
v2
.
Cut
M
ix
(
num_classes
=
NUM_CLASSES
)
mixup
=
v2
.
Mix
U
p
(
num_classes
=
NUM_CLASSES
)
cutmix_or_mixup
=
v2
.
RandomChoice
([
cutmix
,
mixup
])
for
images
,
labels
in
dataloader
:
...
...
@@ -148,5 +148,5 @@ def labels_getter(batch):
return
batch
[
"target"
][
"classes"
]
out
=
v2
.
Cut
m
ix
(
num_classes
=
NUM_CLASSES
,
labels_getter
=
labels_getter
)(
batch
)
out
=
v2
.
Cut
M
ix
(
num_classes
=
NUM_CLASSES
,
labels_getter
=
labels_getter
)(
batch
)
print
(
f
"
{
out
[
'imgs'
].
shape
=
}
,
{
out
[
'target'
][
'classes'
].
shape
=
}
"
)
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