Home

Awesome

Fast Dense Feature Extraction for CNNs

An approach to compute patch-based local feature descriptors efficiently in presence of pooling and striding layers for whole images at once.

A Pytorch and TF (WIP) implementation of the paper "Fast Dense Feature Extraction with CNNs with Pooling Layers" https://arxiv.org/abs/1805.03096

Abstract

In recent years, many publications showed that convolutional neural network based features can have a superior performance to engineered features. However, not much effort was taken so far to extract local features efficiently for a whole image. In this paper, we present an approach to compute patch-based local feature descriptors efficiently in presence of pooling and striding layers for whole images at once. Our approach is generic and can be applied to nearly all existing network architectures. This includes networks for all local feature extraction tasks like camera calibration, Patchmatching, optical flow estimation and stereo matching. In addition, our approach can be applied to other patch-based approaches like sliding window object detection and recognition. We complete our paper with a speed benchmark of popular CNN based feature extraction approaches applied on a whole image, with and without our speedup, and example code (for Torch) that shows how an arbitrary CNN architecture can be easily converted by our approach.

FDFE

Getting Started

These instructions will explain how to use the Fast Dense Feature Extraction (FDFE) project.

Prerequisites

Installing

  1. Install all prerequisites - there maybe some dependency collisions between TF-Pytorch for simplicity choose one for time being
  2. Clone the project

Project Structure

Running the sample code

Now you should sample_code.py to make sure that FDFE project works correctly.

The test generates a random input image <img src="https://latex.codecogs.com/svg.latex?\Small&space;I" /> of size imH X imW and evaluates it on both <img src="https://latex.codecogs.com/svg.latex?\Small&space;C_{p}" /> and <img src="https://latex.codecogs.com/svg.latex?\Small&space;C_{I}" />.

The script continues and evaluates differences between both CNN's outputs and performs speed benchmarking.

There are two modes of operation for <img src="https://latex.codecogs.com/svg.latex?\Small&space;C_{p}" />:

Possible arguments

In sample_code.py there are initial parameters that could be adjusted:

<pre> - <b>imH</b> - Input image height - <b>imW</b> - Input image width - <b>pW</b> - patch Width - current implementation supports only odd width size - <b>pH</b> - patch Height - current implementation supports only odd width size - <b>sL1</b> - First stride value - <b>sL2</b> - Second stride value . . . - <b>sLn</b> - n-th stride value </pre> <pre> - <b>patch_i_center</b> - patch row center - <b>patch_j_center</b> - patch column center </pre> <pre> - <b>batch_size</b> - number of patches to be evaluated at the same time </pre>

Expected output

Script outputs the following:

Expected verbose would look like: (depends on <img src="https://latex.codecogs.com/svg.latex?\Small&space;C_{p}" /> running mode):

<pre> Total time for C_P: 0.017114248275756836 sec ------------------------------------------------------------ Averaged time for C_I per Patch without warm up: 0.0010887398617342114 sec ------- Comparison between a base_net over all patches output and slim_net ------- aggregated difference percentage = 0.0000000000 % maximal abs difference = 0.0000000000 at index i=0,j=0 ------------------------------------------------------------ </pre>

To use FDFE with your own patch based network

In order to use your own pre-trained network that operates on patches you would need to:

WIP

Contributing

Contributions are always welcome! Please read the contribution guidelines first.

Authors

Acknowledgments

A big thanks to the following individuals for designing the approach: