Skip to content

How to pycaffe #1774

@shelhamer

Description

@shelhamer

There's confusion about the Python interface. In particular users get stuck with

Advice on matching the caffe command and caffe python module:

It can be tricky to get the preprocessing options exactly right. Instead of loading a deploy prototxt in Python, load the exact same model as you do by extract_features.

Instead of making a caffe.Classifier, make a caffe.Net and call net.forward() to load inputs from the data layer batch-by-batch:

net = caffe.Net('net_with_data_layer.prototxt', 'weights.caffemodel')
net.forward() # this will load the next mini-batch as defined in the net
fc7 = net.blobs['fc7'].data # or whatever you want

Raw inputs like in deploy model inputs can be processed by the caffe.Net.preprocess() method or caffe.Classifier convenience class since these are bottom blobs. Data layers, like HDF5_DATA or MEMORY_DATA cannot, since these are top blobs in the Net. For models with data layers, call caffe.Net.forward() as shown.

In general I suggest the caffe.Net interface. For input processing #1245 is an important step.

Documentation and examples of all this should follow #1703.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions