Object detection for self-driving cars – Part 1
Before, we get into building the various components of the object detection model, we will perform some preprocessing steps. The preprocessing steps involve resizing the images (according to the input shape accepted by the model) and converting the box coordinates into the appropriate form. Since we will be building a object detection for a self-driving car, we will be detecting and localizing eight different classes. These classes are ‘bike’, ‘bus’, ‘car’, ‘motor’, ‘person’, ‘rider’, ‘train’, and ‘truck’. Therefore, our target variable will be defined as:
where,
(1)y^=[pcbxbybhbwc1c2…c8]T
pc : Probability/confidence of an object being present in the bounding box
bx, by : coordinates of the center of the bounding box
bw : width of the bounding box w.r.t the image width
bh : height of the bounding box w.r.t the image height
ci = Probability of the ith class
But since the box coordinates provided in the dataset are in the following format: xmin, ymin, xmax, ymax (see Fig 1.), we need to convert them according to the target variable defined above. This can be implemented as follows:
W :
width of the original image
H :
height of the original image
(2)bx=(xmin+xmax)2∗W , by=(ymin+ymax)2∗Hbw=(xmax–xmin)2∗W , by=(ymax+ymin)2∗W
Fig 1. Bounding Box Coordinates in the target variable
Intersection over Union (IoU) is an evaluation metric that is used to measure the accuracy of an object detection algorithm. Generally, IoU is a measure of the overlap between two bounding boxes. To calculate this metric, we need:
· The ground truth bounding boxes (i.e. the hand labeled bounding boxes)
· The predicted bounding boxes from the model
Intersection over Union is the ratio of the area of intersection over the union area occupied by the ground truth bounding box and the predicted bounding box. Fig. 9 shows the IoU calculation for different bounding box scenarios.
Intersection over Union is the ratio of the area of intersection over the union area occupied by the ground truth bounding box and the predicted bounding box. Fig. 2 shows the IoU calculation for different bounding box scenarios.
Fig 2. Intersection over Union computation for different bounding boxes.
Now, that we have a better understanding of the metric, let’s code it.