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

Bump version to v1.3.0

Bump version to v1.3.0
parents b0e8ece9 12b595ca
_base_ = ['../../../configs/_base_/default_runtime.py']
custom_imports = dict(
imports=['projects.CENet.cenet'], allow_failed_imports=False)
# For SemanticKitti we usually do 19-class segmentation.
# For labels_map we follow the uniform format of MMDetection & MMSegmentation
# i.e. we consider the unlabeled class as the last one, which is different
# from the original implementation of some methods e.g. Cylinder3D.
dataset_type = 'SemanticKittiDataset'
data_root = 'data/semantickitti/'
class_names = [
'car', 'bicycle', 'motorcycle', 'truck', 'bus', 'person', 'bicyclist',
'motorcyclist', 'road', 'parking', 'sidewalk', 'other-ground', 'building',
'fence', 'vegetation', 'trunck', 'terrian', 'pole', 'traffic-sign'
]
labels_map = {
0: 19, # "unlabeled"
1: 19, # "outlier" mapped to "unlabeled" --------------mapped
10: 0, # "car"
11: 1, # "bicycle"
13: 4, # "bus" mapped to "other-vehicle" --------------mapped
15: 2, # "motorcycle"
16: 4, # "on-rails" mapped to "other-vehicle" ---------mapped
18: 3, # "truck"
20: 4, # "other-vehicle"
30: 5, # "person"
31: 6, # "bicyclist"
32: 7, # "motorcyclist"
40: 8, # "road"
44: 9, # "parking"
48: 10, # "sidewalk"
49: 11, # "other-ground"
50: 12, # "building"
51: 13, # "fence"
52: 19, # "other-structure" mapped to "unlabeled" ------mapped
60: 8, # "lane-marking" to "road" ---------------------mapped
70: 14, # "vegetation"
71: 15, # "trunk"
72: 16, # "terrain"
80: 17, # "pole"
81: 18, # "traffic-sign"
99: 19, # "other-object" to "unlabeled" ----------------mapped
252: 0, # "moving-car" to "car" ------------------------mapped
253: 6, # "moving-bicyclist" to "bicyclist" ------------mapped
254: 5, # "moving-person" to "person" ------------------mapped
255: 7, # "moving-motorcyclist" to "motorcyclist" ------mapped
256: 4, # "moving-on-rails" mapped to "other-vehic------mapped
257: 4, # "moving-bus" mapped to "other-vehicle" -------mapped
258: 3, # "moving-truck" to "truck" --------------------mapped
259: 4 # "moving-other"-vehicle to "other-vehicle"-----mapped
}
metainfo = dict(
classes=class_names, seg_label_mapping=labels_map, max_label=259)
input_modality = dict(use_lidar=True, use_camera=False)
# Example to use different file client
# Method 1: simply set the data root and let the file I/O module
# automatically infer from prefix (not support LMDB and Memcache yet)
# data_root = 's3://openmmlab/datasets/detection3d/semantickitti/'
# Method 2: Use backend_args, file_client_args in versions before 1.1.0
# backend_args = dict(
# backend='petrel',
# path_mapping=dict({
# './data/': 's3://openmmlab/datasets/detection3d/',
# 'data/': 's3://openmmlab/datasets/detection3d/'
# }))
backend_args = None
train_pipeline = [
dict(
type='LoadPointsFromFile',
coord_type='LIDAR',
load_dim=4,
use_dim=4,
backend_args=backend_args),
dict(
type='LoadAnnotations3D',
with_bbox_3d=False,
with_label_3d=False,
with_seg_3d=True,
seg_3d_dtype='np.int32',
seg_offset=2**16,
dataset_type='semantickitti',
backend_args=backend_args),
dict(type='PointSegClassMapping'),
dict(type='PointSample', num_points=0.9),
dict(
type='RandomFlip3D',
sync_2d=False,
flip_ratio_bev_horizontal=0.5,
flip_ratio_bev_vertical=0.5),
dict(
type='GlobalRotScaleTrans',
rot_range=[-3.1415929, 3.1415929],
scale_ratio_range=[0.95, 1.05],
translation_std=[0.1, 0.1, 0.1],
),
dict(
type='SemkittiRangeView',
H=64,
W=512,
fov_up=3.0,
fov_down=-25.0,
means=(11.71279, -0.1023471, 0.4952, -1.0545, 0.2877),
stds=(10.24, 12.295865, 9.4287, 0.8643, 0.1450),
ignore_index=19),
dict(type='Pack3DDetInputs', keys=['img', 'gt_semantic_seg'])
]
test_pipeline = [
dict(
type='LoadPointsFromFile',
coord_type='LIDAR',
load_dim=4,
use_dim=4,
backend_args=backend_args),
dict(
type='LoadAnnotations3D',
with_bbox_3d=False,
with_label_3d=False,
with_seg_3d=True,
seg_3d_dtype='np.int32',
seg_offset=2**16,
dataset_type='semantickitti',
backend_args=backend_args),
dict(type='PointSegClassMapping'),
dict(
type='SemkittiRangeView',
H=64,
W=512,
fov_up=3.0,
fov_down=-25.0,
means=(11.71279, -0.1023471, 0.4952, -1.0545, 0.2877),
stds=(10.24, 12.295865, 9.4287, 0.8643, 0.1450),
ignore_index=19),
dict(
type='Pack3DDetInputs',
keys=['img'],
meta_keys=('proj_x', 'proj_y', 'proj_range', 'unproj_range'))
]
train_dataloader = dict(
batch_size=4,
num_workers=4,
persistent_workers=True,
sampler=dict(type='DefaultSampler', shuffle=True),
dataset=dict(
type=dataset_type,
data_root=data_root,
ann_file='semantickitti_infos_train.pkl',
pipeline=train_pipeline,
metainfo=metainfo,
modality=input_modality,
ignore_index=19,
backend_args=backend_args))
val_dataloader = dict(
batch_size=1,
num_workers=1,
persistent_workers=True,
drop_last=False,
sampler=dict(type='DefaultSampler', shuffle=False),
dataset=dict(
type=dataset_type,
data_root=data_root,
ann_file='semantickitti_infos_val.pkl',
pipeline=test_pipeline,
metainfo=metainfo,
modality=input_modality,
ignore_index=19,
test_mode=True,
backend_args=backend_args))
test_dataloader = val_dataloader
val_evaluator = dict(type='SegMetric')
test_evaluator = val_evaluator
vis_backends = [dict(type='LocalVisBackend')]
visualizer = dict(
type='Det3DLocalVisualizer', vis_backends=vis_backends, name='visualizer')
model = dict(
type='RangeImageSegmentor',
data_preprocessor=dict(type='Det3DDataPreprocessor'),
backbone=dict(
type='CENet',
in_channels=5,
stem_channels=128,
num_stages=4,
stage_blocks=(3, 4, 6, 3),
out_channels=(128, 128, 128, 128),
fuse_channels=(256, 128),
strides=(1, 2, 2, 2),
dilations=(1, 1, 1, 1),
act_cfg=dict(type='HSwish', inplace=True)),
decode_head=dict(
type='RangeImageHead',
channels=128,
num_classes=20,
dropout_ratio=0,
loss_ce=dict(
type='mmdet.CrossEntropyLoss',
use_sigmoid=False,
class_weight=None,
loss_weight=1.0),
loss_lovasz=dict(type='LovaszLoss', loss_weight=1.5, reduction='none'),
loss_boundary=dict(type='BoundaryLoss', loss_weight=1.0),
conv_seg_kernel_size=1,
ignore_index=19),
auxiliary_head=[
dict(
type='RangeImageHead',
channels=128,
num_classes=20,
dropout_ratio=0,
loss_ce=dict(
type='mmdet.CrossEntropyLoss',
use_sigmoid=False,
class_weight=None,
loss_weight=1.0),
loss_lovasz=dict(
type='LovaszLoss', loss_weight=1.5, reduction='none'),
loss_boundary=dict(type='BoundaryLoss', loss_weight=1.0),
conv_seg_kernel_size=1,
ignore_index=19,
indices=2),
dict(
type='RangeImageHead',
channels=128,
num_classes=20,
dropout_ratio=0,
loss_ce=dict(
type='mmdet.CrossEntropyLoss',
use_sigmoid=False,
class_weight=None,
loss_weight=1.0),
loss_lovasz=dict(
type='LovaszLoss', loss_weight=1.5, reduction='none'),
loss_boundary=dict(type='BoundaryLoss', loss_weight=1.0),
conv_seg_kernel_size=1,
ignore_index=19,
indices=3),
dict(
type='RangeImageHead',
channels=128,
num_classes=20,
dropout_ratio=0,
loss_ce=dict(
type='mmdet.CrossEntropyLoss',
use_sigmoid=False,
class_weight=None,
loss_weight=1.0),
loss_lovasz=dict(
type='LovaszLoss', loss_weight=1.5, reduction='none'),
loss_boundary=dict(type='BoundaryLoss', loss_weight=1.0),
conv_seg_kernel_size=1,
ignore_index=19,
indices=4)
],
train_cfg=None,
test_cfg=dict(use_knn=True, knn=7, search=7, sigma=1.0, cutoff=2.0))
# optimizer
# This schedule is mainly used on Semantickitti dataset in segmentation task
optim_wrapper = dict(
type='AmpOptimWrapper',
loss_scale='dynamic',
optimizer=dict(
type='AdamW',
lr=0.04,
betas=(0.9, 0.999),
weight_decay=(0.01),
eps=0.000005))
param_scheduler = [
dict(
type='OneCycleLR',
total_steps=50,
by_epoch=True,
eta_max=0.0025,
pct_start=0.2,
div_factor=25.0,
final_div_factor=100.0,
convert_to_iter_based=True)
]
# runtime settings
train_cfg = dict(by_epoch=True, max_epochs=50, val_interval=1)
val_cfg = dict()
test_cfg = dict()
# Default setting for scaling LR automatically
# - `enable` means enable scaling LR automatically
# or not by default.
# - `base_batch_size` = (4 GPUs) x (4 samples per GPU).
auto_scale_lr = dict(enable=False, base_batch_size=16)
default_hooks = dict(checkpoint=dict(type='CheckpointHook', interval=1))
DETR3D: 3D Object Detection from Multi-view Images via 3D-to-2D Queries
# DETR3D: 3D Object Detection from Multi-view Images via 3D-to-2D Queries
> [DETR3D: 3D Object Detection from Multi-view Images via 3D-to-2D Queries](https://arxiv.org/abs/2110.06922)
......
mmcv>=2.0.0rc4,<2.1.0
mmdet>=3.0.0,<3.2.0
mmcv>=2.0.0rc4,<2.2.0
mmdet>=3.0.0,<3.3.0
mmengine>=0.7.1,<1.0.0
......@@ -3,7 +3,7 @@ networkx>=2.5
numba # you should install numba==0.53.0 if your environment is cuda-9.0
numpy
nuscenes-devkit
open3d==0.16.0
open3d
plyfile
scikit-image
# by default we also use tensorboard to log results
......
......@@ -89,7 +89,7 @@ class TestLidarDet3DInferencer(TestCase):
inputs = dict(points='tests/data/kitti/training/velodyne/000000.bin'),
# img_out_dir
with tempfile.TemporaryDirectory() as tmp_dir:
self.inferencer(inputs, img_out_dir=tmp_dir)
self.inferencer(inputs, out_dir=tmp_dir)
# TODO: For LiDAR-based detection, the saved image only exists when
# show=True.
# self.assertTrue(osp.exists(osp.join(tmp_dir, '000000.png')))
......@@ -102,11 +102,9 @@ class TestLidarDet3DInferencer(TestCase):
res = self.inferencer(inputs, return_datasamples=True)
self.assertTrue(is_list_of(res['predictions'], Det3DDataSample))
# pred_out_file
# pred_out_dir
with tempfile.TemporaryDirectory() as tmp_dir:
pred_out_file = osp.join(tmp_dir, 'tmp.json')
res = self.inferencer(
inputs, print_result=True, pred_out_file=pred_out_file)
dumped_res = mmengine.load(pred_out_file)
self.assert_predictions_equal(res['predictions'],
dumped_res['predictions'])
res = self.inferencer(inputs, print_result=True, out_dir=tmp_dir)
dumped_res = mmengine.load(
osp.join(tmp_dir, 'preds', '000000.json'))
self.assertEqual(res['predictions'][0], dumped_res)
# Copyright (c) OpenMMLab. All rights reserved.
import os
import os.path as osp
import tempfile
from unittest import TestCase
import mmengine
import numpy as np
import pytest
import torch
from mmengine.utils import is_list_of
......@@ -33,9 +35,11 @@ class TestLiDARSeg3DInferencer(TestCase):
np.allclose(pred1['pts_semantic_mask'],
pred2['pts_semantic_mask']))
@pytest.mark.skipif(
not torch.cuda.is_available(), reason='requires CUDA support')
@pytest.mark.skipif(
'DISPLAY' not in os.environ, reason='requires DISPLAY device')
def test_call(self):
if not torch.cuda.is_available():
return
# single point cloud
inputs = dict(points='tests/data/s3dis/points/Area_1_office_2.bin')
torch.manual_seed(0)
......@@ -79,13 +83,15 @@ class TestLiDARSeg3DInferencer(TestCase):
self.assertIn('visualization', res_bs2)
self.assertIn('predictions', res_bs2)
@pytest.mark.skipif(
not torch.cuda.is_available(), reason='requires CUDA support')
@pytest.mark.skipif(
'DISPLAY' not in os.environ, reason='requires DISPLAY device')
def test_visualizer(self):
if not torch.cuda.is_available():
return
inputs = dict(points='tests/data/s3dis/points/Area_1_office_2.bin')
# img_out_dir
with tempfile.TemporaryDirectory() as tmp_dir:
self.inferencer(inputs, img_out_dir=tmp_dir)
self.inferencer(inputs, out_dir=tmp_dir)
def test_post_processor(self):
if not torch.cuda.is_available():
......@@ -95,11 +101,9 @@ class TestLiDARSeg3DInferencer(TestCase):
res = self.inferencer(inputs, return_datasamples=True)
self.assertTrue(is_list_of(res['predictions'], Det3DDataSample))
# pred_out_file
# pred_out_dir
with tempfile.TemporaryDirectory() as tmp_dir:
pred_out_file = osp.join(tmp_dir, 'tmp.json')
res = self.inferencer(
inputs, print_result=True, pred_out_file=pred_out_file)
dumped_res = mmengine.load(pred_out_file)
self.assert_predictions_equal(res['predictions'],
dumped_res['predictions'])
res = self.inferencer(inputs, print_result=True, out_dir=tmp_dir)
dumped_res = mmengine.load(
osp.join(tmp_dir, 'preds', 'Area_1_office_2.json'))
self.assertEqual(res['predictions'][0], dumped_res)
......@@ -42,13 +42,13 @@ class TestMonoDet3DInferencer(TestCase):
def test_call(self, model):
# single img
img_path = 'demo/data/kitti/000008.png'
calib_path = 'demo/data/kitti/000008.txt'
infos_path = 'demo/data/kitti/000008.pkl'
inferencer = MonoDet3DInferencer(model)
inputs = dict(img=img_path, calib=calib_path)
inputs = dict(img=img_path, infos=infos_path)
res_path = inferencer(inputs, return_vis=True)
# ndarray
img = mmcv.imread(img_path)
inputs = dict(img=img, calib=calib_path)
inputs = dict(img=img, infos=infos_path)
res_ndarray = inferencer(inputs, return_vis=True)
self.assert_predictions_equal(res_path['predictions'],
res_ndarray['predictions'])
......@@ -59,16 +59,18 @@ class TestMonoDet3DInferencer(TestCase):
inputs = [
dict(
img='demo/data/kitti/000008.png',
calib='demo/data/kitti/000008.txt'),
infos='demo/data/kitti/000008.pkl'),
dict(
img='demo/data/kitti/000008.png',
calib='demo/data/kitti/000008.txt')
infos='demo/data/kitti/000008.pkl')
]
res_path = inferencer(inputs, return_vis=True)
# list of ndarray
imgs = [mmcv.imread(p['img']) for p in inputs]
inputs[0]['img'] = imgs[0]
inputs[1]['img'] = imgs[1]
inputs = [
dict(img=imgs[0], infos='demo/data/kitti/000008.pkl'),
dict(img=imgs[1], infos='demo/data/kitti/000008.pkl')
]
res_ndarray = inferencer(inputs, return_vis=True)
self.assert_predictions_equal(res_path['predictions'],
res_ndarray['predictions'])
......@@ -77,36 +79,30 @@ class TestMonoDet3DInferencer(TestCase):
@parameterized.expand(['pgd_kitti'])
def test_visualize(self, model):
inputs = [
dict(
img='demo/data/kitti/000008.png',
calib='demo/data/kitti/000008.txt'),
dict(
img='demo/data/kitti/000008.png',
calib='demo/data/kitti/000008.txt')
]
inputs = dict(
img='demo/data/kitti/000008.png',
infos='demo/data/kitti/000008.pkl')
inferencer = MonoDet3DInferencer(model)
# img_out_dir
with tempfile.TemporaryDirectory() as tmp_dir:
inferencer(inputs, img_out_dir=tmp_dir)
for img_dir in ['000008.png', '000008.png']:
self.assertTrue(osp.exists(osp.join(tmp_dir, img_dir)))
inferencer(inputs, out_dir=tmp_dir)
self.assertTrue(
osp.exists(osp.join(tmp_dir, 'vis_camera/CAM2/000008.png')))
@parameterized.expand(['pgd_kitti'])
def test_postprocess(self, model):
# return_datasample
img_path = 'demo/data/kitti/000008.png'
calib_path = 'demo/data/kitti/000008.txt'
inputs = dict(img=img_path, calib=calib_path)
infos_path = 'demo/data/kitti/000008.pkl'
inputs = dict(img=img_path, infos=infos_path)
inferencer = MonoDet3DInferencer(model)
res = inferencer(inputs, return_datasamples=True)
self.assertTrue(is_list_of(res['predictions'], Det3DDataSample))
# pred_out_file
# pred_out_dir
with tempfile.TemporaryDirectory() as tmp_dir:
pred_out_file = osp.join(tmp_dir, 'tmp.json')
res = inferencer(
inputs, print_result=True, pred_out_file=pred_out_file)
dumped_res = mmengine.load(pred_out_file)
self.assert_predictions_equal(res['predictions'],
dumped_res['predictions'])
inputs = dict(img=img_path, infos=infos_path)
res = inferencer(inputs, print_result=True, out_dir=tmp_dir)
dumped_res = mmengine.load(
osp.join(tmp_dir, 'preds', '000008.json'))
self.assertEqual(res['predictions'][0], dumped_res)
......@@ -44,11 +44,11 @@ class TestMultiModalityDet3DInferencer(TestCase):
def test_call(self):
if not torch.cuda.is_available():
return
calib_path = 'tests/data/kitti/training/calib/000000.pkl'
points_path = 'tests/data/kitti/training/velodyne/000000.bin'
img_path = 'tests/data/kitti/training/image_2/000000.png'
infos_path = 'demo/data/kitti/000008.pkl'
points_path = 'demo/data/kitti/000008.bin'
img_path = 'demo/data/kitti/000008.png'
# single img & point cloud
inputs = dict(points=points_path, img=img_path, calib=calib_path)
inputs = dict(points=points_path, img=img_path, infos=infos_path)
res_path = self.inferencer(inputs, return_vis=True)
# ndarray
......@@ -57,7 +57,7 @@ class TestMultiModalityDet3DInferencer(TestCase):
points = points.reshape(-1, 4)
points = points[:, :4]
img = mmcv.imread(inputs['img'])
inputs = dict(points=points, img=img, calib=calib_path)
inputs = dict(points=points, img=img, infos=infos_path)
res_ndarray = self.inferencer(inputs, return_vis=True)
self.assert_predictions_equal(res_path['predictions'],
res_ndarray['predictions'])
......@@ -66,8 +66,8 @@ class TestMultiModalityDet3DInferencer(TestCase):
# multiple imgs & point clouds
inputs = [
dict(points=points_path, img=img_path, calib=calib_path),
dict(points=points_path, img=img_path, calib=calib_path)
dict(points=points_path, img=img_path, infos=infos_path),
dict(points=points_path, img=img_path, infos=infos_path)
]
res_path = self.inferencer(inputs, return_vis=True)
# list of ndarray
......@@ -77,7 +77,7 @@ class TestMultiModalityDet3DInferencer(TestCase):
points = np.frombuffer(pts_bytes, dtype=np.float32)
points = points.reshape(-1, 4)
img = mmcv.imread(p['img'])
all_inputs.append(dict(points=points, img=img, calib=p['calib']))
all_inputs.append(dict(points=points, img=img, infos=infos_path))
res_ndarray = self.inferencer(all_inputs, return_vis=True)
self.assert_predictions_equal(res_path['predictions'],
......@@ -89,12 +89,12 @@ class TestMultiModalityDet3DInferencer(TestCase):
if not torch.cuda.is_available():
return
inputs = dict(
points='tests/data/kitti/training/velodyne/000000.bin',
img='tests/data/kitti/training/image_2/000000.png',
calib='tests/data/kitti/training/calib/000000.pkl'),
points='demo/data/kitti/000008.bin',
img='demo/data/kitti/000008.png',
infos='demo/data/kitti/000008.pkl'),
# img_out_dir
with tempfile.TemporaryDirectory() as tmp_dir:
self.inferencer(inputs, img_out_dir=tmp_dir)
self.inferencer(inputs, out_dir=tmp_dir)
# TODO: For results of LiDAR-based detection, the saved image only
# exists when show=True.
# self.assertTrue(osp.exists(osp.join(tmp_dir, '000000.png')))
......@@ -103,18 +103,18 @@ class TestMultiModalityDet3DInferencer(TestCase):
if not torch.cuda.is_available():
return
# return_datasample
inputs = dict(
points='tests/data/kitti/training/velodyne/000000.bin',
img='tests/data/kitti/training/image_2/000000.png',
calib='tests/data/kitti/training/calib/000000.pkl')
infos_path = 'demo/data/kitti/000008.pkl'
points_path = 'demo/data/kitti/000008.bin'
img_path = 'demo/data/kitti/000008.png'
# single img & point cloud
inputs = dict(points=points_path, img=img_path, infos=infos_path)
res = self.inferencer(inputs, return_datasamples=True)
self.assertTrue(is_list_of(res['predictions'], Det3DDataSample))
# pred_out_file
# pred_out_dir
with tempfile.TemporaryDirectory() as tmp_dir:
pred_out_file = osp.join(tmp_dir, 'tmp.json')
res = self.inferencer(
inputs, print_result=True, pred_out_file=pred_out_file)
dumped_res = mmengine.load(pred_out_file)
self.assert_predictions_equal(res['predictions'],
dumped_res['predictions'])
inputs = dict(points=points_path, img=img_path, infos=infos_path)
res = self.inferencer(inputs, print_result=True, out_dir=tmp_dir)
dumped_res = mmengine.load(
osp.join(tmp_dir, 'preds', '000008.json'))
self.assertEqual(res['predictions'][0], dumped_res)
......@@ -8,7 +8,7 @@ for split in $DOWNLOAD_DIR/nuScenes/raw/*; do
if [[ $tgz_file == *.tgz ]]
then
echo "Unzipping $tgz_file to $DATA_ROOT ......"
unzip -oq $tgz_file -d $DATA_ROOT/
tar -zxvf $tgz_file -C $DATA_ROOT/
echo "[Done] Unzip $tgz_file to $DATA_ROOT"
fi
# delete the original files
......
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