OverFeat: Integrated Recognition, Localization and Detection using Convolutional Networks
- Publication
- ICLR 2014Conference
- First submitted to arXiv
- arXiv:1312.6229
Cite this paper · BibTeX
The citation identifies the linked source version. It cites the original paper and its authors.
@misc{classiccnnsoverfeat2013,
title = {{OverFeat: Integrated Recognition, Localization and Detection using Convolutional Networks}},
author = {Pierre Sermanet and David Eigen and Xiang Zhang and Michael Mathieu and Rob Fergus and Yann LeCun},
year = {2013},
eprint = {1312.6229},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/1312.6229}
}
In 2012, AlexNet won both the classification and the localization tracks of the ImageNet competition.
How they did classification was written up in the paper, and everyone had read it. Localization? At the time, nothing published explained how they did it.
Pierre Sermanet and colleagues from Yann LeCun's lab at New York University released this paper in December 2013. In the introduction they state plainly that this is the first paper to clearly explain how convolutional networks can do localization and detection on ImageNet. Their system won the localization track of the 2013 competition and also entered classification and detection with the same network.
Along with the paper, they released the trained model as a feature extractor, named simply OverFeat.
Defining the Problem
The paper tackles three tasks, each harder than the last, and each one part of the next:
- Classification: each image has a single label. You get 5 guesses, and one correct guess counts as correct.
- Localization: again 5 guesses, but each must come with a box as well as a class. A guess counts only if the class is right and the box's intersection over union (IoU) with the ground truth is at least 50%.
- Detection: an image can contain any number of objects, possibly none. It's scored by mAP, and false boxes are penalized.
In ImageNet's classification data, the object is usually in the center and fills most of the image, but plenty of objects still vary widely in size and position. The most direct approach is a sliding window, which means running the network at every position and every scale of the image.
That raises two problems.
The first is computation. An image has to be cut into thousands upon thousands of windows, and running the full convolutional network on each one is expensive.
The second is that windows and objects don't line up. Many windows capture only part of an object, say just the dog's head; that's enough for the classifier to recognize a dog, but not enough to tell you where the whole dog is. The authors say this yields “decent classification but poor localization and detection.”
So the authors set out to do multi-scale sliding windows efficiently inside the network, have each window predict not only a class but also the position of the object's box relative to the window, and finally accumulate the evidence from all the windows.
Solving the Problem
The Classification Network
OverFeat's classification network is similar to AlexNet, but it drops contrast normalization, uses non-overlapping pooling regions, and has larger feature maps in the first and second layers.
The paper actually provides two versions. The fast model has an first layer with stride 4; the accurate model switches the first layer to with stride 2, and also has one more layer and more feature maps. Their parameter counts are about the same (145 million for fast, 144 million for accurate, versus about 60 million for AlexNet), but the accurate model has nearly twice as many connections.
During training, the image's shorter side is resized to 256 and random crops are taken; at this stage the network is treated as a non-spatial model whose final output is a classification vector. Only at test time does it switch to sliding over the whole image.
Why Sliding Windows Aren't Expensive

Start with the top row. A input becomes after a convolution, and after pooling; the classifier's first layer takes in the whole and outputs a single position, and the two layers after it are both .
The classifier was originally made of fully connected layers. The authors note that a fully connected layer that takes a fixed-size input is equivalent to a convolution kernel of the same size, and that the fully connected layers after it are equivalent to convolutions. That way, the whole network consists only of convolutions, pooling, and ReLU.
Now the bottom row. With the input enlarged to , every layer's feature map gains an extra border, and the final output becomes , which is the classification result for 4 windows. Overlapping regions are computed only once; the only extra computation is the yellow border.
This is the natural advantage of doing sliding windows with a convolutional network. Running it once over the whole image gives answers for every window, without cutting out each window and computing it separately.
The Output Is Too Sparse
Running everything in one pass has a price, though. From the input to the last convolutional layer, the accurate model goes through a stride-2 convolution and three pooling layers, shrinking by a total factor of . In other words, the classifier produces only one output every 36 pixels of the input image.
The better a window lines up with the object, the more confident the network is; looking only once every 36 pixels, it can easily miss the best-aligned position. The authors found that such sparse output does even worse than AlexNet's approach of a fixed 10 crops.
Their solution is to avoid throwing away resolution at the last pooling step. The last pooling was originally a non-overlapping max pooling; now they shift the pooling's starting point by pixels, run it once for each, send each result through the classifier separately, and finally interleave the results back together:

Let's follow the figure. The unpooled layer-5 feature map has length 20. After 3-cell pooling at each offset, 6 cells remain, and a classifier 5 cells wide produces 2 outputs on them, exactly the lengths in (c) and (d) of the figure; interleaving the three groups gives the 6 cells of (e).
Before the last pooling, the network has already shrunk by a factor of , so two adjacent cells in layer 5 are 12 pixels apart in the input. With alone, the classifier steps 3 cells at a time, which is 36 pixels; with all three offsets, every cell gets an output, and the spacing shrinks to 12 pixels.
The authors also describe it another way, as applying the last pooling and the classifier once at every possible offset and then interleaving the results.
Multiple Scales: Take the Max, Then Average
That was a single scale. For actual classification, the authors resize the image to 6 sizes, from to , run the procedure above at each size, and run it again on the horizontally flipped image. The final classification takes three steps:
- For each scale and flip, take each class's maximum over all positions.
- Average the results across scales and flips.
- Take the top 1 or top 5 from the averaged class vector.
The authors also sum up how the two halves of the network are used. The feature extraction layers in front convolve the whole image in one pass, which is most efficient; the classifier behind them works the other way around, taking a fixed input and searching exhaustively over every position and every scale of the layer 5 feature maps.
From Classification to Drawing Boxes
For localization, each window has to say not only “what's here” but also “where the object's box is.”
After layers 1 to 5 of the classification network, the authors attach a separate regression network, with two fully connected layers of 4096 and 1024 channels and a final output of 4 numbers representing the four edges of the box. Like the classifier, it's computed once for each of the offsets. The last layer has a separate copy for each class, 1000 in all.
During training, layers 1 to 5 stay fixed and only the regression network is trained, with an loss between the predicted box and the ground truth. Object boxes that overlap the input window by less than 50% aren't used for training: most of the object lies outside the window, so it's better handled by other windows that contain it.
The regression network is also trained at multiple scales. The authors say this makes predictions agree across scales, which greatly boosts the confidence after merging, so a few scales are enough. The ratio between scales is about 1.4, much larger than the 1.05 to 1.1 typical in pedestrian detection, which also lets the system run faster.
Accumulate, Don't Suppress
Every scale and every position produces a box, adding up to thousands of them. The authors use a greedy merging algorithm to boil them down to a few:
- At each scale, take the top classes the model is most confident about.
- Collect the boxes predicted for these classes at all positions and all scales.
- Repeatedly find the two closest boxes and merge them into one (averaging their coordinates), until the closeness of every pair falls below the threshold.
Closeness is computed from the distance between the two boxes' centers and their intersection area. After merging, a box's confidence is the sum of the classification scores of all the windows merged into it.

In the third row of this figure, most of the regressed boxes crowd onto the bear. A few “turtle” and “whale” boxes show up along the way, but their classification confidence is at most 0.11 and 0.12, and their positions are widely scattered, so merging doesn't add them up and they end up below the threshold. The bear boxes, by contrast, have high confidence (about 0.5 on average per scale) and consistent positions, so they merge into a single box with very high confidence.
The authors contrast this with traditional non-maximum suppression (NMS). NMS keeps only the highest-scoring box and throws the rest away, while here consistent boxes add to each other's scores, so scattered false positives coming from the pure classifier are easier to weed out.
Detection: Picking Negatives on the Fly During Training
The main difference between detection and localization is that detection has to be able to say “there's no object here,” which means one more class for the background.
The traditional approach is to start training on randomly chosen negatives, then add the negatives the model gets most wrong back into the training set, repeating for several rounds (bootstrapping). The authors find this both complicated and prone to letting the collection of negatives fall out of step with training. So instead, during training they pick a few negatives from each image on the spot, some random and some that the model finds most confusing. It costs more computation, but the procedure is much simpler; and since the feature layers have already been trained on the classification task, fine-tuning for detection doesn't take long anyway.
Discussion
Classification
| Setting (validation set) | Top-1 | Top-5 |
|---|---|---|
| AlexNet, 1 model | 40.7 | 18.2 |
| Fast model, 1 scale, only | 39.28 | 17.12 |
| Fast model, 1 scale, three offsets | 39.01 | 16.97 |
| Fast model, 6 scales, three offsets | 38.12 | 16.27 |
| Accurate model, fixed 10 crops | 35.60 | 14.71 |
| Accurate model, 4 scales, three offsets | 35.74 | 14.18 |
| 7 accurate models, 4 scales, three offsets | 33.96 | 13.24 |
At a single scale, the three offsets bring only a small improvement (17.12% → 16.97%); the authors say they matter more with multiple scales. Going from 1 scale to 6, top-5 error falls from 16.97% to 16.27%. The accurate model with multi-scale sliding beats the fixed 10 crops by about half a percentage point (14.71% → 14.18%).
On the competition test set, OverFeat reached 14.2% top-5 error with a vote of 7 fast models, ranking fifth among 18 teams; the best result that year using only ILSVRC13 data was 11.7%. After the competition, they brought it down to 13.6% with bigger models.
Localization
The authors compare several settings on the ILSVRC12 validation set:
- A single center crop only: about 40% error.
- Combining predictions from all positions at two scales: 31.5%.
- Going up to four scales: 30.0%.
- A separate regression head for each class (per-class regressor) turns out much worse than one head shared by all classes: 44.1% versus 31.3%. The authors suspect that each class has too few training examples with boxes, while the parameters grow 1000-fold.
On the competition test set, OverFeat won the 2013 localization track with an error rate of 29.9%.
Detection
During the competition, OverFeat's detection system placed third with 19.4% mAP; the winner, UvA, had 22.6%. After the competition, they trained longer and added lower-resolution input at each scale as context, raising mAP to 24.3%, ahead of every result at the time.
The authors also point out two things. First, the top two entries both used image segmentation to generate candidate regions, cutting the number of windows to examine from about 200,000 to 2,000; the literature indicates that this reduces false positives, whereas OverFeat uses dense sliding windows. Second, NEC and UvA fine-tuned on the detection validation set and OverFeat didn't; the validation and test sets differ enough in distribution from the training set that this step alone improves results by about one percentage point.
Conclusion
OverFeat demonstrated that classification, localization, and detection can share a single convolutional network, and that sliding windows can be computed cheaply inside a convolutional network, which nobody had yet written down clearly at the time. Its localization result was the best of 2013, and its detection result also reached the state of the art after the competition.
That record didn't last long. R-CNN first generates candidate regions with selective search, then runs the convolutional network once on each region; a later version of its paper added the same ILSVRC 2013 detection benchmark and reported 31.4% mAP, versus OverFeat's 24.3%. The same paper also acknowledges that OverFeat is about 9 times faster (about 2 seconds per image), because its sliding windows don't require image-level warping, so overlapping computation can be shared.
In its related work, the later YOLO notes that OverFeat performs sliding-window detection efficiently but is still a disjoint system, optimized for localization rather than detection; each prediction sees only local information and needs significant post-processing to produce coherent detections. YOLO instead has the network look at the whole image at once and output every box directly.
Looking back, this paper already shows traces of YOLO's and FCN's practices of treating fully connected layers as convolutions, computing the whole image in one pass, and regressing boxes directly on feature maps. It's just that OverFeat, in 2013, still split these into several separate steps.
If you've read YOLO, it's worth coming back to compare it with this paper; you'll see more clearly what exactly YOLO changed.