Skip to content

Commit

Permalink
updating feature extraction example
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeyk committed Sep 4, 2014
1 parent a661001 commit d5e9739
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions examples/feature_extraction/imagenet_val.prototxt
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ layers {
top: "data"
top: "label"
image_data_param {
source: "$CAFFE_DIR/examples/_temp/file_list.txt"
source: "examples/_temp/file_list.txt"
batch_size: 50
new_height: 256
new_width: 256
}
transform_param {
crop_size: 227
mean_file: "$CAFFE_DIR/data/ilsvrc12/imagenet_mean.binaryproto"
mean_file: "data/ilsvrc12/imagenet_mean.binaryproto"
mirror: false
}
}
Expand Down
10 changes: 5 additions & 5 deletions examples/feature_extraction/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ Extracting Features
===================

In this tutorial, we will extract features using a pre-trained model with the included C++ utility.
Follow instructions for [installing Caffe](../../installation.html) and for [downloading the reference model](../../getting_pretrained_models.html) for ImageNet.
Note that we recommend using the Python interface for this task, as for example in the [filter visualization example](http://nbviewer.ipython.org/github/BVLC/caffe/blob/master/examples/filter_visualization.ipynb).

Follow instructions for [installing Caffe](../../installation.html) and run `scripts/download_model_binary.py models/bvlc_reference_caffenet` from caffe root directory.
If you need detailed information about the tools below, please consult their source code, in which additional documentation is usually provided.

Select data to run on
Expand All @@ -35,7 +37,7 @@ Define the Feature Extraction Network Architecture
In practice, subtracting the mean image from a dataset significantly improves classification accuracies.
Download the mean image of the ILSVRC dataset.

data/ilsvrc12/get_ilsvrc_aux.sh
./data/ilsvrc12/get_ilsvrc_aux.sh

We will use `data/ilsvrc212/imagenet_mean.binaryproto` in the network definition prototxt.

Expand All @@ -44,14 +46,12 @@ We'll be using the `ImageDataLayer`, which will load and resize images for us.

cp examples/feature_extraction/imagenet_val.prototxt examples/_temp

Edit `examples/_temp/imagenet_val.prototxt` to use correct path for your setup (replace `$CAFFE_DIR`)

Extract Features
----------------

Now everything necessary is in place.

build/tools/extract_features.bin examples/imagenet/caffe_reference_imagenet_model examples/_temp/imagenet_val.prototxt fc7 examples/_temp/features 10
./build/tools/extract_features.bin models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel examples/_temp/imagenet_val.prototxt fc7 examples/_temp/features 10

The name of feature blob that you extract is `fc7`, which represents the highest level feature of the reference model.
We can use any other layer, as well, such as `conv5` or `pool3`.
Expand Down

0 comments on commit d5e9739

Please sign in to comment.