Return a new InstanceData with void clusters, objects and pairs removed. IMPORTANT: By convention, we assume `y ∈ [0, num_classes-1]` ARE ALL VALID LABELS (i.e. not 'void', 'ignored', 'unknown', etc), while `y < 0` AND `y >= num_classes` ARE VOID LABELS.
(
self,
num_classes: int
)
| 545 | return is_a_void, is_pair_void, pair_cropped_count |
| 546 | |
| 547 | def remove_void( |
| 548 | self, |
| 549 | num_classes: int |
| 550 | ) -> Tuple['InstanceData', torch.Tensor]: |
| 551 | """Return a new InstanceData with void clusters, objects and |
| 552 | pairs removed. |
| 553 | |
| 554 | IMPORTANT: |
| 555 | By convention, we assume `y ∈ [0, num_classes-1]` ARE ALL |
| 556 | VALID LABELS (i.e. not 'void', 'ignored', 'unknown', etc), |
| 557 | while `y < 0` AND `y >= num_classes` ARE VOID LABELS. |
| 558 | This applies to both `Data.y` and `Data.obj.y`. |
| 559 | |
| 560 | Points with 'void' labels are handled following the procedure |
| 561 | proposed in: |
| 562 | - https://arxiv.org/abs/1801.00868 |
| 563 | - https://arxiv.org/abs/1905.01220 |
| 564 | |
| 565 | More precisely: |
| 566 | - predictions (i.e. clusters here) containing more than 50% of |
| 567 | 'void' points are removed from the metrics computation |
| 568 | - targets (i.e. objects here) containing more than 50% of |
| 569 | 'void' points are removed from the metrics computation |
| 570 | - the remaining 'void' points are ignored when computing the |
| 571 | prediction-target (i.e. cluster-object here) IoUs |
| 572 | |
| 573 | To this end, the present function returns: |
| 574 | - `instance_data`: a new InstanceData object with all void |
| 575 | clusters, objects, and pairs removed |
| 576 | - `non_void_mask`: boolean mask spanning the clusters, |
| 577 | indicating the clusters that were preserved in the |
| 578 | `instance_data`. This mask can be used outside of this |
| 579 | function to subsample cluster-wise information after |
| 580 | void-removal |
| 581 | |
| 582 | NB: by construction, removing pairs in `pair_mask` from the |
| 583 | InstanceData will also remove all target objects containing |
| 584 | 'void' points. Importantly, this assumes, however, that the |
| 585 | raw instance annotations in the datasets are semantically |
| 586 | pure: all annotated instances contain points of the same |
| 587 | class. Said otherwise: IF AN INSTANCE CONTAINS A SINGLE |
| 588 | 'VOID' POINT, THEN ALL OF ITS POINTS ARE 'VOID'. |
| 589 | """ |
| 590 | # Get the masks for indexing void clusters and pairs |
| 591 | is_cluster_void, is_pair_void, pair_cropped_count = \ |
| 592 | self.search_void(num_classes) |
| 593 | |
| 594 | # Create a new InstanceData without void data |
| 595 | idx = self.indices |
| 596 | idx = idx[~is_pair_void] |
| 597 | idx = consecutive_cluster(idx)[0] |
| 598 | obj = self.obj[~is_pair_void] |
| 599 | count = self.count[~is_pair_void] |
| 600 | y = self.y[~is_pair_void] |
| 601 | pair_cropped_count = pair_cropped_count[~is_pair_void] |
| 602 | instance_data = self.__class__(idx, obj, count, y, dense=True) |
| 603 | |
| 604 | # Save the pair_cropped_count in the new InstanceData. This will |
nothing calls this directly
no test coverage detected