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
fea1f733
Unverified
Commit
fea1f733
authored
Jul 01, 2022
by
vfdev
Committed by
GitHub
Jul 01, 2022
Browse files
Fill arg supports float values, scripted pad op (#6226)
parent
87cde716
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
5 deletions
+5
-5
test/test_functional_tensor.py
test/test_functional_tensor.py
+1
-1
torchvision/transforms/functional.py
torchvision/transforms/functional.py
+2
-2
torchvision/transforms/functional_tensor.py
torchvision/transforms/functional_tensor.py
+2
-2
No files found.
test/test_functional_tensor.py
View file @
fea1f733
...
...
@@ -972,7 +972,7 @@ def test_adjust_gamma(device, dtype, config, channels):
[
{
"padding_mode"
:
"constant"
,
"fill"
:
0
},
{
"padding_mode"
:
"constant"
,
"fill"
:
10
},
{
"padding_mode"
:
"constant"
,
"fill"
:
20
},
{
"padding_mode"
:
"constant"
,
"fill"
:
20
.2
},
{
"padding_mode"
:
"edge"
},
{
"padding_mode"
:
"reflect"
},
{
"padding_mode"
:
"symmetric"
},
...
...
torchvision/transforms/functional.py
View file @
fea1f733
...
...
@@ -2,7 +2,7 @@ import math
import
numbers
import
warnings
from
enum
import
Enum
from
typing
import
List
,
Tuple
,
Any
,
Optional
from
typing
import
List
,
Tuple
,
Any
,
Optional
,
Union
import
numpy
as
np
import
torch
...
...
@@ -474,7 +474,7 @@ def resize(
return
F_t
.
resize
(
img
,
size
=
output_size
,
interpolation
=
interpolation
.
value
,
antialias
=
antialias
)
def
pad
(
img
:
Tensor
,
padding
:
List
[
int
],
fill
:
int
=
0
,
padding_mode
:
str
=
"constant"
)
->
Tensor
:
def
pad
(
img
:
Tensor
,
padding
:
List
[
int
],
fill
:
Union
[
int
,
float
]
=
0
,
padding_mode
:
str
=
"constant"
)
->
Tensor
:
r
"""Pad the given image on all sides with the given "pad" value.
If the image is torch Tensor, it is expected
to have [..., H, W] shape, where ... means at most 2 leading dimensions for mode reflect and symmetric,
...
...
torchvision/transforms/functional_tensor.py
View file @
fea1f733
import
warnings
from
typing
import
Optional
,
Tuple
,
List
from
typing
import
Optional
,
Tuple
,
List
,
Union
import
torch
from
torch
import
Tensor
...
...
@@ -370,7 +370,7 @@ def _parse_pad_padding(padding: List[int]) -> List[int]:
return
[
pad_left
,
pad_right
,
pad_top
,
pad_bottom
]
def
pad
(
img
:
Tensor
,
padding
:
List
[
int
],
fill
:
int
=
0
,
padding_mode
:
str
=
"constant"
)
->
Tensor
:
def
pad
(
img
:
Tensor
,
padding
:
List
[
int
],
fill
:
Union
[
int
,
float
]
=
0
,
padding_mode
:
str
=
"constant"
)
->
Tensor
:
_assert_image_tensor
(
img
)
if
not
isinstance
(
padding
,
(
int
,
tuple
,
list
)):
...
...
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