Unverified Commit b0601631 authored by Zhiqiang Wang's avatar Zhiqiang Wang Committed by GitHub
Browse files

Make target argument in transform.py truly optional (#3866)

parent 26e34735
...@@ -24,8 +24,9 @@ def _fake_cast_onnx(v): ...@@ -24,8 +24,9 @@ def _fake_cast_onnx(v):
def _resize_image_and_masks(image: Tensor, self_min_size: float, self_max_size: float, def _resize_image_and_masks(image: Tensor, self_min_size: float, self_max_size: float,
target: Optional[Dict[str, Tensor]], target: Optional[Dict[str, Tensor]] = None,
fixed_size: Optional[Tuple[int, int]]) -> Tuple[Tensor, Optional[Dict[str, Tensor]]]: fixed_size: Optional[Tuple[int, int]] = None,
) -> Tuple[Tensor, Optional[Dict[str, Tensor]]]:
if torchvision._is_tracing(): if torchvision._is_tracing():
im_shape = _get_shape_onnx(image) im_shape = _get_shape_onnx(image)
else: else:
...@@ -146,8 +147,10 @@ class GeneralizedRCNNTransform(nn.Module): ...@@ -146,8 +147,10 @@ class GeneralizedRCNNTransform(nn.Module):
index = int(torch.empty(1).uniform_(0., float(len(k))).item()) index = int(torch.empty(1).uniform_(0., float(len(k))).item())
return k[index] return k[index]
def resize(self, image, target): def resize(self,
# type: (Tensor, Optional[Dict[str, Tensor]]) -> Tuple[Tensor, Optional[Dict[str, Tensor]]] image: Tensor,
target: Optional[Dict[str, Tensor]] = None,
) -> Tuple[Tensor, Optional[Dict[str, Tensor]]]:
h, w = image.shape[-2:] h, w = image.shape[-2:]
if self.training: if self.training:
size = float(self.torch_choice(self.min_size)) size = float(self.torch_choice(self.min_size))
......
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