|
4 | 4 | """
|
5 | 5 |
|
6 | 6 | from collections import OrderedDict
|
| 7 | +from typing import Union |
7 | 8 | import torch
|
8 | 9 | from torch import nn
|
9 | 10 | import warnings
|
@@ -35,7 +36,7 @@ def __init__(self, backbone, rpn, roi_heads, transform):
|
35 | 36 |
|
36 | 37 | @torch.jit.unused
|
37 | 38 | def eager_outputs(self, losses, detections):
|
38 |
| - # type: (Dict[str, Tensor], List[Dict[str, Tensor]]) -> Tuple[Dict[str, Tensor], List[Dict[str, Tensor]]] |
| 39 | + # type: (Dict[str, Tensor], List[Dict[str, Tensor]]) -> Union[Dict[str, Tensor], List[Dict[str, Tensor]]] |
39 | 40 | if self.training:
|
40 | 41 | return losses
|
41 | 42 |
|
@@ -85,11 +86,11 @@ def forward(self, images, targets=None):
|
85 | 86 | boxes = target["boxes"]
|
86 | 87 | degenerate_boxes = boxes[:, 2:] <= boxes[:, :2]
|
87 | 88 | if degenerate_boxes.any():
|
88 |
| - # print the first degenrate box |
| 89 | + # print the first degenerate box |
89 | 90 | bb_idx = degenerate_boxes.any(dim=1).nonzero().view(-1)[0]
|
90 | 91 | degen_bb: List[float] = boxes[bb_idx].tolist()
|
91 | 92 | raise ValueError("All bounding boxes should have positive height and width."
|
92 |
| - " Found invaid box {} for target at index {}." |
| 93 | + " Found invalid box {} for target at index {}." |
93 | 94 | .format(degen_bb, target_idx))
|
94 | 95 |
|
95 | 96 | features = self.backbone(images.tensors)
|
|
0 commit comments