Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
skyhehe123 committed Mar 20, 2020
0 parents commit 4e7fc4a
Show file tree
Hide file tree
Showing 144 changed files with 17,073 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .gitignore
@@ -0,0 +1,26 @@
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
*.pyc

# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip


# Specific directory #
saved_model_vehicle/
2 changes: 2 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions .idea/SA-SSD.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

203 changes: 203 additions & 0 deletions configs/car_cfg.py
@@ -0,0 +1,203 @@
model = dict(
type='TwoStageDetector',
backbone=dict(
type='SimpleVoxel',
num_input_features=4,
use_norm=True,
num_filters=[32, 64],
with_distance=False),

neck=dict(
type='SpMiddleFHD',
output_shape=[40, 1600, 1408],
num_input_features=4,
num_hidden_features=64 * 5,
),
rpn_head=dict(
type='SSDRotateHead',
num_class=1,
num_output_filters=256,
num_anchor_per_loc=2,
use_sigmoid_cls=True,
encode_rad_error_by_sin=True,
use_direction_classifier=True,
box_code_size=7,
),

bbox_roi_extractor=dict(
type='SingleRoIExtractor',
roi_layer=dict(
type='PSRoIAlignRotated',
out_size=(7, 4), x_offset=0., y_offset=40., sample_num=0),
out_channels=256,
featmap_strides=[.4]),

bbox_head=dict(
type='PSConvBBoxHead',
in_channels=256,
hidden_channels=256,
num_class=1,
num_parts=28
)
)

# model training and testing settings
train_cfg = dict(
rpn=dict(
assigner=dict(
pos_iou_thr=0.6,
neg_iou_thr=0.45,
min_pos_iou=0.45, # this one is to limit the force assignment
ignore_iof_thr=-1,
similarity_fn ='NearestIouSimilarity'
),
nms=dict(
nms_across_levels=False,
nms_pre=2000,
nms_post=2000,
nms_thr=0.7,
min_bbox_size=0
),
allowed_border=0,
pos_weight=-1,
smoothl1_beta=1 / 9.0,
debug=False),

rcnn=
dict(
assigner=dict(
pos_iou_thr=0.7,
neg_iou_thr=0.7,
min_pos_iou=0.7,
ignore_iof_thr=-1,
similarity_fn ='RotateIou3dSimilarity'
),
# sampler=dict(
# num=300,
# pos_fraction=0.25,
# neg_pos_ub=-1,
# add_gt_as_proposals=True,
# pos_balance_sampling=False,
# neg_balance_thr=0),
pos_weight=-1,
debug=False),
)

