Unverified Commit fea1f733 authored by vfdev's avatar vfdev Committed by GitHub
Browse files

Fill arg supports float values, scripted pad op (#6226)

parent 87cde716
...@@ -972,7 +972,7 @@ def test_adjust_gamma(device, dtype, config, channels): ...@@ -972,7 +972,7 @@ def test_adjust_gamma(device, dtype, config, channels):
[ [
{"padding_mode": "constant", "fill": 0}, {"padding_mode": "constant", "fill": 0},
{"padding_mode": "constant", "fill": 10}, {"padding_mode": "constant", "fill": 10},
{"padding_mode": "constant", "fill": 20}, {"padding_mode": "constant", "fill": 20.2},
{"padding_mode": "edge"}, {"padding_mode": "edge"},
{"padding_mode": "reflect"}, {"padding_mode": "reflect"},
{"padding_mode": "symmetric"}, {"padding_mode": "symmetric"},
......
...@@ -2,7 +2,7 @@ import math ...@@ -2,7 +2,7 @@ import math
import numbers import numbers
import warnings import warnings
from enum import Enum from enum import Enum
from typing import List, Tuple, Any, Optional from typing import List, Tuple, Any, Optional, Union
import numpy as np import numpy as np
import torch import torch
...@@ -474,7 +474,7 @@ def resize( ...@@ -474,7 +474,7 @@ def resize(
return F_t.resize(img, size=output_size, interpolation=interpolation.value, antialias=antialias) 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. r"""Pad the given image on all sides with the given "pad" value.
If the image is torch Tensor, it is expected 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, to have [..., H, W] shape, where ... means at most 2 leading dimensions for mode reflect and symmetric,
......
import warnings import warnings
from typing import Optional, Tuple, List from typing import Optional, Tuple, List, Union
import torch import torch
from torch import Tensor from torch import Tensor
...@@ -370,7 +370,7 @@ def _parse_pad_padding(padding: List[int]) -> List[int]: ...@@ -370,7 +370,7 @@ def _parse_pad_padding(padding: List[int]) -> List[int]:
return [pad_left, pad_right, pad_top, pad_bottom] 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) _assert_image_tensor(img)
if not isinstance(padding, (int, tuple, list)): if not isinstance(padding, (int, tuple, list)):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment