Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Object detection with R-CNN?

What does R-CNN actually do? Is it like using features extracted by CNN to detect classes in a specified window area? Is there any tensorflow implementation for this?

like image 574
Shamane Siriwardhana Avatar asked Apr 13 '17 22:04

Shamane Siriwardhana


People also ask

How was the R-CNN used for object detection?

Object detection is the process of finding and classifying objects in an image. One deep learning approach, regions with convolutional neural networks (R-CNN), combines rectangular region proposals with convolutional neural network features. R-CNN is a two-stage detection algorithm.

Can we use CNN for object detection?

Although R-CNN is good at detecting objects, it has its shortcomings. This algorithm is slow and it takes about 47 secs to perform object detection on an image. Training is not done in a single step. There are different models for doing different parts which make the training process time-consuming.

Does R-CNN uses selective search method for object detection?

The first stage of the R-CNN pipeline is the generation of 'region proposals' or regions in an image that could belong to a particular object. The authors use the selective search algorithm .

What is the difference between R-CNN and Fast R-CNN?

This is the basic difference between the Fast R-CNN and Faster R-CNN. Faster R-CNN uses a region proposal method to create the sets of regions. Faster R-CNN possesses an extra CNN for gaining the regional proposal, which we call the regional proposal network.


2 Answers

R-CNN is using the following algorithm:

  1. Get region proposals for object detection (using selective search).
  2. For each region crop the area from the image and run it thorough a CNN which classify the object.

There are more advanced algorithms that are built upon this like fast-R-CNN and faster R-CNN.

fast-R-CNN:

  1. Run the entire image through the CNN
  2. For each region from the region proposals extract the area using "roi polling" layer and than classify the object.

faster R-CNN:

  1. Run the entire image through the CNN
  2. Using the features detected using the CNN find region proposals using a object proposals network.
  3. For each object proposal extract the area using "roi polling" layer and than classify the object.

There are a lot of implantation in tensorflow specifically for faster R-CNN which is the most recent variant just google faster R-CNN tensorflow.

Good luck

like image 127
Amitay Nachmani Avatar answered Sep 21 '22 17:09

Amitay Nachmani


R-CNN is the daddy-algorithm for all the mentioned algos, it really provided the path for researchers to build more complex and better algorithm on top of it. I am trying to explain R-CNN and the other variants of it.

R-CNN, or Region-based Convolutional Neural Network

R-CNN consist of 3 simple steps:

  • Scan the input image for possible objects using an algorithm called Selective Search, generating ~2000 region proposals
  • Run a convolutional neural net (CNN) on top of each of these region proposals
  • Take the output of each CNN and feed it into a) an SVM to classify the region and b) a linear regressor to tighten the bounding box of the object, if such an object exists.

A pictorial description of R-CNN

Fast R-CNN:

Fast R-CNN was immediately followed R-CNN. Fast R-CNN is faster and better by the virtue of following points:

  • Performing feature extraction over the image before proposing regions, thus only running one CNN over the entire image instead of 2000 CNN’s over 2000 overlapping regions
  • Replacing the SVM with a softmax layer, thus extending the neural network for predictions instead of creating a new model.

A pictorial description of Fast R-CNN

Intuitively it makes a lot of sense to remove 2000 conv layers and instead take once Convolution and make boxes on top of that.

Faster R-CNN:

One of the drawbacks of Fast R-CNN was the slow selective search algorithm and Faster R-CNN introduced something called Region Proposal network(RPN).

Here’s is the working of the RPN:

At the last layer of an initial CNN, a 3x3 sliding window moves across the feature map and maps it to a lower dimension (e.g. 256-d) For each sliding-window location, it generates multiple possible regions based on k fixed-ratio anchor boxes (default bounding boxes)

Each region proposal consists of:

  • An “objectness” score for that region and
  • 4 coordinates representing the bounding box of the region In other words, we look at each location in our last feature map and consider k different boxes centered around it: a tall box, a wide box, a large box, etc.

For each of those boxes, we output whether or not we think it contains an object, and what the coordinates for that box are. This is what it looks like at one sliding window location:

Region Proposal Network

The 2k scores represent the softmax probability of each of the k bounding boxes being on “object.” Notice that although the RPN outputs bounding box coordinates, it does not try to classify any potential objects: its sole job is still proposing object regions. If an anchor box has an “objectness” score above a certain threshold, that box’s coordinates get passed forward as a region proposal.

Once we have our region proposals, we feed them straight into what is essentially a Fast R-CNN. We add a pooling layer, some fully-connected layers, and finally a softmax classification layer and bounding box regressor. In a sense, Faster R-CNN = RPN + Fast R-CNN.

Faster R-CNN

Linking some Tensorflow implementation:

https://github.com/smallcorgi/Faster-RCNN_TF

https://github.com/CharlesShang/FastMaskRCNN

You can find a lot of implementation of Github.

P.S. I borrowed a lot of material from Joyce Xu Medium blog.

like image 25
Abhishek Kumar Avatar answered Sep 19 '22 17:09

Abhishek Kumar