test_cfg = dict(
rpn=dict(
nms_across_levels=False,
nms_pre=2000,
nms_post=100,
nms_thr=0.7,
min_bbox_size=0
),
rcnn=dict(
score_thr=0.3, nms=dict(type='nms', iou_thr=0.1), max_per_img=100)
)
# dataset settings
dataset_type = 'KittiLiDAR'
data_root = '/home/billyhe/data/KITTI/'
img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
data = dict(
imgs_per_gpu=2,
workers_per_gpu=4,
train=dict(
type=dataset_type,
root=data_root + 'training/',
ann_file=data_root + 'ImageSets/train.txt',
img_prefix=None,
img_scale=(1242, 375),
img_norm_cfg=img_norm_cfg,
size_divisor=32,
flip_ratio=0.5,
with_mask=False,
with_label=True,
with_point=True,
class_names = ['Car', 'Van'],
augmentor=dict(
type='PointAugmentor',
root_path=data_root,
info_path=data_root + 'kitti_dbinfos_train.pkl',
sample_classes=['Car'],
min_num_points=5,
sample_max_num=15,
removed_difficulties=[-1],
global_rot_range=[-0.78539816, 0.78539816],
gt_rot_range=[-0.78539816, 0.78539816],
center_noise_std=[1., 1., .5],
scale_range=[0.95, 1.05]
),
generator=dict(
type='VoxelGenerator',
voxel_size=[0.05, 0.05, 0.1],
point_cloud_range=[0, -40., -3., 70.4, 40., 1.],
max_num_points=5,
max_voxels=20000
),
anchor_generator=dict(
type='AnchorGeneratorStride',
sizes=[1.6, 3.9, 1.56],
anchor_strides=[0.4, 0.4, 1.0],
anchor_offsets=[0.2, -39.8, -1.78],
rotations=[0, 1.57],
),
anchor_area_threshold=1,
out_size_factor=8,
test_mode=False),

val=dict(
type=dataset_type,
root=data_root + 'training/',
ann_file=data_root + 'ImageSets/val.txt',
img_prefix=None,
img_scale=(1242, 375),
img_norm_cfg=img_norm_cfg,
size_divisor=32,
flip_ratio=0,
with_mask=False,
with_label=False,
with_point=True,
class_names = ['Car'],
generator=dict(
type='VoxelGenerator',
voxel_size=[0.05, 0.05, 0.1],
point_cloud_range=[0., -40., -3., 70.4, 40., 1.],
max_num_points=5,
max_voxels=20000
),
anchor_generator=dict(
type='AnchorGeneratorStride',
sizes=[1.6, 3.9, 1.56],
anchor_strides=[0.4, 0.4, 1.0],
anchor_offsets=[0.2, -39.8, -1.78],
rotations=[0, 1.57],
),
anchor_area_threshold=1,
out_size_factor=8,
test_mode=True),
)
# optimizer
optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.001)
optimizer_config = dict(grad_clip=dict(max_norm=10, norm_type=2))
# learning policy
lr_config = dict(
policy='cosine',
warmup='linear',
warmup_iters=500,
warmup_ratio=1.0 / 3,
)

checkpoint_config = dict(interval=5)
log_config = dict(
interval=20,
hooks=[
dict(type='TextLoggerHook'),
])
total_epochs = 50
dist_params = dict(backend='nccl')
log_level = 'INFO'
work_dir = '../saved_model_vehicle'
load_from = None
resume_from = None
workflow = [('train', 1)]
3 changes: 3 additions & 0 deletions mmdet/__init__.py
@@ -0,0 +1,3 @@
from .version import __version__, short_version

__all__ = ['__version__', 'short_version']
8 changes: 8 additions & 0 deletions mmdet/apis/__init__.py
@@ -0,0 +1,8 @@
from .env import init_dist, get_root_logger, set_random_seed
from .train import train_detector
from .inference import inference_detector, show_result

__all__ = [
'init_dist', 'get_root_logger', 'set_random_seed', 'train_detector',
'inference_detector', 'show_result'
]
57 changes: 57 additions & 0 deletions mmdet/apis/env.py
@@ -0,0 +1,57 @@
import logging
import os
import random

import numpy as np
import torch
import torch.distributed as dist
import torch.multiprocessing as mp
from mmcv.runner import get_dist_info


def init_dist(launcher, backend='nccl', **kwargs):
if mp.get_start_method(allow_none=True) is None:
mp.set_start_method('spawn')
if launcher == 'pytorch':
_init_dist_pytorch(backend, **kwargs)
elif launcher == 'mpi':
_init_dist_mpi(backend, **kwargs)
elif launcher == 'slurm':
_init_dist_slurm(backend, **kwargs)
else:
raise ValueError('Invalid launcher type: {}'.format(launcher))


def _init_dist_pytorch(backend, **kwargs):
# TODO: use local_rank instead of rank % num_gpus
rank = int(os.environ['RANK'])
num_gpus = torch.cuda.device_count()
torch.cuda.set_device(rank % num_gpus)
dist.init_process_group(backend=backend, **kwargs)


def _init_dist_mpi(backend, **kwargs):
raise NotImplementedError


def _init_dist_slurm(backend, **kwargs):
raise NotImplementedError


def set_random_seed(seed):
random.seed(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)


def get_root_logger(log_level=logging.INFO):
logger = logging.getLogger()
if not logger.hasHandlers():
logging.basicConfig(
format='%(asctime)s - %(levelname)s - %(message)s',
level=log_level)
rank, _ = get_dist_info()
if rank != 0:
logger.setLevel('ERROR')
return logger

0 comments on commit 4e7fc4a

Please sign in to comment.