# How to architect a network to find bounding boxes in simple images

I have an application where I want to find the locations of objects on a simple, relatively constant background (fixed camera angle, etc). For investigative purposes I've created a test dataset which displays many characteristics of the actual problem.

Here's a sample from my test dataset.

Our problem description is to find the bounding box of the single circle in the image. If there is more than one circle or no circles, we don't care about the bounding box (but we at least need to know that there is no valid single bounding box).

For my attempt to solve this, I built a CNN that would regress (min_x, min_y, max_y, max_y) as well as one more value which could indicate how many circles were in the image.

I played with different architecture variations, but in general the architecture a was very standard CNN (3-4 relu conv layers with max pooling in between, followed by a dense layer and an output layer with linear activation for the bounding box outputs, set to minimise the mean squared error between the outputs and the ground truth bounding boxes).

Regardless of the architecture, hyperparameters, optimizers, etc, the result was always the same - the CNN could not even get close to building a model that was able to regress an accurate bounding box, even with over 50000 training examples to work with.

What gives? Do I need to look at using another type of network as CNNs are more suited to classification rather than localisation tasks?

Obviously there are computer vision techniques that could solve this easily, but due to the fact that the actual application is more involved, I want to know strictly about NN/AI approaches to this problem.

## 2 Answers

There are some special architectures of CNNs which are designed exactly for the task you mention. The Detector library includes a collection of these architectures, this paper describes the Mask R-CNN network in detail, which is designed for image segmentation tasks.

• Thanks for your answer! The Mask R-CNN, Faster R-CNN are interesting but they all seem to be tailored towards combining classification with bounding box detection - I don't see a simple and effective way to isolate the key elements for finding bounding boxes alone – Daniel Sep 7 '18 at 8:18

In the R-CNN family approach, the BBox regression is performed using a specific module providing region proposal: initially the Selective Search has been used then Region Proposal Network has been introduced, which has the advantage, being a NN, to be trainable.

This has not to be confused with the BBox Regressor which comes after in the architecture and is focused on refining the proposal bboxes for the “Non Background” proposal objects

Please consider that to perform object detection properly, at least using a region proposal based architecture, you need to perform the basic “Background / Non Background” classification (which is where CNN features help) so to filter out non relevant proposals