Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix type hints and spelling mistake in generalized_rcnn and poolers #2550

Merged
merged 7 commits into from
Aug 4, 2020
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