Giter Club home page Giter Club logo

torch2caffe2's Introduction

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 [email protected]: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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.