Commit adb17824 authored by xiangxu-0103's avatar xiangxu-0103 Committed by ZwwWayne
Browse files

[Fix]: fix semantic segmentation related bugs (#1909)

delete whitespace

update docs

remove unnecessary optional docs

update docs

add mmengine assertion

add docstring

fix mminstall

update mmengine version

fix

[Fix]: fix semantic segmentation related bugs (#1909)

fix semantic seg

fix lint

remove unused imports

fix

update pointnet2-s3dis config

update data_list according to scene_idxs

remove useless function

fix bug lack `eval_ann_info` during evaluation

fix bug

update doc

fix lint

update docs

Update det3d_dataset.py

update docstrings

update docs

fix lint

update docs

fix

fix

fix lint
parent b37dc416
......@@ -16,8 +16,8 @@ param_scheduler = [
]
# runtime settings
train_cfg = dict(by_epoch=True, max_epochs=100)
val_cfg = dict(interval=1)
train_cfg = dict(by_epoch=True, max_epochs=100, val_interval=1)
val_cfg = dict()
test_cfg = dict()
# Default setting for scaling LR automatically
......
......@@ -16,8 +16,8 @@ param_scheduler = [
]
# runtime settings
train_cfg = dict(by_epoch=True, max_epochs=150)
val_cfg = dict(interval=1)
train_cfg = dict(by_epoch=True, max_epochs=150, val_interval=1)
val_cfg = dict()
test_cfg = dict()
# Default setting for scaling LR automatically
......
......@@ -16,8 +16,8 @@ param_scheduler = [
]
# runtime settings
train_cfg = dict(by_epoch=True, max_epochs=200)
val_cfg = dict(interval=1)
train_cfg = dict(by_epoch=True, max_epochs=200, val_interval=1)
val_cfg = dict()
test_cfg = dict()
# Default setting for scaling LR automatically
......
......@@ -16,8 +16,8 @@ param_scheduler = [
]
# runtime settings
train_cfg = dict(by_epoch=True, max_epochs=50)
val_cfg = dict(interval=1)
train_cfg = dict(by_epoch=True, max_epochs=50, val_interval=1)
val_cfg = dict()
test_cfg = dict()
# Default setting for scaling LR automatically
......
......@@ -16,6 +16,6 @@ model = dict(
use_normalized_coord=True,
batch_size=24))
default_hooks = dict(checkpoint=dict(type='CheckpointHook', interval=2), )
default_hooks = dict(checkpoint=dict(type='CheckpointHook', interval=2))
train_dataloader = dict(batch_size=32)
val_cfg = dict(interval=2)
train_cfg = dict(val_interval=2)
......@@ -58,5 +58,4 @@ train_pipeline = [
train_dataloader = dict(batch_size=8, dataset=dict(pipeline=train_pipeline))
# runtime settings
val_cfg = dict(interval=1)
train_cfg = dict(by_epoch=True, max_epochs=200)
train_cfg = dict(by_epoch=True, max_epochs=200, val_interval=1)
......@@ -56,4 +56,3 @@ train_pipeline = [
]
train_dataloader = dict(batch_size=8, dataset=dict(pipeline=train_pipeline))
val_cfg = dict(interval=1)
......@@ -101,7 +101,6 @@ val_dataloader = test_dataloader
# runtime settings
default_hooks = dict(checkpoint=dict(type='CheckpointHook', interval=5))
val_cfg = dict(interval=5)
# PointNet2-MSG needs longer training time than PointNet2-SSG
train_cfg = dict(by_epoch=True, max_epochs=250)
train_cfg = dict(by_epoch=True, max_epochs=250, val_interval=5)
......@@ -30,7 +30,6 @@ train_dataloader = dict(batch_size=16)
# runtime settings
default_hooks = dict(checkpoint=dict(type='CheckpointHook', interval=5))
val_cfg = dict(interval=5)
# PointNet2-MSG needs longer training time than PointNet2-SSG
train_cfg = dict(by_epoch=True, max_epochs=250)
train_cfg = dict(by_epoch=True, max_epochs=250, val_interval=5)
......@@ -21,7 +21,6 @@ train_dataloader = dict(batch_size=16)
# runtime settings
default_hooks = dict(checkpoint=dict(type='CheckpointHook', interval=2))
val_cfg = dict(interval=2)
# PointNet2-MSG needs longer training time than PointNet2-SSG
train_cfg = dict(by_epoch=True, max_epochs=80)
train_cfg = dict(by_epoch=True, max_epochs=80, val_interval=2)
......@@ -101,4 +101,4 @@ val_dataloader = test_dataloader
# runtime settings
default_hooks = dict(checkpoint=dict(type='CheckpointHook', interval=5))
val_cfg = dict(interval=5)
train_cfg = dict(val_interval=5)
......@@ -30,4 +30,4 @@ train_dataloader = dict(batch_size=16)
# runtime settings
default_hooks = dict(checkpoint=dict(type='CheckpointHook', interval=5))
val_cfg = dict(interval=5)
train_cfg = dict(val_interval=5)
......@@ -17,8 +17,8 @@ model = dict(
batch_size=24))
# data settings
train_dataloader = dict(batch_size=6)
train_dataloader = dict(batch_size=16)
# runtime settings
default_hooks = dict(checkpoint=dict(type='CheckpointHook', interval=2), )
val_cfg = dict(interval=2)
default_hooks = dict(checkpoint=dict(type='CheckpointHook', interval=2))
train_cfg = dict(val_interval=2)
......@@ -10,9 +10,9 @@ We list some potential troubles encountered by users and developers, along with
| MMDetection3D version | MMEngine version | MMCV version | MMDetection version |
| --------------------- | :----------------------: | :---------------------: | :----------------------: |
| dev-1.x | mmengine>=0.1.0, \<0.2.0 | mmcv>=2.0.0rc0, \<2.1.0 | mmdet>=3.0.0rc0, \<3.1.0 |
| v1.1.0rc1 | mmengine>=0.1.0, \<0.2.0 | mmcv>=2.0.0rc0, \<2.1.0 | mmdet>=3.0.0rc0, \<3.1.0 |
| v1.1.0rc0 | mmengine>=0.1.0, \<0.2.0 | mmcv>=2.0.0rc0, \<2.1.0 | mmdet>=3.0.0rc0, \<3.1.0 |
| dev-1.x | mmengine>=0.1.0, \<1.0.0 | mmcv>=2.0.0rc0, \<2.1.0 | mmdet>=3.0.0rc0, \<3.1.0 |
| v1.1.0rc1 | mmengine>=0.1.0, \<1.0.0 | mmcv>=2.0.0rc0, \<2.1.0 | mmdet>=3.0.0rc0, \<3.1.0 |
| v1.1.0rc0 | mmengine>=0.1.0, \<1.0.0 | mmcv>=2.0.0rc0, \<2.1.0 | mmdet>=3.0.0rc0, \<3.1.0 |
**Note:** If you want to install mmdet3d-v1.0.0x, the compatible MMDetection, MMSegmentation and MMCV versions table can be found at [here](https://mmdetection3d.readthedocs.io/en/latest/faq.html#mmcv-mmdet-mmdet3d-installation). Please choose the correct version of MMCV to avoid installation issues.
......
# Copyright (c) OpenMMLab. All rights reserved.
import mmcv
import mmengine
from mmengine.utils import digit_version
import mmdet
from .version import __version__, short_version
def digit_version(version_str):
digit_version = []
for x in version_str.split('.'):
if x.isdigit():
digit_version.append(int(x))
elif x.find('rc') != -1:
patch_version = x.split('rc')
digit_version.append(int(patch_version[0]) - 1)
digit_version.append(int(patch_version[1]))
return digit_version
from .version import __version__, version_info
mmcv_minimum_version = '2.0.0rc0'
mmcv_maximum_version = '2.1.0'
mmcv_version = digit_version(mmcv.__version__)
mmengine_minimum_version = '0.1.0'
mmengine_maximum_version = '1.0.0'
mmengine_version = digit_version(mmengine.__version__)
mmdet_minimum_version = '3.0.0rc0'
mmdet_maximum_version = '3.1.0'
mmdet_version = digit_version(mmdet.__version__)
assert (mmcv_version >= digit_version(mmcv_minimum_version)
and mmcv_version < digit_version(mmcv_maximum_version)), \
f'MMCV=={mmcv.__version__} is used but incompatible. ' \
f'Please install mmcv>={mmcv_minimum_version}, <={mmcv_maximum_version}.'
f'Please install mmcv>={mmcv_minimum_version}, <{mmcv_maximum_version}.'
assert (mmengine_version >= digit_version(mmengine_minimum_version)
and mmengine_version < digit_version(mmengine_maximum_version)), \
f'MMEngine=={mmengine.__version__} is used but incompatible. ' \
f'Please install mmengine>={mmengine_minimum_version}, ' \
f'<{mmengine_maximum_version}.'
mmdet_minimum_version = '3.0.0rc0'
mmdet_maximum_version = '3.1.0'
mmdet_version = digit_version(mmdet.__version__)
assert (mmdet_version >= digit_version(mmdet_minimum_version)
and mmdet_version < digit_version(mmdet_maximum_version)), \
f'MMDET=={mmdet.__version__} is used but incompatible. ' \
f'Please install mmdet>={mmdet_minimum_version}, ' \
f'<={mmdet_maximum_version}.'
f'<{mmdet_maximum_version}.'
__all__ = ['__version__', 'short_version']
__all__ = ['__version__', 'version_info', 'digit_version']
......@@ -206,11 +206,11 @@ def get_kitti_style_2d_boxes(info: dict,
0 = fully visible, 1 = partly occluded, 2 = largely occluded,
3 = unknown, -1 = DontCare.
Defaults to (0, 1, 2, 3).
annos (dict, optional): Original annotations.
annos (dict, optional): Original annotations. Defaults to None.
mono3d (bool): Whether to get boxes with mono3d annotation.
Defaults to True.
dataset (str): Dataset name of getting 2d bboxes.
Defaults to `kitti`.
Defaults to 'kitti'.
Return:
list[dict]: List of 2d / mono3d annotation record that
......@@ -345,9 +345,10 @@ def post_process_coords(
corner_coords (list[int]): Corner coordinates of reprojected
bounding box.
imsize (tuple[int]): Size of the image canvas.
Defaults to (1600, 900).
Return:
tuple [float]: Intersection of the convex hull of the 2D box
tuple[float]: Intersection of the convex hull of the 2D box
corners and the image canvas.
"""
polygon_from_2d_box = MultiPoint(corner_coords).convex_hull
......@@ -383,10 +384,10 @@ def generate_record(ann_rec: dict, x1: float, y1: float, x2: float, y2: float,
Returns:
dict: A sample 2d annotation record.
- bbox_label (int): 2d box label id
- bbox_label_3d (int): 3d box label id
- bbox (list[float]): left x, top y, right x, bottom y
of 2d box
- bbox (list[float]): left x, top y, right x, bottom y of 2d box
- bbox_3d_isvalid (bool): whether the box is valid
"""
......@@ -398,10 +399,6 @@ def generate_record(ann_rec: dict, x1: float, y1: float, x2: float, y2: float,
cat_name = NuScenesNameMapping[cat_name]
categories = nus_categories
else:
cat_name = ann_rec['name']
if cat_name not in categories:
return None
if dataset == 'kitti':
categories = kitti_categories
elif dataset == 'waymo':
......@@ -409,6 +406,10 @@ def generate_record(ann_rec: dict, x1: float, y1: float, x2: float, y2: float,
else:
raise NotImplementedError('Unsupported dataset!')
cat_name = ann_rec['name']
if cat_name not in categories:
return None
rec = dict()
rec['bbox_label'] = categories.index(cat_name)
rec['bbox_label_3d'] = rec['bbox_label']
......
# Copyright (c) OpenMMLab. All rights reserved.
import copy
from os import path as osp
from typing import Callable, List, Optional, Union
from typing import Callable, List, Optional, Set, Union
import mmengine
import numpy as np
......@@ -28,22 +28,22 @@ class Det3DDataset(BaseDataset):
ann_file (str): Annotation file path. Defaults to ''.
metainfo (dict, optional): Meta information for dataset, such as class
information. Defaults to None.
data_prefix (dict, optional): Prefix for training data. Defaults to
data_prefix (dict): Prefix for training data. Defaults to
dict(pts='velodyne', img='').
pipeline (list[dict], optional): Pipeline used for data processing.
Defaults to None.
modality (dict, optional): Modality to specify the sensor data used
as input, it usually has following keys:
pipeline (list[dict]): Pipeline used for data processing.
Defaults to [].
modality (dict): Modality to specify the sensor data used as input,
it usually has following keys:
- use_camera: bool
- use_lidar: bool
Defaults to `dict(use_lidar=True, use_camera=False)`
default_cam_key (str, optional): The default camera name adopted.
Defaults to None.
box_type_3d (str, optional): Type of 3D box of this dataset.
box_type_3d (str): Type of 3D box of this dataset.
Based on the `box_type_3d`, the dataset will encapsulate the box
to its original format then converted them to `box_type_3d`.
Defaults to 'LiDAR'. Available options includes:
Defaults to 'LiDAR' in this dataset. Available options includes:
- 'LiDAR': Box in LiDAR coordinates, usually for
outdoor point cloud 3d detection.
......@@ -51,19 +51,20 @@ class Det3DDataset(BaseDataset):
indoor point cloud 3d detection.
- 'Camera': Box in camera coordinates, usually
for vision-based 3d detection.
filter_empty_gt (bool, optional): Whether to filter the data with
empty GT. Defaults to True.
test_mode (bool, optional): Whether the dataset is in test mode.
filter_empty_gt (bool): Whether to filter the data with empty GT.
If it's set to be True, the example with empty annotations after
data pipeline will be dropped and a random example will be chosen
in `__getitem__`. Defaults to True.
test_mode (bool): Whether the dataset is in test mode.
Defaults to False.
load_eval_anns (bool, optional): Whether to load annotations
in test_mode, the annotation will be save in `eval_ann_infos`,
which can be used in Evaluator. Defaults to True.
file_client_args (dict, optional): Configuration of file client.
load_eval_anns (bool): Whether to load annotations in test_mode,
the annotation will be save in `eval_ann_infos`, which can be
used in Evaluator. Defaults to True.
file_client_args (dict): Configuration of file client.
Defaults to dict(backend='disk').
show_ins_var (bool, optional): For debug purpose. Whether to show
variation of the number of instances before and after through
pipeline. Defaults to False.
show_ins_var (bool): For debug purpose. Whether to show variation
of the number of instances before and after through pipeline.
Defaults to False.
"""
def __init__(self,
......@@ -154,7 +155,7 @@ class Det3DDataset(BaseDataset):
f'The number of instances per category in the dataset:\n{table.table}', # noqa: E501
'current')
def _remove_dontcare(self, ann_info):
def _remove_dontcare(self, ann_info: dict) -> dict:
"""Remove annotations that do not need to be cared.
-1 indicate dontcare in MMDet3d.
......@@ -197,7 +198,7 @@ class Det3DDataset(BaseDataset):
return ann_info
def parse_ann_info(self, info: dict) -> Optional[dict]:
"""Process the `instances` in data info to `ann_info`
"""Process the `instances` in data info to `ann_info`.
In `Custom3DDataset`, we simply concatenate all the field
in `instances` to `np.ndarray`, you can do the specific
......@@ -263,8 +264,8 @@ class Det3DDataset(BaseDataset):
"""Process the raw data info.
Convert all relative path of needed modality data file to
the absolute path. And process
the `instances` field to `ann_info` in training stage.
the absolute path. And process the `instances` field to
`ann_info` in training stage.
Args:
info (dict): Raw info dict.
......@@ -392,7 +393,7 @@ class Det3DDataset(BaseDataset):
return example
def get_cat_ids(self, idx: int) -> List[int]:
def get_cat_ids(self, idx: int) -> Set[int]:
"""Get category ids by index. Dataset wrapped by ClassBalancedDataset
must implement this method.
......
......@@ -18,13 +18,13 @@ class KittiDataset(Det3DDataset):
Args:
data_root (str): Path of dataset root.
ann_file (str): Path of annotation file.
pipeline (list[dict], optional): Pipeline used for data processing.
Defaults to None.
modality (dict, optional): Modality to specify the sensor data used
as input. Defaults to `dict(use_lidar=True)`.
default_cam_key (str, optional): The default camera name adopted.
pipeline (list[dict]): Pipeline used for data processing.
Defaults to [].
modality (dict): Modality to specify the sensor data used as input.
Defaults to `dict(use_lidar=True)`.
default_cam_key (str): The default camera name adopted.
Defaults to 'CAM2'.
box_type_3d (str, optional): Type of 3D box of this dataset.
box_type_3d (str): Type of 3D box of this dataset.
Based on the `box_type_3d`, the dataset will encapsulate the box
to its original format then converted them to `box_type_3d`.
Defaults to 'LiDAR' in this dataset. Available options includes:
......@@ -32,12 +32,14 @@ class KittiDataset(Det3DDataset):
- 'LiDAR': Box in LiDAR coordinates.
- 'Depth': Box in depth coordinates, usually for indoor dataset.
- 'Camera': Box in camera coordinates.
filter_empty_gt (bool, optional): Whether to filter empty GT.
Defaults to True.
test_mode (bool, optional): Whether the dataset is in test mode.
filter_empty_gt (bool): Whether to filter the data with empty GT.
If it's set to be True, the example with empty annotations after
data pipeline will be dropped and a random example will be chosen
in `__getitem__`. Defaults to True.
test_mode (bool): Whether the dataset is in test mode.
Defaults to False.
pcd_limit_range (list[float], optional): The range of point cloud
used to filter invalid predicted boxes.
pcd_limit_range (list[float]): The range of point cloud used to filter
invalid predicted boxes.
Defaults to [0, -40, -3, 70.4, 40, 0.0].
"""
# TODO: use full classes of kitti
......@@ -119,13 +121,13 @@ class KittiDataset(Det3DDataset):
return info
def parse_ann_info(self, info: dict) -> dict:
"""Get annotation info according to the given index.
"""Process the `instances` in data info to `ann_info`.
Args:
info (dict): Data information of single data sample.
Returns:
dict: annotation information consists of the following keys:
dict: Annotation information consists of the following keys:
- gt_bboxes_3d (:obj:`LiDARInstance3DBoxes`):
3D ground truth bboxes.
......
......@@ -21,10 +21,10 @@ class LyftDataset(Det3DDataset):
Args:
data_root (str): Path of dataset root.
ann_file (str): Path of annotation file.
pipeline (list[dict], optional): Pipeline used for data processing.
Defaults to None.
modality (dict, optional): Modality to specify the sensor data used
as input. Defaults to dict(use_camera=False, use_lidar=True).
pipeline (list[dict]): Pipeline used for data processing.
Defaults to [].
modality (dict): Modality to specify the sensor data used as input.
Defaults to dict(use_camera=False, use_lidar=True).
box_type_3d (str): Type of 3D box of this dataset.
Based on the `box_type_3d`, the dataset will encapsulate the box
to its original format then converted them to `box_type_3d`.
......@@ -33,9 +33,11 @@ class LyftDataset(Det3DDataset):
- 'LiDAR': Box in LiDAR coordinates.
- 'Depth': Box in depth coordinates, usually for indoor dataset.
- 'Camera': Box in camera coordinates.
filter_empty_gt (bool, optional): Whether to filter empty GT.
Defaults to True.
test_mode (bool, optional): Whether the dataset is in test mode.
filter_empty_gt (bool): Whether to filter the data with empty GT.
If it's set to be True, the example with empty annotations after
data pipeline will be dropped and a random example will be chosen
in `__getitem__`. Defaults to True.
test_mode (bool): Whether the dataset is in test mode.
Defaults to False.
"""
......@@ -66,13 +68,13 @@ class LyftDataset(Det3DDataset):
**kwargs)
def parse_ann_info(self, info: dict) -> dict:
"""Get annotation info according to the given index.
"""Process the `instances` in data info to `ann_info`.
Args:
info (dict): Data information of single data sample.
Returns:
dict: annotation information consists of the following keys:
dict: Annotation information consists of the following keys:
- gt_bboxes_3d (:obj:`LiDARInstance3DBoxes`):
3D ground truth bboxes.
......
......@@ -22,9 +22,9 @@ class NuScenesDataset(Det3DDataset):
Args:
data_root (str): Path of dataset root.
ann_file (str): Path of annotation file.
task (str, optional): Detection task. Defaults to 'lidar_det'.
pipeline (list[dict], optional): Pipeline used for data processing.
Defaults to None.
task (str): Detection task. Defaults to 'lidar_det'.
pipeline (list[dict]): Pipeline used for data processing.
Defaults to [].
box_type_3d (str): Type of 3D box of this dataset.
Based on the `box_type_3d`, the dataset will encapsulate the box
to its original format then converted them to `box_type_3d`.
......@@ -33,15 +33,17 @@ class NuScenesDataset(Det3DDataset):
- 'LiDAR': Box in LiDAR coordinates.
- 'Depth': Box in depth coordinates, usually for indoor dataset.
- 'Camera': Box in camera coordinates.
modality (dict, optional): Modality to specify the sensor data used
as input. Defaults to dict(use_camera=False, use_lidar=True).
filter_empty_gt (bool, optional): Whether to filter empty GT.
Defaults to True.
test_mode (bool, optional): Whether the dataset is in test mode.
modality (dict): Modality to specify the sensor data used as input.
Defaults to dict(use_camera=False, use_lidar=True).
filter_empty_gt (bool): Whether to filter the data with empty GT.
If it's set to be True, the example with empty annotations after
data pipeline will be dropped and a random example will be chosen
in `__getitem__`. Defaults to True.
test_mode (bool): Whether the dataset is in test mode.
Defaults to False.
with_velocity (bool, optional): Whether to include velocity prediction
with_velocity (bool): Whether to include velocity prediction
into the experiments. Defaults to True.
use_valid_flag (bool, optional): Whether to use `use_valid_flag` key
use_valid_flag (bool): Whether to use `use_valid_flag` key
in the info file as mask to filter gt_boxes and gt_names.
Defaults to False.
"""
......@@ -108,13 +110,13 @@ class NuScenesDataset(Det3DDataset):
return filtered_annotations
def parse_ann_info(self, info: dict) -> dict:
"""Get annotation info according to the given index.
"""Process the `instances` in data info to `ann_info`.
Args:
info (dict): Data information of single data sample.
Returns:
dict: annotation information consists of the following keys:
dict: Annotation information consists of the following keys:
- gt_bboxes_3d (:obj:`LiDARInstance3DBoxes`):
3D ground truth bboxes.
......
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