Unverified Commit cbc2491f authored by Tai-Wang's avatar Tai-Wang Committed by GitHub
Browse files

Add code-spell pre-commit hook and fix typos (#995)

parent 6b1602f1
# 基准测试 # 基准测试
\ No newline at end of file
# 变更日志 # 变更日志
\ No newline at end of file
...@@ -257,4 +257,3 @@ barrier 0.466 0.581 0.269 0.169 nan nan ...@@ -257,4 +257,3 @@ barrier 0.466 0.581 0.269 0.169 nan nan
总的来说,`NuScenesBox` 和我们的 `CameraInstanceBoxes` 的主要区别主要体现在转向角(yaw)定义上。 `NuScenesBox` 定义了一个四元数或三个欧拉角的旋转,而我们的由于实际情况只定义了一个转向角(yaw),它需要我们在预处理和后处理中手动添加一些额外的旋转,例如[这里](https://github.com/open-mmlab/mmdetection3d/blob/master/mmdet3d/datasets/nuscenes_mono_dataset.py#L673) 总的来说,`NuScenesBox` 和我们的 `CameraInstanceBoxes` 的主要区别主要体现在转向角(yaw)定义上。 `NuScenesBox` 定义了一个四元数或三个欧拉角的旋转,而我们的由于实际情况只定义了一个转向角(yaw),它需要我们在预处理和后处理中手动添加一些额外的旋转,例如[这里](https://github.com/open-mmlab/mmdetection3d/blob/master/mmdet3d/datasets/nuscenes_mono_dataset.py#L673)
另外,请注意,角点和位置的定义在 `NuScenesBox` 中是分离的。例如,在单目 3D 检测中,框位置的定义在其相机坐标中(有关汽车设置,请参阅其官方[插图](https://www.nuscenes.org/nuscenes#data-collection)),即与[我们的](https://github.com/open-mmlab/mmdetection3d/blob/master/mmdet3d/core/bbox/structures/cam_box3d.py)一致。相比之下,它的角点是通过[惯例](https://github.com/nutonomy/nuscenes-devkit/blob/02e9200218977193a1058dd7234f935834378319/python-sdk/nuscenes/utils/data_classes.py#L527) 定义的,“x 向前, y 向左, z 向上”。它导致了与我们的 `CameraInstanceBoxes` 不同的维度和旋转定义理念。一个移除相似冲突的例子是 PR [#744](https://github.com/open-mmlab/mmdetection3d/pull/744)。同样的问题也存在于 LiDAR 系统中。为了解决它们,我们通常会在预处理和后处理中添加一些转换,以保证在整个训练和推理过程中框都在我们的坐标系系统里。 另外,请注意,角点和位置的定义在 `NuScenesBox` 中是分离的。例如,在单目 3D 检测中,框位置的定义在其相机坐标中(有关汽车设置,请参阅其官方[插图](https://www.nuscenes.org/nuscenes#data-collection)),即与[我们的](https://github.com/open-mmlab/mmdetection3d/blob/master/mmdet3d/core/bbox/structures/cam_box3d.py)一致。相比之下,它的角点是通过[惯例](https://github.com/nutonomy/nuscenes-devkit/blob/02e9200218977193a1058dd7234f935834378319/python-sdk/nuscenes/utils/data_classes.py#L527) 定义的,“x 向前, y 向左, z 向上”。它导致了与我们的 `CameraInstanceBoxes` 不同的维度和旋转定义理念。一个移除相似冲突的例子是 PR [#744](https://github.com/open-mmlab/mmdetection3d/pull/744)。同样的问题也存在于 LiDAR 系统中。为了解决它们,我们通常会在预处理和后处理中添加一些转换,以保证在整个训练和推理过程中框都在我们的坐标系系统里。
# 基于Lidar的3D检测 # 基于Lidar的3D检测
\ No newline at end of file
# 基于Lidar的3D语义分割 # 基于Lidar的3D语义分割
\ No newline at end of file
# 基于视觉的3D检测 # 基于视觉的3D检测
\ No newline at end of file
...@@ -198,7 +198,7 @@ python tools/model_converters/publish_model.py work_dirs/faster_rcnn/latest.pth ...@@ -198,7 +198,7 @@ python tools/model_converters/publish_model.py work_dirs/faster_rcnn/latest.pth
为了转换 nuImages 数据集为 COCO 格式,请使用下面的指令: 为了转换 nuImages 数据集为 COCO 格式,请使用下面的指令:
```shell ```shell
python -u tools/data_converter/nuimage_converter.py --data-root ${DATA_ROOT} --version ${VERIONS} \ python -u tools/data_converter/nuimage_converter.py --data-root ${DATA_ROOT} --version ${VERSIONS} \
--out-dir ${OUT_DIR} --nproc ${NUM_WORKERS} --extra-tag ${TAG} --out-dir ${OUT_DIR} --nproc ${NUM_WORKERS} --extra-tag ${TAG}
``` ```
......
...@@ -99,7 +99,7 @@ class Anchor3DRangeGenerator(object): ...@@ -99,7 +99,7 @@ class Anchor3DRangeGenerator(object):
list[torch.Tensor]: Anchors in multiple feature levels. list[torch.Tensor]: Anchors in multiple feature levels.
The sizes of each tensor should be [N, 4], where The sizes of each tensor should be [N, 4], where
N = width * height * num_base_anchors, width and height N = width * height * num_base_anchors, width and height
are the sizes of the corresponding feature lavel, are the sizes of the corresponding feature level,
num_base_anchors is the number of anchors for that level. num_base_anchors is the number of anchors for that level.
""" """
assert self.num_levels == len(featmap_sizes) assert self.num_levels == len(featmap_sizes)
......
...@@ -468,7 +468,7 @@ def rbbox2d_to_near_bbox(rbboxes): ...@@ -468,7 +468,7 @@ def rbbox2d_to_near_bbox(rbboxes):
(N, 5(x, y, xdim, ydim, rad)). (N, 5(x, y, xdim, ydim, rad)).
Returns: Returns:
np.ndarray: Bounding boxes with the shpae of np.ndarray: Bounding boxes with the shape of
(N, 4(xmin, ymin, xmax, ymax)). (N, 4(xmin, ymin, xmax, ymax)).
""" """
rots = rbboxes[..., -1] rots = rbboxes[..., -1]
......
...@@ -23,7 +23,7 @@ class SMOKECoder(BaseBBoxCoder): ...@@ -23,7 +23,7 @@ class SMOKECoder(BaseBBoxCoder):
self.bbox_code_size = code_size self.bbox_code_size = code_size
def encode(self, locations, dimensions, orientations, input_metas): def encode(self, locations, dimensions, orientations, input_metas):
"""Encode CameraInstance3DBoxes by locations, dimemsions, orientations. """Encode CameraInstance3DBoxes by locations, dimensions, orientations.
Args: Args:
locations (Tensor): Center location for 3D boxes. locations (Tensor): Center location for 3D boxes.
...@@ -55,7 +55,7 @@ class SMOKECoder(BaseBBoxCoder): ...@@ -55,7 +55,7 @@ class SMOKECoder(BaseBBoxCoder):
cam2imgs, cam2imgs,
trans_mats, trans_mats,
locations=None): locations=None):
"""Decode regression into locations, dimemsions, orientations. """Decode regression into locations, dimensions, orientations.
Args: Args:
reg (Tensor): Batch regression for each predict center2d point. reg (Tensor): Batch regression for each predict center2d point.
...@@ -80,7 +80,7 @@ class SMOKECoder(BaseBBoxCoder): ...@@ -80,7 +80,7 @@ class SMOKECoder(BaseBBoxCoder):
- locations (Tensor): Centers of 3D boxes. - locations (Tensor): Centers of 3D boxes.
shape: (batch * K (max_objs), 3) shape: (batch * K (max_objs), 3)
- dimensions (Tensor): Dimensions of 3D boxes. - dimensions (Tensor): Dimensions of 3D boxes.
shpae: (batch * K (max_objs), 3) shape: (batch * K (max_objs), 3)
- orientations (Tensor): Orientations of 3D - orientations (Tensor): Orientations of 3D
boxes. boxes.
shape: (batch * K (max_objs), 1) shape: (batch * K (max_objs), 1)
...@@ -185,7 +185,7 @@ class SMOKECoder(BaseBBoxCoder): ...@@ -185,7 +185,7 @@ class SMOKECoder(BaseBBoxCoder):
rays = torch.atan(locations[:, 0] / (locations[:, 2] + 1e-7)) rays = torch.atan(locations[:, 0] / (locations[:, 2] + 1e-7))
alphas = torch.atan(ori_vector[:, 0] / (ori_vector[:, 1] + 1e-7)) alphas = torch.atan(ori_vector[:, 0] / (ori_vector[:, 1] + 1e-7))
# get cosine value positive and negtive index. # get cosine value positive and negative index.
cos_pos_inds = (ori_vector[:, 1] >= 0).nonzero() cos_pos_inds = (ori_vector[:, 1] >= 0).nonzero()
cos_neg_inds = (ori_vector[:, 1] < 0).nonzero() cos_neg_inds = (ori_vector[:, 1] < 0).nonzero()
......
...@@ -106,7 +106,7 @@ def bbox_overlaps_nearest_3d(bboxes1, ...@@ -106,7 +106,7 @@ def bbox_overlaps_nearest_3d(bboxes1,
Note: Note:
This function first finds the nearest 2D boxes in bird eye view This function first finds the nearest 2D boxes in bird eye view
(BEV), and then calculates the 2D IoU using :meth:`bbox_overlaps`. (BEV), and then calculates the 2D IoU using :meth:`bbox_overlaps`.
Ths IoU calculator :class:`BboxOverlapsNearest3D` uses this This IoU calculator :class:`BboxOverlapsNearest3D` uses this
function to calculate IoUs of boxes. function to calculate IoUs of boxes.
If ``is_aligned`` is ``False``, then it calculates the ious between If ``is_aligned`` is ``False``, then it calculates the ious between
...@@ -258,7 +258,7 @@ def axis_aligned_bbox_overlaps_3d(bboxes1, ...@@ -258,7 +258,7 @@ def axis_aligned_bbox_overlaps_3d(bboxes1,
""" """
assert mode in ['iou', 'giou'], f'Unsupported mode {mode}' assert mode in ['iou', 'giou'], f'Unsupported mode {mode}'
# Either the boxes are empty or the length of boxes's last dimenstion is 6 # Either the boxes are empty or the length of boxes's last dimension is 6
assert (bboxes1.size(-1) == 6 or bboxes1.size(0) == 0) assert (bboxes1.size(-1) == 6 or bboxes1.size(0) == 0)
assert (bboxes2.size(-1) == 6 or bboxes2.size(0) == 0) assert (bboxes2.size(-1) == 6 or bboxes2.size(0) == 0)
......
...@@ -220,7 +220,7 @@ def points_img2cam(points, cam2img): ...@@ -220,7 +220,7 @@ def points_img2cam(points, cam2img):
Args: Args:
points (torch.Tensor): 2.5D points in 2D images, [N, 3], points (torch.Tensor): 2.5D points in 2D images, [N, 3],
3 corresponds with x, y in the image and depth. 3 corresponds with x, y in the image and depth.
cam2img (torch.Tensor): Camera instrinsic matrix. The shape can be cam2img (torch.Tensor): Camera intrinsic matrix. The shape can be
[3, 3], [3, 4] or [4, 4]. [3, 3], [3, 4] or [4, 4].
Returns: Returns:
...@@ -239,7 +239,7 @@ def points_img2cam(points, cam2img): ...@@ -239,7 +239,7 @@ def points_img2cam(points, cam2img):
pad_cam2img[:cam2img.shape[0], :cam2img.shape[1]] = cam2img pad_cam2img[:cam2img.shape[0], :cam2img.shape[1]] = cam2img
inv_pad_cam2img = torch.inverse(pad_cam2img).transpose(0, 1) inv_pad_cam2img = torch.inverse(pad_cam2img).transpose(0, 1)
# Do operation in homogenous coordinates. # Do operation in homogeneous coordinates.
num_points = unnormed_xys.shape[0] num_points = unnormed_xys.shape[0]
homo_xys = torch.cat([unnormed_xys, xys.new_ones((num_points, 1))], dim=1) homo_xys = torch.cat([unnormed_xys, xys.new_ones((num_points, 1))], dim=1)
points3D = torch.mm(homo_xys, inv_pad_cam2img)[:, :3] points3D = torch.mm(homo_xys, inv_pad_cam2img)[:, :3]
......
...@@ -26,7 +26,7 @@ def box3d_multiclass_nms(mlvl_bboxes, ...@@ -26,7 +26,7 @@ def box3d_multiclass_nms(mlvl_bboxes,
The coordinate system of the BEV boxes is counterclockwise. The coordinate system of the BEV boxes is counterclockwise.
mlvl_scores (torch.Tensor): Multi-level boxes with shape mlvl_scores (torch.Tensor): Multi-level boxes with shape
(N, C + 1). N is the number of boxes. C is the number of classes. (N, C + 1). N is the number of boxes. C is the number of classes.
score_thr (float): Score thredhold to filter boxes with low score_thr (float): Score threshold to filter boxes with low
confidence. confidence.
max_num (int): Maximum number of boxes will be kept. max_num (int): Maximum number of boxes will be kept.
cfg (dict): Configuration dict of NMS. cfg (dict): Configuration dict of NMS.
......
...@@ -28,7 +28,7 @@ def draw_heatmap_gaussian(heatmap, center, radius, k=1): ...@@ -28,7 +28,7 @@ def draw_heatmap_gaussian(heatmap, center, radius, k=1):
Args: Args:
heatmap (torch.Tensor): Heatmap to be masked. heatmap (torch.Tensor): Heatmap to be masked.
center (torch.Tensor): Center coord of the heatmap. center (torch.Tensor): Center coord of the heatmap.
radius (int): Radius of gausian. radius (int): Radius of gaussian.
K (int, optional): Multiple of masked_gaussian. Defaults to 1. K (int, optional): Multiple of masked_gaussian. Defaults to 1.
Returns: Returns:
......
...@@ -80,10 +80,10 @@ def _draw_bboxes(bbox3d, ...@@ -80,10 +80,10 @@ def _draw_bboxes(bbox3d,
the color of points inside bbox3d. Default: (1, 0, 0). the color of points inside bbox3d. Default: (1, 0, 0).
rot_axis (int, optional): rotation axis of bbox. Default: 2. rot_axis (int, optional): rotation axis of bbox. Default: 2.
center_mode (bool, optional): indicate the center of bbox is center_mode (bool, optional): indicate the center of bbox is
bottom center or gravity center. avaliable mode bottom center or gravity center. available mode
['lidar_bottom', 'camera_bottom']. Default: 'lidar_bottom'. ['lidar_bottom', 'camera_bottom']. Default: 'lidar_bottom'.
mode (str, optional): indicate type of the input points, mode (str, optional): indicate type of the input points,
avaliable mode ['xyz', 'xyzrgb']. Default: 'xyz'. available mode ['xyz', 'xyzrgb']. Default: 'xyz'.
""" """
if isinstance(bbox3d, torch.Tensor): if isinstance(bbox3d, torch.Tensor):
bbox3d = bbox3d.cpu().numpy() bbox3d = bbox3d.cpu().numpy()
...@@ -154,9 +154,9 @@ def show_pts_boxes(points, ...@@ -154,9 +154,9 @@ def show_pts_boxes(points,
the color of points which are in bbox3d. Default: (1, 0, 0). the color of points which are in bbox3d. Default: (1, 0, 0).
rot_axis (int, optional): rotation axis of bbox. Default: 2. rot_axis (int, optional): rotation axis of bbox. Default: 2.
center_mode (bool, optional): indicate the center of bbox is bottom center_mode (bool, optional): indicate the center of bbox is bottom
center or gravity center. avaliable mode center or gravity center. available mode
['lidar_bottom', 'camera_bottom']. Default: 'lidar_bottom'. ['lidar_bottom', 'camera_bottom']. Default: 'lidar_bottom'.
mode (str, optional): indicate type of the input points, avaliable mode (str, optional): indicate type of the input points, available
mode ['xyz', 'xyzrgb']. Default: 'xyz'. mode ['xyz', 'xyzrgb']. Default: 'xyz'.
""" """
# TODO: support score and class info # TODO: support score and class info
...@@ -215,10 +215,10 @@ def _draw_bboxes_ind(bbox3d, ...@@ -215,10 +215,10 @@ def _draw_bboxes_ind(bbox3d,
the color of points which are in bbox3d. Default: (1, 0, 0). the color of points which are in bbox3d. Default: (1, 0, 0).
rot_axis (int, optional): rotation axis of bbox. Default: 2. rot_axis (int, optional): rotation axis of bbox. Default: 2.
center_mode (bool, optional): indicate the center of bbox is center_mode (bool, optional): indicate the center of bbox is
bottom center or gravity center. avaliable mode bottom center or gravity center. available mode
['lidar_bottom', 'camera_bottom']. Default: 'lidar_bottom'. ['lidar_bottom', 'camera_bottom']. Default: 'lidar_bottom'.
mode (str, optional): indicate type of the input points, mode (str, optional): indicate type of the input points,
avaliable mode ['xyz', 'xyzrgb']. Default: 'xyz'. available mode ['xyz', 'xyzrgb']. Default: 'xyz'.
""" """
if isinstance(bbox3d, torch.Tensor): if isinstance(bbox3d, torch.Tensor):
bbox3d = bbox3d.cpu().numpy() bbox3d = bbox3d.cpu().numpy()
...@@ -296,10 +296,10 @@ def show_pts_index_boxes(points, ...@@ -296,10 +296,10 @@ def show_pts_index_boxes(points,
the color of points which are in bbox3d. Default: (1, 0, 0). the color of points which are in bbox3d. Default: (1, 0, 0).
rot_axis (int, optional): rotation axis of bbox. Default: 2. rot_axis (int, optional): rotation axis of bbox. Default: 2.
center_mode (bool, optional): indicate the center of bbox is center_mode (bool, optional): indicate the center of bbox is
bottom center or gravity center. avaliable mode bottom center or gravity center. available mode
['lidar_bottom', 'camera_bottom']. Default: 'lidar_bottom'. ['lidar_bottom', 'camera_bottom']. Default: 'lidar_bottom'.
mode (str, optional): indicate type of the input points, mode (str, optional): indicate type of the input points,
avaliable mode ['xyz', 'xyzrgb']. Default: 'xyz'. available mode ['xyz', 'xyzrgb']. Default: 'xyz'.
""" """
# TODO: support score and class info # TODO: support score and class info
assert 0 <= rot_axis <= 2 assert 0 <= rot_axis <= 2
...@@ -353,10 +353,10 @@ class Visualizer(object): ...@@ -353,10 +353,10 @@ class Visualizer(object):
the color of points which are in bbox3d. Default: (1, 0, 0). the color of points which are in bbox3d. Default: (1, 0, 0).
rot_axis (int, optional): rotation axis of bbox. Default: 2. rot_axis (int, optional): rotation axis of bbox. Default: 2.
center_mode (bool, optional): indicate the center of bbox is center_mode (bool, optional): indicate the center of bbox is
bottom center or gravity center. avaliable mode bottom center or gravity center. available mode
['lidar_bottom', 'camera_bottom']. Default: 'lidar_bottom'. ['lidar_bottom', 'camera_bottom']. Default: 'lidar_bottom'.
mode (str, optional): indicate type of the input points, mode (str, optional): indicate type of the input points,
avaliable mode ['xyz', 'xyzrgb']. Default: 'xyz'. available mode ['xyz', 'xyzrgb']. Default: 'xyz'.
""" """
def __init__(self, def __init__(self,
...@@ -409,9 +409,9 @@ class Visualizer(object): ...@@ -409,9 +409,9 @@ class Visualizer(object):
to be visualized. The 3d bbox is in mode of to be visualized. The 3d bbox is in mode of
Box3DMode.DEPTH with gravity_center (please refer to Box3DMode.DEPTH with gravity_center (please refer to
core.structures.box_3d_mode). core.structures.box_3d_mode).
bbox_color (tuple[float]): the color of bbox. Defaule: None. bbox_color (tuple[float]): the color of bbox. Default: None.
points_in_box_color (tuple[float]): the color of points which points_in_box_color (tuple[float]): the color of points which
are in bbox3d. Defaule: None. are in bbox3d. Default: None.
""" """
if bbox_color is None: if bbox_color is None:
bbox_color = self.bbox_color bbox_color = self.bbox_color
......
...@@ -316,7 +316,7 @@ class KittiDataset(Custom3DDataset): ...@@ -316,7 +316,7 @@ class KittiDataset(Custom3DDataset):
pklfile_prefix (str, optional): The prefix of pkl files, including pklfile_prefix (str, optional): The prefix of pkl files, including
the file path and the prefix of filename, e.g., "a/b/prefix". the file path and the prefix of filename, e.g., "a/b/prefix".
If not specified, a temp file will be created. Default: None. If not specified, a temp file will be created. Default: None.
submission_prefix (str, optional): The prefix of submission datas. submission_prefix (str, optional): The prefix of submission data.
If not specified, the submission data will not be generated. If not specified, the submission data will not be generated.
show (bool, optional): Whether to visualize. show (bool, optional): Whether to visualize.
Default: False. Default: False.
......
...@@ -214,7 +214,7 @@ class KittiMonoDataset(NuScenesMonoDataset): ...@@ -214,7 +214,7 @@ class KittiMonoDataset(NuScenesMonoDataset):
pklfile_prefix (str, optional): The prefix of pkl files, including pklfile_prefix (str, optional): The prefix of pkl files, including
the file path and the prefix of filename, e.g., "a/b/prefix". the file path and the prefix of filename, e.g., "a/b/prefix".
If not specified, a temp file will be created. Default: None. If not specified, a temp file will be created. Default: None.
submission_prefix (str, optional): The prefix of submission datas. submission_prefix (str, optional): The prefix of submission data.
If not specified, the submission data will not be generated. If not specified, the submission data will not be generated.
show (bool, optional): Whether to visualize. show (bool, optional): Whether to visualize.
Default: False. Default: False.
......
...@@ -143,7 +143,7 @@ class LyftDataset(Custom3DDataset): ...@@ -143,7 +143,7 @@ class LyftDataset(Custom3DDataset):
""" """
info = self.data_infos[index] info = self.data_infos[index]
# standard protocal modified from SECOND.Pytorch # standard protocol modified from SECOND.Pytorch
input_dict = dict( input_dict = dict(
sample_idx=info['token'], sample_idx=info['token'],
pts_filename=info['lidar_path'], pts_filename=info['lidar_path'],
......
...@@ -210,7 +210,7 @@ class NuScenesDataset(Custom3DDataset): ...@@ -210,7 +210,7 @@ class NuScenesDataset(Custom3DDataset):
- ann_info (dict): Annotation info. - ann_info (dict): Annotation info.
""" """
info = self.data_infos[index] info = self.data_infos[index]
# standard protocal modified from SECOND.Pytorch # standard protocol modified from SECOND.Pytorch
input_dict = dict( input_dict = dict(
sample_idx=info['token'], sample_idx=info['token'],
pts_filename=info['lidar_path'], pts_filename=info['lidar_path'],
......
...@@ -49,7 +49,7 @@ class LoadMultiViewImageFromFiles(object): ...@@ -49,7 +49,7 @@ class LoadMultiViewImageFromFiles(object):
if self.to_float32: if self.to_float32:
img = img.astype(np.float32) img = img.astype(np.float32)
results['filename'] = filename results['filename'] = filename
# unravel to list, see `DefaultFormatBundle` in formating.py # unravel to list, see `DefaultFormatBundle` in formatting.py
# which will transpose each image separately and then stack into array # which will transpose each image separately and then stack into array
results['img'] = [img[..., i] for i in range(img.shape[-1])] results['img'] = [img[..., i] for i in range(img.shape[-1])]
results['img_shape'] = img.shape results['img_shape'] = img.shape
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment