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
1d6a259c
"vscode:/vscode.git/clone" did not exist on "e5a5f0be08ec1302e13e1c97c2b11b5442e160b0"
Unverified
Commit
1d6a259c
authored
Sep 08, 2022
by
vfdev
Committed by
GitHub
Sep 08, 2022
Browse files
Fixed error condition in RandomCrop (#6548)
parent
112accf9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
3 deletions
+3
-3
test/test_transforms.py
test/test_transforms.py
+1
-1
torchvision/prototype/transforms/_geometry.py
torchvision/prototype/transforms/_geometry.py
+1
-1
torchvision/transforms/transforms.py
torchvision/transforms/transforms.py
+1
-1
No files found.
test/test_transforms.py
View file @
1d6a259c
...
...
@@ -1670,7 +1670,7 @@ def test_random_crop():
assert
result
.
size
(
1
)
==
height
+
1
assert
result
.
size
(
2
)
==
width
+
1
t
=
transforms
.
RandomCrop
(
48
)
t
=
transforms
.
RandomCrop
(
33
)
img
=
torch
.
ones
(
3
,
32
,
32
)
with
pytest
.
raises
(
ValueError
,
match
=
r
"Required crop size .+ is larger than input image size .+"
):
t
(
img
)
...
...
torchvision/prototype/transforms/_geometry.py
View file @
1d6a259c
...
...
@@ -443,7 +443,7 @@ class RandomCrop(Transform):
if
height
<
output_height
:
height
+=
2
*
(
output_height
-
height
)
if
height
+
1
<
output_height
or
width
+
1
<
output_width
:
if
height
<
output_height
or
width
<
output_width
:
raise
ValueError
(
f
"Required crop size
{
(
output_height
,
output_width
)
}
is larger then input image size
{
(
height
,
width
)
}
"
)
...
...
torchvision/transforms/transforms.py
View file @
1d6a259c
...
...
@@ -628,7 +628,7 @@ class RandomCrop(torch.nn.Module):
_
,
h
,
w
=
F
.
get_dimensions
(
img
)
th
,
tw
=
output_size
if
h
+
1
<
th
or
w
+
1
<
tw
:
if
h
<
th
or
w
<
tw
:
raise
ValueError
(
f
"Required crop size
{
(
th
,
tw
)
}
is larger than input image size
{
(
h
,
w
)
}
"
)
if
w
==
tw
and
h
==
th
:
...
...
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