Welcome to barrista’s documentation!

Barrista will serve your caffe right! It is a Python library that offers a full-featured interface to caffe, similar to keras and Theano.

Why barrista?

barrista gives you full, pythonic control over the entire caffe framework. It is different from the plain caffe Python interface in the way, that it exposes the entire caffe functionality (from net design over training and prediction) in a principled way to Python.

  • Design your nets with the full power of caffe within Python. Creating a network is as easy as:

    import barrista.design as ds
    netspec = ds.NetSpecification([[10, 3, 51, 51], [10]],
                                  # batchsize 10, 3 dim. of 51x51 signal, 10 labels
                                  inputs=['data', 'annotations'])
    # The layers are wired together automatically, unless you specify something else:
    net = netspec.instantiate()
  • barrista naturally understands and writes every .prototxt file your caffe version does! Load .prototxt files (also from the model zoo!) and use or modify the networks with barrista:

    net.save('net.caffemodel')  # Save the weights.
    new_netspec = ds.NetSpecification.from_prototxt(filename='net.prototxt')
    new_network = new_netspec.instantiate()
    new_network.load_blobs_from('net.caffemodel')  # Load the weights.
  • Use your networks in a principled way from Python. You get transparent support for repetitive tasks like batching or padding, with a clear separation of preprocessing:

    import barrista.solver
            X={'data': np.ones((21, 3, 51, 51)),  # Automatically batched.
               'annotations': np.zeros((21,))})
    net.predict({'data': np.zeros((5, 3, 51, 51)), [...]})
  • Use callbacks (functions that are called before and after processing a batch) to monitor training and prediction, or to dynamically modify the data used in the batches. barrista comes with a standard set of frequently used callbacks and it is very easy to add your own:

    import barrista.monitoring
    net.fit(# ... as before
              # Write the network weights every 100 iterations to disk.
              barrista.monitoring.Checkpointer('/tmp', 100),
              # Get a progress bar with ETA.
  • barrista is always fully consistent with caffe. We internally inspect the protobuf module generated by caffe to infer the interface. Adding your own layers is as easy as:

    import barrista.config
    barrista.config.LAYER_TYPES['Amazing'] = ['AmazingParameter']
  • It runs on every platform caffe runs on, and can be used with Python 2 and 3.

What’s the license?

You can use barrista under the MIT License, which means you may use it freely in any projects. The full license can be found in the main folder of the barrista repository.

Get the source & documentation

The source is hosted on github and the documentation/homepage is available on github pages at http://classner.github.io/barrista.

Indices and tables


This software was created at the Bernstein Center for Computational Neuroscience at the University of Tuebingen and the Max Planck Institute for Intelligent Systems Tuebingen. The main contributors are:

We thank Yangqing Jia and the BVLC vision group for creating the great caffe package!