Child class of CSRData to simplify some common operations dedicated to instance labels clustering. In particular, this data structure stores the cluster-object overlaps: for each cluster (i.e. segment, superpoint, node in the superpoint graph, etc), we store all the object instances
| 13 | |
| 14 | |
| 15 | class InstanceData(CSRData): |
| 16 | """Child class of CSRData to simplify some common operations |
| 17 | dedicated to instance labels clustering. In particular, this data |
| 18 | structure stores the cluster-object overlaps: for each cluster (i.e. |
| 19 | segment, superpoint, node in the superpoint graph, etc), we store |
| 20 | all the object instances with which it overlaps. Concretely, for |
| 21 | each cluster-object pair, we store: |
| 22 | - `obj`: the object's index |
| 23 | - `count`: the number of points in the cluster-object overlap |
| 24 | - `y`: the object's semantic label |
| 25 | |
| 26 | Importantly, each object in the InstanceData is expected to be |
| 27 | described by a unique index in `obj', regardless of its actual |
| 28 | semantic class. It is not required for the object instances to be |
| 29 | contiguous in `[0, obj_max]`, although enforcing it may have |
| 30 | beneficial downstream effects on memory and I/O times. Finally, |
| 31 | when two InstanceData are batched in an InstanceBatch, the `obj' |
| 32 | indices will be updated to avoid collision between the batch items. |
| 33 | |
| 34 | :param pointers: torch.LongTensor |
| 35 | Pointers to address the data in the associated value tensors. |
| 36 | `values[Pointers[i]:Pointers[i+1]]` hold the values for the ith |
| 37 | cluster. If `dense=True`, the `pointers` are actually the dense |
| 38 | indices to be converted to pointer format. |
| 39 | :param obj: torch.LongTensor |
| 40 | Object index for each cluster-object pair. Assumes there are |
| 41 | NO DUPLICATE CLUSTER-OBJECT pairs in the input data, unless |
| 42 | 'dense=True'. |
| 43 | :param count: torch.LongTensor |
| 44 | Number of points in the overlap for each cluster-object pair. |
| 45 | :param y: torch.LongTensor |
| 46 | Semantic label the object for each cluster-object pair. By |
| 47 | definition, we assume the objects to be SEMANTICALLY PURE. For |
| 48 | that reason, we only store a single semantic label for objects, |
| 49 | as opposed to superpoints, for which we want to maintain a |
| 50 | histogram of labels. |
| 51 | :param dense: bool |
| 52 | If `dense=True`, the `pointers` are actually the dense indices |
| 53 | to be converted to pointer format. Besides, any duplicate |
| 54 | cluster-obj pairs will be merged and the corresponding `count` |
| 55 | will be updated. |
| 56 | :param kwargs: |
| 57 | Other kwargs will be ignored. |
| 58 | """ |
| 59 | |
| 60 | __value_keys__ = ['obj', 'count', 'y'] |
| 61 | __is_index_value_serialization_key__ = None |
| 62 | |
| 63 | def __init__( |
| 64 | self, |
| 65 | pointers: torch.Tensor, |
| 66 | obj: torch.Tensor, |
| 67 | count: torch.Tensor, |
| 68 | y: torch.Tensor, |
| 69 | dense: bool = False, |
| 70 | **kwargs): |
| 71 | # If the input data is passed in 'dense' format, we merge the |
| 72 | # potential duplicate cluster-obj pairs before anything else. |
no outgoing calls
no test coverage detected