-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] Support PointRCNN backbone (#974)
* [Refactor] Main code modification for coordinate system refactor (#677) * [Enhance] Add script for data update (#774) * Fixed wrong config paths and fixed a bug in test * Fixed metafile * Coord sys refactor (main code) * Update test_waymo_dataset.py * Manually resolve conflict * Removed unused lines and fixed imports * remove coord2box and box2coord * update dir_limit_offset * Some minor improvements * Removed some \s in comments * Revert a change * Change Box3DMode to Coord3DMode where points are converted * Fix points_in_bbox function * Fix Imvoxelnet config * Revert adding a line * Fix rotation bug when batch size is 0 * Keep sign of dir_scores as before * Fix several comments * Add a comment * Fix docstring * Add data update scripts * Fix comments * fix import (#839) * [Enhance] refactor iou_neg_piecewise_sampler.py (#842) * [Refactor] Main code modification for coordinate system refactor (#677) * [Enhance] Add script for data update (#774) * Fixed wrong config paths and fixed a bug in test * Fixed metafile * Coord sys refactor (main code) * Update test_waymo_dataset.py * Manually resolve conflict * Removed unused lines and fixed imports * remove coord2box and box2coord * update dir_limit_offset * Some minor improvements * Removed some \s in comments * Revert a change * Change Box3DMode to Coord3DMode where points are converted * Fix points_in_bbox function * Fix Imvoxelnet config * Revert adding a line * Fix rotation bug when batch size is 0 * Keep sign of dir_scores as before * Fix several comments * Add a comment * Fix docstring * Add data update scripts * Fix comments * fix import * refactor iou_neg_piecewise_sampler.py * add docstring * modify docstring Co-authored-by: Yezhen Cong <[email protected]> Co-authored-by: THU17cyz <[email protected]> * [Feature] Add roipooling cuda ops (#843) * [Refactor] Main code modification for coordinate system refactor (#677) * [Enhance] Add script for data update (#774) * Fixed wrong config paths and fixed a bug in test * Fixed metafile * Coord sys refactor (main code) * Update test_waymo_dataset.py * Manually resolve conflict * Removed unused lines and fixed imports * remove coord2box and box2coord * update dir_limit_offset * Some minor improvements * Removed some \s in comments * Revert a change * Change Box3DMode to Coord3DMode where points are converted * Fix points_in_bbox function * Fix Imvoxelnet config * Revert adding a line * Fix rotation bug when batch size is 0 * Keep sign of dir_scores as before * Fix several comments * Add a comment * Fix docstring * Add data update scripts * Fix comments * fix import * add roipooling cuda ops * add roi extractor * add test_roi_extractor unittest * Modify setup.py to install roipooling ops * modify docstring * remove enlarge bbox in roipoint pooling * add_roipooling_ops * modify docstring Co-authored-by: Yezhen Cong <[email protected]> Co-authored-by: THU17cyz <[email protected]> * [Refactor] Refactor code structure and docstrings (#803) * refactor points_in_boxes * Merge same functions of three boxes * More docstring fixes and unify x/y/z size * Add "optional" and fix "Default" * Add "optional" and fix "Default" * Add "optional" and fix "Default" * Add "optional" and fix "Default" * Add "optional" and fix "Default" * Remove None in function param type * Fix unittest * Add comments for NMS functions * Merge methods of Points * Add unittest * Add optional and default value * Fix box conversion and add unittest * Fix comments * Add unit test * Indent * Fix CI * Remove useless \\ * Remove useless \\ * Remove useless \\ * Remove useless \\ * Remove useless \\ * Add unit test for box bev * More unit tests and refine docstrings in box_np_ops * Fix comment * Add deprecation warning * support pointrcnn backbone * add docstring * modify docstring * modify docstring * modify docstring * Update pointnet2_fp_neck.py * add code block * refine docstring & code * add unittest on fp_neck * refine unittest * refine unittest * refine unittest * refine unittest * refine unittest * fix docstring Co-authored-by: Yezhen Cong <[email protected]> Co-authored-by: Xi Liu <[email protected]> Co-authored-by: THU17cyz <[email protected]> Co-authored-by: xiliu8006 <[email protected]>
- Loading branch information
1 parent
7c62335
commit b8856a1
Showing
9 changed files
with
170 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
from mmcv.runner import BaseModule | ||
from torch import nn as nn | ||
|
||
from mmdet3d.ops import PointFPModule | ||
from mmdet.models import NECKS | ||
|
||
|
||
@NECKS.register_module() | ||
class PointNetFPNeck(BaseModule): | ||
r"""PointNet FP Module used in PointRCNN. | ||
Refer to the `official code <https://github.com/charlesq34/pointnet2>`_. | ||
.. code-block:: none | ||
sa_n ---------------------------------------- | ||
| | ||
... --------------------------------- | | ||
| | | ||
sa_1 ------------- | | | ||
| | | | ||
sa_0 -> fp_0 -> fp_module ->fp_1 -> ... -> fp_module -> fp_n | ||
sa_n including sa_xyz (torch.Tensor) and sa_features (torch.Tensor) | ||
fp_n including fp_xyz (torch.Tensor) and fp_features (torch.Tensor) | ||
Args: | ||
fp_channels (tuple[tuple[int]]): Tuple of mlp channels in FP modules. | ||
init_cfg (dict or list[dict], optional): Initialization config dict. | ||
Default: None | ||
""" | ||
|
||
def __init__(self, fp_channels, init_cfg=None): | ||
super(PointNetFPNeck, self).__init__(init_cfg=init_cfg) | ||
|
||
self.num_fp = len(fp_channels) | ||
self.FP_modules = nn.ModuleList() | ||
for cur_fp_mlps in fp_channels: | ||
self.FP_modules.append(PointFPModule(mlp_channels=cur_fp_mlps)) | ||
|
||
def _extract_input(self, feat_dict): | ||
"""Extract inputs from features dictionary. | ||
Args: | ||
feat_dict (dict): Feature dict from backbone, which may contain | ||
the following keys and values: | ||
- sa_xyz (list[torch.Tensor]): Points of each sa module | ||
in shape (N, 3). | ||
- sa_features (list[torch.Tensor]): Output features of | ||
each sa module in shape (N, M). | ||
Returns: | ||
list[torch.Tensor]: Coordinates of multiple levels of points. | ||
list[torch.Tensor]: Features of multiple levels of points. | ||
""" | ||
sa_xyz = feat_dict['sa_xyz'] | ||
sa_features = feat_dict['sa_features'] | ||
assert len(sa_xyz) == len(sa_features) | ||
|
||
return sa_xyz, sa_features | ||
|
||
def forward(self, feat_dict): | ||
"""Forward pass. | ||
Args: | ||
feat_dict (dict): Feature dict from backbone. | ||
Returns: | ||
dict[str, torch.Tensor]: Outputs of the Neck. | ||
- fp_xyz (torch.Tensor): The coordinates of fp features. | ||
- fp_features (torch.Tensor): The features from the last | ||
feature propogation layers. | ||
""" | ||
sa_xyz, sa_features = self._extract_input(feat_dict) | ||
|
||
fp_feature = sa_features[-1] | ||
fp_xyz = sa_xyz[-1] | ||
|
||
for i in range(self.num_fp): | ||
# consume the points in a bottom-up manner | ||
fp_feature = self.FP_modules[i](sa_xyz[-(i + 2)], sa_xyz[-(i + 1)], | ||
sa_features[-(i + 2)], fp_feature) | ||
fp_xyz = sa_xyz[-(i + 2)] | ||
|
||
ret = dict(fp_xyz=fp_xyz, fp_features=fp_feature) | ||
return ret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters