Skip to content
This repository has been archived by the owner on Nov 20, 2023. It is now read-only.

Some tweaks #91

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,21 @@ This is an unofficial inplementation of [VoxelNet: End-to-End Learning for Point

# Installation
1. Clone this repository.
2. Compile the Cython module
2. Install the necessary packages
```bash
$ sudo apt-get install libboost-all-dev
$ sudo apt-get install python-numpy
```
3. Compile the Cython module
```bash
$ python3 setup.py build_ext --inplace
```
3. Compile the evaluation code
4. Compile the evaluation code
```bash
$ cd kitti_eval
$ g++ -o evaluate_object_3d_offline evaluate_object_3d_offline.cpp
```
4. grant the execution permission to evaluation script
5. grant the execution permission to evaluation script
```bash
$ cd kitti_eval
$ chmod +x launch_test.sh
Expand Down Expand Up @@ -66,9 +71,6 @@ Training on two Nvidia 1080 Ti GPUs takes around 3 days (160 epochs as reported
$ python3 parse_log.py predictions
```

4. There is a pre-trained model for car in `save_model/pre_trained_car`.


# Evaluate
1. run `test.py -n default` to produce final predictions on the validation set after training is done. Change `-n` flag to `pre_trained_car` will start testing for the pre-trained model (only car model provided for now).
```bash
Expand Down
6 changes: 3 additions & 3 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
cfg = __C

# for dataset dir
__C.DATA_DIR = '/media/hdc/KITTI/for_voxelnet/cropped_dataset'
__C.CALIB_DIR = '/media/hdc/KITTI/calib/data_object_calib/training/calib'
__C.DATA_DIR = '/home/anshul/Project/voxelnet-1/data_dir'
__C.CALIB_DIR = '/home/anshul/Project/voxelnet-1/data_object_calib/training/calib'


# for gpu allocation
__C.GPU_AVAILABLE = '0,1'
__C.GPU_AVAILABLE = '0,1,2'
__C.GPU_USE_COUNT = len(__C.GPU_AVAILABLE.split(','))
__C.GPU_MEMORY_FRACTION = 1

Expand Down
25 changes: 11 additions & 14 deletions data/crop.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import numpy as np
from scipy.misc import imread

import PIL
from imageio import imread
#from scipy.misc.pilutil import imread
CAM = 2

def load_velodyne_points(filename):
Expand Down Expand Up @@ -50,7 +51,7 @@ def project_velo_points_in_img(pts3d, T_cam_velo, Rrect, Prect):


def align_img_and_pc(img_dir, pc_dir, calib_dir):

img = imread(img_dir)
pts = load_velodyne_points( pc_dir )
P, Tr_velo_to_cam, R_cam_to_rect = load_calib(calib_dir)
Expand Down Expand Up @@ -79,9 +80,9 @@ def align_img_and_pc(img_dir, pc_dir, calib_dir):
return points

# update the following directories
IMG_ROOT = '/media/hdc/KITTI/image/training/image_2/'
PC_ROOT = '/media/hdc/KITTI/point_cloud/raw_bin_files/training/velodyne/'
CALIB_ROOT = '/media/hdc/KITTI/calib/data_object_calib/training/calib/'
IMG_ROOT = "/home/anshul/Project/voxelnet-1/data_object_image_2/training/image_2/"
PC_ROOT = "/home/anshul/Project/voxelnet-1/data_object_velodyne/training/velodyne/"
CALIB_ROOT = "/home/anshul/Project/voxelnet-1/data_object_calib/training/calib/"



Expand All @@ -91,12 +92,8 @@ def align_img_and_pc(img_dir, pc_dir, calib_dir):
calib_dir = CALIB_ROOT + '%06d.txt' % frame

points = align_img_and_pc(img_dir, pc_dir, calib_dir)

output_name = PC_ROOT + frame + '.bin'
points[:,:4].astype('float32').tofile(output_name)






#output_name = PC_ROOT + str(frame) + '.bin'
output_name = PC_ROOT + str('%06d' % frame) + '.bin'
print(frame)
points[:,:4].astype('float32').tofile(output_name)
28 changes: 28 additions & 0 deletions datasplit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import os
import shutil

#dir="/home/anshul/Project/voxelnet-1/data_object_velodyne/training/velodyne"
#dir="/home/anshul/Project/voxelnet-1/data_object_label_2/training/label_2"
dir="/home/anshul/Project/voxelnet-1/data_object_image_2/training/image_2"
val_find="/home/anshul/Project/voxelnet-1/val.txt"
#dest="/home/anshul/Project/voxelnet-1/data_object_velodyne/validation/velodyne"
#dest="/home/anshul/Project/voxelnet-1/data_object_label_2/validation/label_2"
dest="/home/anshul/Project/voxelnet-1/data_object_image_2/validation/image_2"

#dest="D:\VoxelNet-tensorflow\data_object_velodyne\\train\\velodyne"
#dest="D:\VoxelNet-tensorflow\data_object_label_2\\train\label_2"
#dest="D:\VoxelNet-tensorflow\data_object_image_2\\train\image_2"

num=[]
with open(val_find) as vf:
for i in vf:
i=i.split()
#num.append(i[0]+'.bin')
#num.append(i[0]+'.txt')
num.append(i[0]+'.png')
print(dest)

os.makedirs(dest)
for i in num:
shutil.move(os.path.join(dir,i),dest)
#shutil.move('D:\\000000.bin',dest)
Binary file removed img/learning_curve.jpg
Binary file not shown.
2 changes: 1 addition & 1 deletion kitti_eval/launch_test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# crooped gt dir
GT_DIR=/media/hdc/KITTI/for_voxelnet/cropped_dataset/validation/label_2
GT_DIR=/home/anshul/Project/voxelnet-1/data_dir/validation/label_2
# pred dir
PRED_DIR=$1

Expand Down
30 changes: 14 additions & 16 deletions model/group_pointcloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ class VFELayer(object):
def __init__(self, out_channels, name):
super(VFELayer, self).__init__()
self.units = int(out_channels / 2)
with tf.variable_scope(name, reuse=tf.AUTO_REUSE) as scope:
self.dense = tf.layers.Dense(
self.units, tf.nn.relu, name='dense', _reuse=tf.AUTO_REUSE, _scope=scope)
self.batch_norm = tf.layers.BatchNormalization(
name='batch_norm', fused=True, _reuse=tf.AUTO_REUSE, _scope=scope)
with tf.compat.v1.variable_scope(name, reuse=tf.compat.v1.AUTO_REUSE) as scope:
self.dense = tf.compat.v1.layers.Dense(
self.units, tf.compat.v1.nn.relu, name='dense', _reuse=tf.compat.v1.AUTO_REUSE, _scope=scope)
self.batch_norm = tf.compat.v1.layers.BatchNormalization(
name='batch_norm', fused=True, _reuse=tf.compat.v1.AUTO_REUSE, _scope=scope)

def apply(self, inputs, mask, training):
# [K, T, 7] tensordot [7, units] = [K, T, units]
pointwise = self.batch_norm.apply(self.dense.apply(inputs), training)

#n [K, 1, units]
aggregated = tf.reduce_max(pointwise, axis=1, keep_dims=True)
aggregated = tf.reduce_max(pointwise, axis=1, keepdims=True)

# [K, T, units]
repeated = tf.tile(aggregated, [1, cfg.VOXEL_POINT_COUNT, 1])
Expand All @@ -49,30 +49,28 @@ def __init__(self, training, batch_size, name=''):
# scalar
self.batch_size = batch_size
# [ΣK, 35/45, 7]
self.feature = tf.placeholder(
self.feature = tf.compat.v1.placeholder(
tf.float32, [None, cfg.VOXEL_POINT_COUNT, 7], name='feature')
# [ΣK]
self.number = tf.placeholder(tf.int64, [None], name='number')
self.number = tf.compat.v1.placeholder(tf.int64, [None], name='number')
# [ΣK, 4], each row stores (batch, d, h, w)
self.coordinate = tf.placeholder(
self.coordinate = tf.compat.v1.placeholder(
tf.int64, [None, 4], name='coordinate')

with tf.variable_scope(name, reuse=tf.AUTO_REUSE) as scope:
with tf.compat.v1.variable_scope(name, reuse=tf.compat.v1.AUTO_REUSE) as scope:
self.vfe1 = VFELayer(32, 'VFE-1')
self.vfe2 = VFELayer(128, 'VFE-2')

# boolean mask [K, T, 2 * units]
mask = tf.not_equal(tf.reduce_max(
self.feature, axis=2, keep_dims=True), 0)
mask = tf.compat.v1.not_equal(tf.reduce_max(
self.feature, axis=2, keepdims=True), 0)
x = self.vfe1.apply(self.feature, mask, self.training)
x = self.vfe2.apply(x, mask, self.training)

# [ΣK, 128]
voxelwise = tf.reduce_max(x, axis=1)
voxelwise = tf.compat.v1.reduce_max(x, axis=1)

# car: [N * 10 * 400 * 352 * 128]
# pedestrian/cyclist: [N * 10 * 200 * 240 * 128]
self.outputs = tf.scatter_nd(
self.outputs = tf.compat.v1.scatter_nd(
self.coordinate, voxelwise, [self.batch_size, 10, cfg.INPUT_HEIGHT, cfg.INPUT_WIDTH, 128])


Loading