MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / AssignResult

Class AssignResult

detrsmpl/core/post_processing/bbox/assigners/assign_result.py:8–208  ·  view source on GitHub ↗

Stores assignments between predicted and truth boxes. Attributes: num_gts (int): the number of truth boxes considered when computing this assignment gt_inds (LongTensor): for each predicted box indicates the 1-based index of the assigned truth box. 0 mea

Source from the content-addressed store, hash-verified

6
7
8class AssignResult(util_mixins.NiceRepr):
9 """Stores assignments between predicted and truth boxes.
10
11 Attributes:
12 num_gts (int): the number of truth boxes considered when computing this
13 assignment
14
15 gt_inds (LongTensor): for each predicted box indicates the 1-based
16 index of the assigned truth box. 0 means unassigned and -1 means
17 ignore.
18
19 max_overlaps (FloatTensor): the iou between the predicted box and its
20 assigned truth box.
21
22 labels (None | LongTensor): If specified, for each predicted box
23 indicates the category label of the assigned truth box.
24
25 Example:
26 >>> # An assign result between 4 predicted boxes and 9 true boxes
27 >>> # where only two boxes were assigned.
28 >>> num_gts = 9
29 >>> max_overlaps = torch.LongTensor([0, .5, .9, 0])
30 >>> gt_inds = torch.LongTensor([-1, 1, 2, 0])
31 >>> labels = torch.LongTensor([0, 3, 4, 0])
32 >>> self = AssignResult(num_gts, gt_inds, max_overlaps, labels)
33 >>> print(str(self)) # xdoctest: +IGNORE_WANT
34 <AssignResult(num_gts=9, gt_inds.shape=(4,), max_overlaps.shape=(4,),
35 labels.shape=(4,))>
36 >>> # Force addition of gt labels (when adding gt as proposals)
37 >>> new_labels = torch.LongTensor([3, 4, 5])
38 >>> self.add_gt_(new_labels)
39 >>> print(str(self)) # xdoctest: +IGNORE_WANT
40 <AssignResult(num_gts=9, gt_inds.shape=(7,), max_overlaps.shape=(7,),
41 labels.shape=(7,))>
42 """
43 def __init__(self, num_gts, gt_inds, max_overlaps, labels=None):
44 self.num_gts = num_gts
45 self.gt_inds = gt_inds
46 self.max_overlaps = max_overlaps
47 self.labels = labels
48 # Interface for possible user-defined properties
49 self._extra_properties = {}
50
51 @property
52 def num_preds(self):
53 """int: the number of predictions in this assignment"""
54 return len(self.gt_inds)
55
56 def set_extra_property(self, key, value):
57 """Set user-defined new property."""
58 assert key not in self.info
59 self._extra_properties[key] = value
60
61 def get_extra_property(self, key):
62 """Get user-defined property."""
63 return self._extra_properties.get(key, None)
64
65 @property

Callers 1

assignMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected