> For the complete documentation index, see [llms.txt](https://lauradang.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lauradang.gitbook.io/notes/machine-learning/convolutional-neural-networks/localization-object-detection.md).

# Localization Object Detection

![](https://868646840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LztfBhQUrZzyA7O_ZkJ%2Fuploads%2Fgit-blob-67e1ec2199d0509d91723bb7bed1a30b442c37d7%2Fobject-detection.png?alt=media)

## Localization

Find where the object is in the image and draw a bounding box around it.

## Semantic Segmentation

Classify every pixel in the image to a class according to its context, so that each pixel is assigned to an object. Each colour is assigned to a type of object (in this case, red is cat, blue is dog, green is duck).

## How can we achieve both?

Potentialy can use **Fully Convolutional Networks**. They are networks that only consist of convolutional layers without a need to be connected.

There were 2 problems with them:

* FCNs couldn’t use any downsampling or pooling layers as it will mess up the location of the image instances
* Many layers had to be added to learn both low-level and high-level features to maintain image resolution (computational expensive)

**Solution**: Encoders!

Encoders are typical CNNs such as ResNet that downsample. Decoders would be \*\*deconvolutional \*\*and **up-sampling** layers. This way, we can downsample to capture semantic information and recover the spatial information (both localization and semantic segmentation are achieved!).

### Visual Comparison

![Old way](https://868646840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LztfBhQUrZzyA7O_ZkJ%2Fuploads%2Fgit-blob-284eafe86a106266957c9d99b07316676323c5ce%2Fold_way1.png?alt=media)

![New way](https://868646840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LztfBhQUrZzyA7O_ZkJ%2Fuploads%2Fgit-blob-382dd6775b66e6d175dd8f281ad6b63bb35f7ac7%2Fnew_way.png?alt=media)

However, another problem still persists. When the encoder downsamples, the image resolution is sacrificed. A way to solve this is using something called **Skip Connections**.

## Skip Connections

Bypass layers and transfer the information intact to the next layers. i.e. Passes information from early layers to the encoder (*skips* the encoder).
