Skip to content

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Torch2Caffe2

Python and shell script to convert Torch models into Caffe2 protobuf files. The conversion uses ONNX-Caffe2 backend and has three steps like: Torch (.t7) -> PyTorch (.pth) -> ONNX (.onnx.pb) -> Caffe2 (.pb)

IMPORTANT: You need to specify the input dimension of the model.

Source Download

git clone --recursive git@github.com:ca1773130n/Torch2Caffe2.git

Requirements

  • Python 3.5
  • PyTorch
  • ONNX, ONNX-Caffe2
  • Caffe2 (optional)

NOTE:

Usage

torch_to_caffe2.sh <model_filename> <input_dimension>
  • The model file must be in the same directory of the shell script
  • The input dimension needs to be surrounded by quotes. It should look like this: "(1,3,512,512)"

Acknowledgement

This work is based on a GitHub project below.

Tested environment

  • Ubuntu 16.04
  • Anaconda Python 3.6
  • A Torch VGG-19 model file

Known Issues

  • PyTorch to ONNX conversion is imperfect (e.g. ONNX doesn't support ceil_mode in MaxPooling)

About

No description, website, or topics provided.

Resources

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages