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
69dc971e
Unverified
Commit
69dc971e
authored
Oct 14, 2020
by
vfdev
Committed by
GitHub
Oct 14, 2020
Browse files
Added sizes check and a test (#2816)
parent
3f222e81
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
0 deletions
+11
-0
test/test_transforms.py
test/test_transforms.py
+5
-0
torchvision/transforms/transforms.py
torchvision/transforms/transforms.py
+6
-0
No files found.
test/test_transforms.py
View file @
69dc971e
...
...
@@ -298,6 +298,11 @@ class Tester(unittest.TestCase):
self
.
assertEqual
(
result
.
size
(
1
),
height
+
1
)
self
.
assertEqual
(
result
.
size
(
2
),
width
+
1
)
t
=
transforms
.
RandomCrop
(
48
)
img
=
torch
.
ones
(
3
,
32
,
32
)
with
self
.
assertRaisesRegex
(
ValueError
,
r
"Required crop size .+ is larger then input image size .+"
):
t
(
img
)
def
test_pad
(
self
):
height
=
random
.
randint
(
10
,
32
)
*
2
width
=
random
.
randint
(
10
,
32
)
*
2
...
...
torchvision/transforms/transforms.py
View file @
69dc971e
...
...
@@ -532,6 +532,12 @@ class RandomCrop(torch.nn.Module):
"""
w
,
h
=
F
.
_get_image_size
(
img
)
th
,
tw
=
output_size
if
h
+
1
<
th
or
w
+
1
<
tw
:
raise
ValueError
(
"Required crop size {} is larger then input image size {}"
.
format
((
th
,
tw
),
(
h
,
w
))
)
if
w
==
tw
and
h
==
th
:
return
0
,
0
,
h
,
w
...
...
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