Convert Caffe models to TensorFlow.
git clone https://github.com/psaboia/caffe-tensorflow
# This fork has only be tested with Python 2.7 and Tensorflow CPU
cd caffe-tensorflow
sudo docker build -t caffe-tensorflow .
docker run -ti caffe-tensorflow bash
cd caffe-tensorflow
python2.7 convert.py --caffemodel ./model.caffemodel ./model.prototxt --standalone-output-path ./standalone.pb --code-output-path ./output.py
It contains the weights and the architecture of the network.
Run convert.py
to convert an existing Caffe model to TensorFlow.
The input consists of an existing Caffe model.
--caffemodel ./model.caffemodel ./model.prototxt
. Make sure you're using the latest Caffe format.
The output consists of the files:
--standalone-output-path ./standalone.pb
, a standalone.pb GraphDef model file containing the model's graph and learned parameters (to be loaded on Tensorflow)--code-output-path ./output.py
, a Python class that constructs the model's graph.--data-output-path ./output.mat
, a data file (in NumPy's native format) containing the model's learned parameters.
# get Caffe model
wget http://dl.caffe.berkeleyvision.org/bvlc_googlenet.caffemodel
wget https://raw.githubusercontent.com/BVLC/caffe/master/models/bvlc_googlenet/deploy.prototxt
# convert
python2.7 convert.py --caffemodel ./bvlc_googlenet.caffemodel ./deploy.prototxt --standalone-output-path ./standalone.pb --code-output-path ./output.py