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
f5af07b4
"git@developer.sourcefind.cn:OpenDAS/ktransformers.git" did not exist on "c515cc49a595696fedaca6032e100951c42ad36f"
Unverified
Commit
f5af07b4
authored
Nov 04, 2021
by
Nicolas Hug
Committed by
GitHub
Nov 04, 2021
Browse files
More robust test_random_apply and test_random_choice (#4775)
parent
b47ea834
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
test/test_transforms.py
test/test_transforms.py
+2
-2
No files found.
test/test_transforms.py
View file @
f5af07b4
...
@@ -1364,7 +1364,7 @@ def test_to_grayscale():
...
@@ -1364,7 +1364,7 @@ def test_to_grayscale():
@
pytest
.
mark
.
parametrize
(
"p"
,
(
0
,
1
))
@
pytest
.
mark
.
parametrize
(
"p"
,
(
0
,
1
))
def
test_random_apply
(
p
,
seed
):
def
test_random_apply
(
p
,
seed
):
torch
.
manual_seed
(
seed
)
torch
.
manual_seed
(
seed
)
random_apply_transform
=
transforms
.
RandomApply
([
transforms
.
RandomRotation
((
1
,
45
))],
p
=
p
)
random_apply_transform
=
transforms
.
RandomApply
([
transforms
.
RandomRotation
((
45
,
50
))],
p
=
p
)
img
=
transforms
.
ToPILImage
()(
torch
.
rand
(
3
,
30
,
40
))
img
=
transforms
.
ToPILImage
()(
torch
.
rand
(
3
,
30
,
40
))
out
=
random_apply_transform
(
img
)
out
=
random_apply_transform
(
img
)
if
p
==
0
:
if
p
==
0
:
...
@@ -1384,7 +1384,7 @@ def test_random_choice(proba_passthrough, seed):
...
@@ -1384,7 +1384,7 @@ def test_random_choice(proba_passthrough, seed):
random_choice_transform
=
transforms
.
RandomChoice
(
random_choice_transform
=
transforms
.
RandomChoice
(
[
[
lambda
x
:
x
,
# passthrough
lambda
x
:
x
,
# passthrough
transforms
.
RandomRotation
((
1
,
45
)),
transforms
.
RandomRotation
((
45
,
50
)),
],
],
p
=
[
proba_passthrough
,
1
-
proba_passthrough
],
p
=
[
proba_passthrough
,
1
-
proba_passthrough
],
)
)
...
...
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