Cs231n lecture 11 detection and segmentation

Screenshot 2020-02-28 at 10.28.33 AM.png

**

** **

1. Semantic Segmentaiton**

Naive Approach: A naive approach is sliding window (Appendix 1). No one does this, it’s a bad idea.

Naive Approach 2: (Appendix 2) Vanilla Fully Concolutional layer. Have the network be a stack of convolutional layers which all preserve the spatial size of the image, with no fully connected layers.

Approach 3:

2. Classification + Localization

Classify the image, and find out where the object is in the image (draw a bounding box).

Idea 1: Run an ordinary CNN for classification, but also have an additional task of predicting the locations of the bounding box (x,y,w,h). Now there are two loss functions - one classification loss and the bounding box. Often we just use L2 loss for the bounding box coordinates (And treat the bounding box prediction as a regression problem). (Appendix 4)

Aside: Using Regression to find locations in an image can be used to do human pose estimation also.

3. Object Detection

(over a fixed set of categories)

Region Proposals Methods for Object Detection-

Find ‘blobby’ image patches likely to contain objects with a fast algorithm

Perform object classification on each patch to see if there’s an object we care about in that region. Selective Search is a commonly used one. (Appendix 5)

R-CNN is a 2014 paper that does region proposal.

Take each of the regions and warp them to a fixed square size, and run a conv net through each of them to mamek classification decisons. (Appendix 5). R-CNN will also use regression to produce a correction to the bounding box proposed at the region proposal stage. However, R-CNN has some problems (it is pretty slow).

Fast-R-CNN puts the crops on the convolutional feature map, not the original image. They then turn these crops into squares in a differentiable way using an “RoI Pooling Layer”. It is 10x faster to train and test because we’re sharing computation between feature maps. (Appendix 5) Now the time bottleneck is the region proposals.

This was made even faster by Faster R-CNN, where the region proposals is done by the CNN. They insert a Region proposal Network to predict proposals from features, and jointly train on: 1. RPN classify object/not object, 2. RPN regress box coordinates 3. Final Classification Score, 4. Final box coordinates. [The region proposal network was trained based on % overlap with ground truth objects]

**YOLO/SSD based Methods for Object Detection **

YOLO/SSD (Single Shot Detection)

Instead of doing independent processing for each of these separate regions, instaed we want ot treat this like a regression problem and make all these predictions all at once with some kind of big CNN.

In each input image, divide that input image into some coarse grid, and within that grid cells, imagine a set of base boxes centered at each grid cell. For each of the big grid cells, predict (Appendix 6)

Thus assuming 7x7 grid, our output is a 3D 7 x 7 x (5 * B + C) tensor. We can have the input be an image, the output be a hand-labelled 3D tensor, and train the whole thing with a giant CNN.

There is a whole family of obkect detection methods. (Appendix 6) Faster RCC is slower but more accurage, SSD is much faster buch not as accuate. “Huang er al Speed/accuracy rtadeoffs for modern convolutional object detectors” 2017.

Now there is YOLO-v2.

** **

**4. Instance Segmentation **

Mask R-CNN for Instance Segmentation

Given a full image, predict 1) the locations and identities of objects in that image, and find out which pixels belong to that image instead of just a bounding box.

Mask R-CNN was used in 2017.

Screenshot 2020-02-28 at 12.39.22 PM.png** **

You take the whole image, and the whole image goes into a convolutional network and a learned region proposal network (like Faster R-CNN). Once we have our region proposals, we project htose proposals onto our convolutional feature map, and instead of just making a classification, we want to predict a segmentation mask for each of these region proposals. So we have two branch betworks - one is eaxctly the same as Faster R-CNN, running classification to tell us what is the category of object in that region proposal, and also predict some bounding box coordinates, and the second branch, which looks like a semantic segmantation mini-network that predicts for each pixel whether or now it is an object.

(Appendix 7)

Mask R-CNN also does pose estimation, if you add joint coordinates as a learning objective to the classification scores in the Faster-R-CNN top branch! (Appendix 7)

Appendix 1:

Naive Sliding window approach to semantic segmentaiton - Slide a small window over each patch of the input image and train a classifier for each window. Super super computationally expensive, thus never used.

Screenshot 2020-02-28 at 10.30.49 AM.png

Appendix 2:

Fully Convolutional Network for Semantic Segmentaiton - A better idea. Will work, but is super computationally expensive because we have multiple stacked convolutions over a high resolution image.

Screenshot 2020-02-28 at 10.31.43 AM.png

Appendix 3:

Screenshot 2020-02-28 at 10.38.49 AM.png

Downsample like Maxpool (or stride 2).

Screenshot 2020-02-28 at 10.44.05 AM.png

Screenshot 2020-02-28 at 10.45.20 AM.png

Upsample like Nearest Neighbors, Bed of Nails, or Max Unpooling.

Transpose Convolution (Upconvolution)

Screenshot 2020-02-28 at 11.52.43 AM.pngScreenshot 2020-02-28 at 11.53.47 AM.pngScreenshot 2020-02-28 at 11.54.52 AM.png

Appendix 4: Object Classification and Localization

Screenshot 2020-02-28 at 11.58.50 AM.png

Aside: Using Regression to find locations in an image can be used to do human pose estimation also.

Screenshot 2020-02-28 at 12.03.15 PM.pngScreenshot 2020-02-28 at 12.03.58 PM.png

Appendix 5: Region Proposal for Object Detection, R-CNN

Screenshot 2020-02-28 at 12.10.00 PM.png

R-CNN (2014) a region proposal algo, is pretty slow.

Screenshot 2020-02-28 at 12.12.51 PM.png

Screenshot 2020-02-28 at 12.15.58 PM.png

It was imrpoved by Fast R-CNN, which crops in the intermedate convolutional layers, so can share features between crops. This makes it a lot faster, and it can execute in less than a second. Fast R-CNN’s speed is bottlenecked by the region proposals.

Screenshot 2020-02-28 at 12.17.58 PM.png

Screenshot 2020-02-28 at 12.18.06 PM.png

Screenshot 2020-02-28 at 12.18.14 PM.png

This was made even faster by Faster R-CNN, where the region proposal is put inside of the network as a Region Proposal Network.

Screenshot 2020-02-28 at 12.19.14 PM.png

Appendix 6: YOLO/SSD Object Detection

Screenshot 2020-02-28 at 12.27.24 PM.png

Screenshot 2020-02-28 at 12.35.29 PM.png

Aside:Screenshot 2020-02-28 at 12.36.56 PM.png

Appendix 7: Mask R-CNN

For Instance Segmentation

Mask R-CNN can do object detection, object segmentation, and pose estimation! With very good results!

A single Feedforward network is determining how many people are in an image, determining where (which pixels) correspond to that image, and what that person’s pose is, even in crowded scenes, and also runs in real time (5 times per second).

Screenshot 2020-02-28 at 12.42.40 PM.png

Screenshot 2020-02-28 at 12.43.59 PM.png

Screenshot 2020-02-28 at 12.45.18 PM.png