(forked from Cysu's branch, originally from fb-caffe-exts)
❌ I have stopped maintaining this repo. If you still want to use the converter, please use the AWS option:
The easiest option is to launch an AWS EC2 g2.2xlarge instance I created. Choose N.California Sever and search for the instance name of FB-Torch2Caffe (ami-03542e63). [You can follow the AWS tutorial]
-
Please make sure Torch and Caffe (with pycaffe and python layer) are correctly installed.
-
Download the code and install the dependencies (:x: If you still would like to set it up on you own workstation, please follow the steps here to install dependencies (fbcunn/install). Good luck!)
git clone https://github.com/zhanghang1989/fb-caffe-exts.git sudo bash install-dep.sh
-
Add Environment Variables (Change the path for your own machine)
echo "export LD_PRELOAD=/path/to/libcaffe.so; export PYTHONPATH=$PYTHONPATH:/path/to/caffe/python/:/path/to/fb-caffe-exts/;" >>~/.bashrc && source ~/.bashrc source ~/.bashrc
-
Convert your first model:
th convert.lua torch_model.t7b
-
Or custormize the conversion:
th torch2caffe/torch2caffe.lua --input torch_model.t7b --preprocessing prepnv.lua --prototxt name.prototxt --caffemodel name.caffemodel --input_dims 1 3 224 224
ELU
SpatialDropout
We scale the weights of previous layers by (1-p) to hide the difference between torch and caffe.SpatialMaxPooling
It has slightly different behaviours in Torch and Caffe. Torch uses floor(n/s+1) and Caffe uses floor(n/s). Therefore, only the conversion of even featuremap size is supported.SpatialBatchNormalization
Caffe BatchNorm doesn't have bias. We only support non-affine BN. Alternatively, you can convert it into a customized version of BN as in Cysu's branch.
LD_PRELOAD
crashes your gedit (If you know how to fix it, please update this wiki.)- The opencv package that Caffe relies on may cause the error of "libdc1394" failed to initialize, just create a fake device:
sudo ln /dev/null /dev/raw1394