Unverified Commit 3fa8b512 authored by Shaoshuai Shi's avatar Shaoshuai Shi Committed by GitHub
Browse files

Merge pull request #683 from sshaoshuai/master

Release OpenPCDet v0.5.0
parents 70857b83 d1368b01
import os import os
import sys
import subprocess import subprocess
from setuptools import find_packages, setup from setuptools import find_packages, setup
from setuptools.command.install import install
# TODO: This is a bit buggy since it requires torch before installing torch.
from torch.utils.cpp_extension import BuildExtension, CUDAExtension from torch.utils.cpp_extension import BuildExtension, CUDAExtension
...@@ -30,17 +27,8 @@ def write_version_to_file(version, target_file): ...@@ -30,17 +27,8 @@ def write_version_to_file(version, target_file):
print('__version__ = "%s"' % version, file=f) print('__version__ = "%s"' % version, file=f)
class PostInstallation(install):
"""Post-installation for installation mode."""
def run(self):
install.run(self)
# Note: buggy for kornia==0.5.3 and it will be fixed in the next version.
# Set kornia to 0.5.2 temporarily
subprocess.call([sys.executable, '-m', 'pip', 'install', 'kornia==0.5.2', '--no-dependencies'])
if __name__ == '__main__': if __name__ == '__main__':
version = '0.4.0+%s' % get_git_commit_number() version = '0.5.0+%s' % get_git_commit_number()
write_version_to_file(version, 'pcdet/version.py') write_version_to_file(version, 'pcdet/version.py')
setup( setup(
...@@ -48,23 +36,24 @@ if __name__ == '__main__': ...@@ -48,23 +36,24 @@ if __name__ == '__main__':
version=version, version=version,
description='OpenPCDet is a general codebase for 3D object detection from point cloud', description='OpenPCDet is a general codebase for 3D object detection from point cloud',
install_requires=[ install_requires=[
'numpy', 'numpy<=1.20',
'torch>=1.1', 'llvmlite',
# 'spconv', # spconv has different names depending on the cuda version
'numba', 'numba',
'tensorboardX', 'tensorboardX',
'easydict', 'easydict',
'pyyaml' 'pyyaml',
'scikit-image',
'tqdm',
'SharedArray',
# 'spconv', # spconv has different names depending on the cuda version
], ],
author='Shaoshuai Shi', author='Shaoshuai Shi',
author_email='shaoshuaics@gmail.com', author_email='shaoshuaics@gmail.com',
license='Apache License 2.0', license='Apache License 2.0',
packages=find_packages(exclude=['tools', 'data', 'output']), packages=find_packages(exclude=['tools', 'data', 'output']),
cmdclass={ cmdclass={
'build_ext': BuildExtension, 'build_ext': BuildExtension,
'install': PostInstallation,
# Post installation cannot be done. ref: https://github.com/pypa/setuptools/issues/1936.
# 'develop': PostInstallation,
}, },
ext_modules=[ ext_modules=[
make_cuda_ext( make_cuda_ext(
......
import sys
sys.path.insert(0, '../')
\ No newline at end of file
DATASET: 'WaymoDataset' DATASET: 'WaymoDataset'
DATA_PATH: '../data/waymo' DATA_PATH: '../data/waymo'
PROCESSED_DATA_TAG: 'waymo_processed_data' PROCESSED_DATA_TAG: 'waymo_processed_data_v0_5_0'
POINT_CLOUD_RANGE: [-75.2, -75.2, -2, 75.2, 75.2, 4] POINT_CLOUD_RANGE: [-75.2, -75.2, -2, 75.2, 75.2, 4]
...@@ -11,16 +11,27 @@ DATA_SPLIT: { ...@@ -11,16 +11,27 @@ DATA_SPLIT: {
SAMPLED_INTERVAL: { SAMPLED_INTERVAL: {
'train': 5, 'train': 5,
'test': 5 'test': 1
} }
FILTER_EMPTY_BOXES_FOR_TRAIN: True
DISABLE_NLZ_FLAG_ON_POINTS: True
USE_SHARED_MEMORY: False # it will load the data to shared memory to speed up (DO NOT USE IT IF YOU DO NOT FULLY UNDERSTAND WHAT WILL HAPPEN)
SHARED_MEMORY_FILE_LIMIT: 35000 # set it based on the size of your shared memory
DATA_AUGMENTOR: DATA_AUGMENTOR:
DISABLE_AUG_LIST: ['placeholder'] DISABLE_AUG_LIST: ['placeholder']
AUG_CONFIG_LIST: AUG_CONFIG_LIST:
- NAME: gt_sampling - NAME: gt_sampling
USE_ROAD_PLANE: False USE_ROAD_PLANE: False
DB_INFO_PATH: DB_INFO_PATH:
- pcdet_waymo_dbinfos_train_sampled_10.pkl - waymo_processed_data_v0_5_0_waymo_dbinfos_train_sampled_1.pkl
USE_SHARED_MEMORY: False # set it to True to speed up (it costs about 15GB shared memory)
DB_DATA_PATH:
- waymo_processed_data_v0_5_0_gt_database_train_sampled_1_global.npy
PREPARE: { PREPARE: {
filter_by_min_points: ['Vehicle:5', 'Pedestrian:5', 'Cyclist:5'], filter_by_min_points: ['Vehicle:5', 'Pedestrian:5', 'Cyclist:5'],
filter_by_difficulty: [-1], filter_by_difficulty: [-1],
...@@ -62,6 +73,6 @@ DATA_PROCESSOR: ...@@ -62,6 +73,6 @@ DATA_PROCESSOR:
VOXEL_SIZE: [0.1, 0.1, 0.15] VOXEL_SIZE: [0.1, 0.1, 0.15]
MAX_POINTS_PER_VOXEL: 5 MAX_POINTS_PER_VOXEL: 5
MAX_NUMBER_OF_VOXELS: { MAX_NUMBER_OF_VOXELS: {
'train': 80000, 'train': 150000,
'test': 90000 'test': 150000
} }
...@@ -119,9 +119,12 @@ MODEL: ...@@ -119,9 +119,12 @@ MODEL:
TEST: TEST:
NMS_TYPE: nms_gpu NMS_TYPE: nms_gpu
MULTI_CLASSES_NMS: False MULTI_CLASSES_NMS: False
NMS_PRE_MAXSIZE: 1024 # NMS_PRE_MAXSIZE: 1024
NMS_POST_MAXSIZE: 100 # NMS_POST_MAXSIZE: 100
NMS_THRESH: 0.7 # NMS_THRESH: 0.7
NMS_PRE_MAXSIZE: 4096
NMS_POST_MAXSIZE: 300
NMS_THRESH: 0.85
ROI_AWARE_POOL: ROI_AWARE_POOL:
POOL_SIZE: 10 POOL_SIZE: 10
...@@ -164,13 +167,13 @@ MODEL: ...@@ -164,13 +167,13 @@ MODEL:
NMS_CONFIG: NMS_CONFIG:
MULTI_CLASSES_NMS: False MULTI_CLASSES_NMS: False
NMS_TYPE: nms_gpu NMS_TYPE: nms_gpu
NMS_THRESH: 0.1 NMS_THRESH: 0.7
NMS_PRE_MAXSIZE: 4096 NMS_PRE_MAXSIZE: 4096
NMS_POST_MAXSIZE: 500 NMS_POST_MAXSIZE: 500
OPTIMIZATION: OPTIMIZATION:
BATCH_SIZE_PER_GPU: 3 BATCH_SIZE_PER_GPU: 2
NUM_EPOCHS: 30 NUM_EPOCHS: 30
OPTIMIZER: adam_onecycle OPTIMIZER: adam_onecycle
......
CLASS_NAMES: ['Vehicle', 'Pedestrian', 'Cyclist']
DATA_CONFIG:
_BASE_CONFIG_: cfgs/dataset_configs/waymo_dataset.yaml
MODEL:
NAME: CenterPoint
VFE:
NAME: MeanVFE
BACKBONE_3D:
NAME: VoxelResBackBone8x
MAP_TO_BEV:
NAME: HeightCompression
NUM_BEV_FEATURES: 256
BACKBONE_2D:
NAME: BaseBEVBackbone
LAYER_NUMS: [5, 5]
LAYER_STRIDES: [1, 2]
NUM_FILTERS: [128, 256]
UPSAMPLE_STRIDES: [1, 2]
NUM_UPSAMPLE_FILTERS: [256, 256]
DENSE_HEAD:
NAME: CenterHead
CLASS_AGNOSTIC: False
CLASS_NAMES_EACH_HEAD: [
['Vehicle', 'Pedestrian', 'Cyclist']
]
SHARED_CONV_CHANNEL: 64
USE_BIAS_BEFORE_NORM: True
NUM_HM_CONV: 2
SEPARATE_HEAD_CFG:
HEAD_ORDER: ['center', 'center_z', 'dim', 'rot']
HEAD_DICT: {
'center': {'out_channels': 2, 'num_conv': 2},
'center_z': {'out_channels': 1, 'num_conv': 2},
'dim': {'out_channels': 3, 'num_conv': 2},
'rot': {'out_channels': 2, 'num_conv': 2},
}
TARGET_ASSIGNER_CONFIG:
FEATURE_MAP_STRIDE: 8
NUM_MAX_OBJS: 500
GAUSSIAN_OVERLAP: 0.1
MIN_RADIUS: 2
LOSS_CONFIG:
LOSS_WEIGHTS: {
'cls_weight': 1.0,
'loc_weight': 2.0,
'code_weights': [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
}
POST_PROCESSING:
SCORE_THRESH: 0.1
POST_CENTER_LIMIT_RANGE: [-75.2, -75.2, -2, 75.2, 75.2, 4]
MAX_OBJ_PER_SAMPLE: 500
NMS_CONFIG:
NMS_TYPE: nms_gpu
NMS_THRESH: 0.7
NMS_PRE_MAXSIZE: 4096
NMS_POST_MAXSIZE: 500
POST_PROCESSING:
RECALL_THRESH_LIST: [0.3, 0.5, 0.7]
EVAL_METRIC: waymo
OPTIMIZATION:
BATCH_SIZE_PER_GPU: 4
NUM_EPOCHS: 30
OPTIMIZER: adam_onecycle
LR: 0.003
WEIGHT_DECAY: 0.01
MOMENTUM: 0.9
MOMS: [0.95, 0.85]
PCT_START: 0.4
DIV_FACTOR: 10
DECAY_STEP_LIST: [35, 45]
LR_DECAY: 0.1
LR_CLIP: 0.0000001
LR_WARMUP: False
WARMUP_EPOCH: 1
GRAD_NORM_CLIP: 10
CLASS_NAMES: ['Vehicle', 'Pedestrian', 'Cyclist']
DATA_CONFIG:
_BASE_CONFIG_: cfgs/dataset_configs/waymo_dataset.yaml
MODEL:
NAME: CenterPoint
VFE:
NAME: MeanVFE
BACKBONE_3D:
NAME: VoxelBackBone8x
MAP_TO_BEV:
NAME: HeightCompression
NUM_BEV_FEATURES: 256
BACKBONE_2D:
NAME: BaseBEVBackbone
LAYER_NUMS: [5, 5]
LAYER_STRIDES: [1, 2]
NUM_FILTERS: [128, 256]
UPSAMPLE_STRIDES: [1, 2]
NUM_UPSAMPLE_FILTERS: [256, 256]
DENSE_HEAD:
NAME: CenterHead
CLASS_AGNOSTIC: False
CLASS_NAMES_EACH_HEAD: [
['Vehicle', 'Pedestrian', 'Cyclist']
]
SHARED_CONV_CHANNEL: 64
USE_BIAS_BEFORE_NORM: True
NUM_HM_CONV: 2
SEPARATE_HEAD_CFG:
HEAD_ORDER: ['center', 'center_z', 'dim', 'rot']
HEAD_DICT: {
'center': {'out_channels': 2, 'num_conv': 2},
'center_z': {'out_channels': 1, 'num_conv': 2},
'dim': {'out_channels': 3, 'num_conv': 2},
'rot': {'out_channels': 2, 'num_conv': 2},
}
TARGET_ASSIGNER_CONFIG:
FEATURE_MAP_STRIDE: 8
NUM_MAX_OBJS: 500
GAUSSIAN_OVERLAP: 0.1
MIN_RADIUS: 2
LOSS_CONFIG:
LOSS_WEIGHTS: {
'cls_weight': 1.0,
'loc_weight': 2.0,
'code_weights': [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
}
POST_PROCESSING:
SCORE_THRESH: 0.1
POST_CENTER_LIMIT_RANGE: [-75.2, -75.2, -2, 75.2, 75.2, 4]
MAX_OBJ_PER_SAMPLE: 500
NMS_CONFIG:
NMS_TYPE: nms_gpu
NMS_THRESH: 0.7
NMS_PRE_MAXSIZE: 4096
NMS_POST_MAXSIZE: 500
POST_PROCESSING:
RECALL_THRESH_LIST: [0.3, 0.5, 0.7]
EVAL_METRIC: waymo
OPTIMIZATION:
BATCH_SIZE_PER_GPU: 4
NUM_EPOCHS: 30
OPTIMIZER: adam_onecycle
LR: 0.003
WEIGHT_DECAY: 0.01
MOMENTUM: 0.9
MOMS: [0.95, 0.85]
PCT_START: 0.4
DIV_FACTOR: 10
DECAY_STEP_LIST: [35, 45]
LR_DECAY: 0.1
LR_CLIP: 0.0000001
LR_WARMUP: False
WARMUP_EPOCH: 1
GRAD_NORM_CLIP: 10
...@@ -150,9 +150,13 @@ MODEL: ...@@ -150,9 +150,13 @@ MODEL:
TEST: TEST:
NMS_TYPE: nms_gpu NMS_TYPE: nms_gpu
MULTI_CLASSES_NMS: False MULTI_CLASSES_NMS: False
NMS_PRE_MAXSIZE: 1024 # NMS_PRE_MAXSIZE: 1024
NMS_POST_MAXSIZE: 100 # NMS_POST_MAXSIZE: 100
NMS_THRESH: 0.7 # NMS_THRESH: 0.7
NMS_PRE_MAXSIZE: 4096
NMS_POST_MAXSIZE: 300
NMS_THRESH: 0.85
ROI_GRID_POOL: ROI_GRID_POOL:
GRID_SIZE: 6 GRID_SIZE: 6
...@@ -197,7 +201,7 @@ MODEL: ...@@ -197,7 +201,7 @@ MODEL:
NMS_CONFIG: NMS_CONFIG:
MULTI_CLASSES_NMS: False MULTI_CLASSES_NMS: False
NMS_TYPE: nms_gpu NMS_TYPE: nms_gpu
NMS_THRESH: 0.1 NMS_THRESH: 0.7
NMS_PRE_MAXSIZE: 4096 NMS_PRE_MAXSIZE: 4096
NMS_POST_MAXSIZE: 500 NMS_POST_MAXSIZE: 500
......
CLASS_NAMES: ['Vehicle', 'Pedestrian', 'Cyclist']
DATA_CONFIG:
_BASE_CONFIG_: cfgs/dataset_configs/waymo_dataset.yaml
MODEL:
NAME: PVRCNN
VFE:
NAME: MeanVFE
BACKBONE_3D:
NAME: VoxelBackBone8x
MAP_TO_BEV:
NAME: HeightCompression
NUM_BEV_FEATURES: 256
BACKBONE_2D:
NAME: BaseBEVBackbone
LAYER_NUMS: [5, 5]
LAYER_STRIDES: [1, 2]
NUM_FILTERS: [128, 256]
UPSAMPLE_STRIDES: [1, 2]
NUM_UPSAMPLE_FILTERS: [256, 256]
DENSE_HEAD:
NAME: CenterHead
CLASS_AGNOSTIC: False
CLASS_NAMES_EACH_HEAD: [
[ 'Vehicle', 'Pedestrian', 'Cyclist' ]
]
SHARED_CONV_CHANNEL: 64
USE_BIAS_BEFORE_NORM: True
NUM_HM_CONV: 2
SEPARATE_HEAD_CFG:
HEAD_ORDER: [ 'center', 'center_z', 'dim', 'rot' ]
HEAD_DICT: {
'center': { 'out_channels': 2, 'num_conv': 2 },
'center_z': { 'out_channels': 1, 'num_conv': 2 },
'dim': { 'out_channels': 3, 'num_conv': 2 },
'rot': { 'out_channels': 2, 'num_conv': 2 },
}
TARGET_ASSIGNER_CONFIG:
FEATURE_MAP_STRIDE: 8
NUM_MAX_OBJS: 500
GAUSSIAN_OVERLAP: 0.1
MIN_RADIUS: 2
LOSS_CONFIG:
LOSS_WEIGHTS: {
'cls_weight': 1.0,
'loc_weight': 2.0,
'code_weights': [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ]
}
POST_PROCESSING:
SCORE_THRESH: 0.1
POST_CENTER_LIMIT_RANGE: [ -75.2, -75.2, -2, 75.2, 75.2, 4 ]
MAX_OBJ_PER_SAMPLE: 500
NMS_CONFIG:
NMS_TYPE: nms_gpu
NMS_THRESH: 0.7
NMS_PRE_MAXSIZE: 4096
NMS_POST_MAXSIZE: 500
PFE:
NAME: VoxelSetAbstraction
POINT_SOURCE: raw_points
NUM_KEYPOINTS: 4096
NUM_OUTPUT_FEATURES: 90
SAMPLE_METHOD: FPS
FEATURES_SOURCE: ['bev', 'x_conv3', 'x_conv4', 'raw_points']
SA_LAYER:
raw_points:
MLPS: [[16, 16], [16, 16]]
POOL_RADIUS: [0.4, 0.8]
NSAMPLE: [16, 16]
x_conv1:
DOWNSAMPLE_FACTOR: 1
MLPS: [[16, 16], [16, 16]]
POOL_RADIUS: [0.4, 0.8]
NSAMPLE: [16, 16]
x_conv2:
DOWNSAMPLE_FACTOR: 2
MLPS: [[32, 32], [32, 32]]
POOL_RADIUS: [0.8, 1.2]
NSAMPLE: [16, 32]
x_conv3:
DOWNSAMPLE_FACTOR: 4
MLPS: [[64, 64], [64, 64]]
POOL_RADIUS: [1.2, 2.4]
NSAMPLE: [16, 32]
x_conv4:
DOWNSAMPLE_FACTOR: 8
MLPS: [[64, 64], [64, 64]]
POOL_RADIUS: [2.4, 4.8]
NSAMPLE: [16, 32]
POINT_HEAD:
NAME: PointHeadSimple
CLS_FC: [256, 256]
CLASS_AGNOSTIC: True
USE_POINT_FEATURES_BEFORE_FUSION: True
TARGET_CONFIG:
GT_EXTRA_WIDTH: [0.2, 0.2, 0.2]
LOSS_CONFIG:
LOSS_REG: smooth-l1
LOSS_WEIGHTS: {
'point_cls_weight': 1.0,
}
ROI_HEAD:
NAME: PVRCNNHead
CLASS_AGNOSTIC: True
SHARED_FC: [256, 256]
CLS_FC: [256, 256]
REG_FC: [256, 256]
DP_RATIO: 0.3
NMS_CONFIG:
TRAIN:
NMS_TYPE: nms_gpu
MULTI_CLASSES_NMS: False
NMS_PRE_MAXSIZE: 9000
NMS_POST_MAXSIZE: 512
NMS_THRESH: 0.8
TEST:
NMS_TYPE: nms_gpu
MULTI_CLASSES_NMS: False
NMS_PRE_MAXSIZE: 1024
NMS_POST_MAXSIZE: 100
NMS_THRESH: 0.7
SCORE_THRESH: 0.1
# NMS_PRE_MAXSIZE: 4096
# NMS_POST_MAXSIZE: 500
# NMS_THRESH: 0.85
ROI_GRID_POOL:
GRID_SIZE: 6
MLPS: [[64, 64], [64, 64]]
POOL_RADIUS: [0.8, 1.6]
NSAMPLE: [16, 16]
POOL_METHOD: max_pool
TARGET_CONFIG:
BOX_CODER: ResidualCoder
ROI_PER_IMAGE: 128
FG_RATIO: 0.5
SAMPLE_ROI_BY_EACH_CLASS: True
CLS_SCORE_TYPE: roi_iou
CLS_FG_THRESH: 0.75
CLS_BG_THRESH: 0.25
CLS_BG_THRESH_LO: 0.1
HARD_BG_RATIO: 0.8
REG_FG_THRESH: 0.55
LOSS_CONFIG:
CLS_LOSS: BinaryCrossEntropy
REG_LOSS: smooth-l1
CORNER_LOSS_REGULARIZATION: True
LOSS_WEIGHTS: {
'rcnn_cls_weight': 1.0,
'rcnn_reg_weight': 1.0,
'rcnn_corner_weight': 1.0,
'code_weights': [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
}
POST_PROCESSING:
RECALL_THRESH_LIST: [0.3, 0.5, 0.7]
SCORE_THRESH: 0.1
OUTPUT_RAW_SCORE: False
EVAL_METRIC: waymo
NMS_CONFIG:
MULTI_CLASSES_NMS: False
NMS_TYPE: nms_gpu
NMS_THRESH: 0.7
NMS_PRE_MAXSIZE: 4096
NMS_POST_MAXSIZE: 500
OPTIMIZATION:
BATCH_SIZE_PER_GPU: 2
NUM_EPOCHS: 30
OPTIMIZER: adam_onecycle
LR: 0.01
WEIGHT_DECAY: 0.001
MOMENTUM: 0.9
MOMS: [0.95, 0.85]
PCT_START: 0.4
DIV_FACTOR: 10
DECAY_STEP_LIST: [35, 45]
LR_DECAY: 0.1
LR_CLIP: 0.0000001
LR_WARMUP: False
WARMUP_EPOCH: 1
GRAD_NORM_CLIP: 10
\ No newline at end of file
...@@ -94,7 +94,7 @@ MODEL: ...@@ -94,7 +94,7 @@ MODEL:
NMS_CONFIG: NMS_CONFIG:
MULTI_CLASSES_NMS: False MULTI_CLASSES_NMS: False
NMS_TYPE: nms_gpu NMS_TYPE: nms_gpu
NMS_THRESH: 0.01 NMS_THRESH: 0.7
NMS_PRE_MAXSIZE: 4096 NMS_PRE_MAXSIZE: 4096
NMS_POST_MAXSIZE: 500 NMS_POST_MAXSIZE: 500
......
...@@ -2,7 +2,15 @@ import argparse ...@@ -2,7 +2,15 @@ import argparse
import glob import glob
from pathlib import Path from pathlib import Path
import mayavi.mlab as mlab try:
import open3d
from visual_utils import open3d_vis_utils as V
OPEN3D_FLAG = True
except:
import mayavi.mlab as mlab
from visual_utils import visualize_utils as V
OPEN3D_FLAG = False
import numpy as np import numpy as np
import torch import torch
...@@ -10,7 +18,6 @@ from pcdet.config import cfg, cfg_from_yaml_file ...@@ -10,7 +18,6 @@ from pcdet.config import cfg, cfg_from_yaml_file
from pcdet.datasets import DatasetTemplate from pcdet.datasets import DatasetTemplate
from pcdet.models import build_network, load_data_to_gpu from pcdet.models import build_network, load_data_to_gpu
from pcdet.utils import common_utils from pcdet.utils import common_utils
from visual_utils import visualize_utils as V
class DemoDataset(DatasetTemplate): class DemoDataset(DatasetTemplate):
...@@ -94,6 +101,8 @@ def main(): ...@@ -94,6 +101,8 @@ def main():
points=data_dict['points'][:, 1:], ref_boxes=pred_dicts[0]['pred_boxes'], points=data_dict['points'][:, 1:], ref_boxes=pred_dicts[0]['pred_boxes'],
ref_scores=pred_dicts[0]['pred_scores'], ref_labels=pred_dicts[0]['pred_labels'] ref_scores=pred_dicts[0]['pred_scores'], ref_labels=pred_dicts[0]['pred_labels']
) )
if not OPEN3D_FLAG:
mlab.show(stop=True) mlab.show(stop=True)
logger.info('Demo done.') logger.info('Demo done.')
......
import _init_path
import argparse import argparse
import datetime import datetime
import glob import glob
......
import _init_path
import argparse import argparse
import datetime import datetime
import glob import glob
...@@ -6,7 +7,6 @@ from pathlib import Path ...@@ -6,7 +7,6 @@ from pathlib import Path
from test import repeat_eval_ckpt from test import repeat_eval_ckpt
import torch import torch
import torch.distributed as dist
import torch.nn as nn import torch.nn as nn
from tensorboardX import SummaryWriter from tensorboardX import SummaryWriter
...@@ -24,7 +24,7 @@ def parse_config(): ...@@ -24,7 +24,7 @@ def parse_config():
parser.add_argument('--batch_size', type=int, default=None, required=False, help='batch size for training') parser.add_argument('--batch_size', type=int, default=None, required=False, help='batch size for training')
parser.add_argument('--epochs', type=int, default=None, required=False, help='number of epochs to train for') parser.add_argument('--epochs', type=int, default=None, required=False, help='number of epochs to train for')
parser.add_argument('--workers', type=int, default=8, help='number of workers for dataloader') parser.add_argument('--workers', type=int, default=4, help='number of workers for dataloader')
parser.add_argument('--extra_tag', type=str, default='default', help='extra tag for this experiment') parser.add_argument('--extra_tag', type=str, default='default', help='extra tag for this experiment')
parser.add_argument('--ckpt', type=str, default=None, help='checkpoint to start from') parser.add_argument('--ckpt', type=str, default=None, help='checkpoint to start from')
parser.add_argument('--pretrained_model', type=str, default=None, help='pretrained_model') parser.add_argument('--pretrained_model', type=str, default=None, help='pretrained_model')
...@@ -170,6 +170,9 @@ def main(): ...@@ -170,6 +170,9 @@ def main():
merge_all_iters_to_one_epoch=args.merge_all_iters_to_one_epoch merge_all_iters_to_one_epoch=args.merge_all_iters_to_one_epoch
) )
if hasattr(train_set, 'use_shared_memory') and train_set.use_shared_memory:
train_set.clean_shared_memory()
logger.info('**********************End training %s/%s(%s)**********************\n\n\n' logger.info('**********************End training %s/%s(%s)**********************\n\n\n'
% (cfg.EXP_GROUP_PATH, cfg.TAG, args.extra_tag)) % (cfg.EXP_GROUP_PATH, cfg.TAG, args.extra_tag))
...@@ -183,7 +186,7 @@ def main(): ...@@ -183,7 +186,7 @@ def main():
) )
eval_output_dir = output_dir / 'eval' / 'eval_with_train' eval_output_dir = output_dir / 'eval' / 'eval_with_train'
eval_output_dir.mkdir(parents=True, exist_ok=True) eval_output_dir.mkdir(parents=True, exist_ok=True)
args.start_epoch = max(args.epochs - 10, 0) # Only evaluate the last 10 epochs args.start_epoch = max(args.epochs - 0, 0) # Only evaluate the last 10 epochs
repeat_eval_ckpt( repeat_eval_ckpt(
model.module if dist_train else model, model.module if dist_train else model,
......
# This file is modified from https://github.com/traveller59/second.pytorch # This file is modified from https://github.com/traveller59/second.pytorch
from collections import Iterable try:
from collections.abc import Iterable
except:
from collections import Iterable
import torch import torch
from torch import nn from torch import nn
......
"""
Open3d visualization tool box
Written by Jihan YANG
All rights preserved from 2021 - present.
"""
import open3d
import torch
import matplotlib
import numpy as np
box_colormap = [
[1, 1, 1],
[0, 1, 0],
[0, 1, 1],
[1, 1, 0],
]
def get_coor_colors(obj_labels):
"""
Args:
obj_labels: 1 is ground, labels > 1 indicates different instance cluster
Returns:
rgb: [N, 3]. color for each point.
"""
colors = matplotlib.colors.XKCD_COLORS.values()
max_color_num = obj_labels.max()
color_list = list(colors)[:max_color_num+1]
colors_rgba = [matplotlib.colors.to_rgba_array(color) for color in color_list]
label_rgba = np.array(colors_rgba)[obj_labels]
label_rgba = label_rgba.squeeze()[:, :3]
return label_rgba
def draw_scenes(points, gt_boxes=None, ref_boxes=None, ref_labels=None, ref_scores=None, point_colors=None, draw_origin=True):
if isinstance(points, torch.Tensor):
points = points.cpu().numpy()
if isinstance(gt_boxes, torch.Tensor):
gt_boxes = gt_boxes.cpu().numpy()
if isinstance(ref_boxes, torch.Tensor):
ref_boxes = ref_boxes.cpu().numpy()
vis = open3d.visualization.Visualizer()
vis.create_window()
vis.get_render_option().point_size = 1.0
vis.get_render_option().background_color = np.zeros(3)
# draw origin
if draw_origin:
axis_pcd = open3d.geometry.TriangleMesh.create_coordinate_frame(size=1.0, origin=[0, 0, 0])
vis.add_geometry(axis_pcd)
pts = open3d.geometry.PointCloud()
pts.points = open3d.utility.Vector3dVector(points[:, :3])
vis.add_geometry(pts)
if point_colors is None:
pts.colors = open3d.utility.Vector3dVector(np.ones((points.shape[0], 3)))
else:
pts.colors = open3d.utility.Vector3dVector(point_colors)
if gt_boxes is not None:
vis = draw_box(vis, gt_boxes, (0, 0, 1))
if ref_boxes is not None:
vis = draw_box(vis, ref_boxes, (0, 1, 0), ref_labels, ref_scores)
vis.run()
vis.destroy_window()
def translate_boxes_to_open3d_instance(gt_boxes):
"""
4-------- 6
/| /|
5 -------- 3 .
| | | |
. 7 -------- 1
|/ |/
2 -------- 0
"""
center = gt_boxes[0:3]
lwh = gt_boxes[3:6]
axis_angles = np.array([0, 0, gt_boxes[6] + 1e-10])
rot = open3d.geometry.get_rotation_matrix_from_axis_angle(axis_angles)
box3d = open3d.geometry.OrientedBoundingBox(center, rot, lwh)
line_set = open3d.geometry.LineSet.create_from_oriented_bounding_box(box3d)
# import ipdb; ipdb.set_trace(context=20)
lines = np.asarray(line_set.lines)
lines = np.concatenate([lines, np.array([[1, 4], [7, 6]])], axis=0)
line_set.lines = open3d.utility.Vector2iVector(lines)
return line_set, box3d
def draw_box(vis, gt_boxes, color=(0, 1, 0), ref_labels=None, score=None):
for i in range(gt_boxes.shape[0]):
line_set, box3d = translate_boxes_to_open3d_instance(gt_boxes[i])
if ref_labels is None:
line_set.paint_uniform_color(color)
else:
line_set.paint_uniform_color(box_colormap[ref_labels[i]])
vis.add_geometry(line_set)
# if score is not None:
# corners = box3d.get_box_points()
# vis.add_3d_label(corners[5], '%.2f' % score[i])
return vis
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