Skip to content

Commit 3cc1964

Browse files
committed
fix typing issues
1 parent d986b78 commit 3cc1964

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

torchvision/prototype/transforms/_geometry.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -261,12 +261,12 @@ def apply_recursively(obj: Any) -> Any:
261261
class RandomCrop(Transform):
262262
def __init__(
263263
self,
264-
size=Union[int, Sequence[int]],
265-
padding: Sequence[int] = None,
264+
size: Union[int, Sequence[int]],
265+
padding: Sequence[int],
266266
pad_if_needed: bool = False,
267267
fill: Union[int, str, Sequence[int]] = 0,
268-
padding_mode: Union[str, Literal["constant", "edge", "reflect", "symmetric"]] = "constant",
269-
):
268+
padding_mode: Literal["constant", "edge", "reflect", "symmetric"] = "constant",
269+
) -> None:
270270
super().__init__()
271271
self.size = _setup_size(size, error_msg="Please provide only two dimensions (h, w) for size.")
272272

@@ -318,7 +318,7 @@ def forward(self, *inputs: Any) -> Any:
318318
sample,
319319
output_size=self.size,
320320
image_size=get_image_dimensions(sample),
321-
padding=self.padding,
321+
padding=cast(List[int], tuple(self.padding)),
322322
pad_if_needed=self.pad_if_needed,
323323
fill=self.fill,
324324
padding_mode=self.padding_mode,
@@ -329,7 +329,7 @@ def forward(self, *inputs: Any) -> Any:
329329
sample,
330330
output_size=self.size,
331331
image_size=get_image_dimensions(sample),
332-
padding=self.padding,
332+
padding=cast(List[int], tuple(self.padding)),
333333
pad_if_needed=self.pad_if_needed,
334334
fill=self.fill,
335335
padding_mode=self.padding_mode,
@@ -339,9 +339,9 @@ def forward(self, *inputs: Any) -> Any:
339339
sample,
340340
output_size=self.size,
341341
image_size=get_image_dimensions(sample),
342-
padding=self.padding,
342+
padding=cast(List[int], tuple(self.padding)),
343343
pad_if_needed=self.pad_if_needed,
344-
fill=self.fill,
344+
fill=self.fill, # TODO: should be converted to number
345345
padding_mode=self.padding_mode,
346346
)
347347

torchvision/prototype/transforms/functional/_geometry.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ def random_pad_image_tensor(
457457
img: torch.Tensor,
458458
output_size: List[int],
459459
image_size: Tuple[int, int, int],
460-
padding: List[int] = None,
460+
padding: List[int],
461461
pad_if_needed: bool = False,
462462
fill: int = 0,
463463
padding_mode: str = "constant",
@@ -481,9 +481,9 @@ def random_pad_image_pil(
481481
img: PIL.Image.Image,
482482
output_size: List[int],
483483
image_size: Tuple[int, int, int],
484-
padding: List[int] = None,
484+
padding: List[int],
485485
pad_if_needed: bool = False,
486-
fill: int = 0,
486+
fill: Union[int, str, Sequence[int]] = 0,
487487
padding_mode: Literal["constant", "edge", "reflect", "symmetric"] = "constant",
488488
) -> PIL.Image.Image:
489489

0 commit comments

Comments
 (0)