Skip to content

Commit a36da7d

Browse files
committed
Code updates
1 parent 8bf31ba commit a36da7d

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

torchvision/prototype/features/_image.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,7 @@ def pad(
177177
if not isinstance(padding, int):
178178
padding = list(padding)
179179

180-
# This cast does Sequence -> List and is required to make mypy happy
181-
if not (fill is None or isinstance(fill, (int, float))):
182-
fill = list(fill)
180+
fill = self._F._geometry._convert_fill_arg(fill)
183181

184182
output = self._F.pad_image_tensor(self, padding, fill=fill, padding_mode=padding_mode)
185183
return Image.new_like(self, output)

torchvision/prototype/features/_mask.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ def pad(
5858
if not isinstance(padding, int):
5959
padding = list(padding)
6060

61+
fill = self._F._geometry._convert_fill_arg(fill)
62+
6163
output = self._F.pad_mask(self, padding, padding_mode=padding_mode, fill=fill)
6264
return Mask.new_like(self, output)
6365

torchvision/prototype/transforms/functional/_geometry.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ def pad_image_tensor(
594594
padding_mode: str = "constant",
595595
) -> torch.Tensor:
596596
if fill is None:
597-
# This JIT workaround
597+
# This is a JIT workaround
598598
return _pad_with_scalar_fill(img, padding, fill=None, padding_mode=padding_mode)
599599
elif isinstance(fill, (int, float)) or len(fill) == 1:
600600
fill_number = fill[0] if isinstance(fill, list) else fill
@@ -714,9 +714,7 @@ def pad(
714714
if not isinstance(padding, int):
715715
padding = list(padding)
716716

717-
# This cast does Sequence -> List and is required to make mypy happy
718-
if not (fill is None or isinstance(fill, (int, float))):
719-
fill = list(fill)
717+
fill = _convert_fill_arg(fill)
720718

721719
return pad_image_tensor(inpt, padding, fill=fill, padding_mode=padding_mode)
722720

0 commit comments

Comments
 (0)