From 66417d1f43a049a8d023ef68fbde039af1415022 Mon Sep 17 00:00:00 2001 From: ZwwWayne Date: Sat, 11 Jul 2020 23:12:02 +0800 Subject: [PATCH 1/9] Refine docs and license --- LICENSE | 203 ++++++++++++++++++++ docs/api.rst | 10 + docs/config.md | 2 +- docs/getting_started.md | 20 +- docs/install.md | 40 ++-- mmdet3d/core/anchor/anchor_3d_generator.py | 26 +-- mmdet3d/core/bbox/structures/base_box3d.py | 66 ++----- mmdet3d/core/bbox/structures/cam_box3d.py | 54 ++---- mmdet3d/core/bbox/structures/depth_box3d.py | 24 +-- mmdet3d/core/bbox/structures/lidar_box3d.py | 28 +-- mmdet3d/core/visualizer/show_result.py | 2 +- requirements/build.txt | 3 - requirements/runtime.txt | 14 +- 13 files changed, 319 insertions(+), 173 deletions(-) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000..04adf5cbc6 --- /dev/null +++ b/LICENSE @@ -0,0 +1,203 @@ +Copyright 2018-2019 Open-MMLab. All rights reserved. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2018-2019 Open-MMLab. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/docs/api.rst b/docs/api.rst index 5843be582a..458fe631bd 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -19,6 +19,16 @@ evaluation .. automodule:: mmdet3d.core.evaluation :members: +visualizer +^^^^^^^^^^^^^^^ +.. automodule:: mmdet3d.core.visualizer + :members: + +voxel +^^^^^^^^^^^^^^^ +.. automodule:: mmdet3d.core.voxel + :members: + post_processing ^^^^^^^^^^^^^^^ .. automodule:: mmdet3d.core.post_processing diff --git a/docs/config.md b/docs/config.md index 8b0c42edb8..d4c5cb00cd 100644 --- a/docs/config.md +++ b/docs/config.md @@ -6,7 +6,7 @@ You may also pass `--options xxx.yyy=zzz` to see updated config. ## Config File Structure There are 4 basic component types under `config/_base_`, dataset, model, schedule, default_runtime. -Many methods could be easily constructed with one of each like SECOND, PointPillars, PartA2 and VoteNet. +Many methods could be easily constructed with one of each like SECOND, PointPillars, PartA2, and VoteNet. The configs that are composed by components from `_base_` are called _primitive_. For all configs under the same folder, it is recommended to have only **one** _primitive_ config. All other configs should inherit from the _primitive_ config. In this way, the maximum of inheritance level is 3. diff --git a/docs/getting_started.md b/docs/getting_started.md index 6ceebe16b0..2fe137de10 100644 --- a/docs/getting_started.md +++ b/docs/getting_started.md @@ -252,8 +252,8 @@ By default we evaluate the model on the validation set after each epoch, you can evaluation = dict(interval=12) # This evaluate the model per 12 epoch. ``` -**\*Important\***: The default learning rate in config files is for 8 GPUs and the exact batch size is marked by the config's file name, e.g. '2x8' means 2 samples per GPU using 8 GPUs. -According to the [Linear Scaling Rule](https://arxiv.org/abs/1706.02677), you need to set the learning rate proportional to the batch size if you use different GPUs or images per GPU, e.g., lr=0.01 for 4 GPUs * 2 img/gpu and lr=0.08 for 16 GPUs * 4 img/gpu. +**Important**: The default learning rate in config files is for 8 GPUs and the exact batch size is marked by the config's file name, e.g. '2x8' means 2 samples per GPU using 8 GPUs. +According to the [Linear Scaling Rule](https://arxiv.org/abs/1706.02677), you need to set the learning rate proportional to the batch size if you use different GPUs or images per GPU, e.g., lr=0.01 for 4 GPUs * 2 img/gpu and lr=0.08 for 16 GPUs * 4 img/gpu. However, since most of the models in this repo use ADAM rather than SGD for optimization, the rule may not hold and users need to tune the learning rate by themselves. ### Train with a single GPU @@ -314,7 +314,14 @@ CUDA_VISIBLE_DEVICES=4,5,6,7 PORT=29501 ./tools/dist_train.sh ${CONFIG_FILE} 4 If you use launch training jobs with Slurm, there are two ways to specify the ports. -1. Modify the config files (usually the 6th line from the bottom in config files) to set different communication ports. +1. Set the port through `--options`. This is more recommended since it does not change the original configs. + + ```shell + CUDA_VISIBLE_DEVICES=0,1,2,3 GPUS=4 ./tools/slurm_train.sh ${PARTITION} ${JOB_NAME} config1.py ${WORK_DIR} --options 'dist_params.port=29500' + CUDA_VISIBLE_DEVICES=4,5,6,7 GPUS=4 ./tools/slurm_train.sh ${PARTITION} ${JOB_NAME} config2.py ${WORK_DIR} --options 'dist_params.port=29501' + ``` + +2. Modify the config files (usually the 6th line from the bottom in config files) to set different communication ports. In `config1.py`, @@ -335,13 +342,6 @@ If you use launch training jobs with Slurm, there are two ways to specify the po CUDA_VISIBLE_DEVICES=4,5,6,7 GPUS=4 ./tools/slurm_train.sh ${PARTITION} ${JOB_NAME} config2.py ${WORK_DIR} ``` -2. Set the port through `--options`. This is more recommended since it does not change the original configs. - - ```shell - CUDA_VISIBLE_DEVICES=0,1,2,3 GPUS=4 ./tools/slurm_train.sh ${PARTITION} ${JOB_NAME} config1.py ${WORK_DIR} --options 'dist_params.port=29500' - CUDA_VISIBLE_DEVICES=4,5,6,7 GPUS=4 ./tools/slurm_train.sh ${PARTITION} ${JOB_NAME} config2.py ${WORK_DIR} --options 'dist_params.port=29501' - ``` - ## Useful tools We provide lots of useful tools under `tools/` directory. diff --git a/docs/install.md b/docs/install.md index 2b3943229f..cbe7afabda 100644 --- a/docs/install.md +++ b/docs/install.md @@ -45,18 +45,30 @@ conda install pytorch=1.3.1 cudatoolkit=9.2 torchvision=0.4.2 -c pytorch If you build PyTorch from source instead of installing the prebuilt pacakge, you can use more CUDA versions such as 9.0. -c. Clone the mmdetection repository. +c. Install [MMCV](https://mmcv.readthedocs.io/en/latest/). +*mmcv-full* is necessary since MMDetection3D relies on MMDetection, CUDA ops in *mmcv-full* are required. +The pre-build *mmcv-full* could be installed by running: (available versions could be found [here](https://mmcv.readthedocs.io/en/latest/#install-with-pip)) ```shell -git clone https://github.com/open-mmlab/mmdetection.git -cd mmdetection +pip install mmcv-full==latest+torch1.5.0+cu101 -f https://openmmlab.oss-accelerate.aliyuncs.com/mmcv/dist/index.html ``` -d. Install build requirements and then install mmdetection. -(We install our forked version of pycocotools via the github repo instead of pypi -for better compatibility with our repo.) +Optionally, you could also build full version from source: + +```shell +pip install mmcv-full +``` + +d. Install [MMDetection](https://github.com/open-mmlab/mmdetection). + +```shell +pip install git+https://github.com/open-mmlab/mmdetection.git +``` +Optionally, you could also build full version from source: ```shell +git clone https://github.com/open-mmlab/mmdetection.git +cd mmdetection pip install -r requirements/build.txt pip install cython # cython is necessary for pycocotools pip install "git+https://github.com/open-mmlab/cocoapi.git#subdirectory=pycocotools" @@ -69,14 +81,14 @@ If you build mmdetection on macOS, replace the last command with CC=clang CXX=clang++ CFLAGS='-stdlib=libc++' pip install -e . ``` -e. Clone the mmdetection3d repository. +e. Clone the MMDetection3D repository. ```shell git clone https://github.com/open-mmlab/mmdetection3d.git cd mmdetection3d ``` -f.Install build requirements and then install mmdetection3d. +f.Install build requirements and then install MMDetection3D. ```shell pip install -r requirements/build.txt @@ -116,14 +128,14 @@ conda activate open-mmlab # install latest pytorch prebuilt with the default prebuilt CUDA version (usually the latest) conda install -c pytorch pytorch torchvision -y + +# install mmcv +pip install mmcv-full + +# install mmdetection git clone https://github.com/open-mmlab/mmdetection.git -cd mmdetection -pip install -r requirements/build.txt -pip install cython -pip install "git+https://github.com/open-mmlab/cocoapi.git#subdirectory=pycocotools" -pip install -v -e . -cd .. +# install mmdetection3d git clone https://github.com/open-mmlab/mmdetection3d.git cd mmdetection3d pip install -r requirements/build.txt diff --git a/mmdet3d/core/anchor/anchor_3d_generator.py b/mmdet3d/core/anchor/anchor_3d_generator.py index dfe066dbd1..ccaa39ad9c 100644 --- a/mmdet3d/core/anchor/anchor_3d_generator.py +++ b/mmdet3d/core/anchor/anchor_3d_generator.py @@ -107,8 +107,7 @@ def grid_anchors(self, featmap_sizes, device='cuda'): def single_level_grid_anchors(self, featmap_size, scale, device='cuda'): """Generate grid anchors of a single level feature map. - Note: - This function is usually called by method ``self.grid_anchors``. + This function is usually called by method ``self.grid_anchors``. Args: featmap_size (tuple[int]): Size of the feature map. @@ -215,19 +214,20 @@ class AlignedAnchor3DRangeGenerator(Anchor3DRangeGenerator): """Aligned 3D Anchor Generator by range. This anchor generator uses a different manner to generate the positions - of anchors' centers from `Anchor3DRangeGenerator`. + of anchors' centers from :class:`Anchor3DRangeGenerator`. Note: - The `align` means that the anchor's center is aligned with the voxel grid, - which is also the feature grid. The previous implementation of - `Anchor3DRangeGenerator` does not generate the anchors' center according - to the voxel grid. Rather, it generates the center by uniformly - distributing the anchors inside the minimum and maximum anchor ranges - according to the feature map sizes. - However, this makes the anchors center does not match the feature grid. - The AlignedAnchor3DRangeGenerator add + 1 when using the feature map sizes - to obtain the corners of the voxel grid. Then it shifts the coordinates to - the center of voxel grid and use the left up corner to distribute anchors. + The `align` means that the anchor's center is aligned with the voxel + grid, which is also the feature grid. The previous implementation of + :class:`Anchor3DRangeGenerator` does not generate the anchors' center + according to the voxel grid. Rather, it generates the center by + uniformly distributing the anchors inside the minimum and maximum + anchor ranges according to the feature map sizes. + However, this makes the anchors center does not match the feature grid. + The AlignedAnchor3DRangeGenerator add + 1 when using the feature map + sizes to obtain the corners of the voxel grid. Then it shifts the + coordinates to the center of voxel grid and use the left up corner to + distribute anchors. Args: anchor_corner (bool): Whether to align with the corner of the voxel diff --git a/mmdet3d/core/bbox/structures/base_box3d.py b/mmdet3d/core/bbox/structures/base_box3d.py index c9ef347484..2b0dafe4cc 100644 --- a/mmdet3d/core/bbox/structures/base_box3d.py +++ b/mmdet3d/core/bbox/structures/base_box3d.py @@ -59,57 +59,35 @@ def __init__(self, tensor, box_dim=7, with_yaw=True, origin=(0.5, 0.5, 0)): @property def volume(self): - """Compute the volume of all the boxes. - - Returns: - torch.Tensor: A vector with volume of each box. - """ + """torch.Tensor: A vector with volume of each box.""" return self.tensor[:, 3] * self.tensor[:, 4] * self.tensor[:, 5] @property def dims(self): - """Calculate the length in each dimension of all the boxes. - - Convert the boxes to the form of (x_size, y_size, z_size). - - Returns: - torch.Tensor: Corners of each box with size (N, 8, 3). - """ + """torch.Tensor: Corners of each box with size (N, 8, 3).""" return self.tensor[:, 3:6] @property def yaw(self): - """Obtain the rotations of all the boxes. - - Returns: - torch.Tensor: A vector with yaw of each box. + """torch.Tensor: A vector with yaw of each box. """ return self.tensor[:, 6] @property def height(self): - """Obtain the height of all the boxes. - - Returns: - torch.Tensor: A vector with height of each box. + """torch.Tensor: A vector with height of each box. """ return self.tensor[:, 5] @property def top_height(self): - """Obtain the top height of all the boxes. - - Returns: - torch.Tensor: A vector with the top height of each box. + """torch.Tensor: A vector with the top height of each box. """ return self.bottom_height + self.height @property def bottom_height(self): - """Obtain the bottom's height of all the boxes. - - Returns: - torch.Tensor: A vector with bottom's height of each box. + """torch.Tensor: A vector with bottom's height of each box. """ return self.tensor[:, 2] @@ -124,7 +102,7 @@ def center(self): The relative position of the centers in different kinds of boxes are different, e.g., the relative center of a boxes is (0.5, 1.0, 0.5) in camera and (0.5, 0.5, 0) in lidar. - It is recommended to use `bottom_center` or `gravity_center` + It is recommended to use ``bottom_center`` or ``gravity_center`` for more clear usage. Returns: @@ -134,28 +112,19 @@ def center(self): @property def bottom_center(self): - """Calculate the bottom center of all the boxes. - - Returns: - torch.Tensor: A tensor with center of each box. + """torch.Tensor: A tensor with center of each box. """ return self.tensor[:, :3] @property def gravity_center(self): - """Calculate the gravity center of all the boxes. - - Returns: - torch.Tensor: A tensor with center of each box. + """torch.Tensor: A tensor with center of each box. """ pass @property def corners(self): - """Calculate the coordinates of corners of all the boxes. - - Returns: - torch.Tensor: a tensor with 8 corners of each box. + """torch.Tensor: a tensor with 8 corners of each box. """ pass @@ -235,8 +204,8 @@ def convert_to(self, dst, rt_mat=None): to LiDAR. This requires a transformation matrix. Returns: - A new object of :class:`BaseInstance3DBoxes` after indexing: \ - The converted box of the same type in the `dst` mode. + :obj:`BaseInstance3DBoxes`: The converted box of the same type \ + in the `dst` mode. """ pass @@ -294,7 +263,8 @@ def __getitem__(self, item): subject to Pytorch's indexing semantics. Returns: - A new object of :class:`BaseInstances3DBoxes` after indexing. + :obj:`BaseInstances3DBoxes`: A new object of \ + :class:`BaseInstances3DBoxes` after indexing. """ original_type = type(self) if isinstance(item, int): @@ -416,7 +386,7 @@ def overlaps(cls, boxes1, boxes2, mode='iou'): Note: This function calculates the overlaps between boxes1 and boxes2, - boxes1 and boxes2 are not necessarily in the same type. + ``boxes1`` and ``boxes2`` should be in the same type. Args: boxes1 (:obj:`BaseInstanceBoxes`): Boxes 1 contain N boxes. @@ -424,7 +394,7 @@ def overlaps(cls, boxes1, boxes2, mode='iou'): mode (str, optional): Mode of iou calculation. Defaults to 'iou'. Returns: - torch.Tensor: Calculated iou of boxes. + torch.Tensor: Calculated iou of boxes' heights. """ assert isinstance(boxes1, BaseInstance3DBoxes) assert isinstance(boxes2, BaseInstance3DBoxes) @@ -477,8 +447,8 @@ def new_box(self, data): data (torch.Tensor | numpy.array | list): Data to be copied. Returns: - :obj:`BaseInstance3DBoxes`: A new bbox with data and other \ - properties are similar to self. + :obj:`BaseInstance3DBoxes`: A new bbox object with ``data``, \ + the object's other properties are similar to ``self``. """ new_tensor = self.tensor.new_tensor(data) \ if not isinstance(data, torch.Tensor) else data.to(self.device) diff --git a/mmdet3d/core/bbox/structures/cam_box3d.py b/mmdet3d/core/bbox/structures/cam_box3d.py index a900fe96dd..e33d5e00d0 100644 --- a/mmdet3d/core/bbox/structures/cam_box3d.py +++ b/mmdet3d/core/bbox/structures/cam_box3d.py @@ -36,38 +36,26 @@ class CameraInstance3DBoxes(BaseInstance3DBoxes): @property def height(self): - """Obtain the heights of all the boxes. - - Returns: - torch.Tensor: A vector with height of each box. + """torch.Tensor: A vector with height of each box. """ return self.tensor[:, 4] @property def top_height(self): - """Obtain the top height of all the boxes. - - Returns: - torch.Tensor: A vector with the top height of each box. + """torch.Tensor: A vector with the top height of each box. """ # the positive direction is down rather than up return self.bottom_height - self.height @property def bottom_height(self): - """Obtain the bottom's height of all the boxes. - - Returns: - torch.Tensor: A vector with bottom's height of each box. + """torch.Tensor: A vector with bottom's height of each box. """ return self.tensor[:, 1] @property def gravity_center(self): - """Calculate the gravity center of all the boxes. - - Returns: - torch.Tensor: A tensor with center of each box. + """torch.Tensor: A tensor with center of each box. """ bottom_center = self.bottom_center gravity_center = torch.zeros_like(bottom_center) @@ -122,20 +110,15 @@ def corners(self): @property def bev(self): - """Calculate the 2D bounding boxes in BEV with rotation. - - Returns: - torch.Tensor: A n x 5 tensor of 2D BEV box of each box. \ - The box is in XYWHR format. + """torch.Tensor: A n x 5 tensor of 2D BEV box of each box + with rotation in XYWHR format. """ return self.tensor[:, [0, 2, 3, 5, 6]] @property def nearest_bev(self): - """Calculate the 2D bounding boxes in BEV without rotation. - - Returns: - torch.Tensor: A tensor of 2D BEV box of each box. + """torch.Tensor: A tensor of 2D BEV box of each box + without rotation. """ # Obtain BEV boxes with rotation in XZWHR format bev_rotated_boxes = self.bev @@ -244,22 +227,19 @@ def in_range_bev(self, box_range): def height_overlaps(cls, boxes1, boxes2, mode='iou'): """Calculate height overlaps of two boxes. - Note: - This function calculates the height overlaps between boxes1 and - boxes2, where boxes1 and boxes2 should be in the same type. + This function calculates the height overlaps between ``boxes1`` and + ``boxes2``, where ``boxes1`` and ``boxes2`` should be in the same type. Args: - boxes1 (:obj:`BaseInstanceBoxes`): Boxes 1 contain N boxes. - boxes2 (:obj:`BaseInstanceBoxes`): Boxes 2 contain M boxes. + boxes1 (:obj:`CameraInstance3DBoxes`): Boxes 1 contain N boxes. + boxes2 (:obj:`CameraInstance3DBoxes`): Boxes 2 contain M boxes. mode (str, optional): Mode of iou calculation. Defaults to 'iou'. Returns: - torch.Tensor: Calculated iou of boxes. + torch.Tensor: Calculated iou of boxes' heights. """ - assert isinstance(boxes1, BaseInstance3DBoxes) - assert isinstance(boxes2, BaseInstance3DBoxes) - assert type(boxes1) == type(boxes2), '"boxes1" and "boxes2" should' \ - f'be in the same type, got {type(boxes1)} and {type(boxes2)}.' + assert isinstance(boxes1, CameraInstance3DBoxes) + assert isinstance(boxes2, CameraInstance3DBoxes) boxes1_top_height = boxes1.top_height.view(-1, 1) boxes1_bottom_height = boxes1.bottom_height.view(-1, 1) @@ -281,13 +261,13 @@ def convert_to(self, dst, rt_mat=None): dst (:obj:`BoxMode`): The target Box mode. rt_mat (np.dnarray | torch.Tensor): The rotation and translation matrix between different coordinates. Defaults to None. - The conversion from `src` coordinates to `dst` coordinates + The conversion from ``src`` coordinates to ``dst`` coordinates usually comes along the change of sensors, e.g., from camera to LiDAR. This requires a transformation matrix. Returns: :obj:`BaseInstance3DBoxes`: \ - The converted box of the same type in the `dst` mode. + The converted box of the same type in the ``dst`` mode. """ from .box_3d_mode import Box3DMode return Box3DMode.convert( diff --git a/mmdet3d/core/bbox/structures/depth_box3d.py b/mmdet3d/core/bbox/structures/depth_box3d.py index fcb7479e69..7011e2fc49 100644 --- a/mmdet3d/core/bbox/structures/depth_box3d.py +++ b/mmdet3d/core/bbox/structures/depth_box3d.py @@ -34,10 +34,7 @@ class DepthInstance3DBoxes(BaseInstance3DBoxes): @property def gravity_center(self): - """Calculate the gravity center of all the boxes. - - Returns: - torch.Tensor: A tensor with center of each box. + """torch.Tensor: A tensor with center of each box. """ bottom_center = self.bottom_center gravity_center = torch.zeros_like(bottom_center) @@ -90,20 +87,15 @@ def corners(self): @property def bev(self): - """Calculate the 2D bounding boxes in BEV with rotation. - - Returns: - torch.Tensor: A n x 5 tensor of 2D BEV box of each box. \ - The box is in XYWHR format. + """torch.Tensor: A n x 5 tensor of 2D BEV box of each box + in XYWHR format. """ return self.tensor[:, [0, 1, 3, 4, 6]] @property def nearest_bev(self): - """Calculate the 2D bounding boxes in BEV without rotation. - - Returns: - torch.Tensor: A tensor of 2D BEV box of each box. + """torch.Tensor: A tensor of 2D BEV box of each box + without rotation. """ # Obtain BEV boxes with rotation in XYWHR format bev_rotated_boxes = self.bev @@ -225,13 +217,13 @@ def convert_to(self, dst, rt_mat=None): dst (:obj:`BoxMode`): The target Box mode. rt_mat (np.ndarray | torch.Tensor): The rotation and translation matrix between different coordinates. Defaults to None. - The conversion from `src` coordinates to `dst` coordinates + The conversion from ``src`` coordinates to ``dst`` coordinates usually comes along the change of sensors, e.g., from camera to LiDAR. This requires a transformation matrix. Returns: - :obj:`BaseInstance3DBoxes`: \ - The converted box of the same type in the `dst` mode. + :obj:`DepthInstance3DBoxes`: \ + The converted box of the same type in the ``dst`` mode. """ from .box_3d_mode import Box3DMode return Box3DMode.convert( diff --git a/mmdet3d/core/bbox/structures/lidar_box3d.py b/mmdet3d/core/bbox/structures/lidar_box3d.py index f223f76e7b..ba369fd381 100644 --- a/mmdet3d/core/bbox/structures/lidar_box3d.py +++ b/mmdet3d/core/bbox/structures/lidar_box3d.py @@ -34,10 +34,7 @@ class LiDARInstance3DBoxes(BaseInstance3DBoxes): @property def gravity_center(self): - """Calculate the gravity center of all the boxes. - - Returns: - torch.Tensor: A tensor with center of each box. + """torch.Tensor: A tensor with center of each box. """ bottom_center = self.bottom_center gravity_center = torch.zeros_like(bottom_center) @@ -47,7 +44,8 @@ def gravity_center(self): @property def corners(self): - """Calculate the coordinates of corners of all the boxes. + """torch.Tensor: Coordinates of corners of all the boxes + in shape (N, 8, 3). Convert the boxes to corners in clockwise order, in form of (x0y0z0, x0y0z1, x0y1z1, x0y1z0, x1y0z0, x1y0z1, x1y1z1, x1y1z0) @@ -66,9 +64,6 @@ def corners(self): | / oriign | / left y<-------- + ----------- + (x0, y1, z0) (x0, y0, z0) - - Returns: - torch.Tensor: Corners of each box with size (N, 8, 3). """ # TODO: rotation_3d_in_axis function do not support # empty tensor currently. @@ -90,20 +85,15 @@ def corners(self): @property def bev(self): - """Calculate the 2D bounding boxes in BEV with rotation. - - Returns: - torch.Tensor: A n x 5 tensor of 2D BEV box of each box. \ - The box is in XYWHR format. + """torch.Tensor: 2D BEV box of each box with rotation + in XYWHR format. """ return self.tensor[:, [0, 1, 3, 4, 6]] @property def nearest_bev(self): - """Calculate the 2D bounding boxes in BEV without rotation. - - Returns: - torch.Tensor: A tensor of 2D BEV box of each box. + """torch.Tensor: A tensor of 2D BEV box of each box + without rotation """ # Obtain BEV boxes with rotation in XYWHR format bev_rotated_boxes = self.bev @@ -218,13 +208,13 @@ def convert_to(self, dst, rt_mat=None): dst (:obj:`BoxMode`): the target Box mode rt_mat (np.ndarray | torch.Tensor): The rotation and translation matrix between different coordinates. Defaults to None. - The conversion from `src` coordinates to `dst` coordinates + The conversion from ``src`` coordinates to ``dst`` coordinates usually comes along the change of sensors, e.g., from camera to LiDAR. This requires a transformation matrix. Returns: :obj:`BaseInstance3DBoxes`: \ - The converted box of the same type in the `dst` mode. + The converted box of the same type in the ``dst`` mode. """ from .box_3d_mode import Box3DMode return Box3DMode.convert( diff --git a/mmdet3d/core/visualizer/show_result.py b/mmdet3d/core/visualizer/show_result.py index 8c414bb6f5..a21502840b 100644 --- a/mmdet3d/core/visualizer/show_result.py +++ b/mmdet3d/core/visualizer/show_result.py @@ -5,7 +5,7 @@ def _write_ply(points, out_filename): - """Write points into ply format for meshlab visualization. + """Write points into ``ply`` format for meshlab visualization. Args: points (np.ndarray): Points in shape (N, dim). diff --git a/requirements/build.txt b/requirements/build.txt index 0da9929b1c..e69de29bb2 100644 --- a/requirements/build.txt +++ b/requirements/build.txt @@ -1,3 +0,0 @@ -# These must be installed before building mmdetection -numpy -torch>=1.3 diff --git a/requirements/runtime.txt b/requirements/runtime.txt index d3b1647254..31aab16b43 100644 --- a/requirements/runtime.txt +++ b/requirements/runtime.txt @@ -1,17 +1,9 @@ +lyft_dataset_sdk networkx>=2.2,<2.3 -trimesh>=2.35.39,<2.35.40 -matplotlib -mmcv>=1.0.2 +# we may unlock the verion of numba in the future numba==0.48.0 -numpy nuscenes-devkit==1.0.5 -lyft_dataset_sdk -# need older pillow until torchvision is fixed -Pillow<=6.2.2 plyfile -six -terminaltables -torch>=1.3 -torchvision # by default we also use tensorboard to log results tensorboard +trimesh>=2.35.39,<2.35.40 From c883655e2aa8a466875a830c19513f4a8fece3b7 Mon Sep 17 00:00:00 2001 From: ZwwWayne Date: Sat, 11 Jul 2020 23:23:53 +0800 Subject: [PATCH 2/9] Change order of install --- .readthedocs.yml | 1 + requirements/readthedocs.txt | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index e4ee8c9c19..c4dc4b39ab 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -7,3 +7,4 @@ python: - requirements: requirements/build.txt - requirements: requirements/runtime.txt - requirements: requirements/readthedocs.txt + - requirements: git+https://github.com/open-mmlab/mmdetection.git diff --git a/requirements/readthedocs.txt b/requirements/readthedocs.txt index e08deec84c..0542bfce6d 100644 --- a/requirements/readthedocs.txt +++ b/requirements/readthedocs.txt @@ -1,4 +1,3 @@ mmcv torch torchvision -git+https://github.com/open-mmlab/mmdetection.git From b0ec2d0de087f15d64a56d15dc5cb778839c6709 Mon Sep 17 00:00:00 2001 From: ZwwWayne Date: Sat, 11 Jul 2020 23:27:07 +0800 Subject: [PATCH 3/9] Clean unnecessary requirements --- .readthedocs.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index c4dc4b39ab..cce3591ce0 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -4,7 +4,6 @@ python: version: 3.7 install: - requirements: requirements/docs.txt - - requirements: requirements/build.txt - requirements: requirements/runtime.txt - requirements: requirements/readthedocs.txt - requirements: git+https://github.com/open-mmlab/mmdetection.git From 67f5dfc8204543d58c6e65b80781b32110f45e44 Mon Sep 17 00:00:00 2001 From: ZwwWayne Date: Sat, 11 Jul 2020 23:38:14 +0800 Subject: [PATCH 4/9] Install mmdet manually in readthedocs --- .readthedocs.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index cce3591ce0..fe2dd59272 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -6,4 +6,5 @@ python: - requirements: requirements/docs.txt - requirements: requirements/runtime.txt - requirements: requirements/readthedocs.txt - - requirements: git+https://github.com/open-mmlab/mmdetection.git + - method: pip + path: git+https://github.com/open-mmlab/mmdetection.git From 81ae80d31923c0449c30aaa7d18d3d464e5ad6b8 Mon Sep 17 00:00:00 2001 From: ZwwWayne Date: Sat, 11 Jul 2020 23:47:39 +0800 Subject: [PATCH 5/9] delete mmdet install --- .readthedocs.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index fe2dd59272..c38b70124d 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -6,5 +6,3 @@ python: - requirements: requirements/docs.txt - requirements: requirements/runtime.txt - requirements: requirements/readthedocs.txt - - method: pip - path: git+https://github.com/open-mmlab/mmdetection.git From 14b7236fa0afd188b85fce25527a3d42901fe876 Mon Sep 17 00:00:00 2001 From: ZwwWayne Date: Sun, 12 Jul 2020 00:09:53 +0800 Subject: [PATCH 6/9] reformat docstring in code --- docs/install.md | 2 -- mmdet3d/core/bbox/structures/base_box3d.py | 21 +++++++-------------- mmdet3d/core/bbox/structures/cam_box3d.py | 18 ++++++------------ mmdet3d/core/bbox/structures/depth_box3d.py | 9 +++------ mmdet3d/core/bbox/structures/lidar_box3d.py | 9 +++------ 5 files changed, 19 insertions(+), 40 deletions(-) diff --git a/docs/install.md b/docs/install.md index cbe7afabda..82712e7658 100644 --- a/docs/install.md +++ b/docs/install.md @@ -91,7 +91,6 @@ cd mmdetection3d f.Install build requirements and then install MMDetection3D. ```shell -pip install -r requirements/build.txt pip install -v -e . # or "python setup.py develop" ``` @@ -138,7 +137,6 @@ git clone https://github.com/open-mmlab/mmdetection.git # install mmdetection3d git clone https://github.com/open-mmlab/mmdetection3d.git cd mmdetection3d -pip install -r requirements/build.txt pip install -v -e . ``` diff --git a/mmdet3d/core/bbox/structures/base_box3d.py b/mmdet3d/core/bbox/structures/base_box3d.py index 2b0dafe4cc..04abd48dcf 100644 --- a/mmdet3d/core/bbox/structures/base_box3d.py +++ b/mmdet3d/core/bbox/structures/base_box3d.py @@ -69,26 +69,22 @@ def dims(self): @property def yaw(self): - """torch.Tensor: A vector with yaw of each box. - """ + """torch.Tensor: A vector with yaw of each box.""" return self.tensor[:, 6] @property def height(self): - """torch.Tensor: A vector with height of each box. - """ + """torch.Tensor: A vector with height of each box.""" return self.tensor[:, 5] @property def top_height(self): - """torch.Tensor: A vector with the top height of each box. - """ + """torch.Tensor: A vector with the top height of each box.""" return self.bottom_height + self.height @property def bottom_height(self): - """torch.Tensor: A vector with bottom's height of each box. - """ + """torch.Tensor: A vector with bottom's height of each box.""" return self.tensor[:, 2] @property @@ -112,20 +108,17 @@ def center(self): @property def bottom_center(self): - """torch.Tensor: A tensor with center of each box. - """ + """torch.Tensor: A tensor with center of each box.""" return self.tensor[:, :3] @property def gravity_center(self): - """torch.Tensor: A tensor with center of each box. - """ + """torch.Tensor: A tensor with center of each box.""" pass @property def corners(self): - """torch.Tensor: a tensor with 8 corners of each box. - """ + """torch.Tensor: a tensor with 8 corners of each box.""" pass @abstractmethod diff --git a/mmdet3d/core/bbox/structures/cam_box3d.py b/mmdet3d/core/bbox/structures/cam_box3d.py index e33d5e00d0..4b63f745d9 100644 --- a/mmdet3d/core/bbox/structures/cam_box3d.py +++ b/mmdet3d/core/bbox/structures/cam_box3d.py @@ -36,27 +36,23 @@ class CameraInstance3DBoxes(BaseInstance3DBoxes): @property def height(self): - """torch.Tensor: A vector with height of each box. - """ + """torch.Tensor: A vector with height of each box.""" return self.tensor[:, 4] @property def top_height(self): - """torch.Tensor: A vector with the top height of each box. - """ + """torch.Tensor: A vector with the top height of each box.""" # the positive direction is down rather than up return self.bottom_height - self.height @property def bottom_height(self): - """torch.Tensor: A vector with bottom's height of each box. - """ + """torch.Tensor: A vector with bottom's height of each box.""" return self.tensor[:, 1] @property def gravity_center(self): - """torch.Tensor: A tensor with center of each box. - """ + """torch.Tensor: A tensor with center of each box.""" bottom_center = self.bottom_center gravity_center = torch.zeros_like(bottom_center) gravity_center[:, [0, 2]] = bottom_center[:, [0, 2]] @@ -111,15 +107,13 @@ def corners(self): @property def bev(self): """torch.Tensor: A n x 5 tensor of 2D BEV box of each box - with rotation in XYWHR format. - """ + with rotation in XYWHR format.""" return self.tensor[:, [0, 2, 3, 5, 6]] @property def nearest_bev(self): """torch.Tensor: A tensor of 2D BEV box of each box - without rotation. - """ + without rotation.""" # Obtain BEV boxes with rotation in XZWHR format bev_rotated_boxes = self.bev # convert the rotation to a valid range diff --git a/mmdet3d/core/bbox/structures/depth_box3d.py b/mmdet3d/core/bbox/structures/depth_box3d.py index 7011e2fc49..c60c69523c 100644 --- a/mmdet3d/core/bbox/structures/depth_box3d.py +++ b/mmdet3d/core/bbox/structures/depth_box3d.py @@ -34,8 +34,7 @@ class DepthInstance3DBoxes(BaseInstance3DBoxes): @property def gravity_center(self): - """torch.Tensor: A tensor with center of each box. - """ + """torch.Tensor: A tensor with center of each box.""" bottom_center = self.bottom_center gravity_center = torch.zeros_like(bottom_center) gravity_center[:, :2] = bottom_center[:, :2] @@ -88,15 +87,13 @@ def corners(self): @property def bev(self): """torch.Tensor: A n x 5 tensor of 2D BEV box of each box - in XYWHR format. - """ + in XYWHR format.""" return self.tensor[:, [0, 1, 3, 4, 6]] @property def nearest_bev(self): """torch.Tensor: A tensor of 2D BEV box of each box - without rotation. - """ + without rotation.""" # Obtain BEV boxes with rotation in XYWHR format bev_rotated_boxes = self.bev # convert the rotation to a valid range diff --git a/mmdet3d/core/bbox/structures/lidar_box3d.py b/mmdet3d/core/bbox/structures/lidar_box3d.py index ba369fd381..a07b7c9910 100644 --- a/mmdet3d/core/bbox/structures/lidar_box3d.py +++ b/mmdet3d/core/bbox/structures/lidar_box3d.py @@ -34,8 +34,7 @@ class LiDARInstance3DBoxes(BaseInstance3DBoxes): @property def gravity_center(self): - """torch.Tensor: A tensor with center of each box. - """ + """torch.Tensor: A tensor with center of each box.""" bottom_center = self.bottom_center gravity_center = torch.zeros_like(bottom_center) gravity_center[:, :2] = bottom_center[:, :2] @@ -86,15 +85,13 @@ def corners(self): @property def bev(self): """torch.Tensor: 2D BEV box of each box with rotation - in XYWHR format. - """ + in XYWHR format.""" return self.tensor[:, [0, 1, 3, 4, 6]] @property def nearest_bev(self): """torch.Tensor: A tensor of 2D BEV box of each box - without rotation - """ + without rotation.""" # Obtain BEV boxes with rotation in XYWHR format bev_rotated_boxes = self.bev # convert the rotation to a valid range From 2fcd9e79503ab1095d24a17bc21dccfaed4cbf8b Mon Sep 17 00:00:00 2001 From: ZwwWayne Date: Sun, 12 Jul 2020 00:32:52 +0800 Subject: [PATCH 7/9] Refine docs --- docs/api.rst | 7 ------- mmdet3d/core/anchor/anchor_3d_generator.py | 8 ++++---- mmdet3d/core/bbox/structures/base_box3d.py | 13 ++++++++++--- mmdet3d/core/bbox/structures/cam_box3d.py | 13 +++++-------- mmdet3d/core/bbox/structures/depth_box3d.py | 12 +++++------- mmdet3d/core/bbox/structures/lidar_box3d.py | 10 +++++----- 6 files changed, 29 insertions(+), 34 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index 458fe631bd..16e6c9bacd 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -37,16 +37,9 @@ post_processing mmdet3d.datasets ---------------- -datasets -^^^^^^^^^^ .. automodule:: mmdet3d.datasets :members: -pipelines -^^^^^^^^^^ -.. automodule:: mmdet3d.datasets.pipelines - :members: - mmdet3d.models -------------- diff --git a/mmdet3d/core/anchor/anchor_3d_generator.py b/mmdet3d/core/anchor/anchor_3d_generator.py index ccaa39ad9c..fb6be301f3 100644 --- a/mmdet3d/core/anchor/anchor_3d_generator.py +++ b/mmdet3d/core/anchor/anchor_3d_generator.py @@ -224,10 +224,10 @@ class AlignedAnchor3DRangeGenerator(Anchor3DRangeGenerator): uniformly distributing the anchors inside the minimum and maximum anchor ranges according to the feature map sizes. However, this makes the anchors center does not match the feature grid. - The AlignedAnchor3DRangeGenerator add + 1 when using the feature map - sizes to obtain the corners of the voxel grid. Then it shifts the - coordinates to the center of voxel grid and use the left up corner to - distribute anchors. + The :class:`AlignedAnchor3DRangeGenerator` add + 1 when using the + feature map sizes to obtain the corners of the voxel grid. Then it + shifts the coordinates to the center of voxel grid and use the left + up corner to distribute anchors. Args: anchor_corner (bool): Whether to align with the corner of the voxel diff --git a/mmdet3d/core/bbox/structures/base_box3d.py b/mmdet3d/core/bbox/structures/base_box3d.py index 04abd48dcf..823a9b7ba2 100644 --- a/mmdet3d/core/bbox/structures/base_box3d.py +++ b/mmdet3d/core/bbox/structures/base_box3d.py @@ -24,6 +24,13 @@ class BaseInstance3DBoxes(object): origin (tuple[float]): The relative position of origin in the box. Default to (0.5, 0.5, 0). This will guide the box be converted to (0.5, 0.5, 0) mode. + + Attributes: + tensor (torch.Tensor): Float matrix of N x box_dim. + box_dim (int): Integer indicating the dimension of a box. + Each row is (x, y, z, x_size, y_size, z_size, yaw, ...). + with_yaw (bool): If True, the value of yaw will be set to 0 as minmax + boxes. """ def __init__(self, tensor, box_dim=7, with_yaw=True, origin=(0.5, 0.5, 0)): @@ -186,7 +193,7 @@ def in_range_bev(self, box_range): @abstractmethod def convert_to(self, dst, rt_mat=None): - """Convert self to `dst` mode. + """Convert self to ``dst`` mode. Args: dst (:obj:`BoxMode`): The target Box mode. @@ -378,8 +385,8 @@ def overlaps(cls, boxes1, boxes2, mode='iou'): """Calculate 3D overlaps of two boxes. Note: - This function calculates the overlaps between boxes1 and boxes2, - ``boxes1`` and ``boxes2`` should be in the same type. + This function calculates the overlaps between ``boxes1`` and + ``boxes2``, ``boxes1`` and ``boxes2`` should be in the same type. Args: boxes1 (:obj:`BaseInstanceBoxes`): Boxes 1 contain N boxes. diff --git a/mmdet3d/core/bbox/structures/cam_box3d.py b/mmdet3d/core/bbox/structures/cam_box3d.py index 4b63f745d9..f87761afa3 100644 --- a/mmdet3d/core/bbox/structures/cam_box3d.py +++ b/mmdet3d/core/bbox/structures/cam_box3d.py @@ -61,7 +61,7 @@ def gravity_center(self): @property def corners(self): - """Calculate the coordinates of corners of all the boxes. + """torch.Tensor: Coordinates of corners of all the boxes in shape (N, 8, 3). Convert the boxes to in clockwise order, in the form of (x0y0z0, x0y0z1, x0y1z1, x0y1z0, x1y0z0, x1y0z1, x1y1z1, x1y1z0) @@ -82,9 +82,6 @@ def corners(self): | v down y - - Returns: - torch.Tensor: Corners of each box with size (N, 8, 3). """ # TODO: rotation_3d_in_axis function do not support # empty tensor currently. @@ -203,9 +200,9 @@ def in_range_bev(self, box_range): (x_min, z_min, x_max, z_max). Note: - In the original implementation of SECOND, checking whether - a box in the range checks whether the points are in a convex - polygon, we try to reduce the burden for simpler cases. + The original implementation of SECOND checks whether boxes in + a range by checking whether the points are in a convex + polygon, we reduce the burden for simpler cases. Returns: torch.Tensor: Indicating whether each box is inside \ @@ -249,7 +246,7 @@ def height_overlaps(cls, boxes1, boxes2, mode='iou'): return overlaps_h def convert_to(self, dst, rt_mat=None): - """Convert self to `dst` mode. + """Convert self to ``dst`` mode. Args: dst (:obj:`BoxMode`): The target Box mode. diff --git a/mmdet3d/core/bbox/structures/depth_box3d.py b/mmdet3d/core/bbox/structures/depth_box3d.py index c60c69523c..7e5cdbb75b 100644 --- a/mmdet3d/core/bbox/structures/depth_box3d.py +++ b/mmdet3d/core/bbox/structures/depth_box3d.py @@ -24,7 +24,7 @@ class DepthInstance3DBoxes(BaseInstance3DBoxes): The yaw is 0 at the positive direction of x axis, and increases from the positive direction of x to the positive direction of y. - Args: + Attributes: tensor (torch.Tensor): Float matrix of N x box_dim. box_dim (int): Integer indicates the dimension of a box Each row is (x, y, z, x_size, y_size, z_size, yaw, ...). @@ -43,10 +43,11 @@ def gravity_center(self): @property def corners(self): - """Calculate the coordinates of corners of all the boxes. + """torch.Tensor: Coordinates of corners of all the boxes + in shape (N, 8, 3). Convert the boxes to corners in clockwise order, in form of - (x0y0z0, x0y0z1, x0y1z1, x0y1z0, x1y0z0, x1y0z1, x1y1z1, x1y1z0) + ``(x0y0z0, x0y0z1, x0y1z1, x0y1z0, x1y0z0, x1y0z1, x1y1z1, x1y1z0)`` .. code-block:: none @@ -62,9 +63,6 @@ def corners(self): | / oriign | / (x0, y0, z0) + ----------- + --------> right x (x1, y0, z0) - - Returns: - torch.Tensor: Corners of each box with size (N, 8, 3). """ # TODO: rotation_3d_in_axis function do not support # empty tensor currently. @@ -208,7 +206,7 @@ def in_range_bev(self, box_range): return in_range_flags def convert_to(self, dst, rt_mat=None): - """Convert self to `dst` mode. + """Convert self to ``dst`` mode. Args: dst (:obj:`BoxMode`): The target Box mode. diff --git a/mmdet3d/core/bbox/structures/lidar_box3d.py b/mmdet3d/core/bbox/structures/lidar_box3d.py index a07b7c9910..b2bd8e0cec 100644 --- a/mmdet3d/core/bbox/structures/lidar_box3d.py +++ b/mmdet3d/core/bbox/structures/lidar_box3d.py @@ -47,7 +47,7 @@ def corners(self): in shape (N, 8, 3). Convert the boxes to corners in clockwise order, in form of - (x0y0z0, x0y0z1, x0y1z1, x0y1z0, x1y0z0, x1y0z1, x1y1z1, x1y1z0) + ``(x0y0z0, x0y0z1, x0y1z1, x0y1z0, x1y0z0, x1y0z1, x1y1z1, x1y1z0)`` .. code-block:: none @@ -185,9 +185,9 @@ def in_range_bev(self, box_range): (x_min, y_min, x_max, y_max) Note: - In the original implementation of SECOND, checking whether - a box in the range checks whether the points are in a convex - polygon, we try to reduce the burdun for simpler cases. + The original implementation of SECOND checks whether boxes in + a range by checking whether the points are in a convex + polygon, we reduce the burden for simpler cases. Returns: torch.Tensor: Whether each box is inside the reference range. @@ -199,7 +199,7 @@ def in_range_bev(self, box_range): return in_range_flags def convert_to(self, dst, rt_mat=None): - """Convert self to `dst` mode. + """Convert self to ``dst`` mode. Args: dst (:obj:`BoxMode`): the target Box mode From 0d010accc456b2bd95f60ea7930ec7776b7e2959 Mon Sep 17 00:00:00 2001 From: ZwwWayne Date: Sun, 12 Jul 2020 00:46:39 +0800 Subject: [PATCH 8/9] Reformat --- docs/install.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/install.md b/docs/install.md index 82712e7658..9b3530e621 100644 --- a/docs/install.md +++ b/docs/install.md @@ -53,7 +53,7 @@ The pre-build *mmcv-full* could be installed by running: (available versions cou pip install mmcv-full==latest+torch1.5.0+cu101 -f https://openmmlab.oss-accelerate.aliyuncs.com/mmcv/dist/index.html ``` -Optionally, you could also build full version from source: +Optionally, you could also build the full version from source: ```shell pip install mmcv-full @@ -65,7 +65,8 @@ d. Install [MMDetection](https://github.com/open-mmlab/mmdetection). pip install git+https://github.com/open-mmlab/mmdetection.git ``` -Optionally, you could also build full version from source: +Optionally, you could also build MMDetection from source in case you want to modify the code: + ```shell git clone https://github.com/open-mmlab/mmdetection.git cd mmdetection From 20de62334d99cf1282e413a1dc1828795baf6cb5 Mon Sep 17 00:00:00 2001 From: ZwwWayne Date: Sun, 12 Jul 2020 00:50:54 +0800 Subject: [PATCH 9/9] fix format issue --- mmdet3d/core/bbox/structures/base_box3d.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmdet3d/core/bbox/structures/base_box3d.py b/mmdet3d/core/bbox/structures/base_box3d.py index 823a9b7ba2..12034c5612 100644 --- a/mmdet3d/core/bbox/structures/base_box3d.py +++ b/mmdet3d/core/bbox/structures/base_box3d.py @@ -385,7 +385,7 @@ def overlaps(cls, boxes1, boxes2, mode='iou'): """Calculate 3D overlaps of two boxes. Note: - This function calculates the overlaps between ``boxes1`` and + This function calculates the overlaps between ``boxes1`` and ``boxes2``, ``boxes1`` and ``boxes2`` should be in the same type. Args: