34 min total

Deep Learning

Object detection

Object detection

Object localization

Object detection — diagram

Landmark detection

Landmark detection is a technique where a neural network identifies and localizes specific key points or features in an image, referred to as landmarks. This is an extension of the concept of bounding boxes used in object localization. Instead of a bounding box, the network outputs X and Y coordinates for specific important points in the image.

The training set must include images with the landmarks labeled consistently. This usually involves significant manual labeling to ensure the landmarks are accurately marked.

Typically, use regression loss functions to minimize the error in predicted coordinates compared to the actual landmark positions.

Sliding-window detection

involves scanning an image using windows of varying sizes and strides to identify objects, utilizing a pre-trained Convolutional Neural Network (ConvNet)

ConvNet is trained on a dataset of closely cropped images centered around the objects of interest, like cars.

this method is computationally expensive because it requires evaluating a vast number of overlapping regions, especially with fine strides. This high computational cost can make the approach impractical with modern ConvNets.

Convolutional sliding windows

we can process the entire image at once by leveraging convolutional layers. For example, a ConvNet designed for 14x14 images can be adapted to handle larger images like 28x28 by treating each position in the output volume as corresponding to different sliding windows in the input image. This convolutional approach significantly reduces redundant calculations by sharing computations across overlapping regions. As a result, this method allows for the simultaneous detection of objects in all windows, improving efficiency without compromising accuracy. Despite these advances, this method may still struggle with precisely localizing bounding boxes, a challenge addressed in subsequent techniques.

Object detection — diagram

YOLO

YOLO places a grid over the input image and applies the image classification and localization algorithm to each grid cell. For each cell, the algorithm predicts an eight-dimensional vector: the presence of an object, the bounding box coordinates, and the class of the object. This allows YOLO to output precise bounding boxes with various aspect ratios and more accurate coordinates. Unlike the traditional sliding windows approach, YOLO processes the entire image in a single pass through the convolutional network, making it computationally efficient and suitable for real-time object detection. YOLO assigns each object to the grid cell containing its midpoint, ensuring each object is uniquely assigned, even if it spans multiple cells. To encode the bounding boxes, YOLO uses coordinates relative to the grid cell, keeping values between 0 and 1 for positions within the cell and potentially greater for dimensions.

Non-maximum suppression

In YOLO, each grid cell predicts whether there is an object present and provides the bounding box coordinates.

YOLO assigns each object to a single grid cell based on the object's center (or midpoint).

Even if the object spans multiple grid cells, only the grid cell containing the center of the object is responsible for predicting the object.

bx​ and by​: Offsets from the top-left corner of the grid cell (normalized between 0 and 1).

bw​ and bh​: Width and height of the bounding box (normalized to the whole image dimensions).

if an object's bounding box is larger than the grid cell, the width bw and height bh ​values can be greater than 1, effectively spanning beyond the grid cell.

Anchor boxes

When multiple objects are present in the same grid cell, a traditional detection system can’t recognize both of them.

Objects with different shapes might have similar midpoints, leading to conflicts.

Pre-define Shapes: Choose anchor box shapes that represent common object shapes in the dataset. For simplification, let’s say there are two anchor boxes If two objects in a grid cell match the same anchor box shape, the system can’t handle it perfectly. A default tiebreaker or method needs to be implemented.

Choosing Anchor Boxes:

Manual Selection: Initially, anchor boxes were hand-picked based on the variety of object shapes in the dataset.

Advanced Technique: Implement K-means clustering on the dataset shapes to select representative anchor boxes automatically.

R-CNN

This approach contrasts with the sliding window technique

proposes regions (potential object locations) using an algorithm like selective search and then applies a CNN to each proposed region.

Classify each region and refine its bounding box to better fit the detected object.

Fast R-CNN

Instead of processing each region proposal separately, Fast R-CNN processes the entire image using convolutional layers, then uses a Region of Interest (RoI) pooling layer to extract fixed-size feature maps for each proposal.

Faster R-CNN

Faster R-CNN integrates a Region Proposal Network into the CNN architecture to generate region proposals directly from the convolutional feature maps.

Apply RoI pooling to extract features for each proposal and classify them, while refining their bounding boxes.

Typically achieves higher accuracy than YOLO, but slower than YOLO