Lidar Car Detection
Keras Classification for Lidar Car Detection (counting)
Count the cars in 3D lidar data
In this dataset we got 3D points cloud from lidars and the task is to train a classifier to count other cars on the road.
To make things easyer to work with, we are going to remove useless data (over the car, floor informations), flatten the 3D points to obtain 2D images (view from top), augment the quantity of data (x4) by rotating the images and then train a Keras NN classifer on it...
Let's go !
Starter Code for Lidar Car Detection
What we are going to Learn¶
- Learning about how lidar works
- data normalisation
- data augmentation
- Using Keras for binary classification.
Note : Create a copy of the notebook and use the copy for submission. Go to File > Save a Copy in Drive to create a new copy
Hi fellas !¶
In this dataset we got 3D points cloud from lidars and the task is to train a classifier to count other cars on the road. To make things easyer to work with, we are going to remove useless data (over the car, floor informations), flatten the 3D points to obtain 2D images (view from top), augment the quantity of data (x4) by rotating the images and then train a Keras NN classifer on it... Let's go !
Downloading Dataset¶
Installing aicrowd-cli
!pip install aicrowd-cli
%load_ext aicrowd.magic
%aicrowd login
!rm -rf data
!mkdir data
%aicrowd ds dl -c lidar-car-detection -o data
Importing Libraries¶
import pandas as pd
import numpy as np
from sklearn.model_selection import StratifiedKFold
import random
import os
import matplotlib.pyplot as plt
import plotly.graph_objects as go
%matplotlib notebook
import tensorflow as tf
from tensorflow.keras.layers import *
from tensorflow.keras.models import Model, load_model
from tensorflow.keras.optimizers import Adam
from tensorflow.keras.utils import to_categorical
import tensorflow.keras.backend as K
Reading the dataset¶
# Reading the training dataset
train_data = np.load("data/train.npz", allow_pickle=True)
test_data = np.load("data/test.npz", allow_pickle=True)
train_data = train_data['train']
test_data = test_data['test']
train_data.shape, test_data.shape
Visualizing the dataset¶
In this section, we will be visualizing a sample 3D lidar data
# Getting a random 3D lidar sample data
INDEX = random.randint(0, train_data.shape[0]-1)
# Getting the individual x,y and z points.
x = train_data[INDEX][0][:, 0].tolist()
y = train_data[INDEX][0][:, 1].tolist()
z = train_data[INDEX][0][:, 2].tolist()
# Label for the corrosponding sample ( no. of cars )
label = train_data[INDEX][1]
# Generating the 3D graph
fig = go.Figure(data=[go.Scatter3d(x=x, y=y, z=z,
mode='markers',
marker=dict(
size=1,
colorscale='Viridis',
opacity=0.8))])
print("No. of cars : ", label)
fig.show()