Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions torchvision/models/detection/generalized_rcnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"""

from collections import OrderedDict
from typing import Union
import torch
from torch import nn
import warnings
Expand Down Expand Up @@ -35,7 +36,7 @@ def __init__(self, backbone, rpn, roi_heads, transform):

@torch.jit.unused
def eager_outputs(self, losses, detections):
# type: (Dict[str, Tensor], List[Dict[str, Tensor]]) -> Tuple[Dict[str, Tensor], List[Dict[str, Tensor]]]
# type: (Dict[str, Tensor], List[Dict[str, Tensor]]) -> Union[Dict[str, Tensor], List[Dict[str, Tensor]]]
if self.training:
return losses

Expand Down Expand Up @@ -85,11 +86,11 @@ def forward(self, images, targets=None):
boxes = target["boxes"]
degenerate_boxes = boxes[:, 2:] <= boxes[:, :2]
if degenerate_boxes.any():
# print the first degenrate box
# print the first degenerate box
bb_idx = degenerate_boxes.any(dim=1).nonzero().view(-1)[0]
degen_bb: List[float] = boxes[bb_idx].tolist()
raise ValueError("All bounding boxes should have positive height and width."
" Found invaid box {} for target at index {}."
" Found invalid box {} for target at index {}."
.format(degen_bb, target_idx))

features = self.backbone(images.tensors)
Expand Down
4 changes: 3 additions & 1 deletion torchvision/ops/poolers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from typing import Union

import torch
import torch.nn.functional as F
from torch import nn, Tensor
Expand Down Expand Up @@ -119,7 +121,7 @@ class MultiScaleRoIAlign(nn.Module):
def __init__(
self,
featmap_names: List[str],
output_size: List[int],
output_size: Union[int, Tuple[int], List[int]],
sampling_ratio: int,
):
super(MultiScaleRoIAlign, self).__init__()
Expand Down