Skip to content
This repository has been archived by the owner on Aug 30, 2018. It is now read-only.

tutorial/example #3

Closed
mbehrisch opened this issue Sep 8, 2017 · 3 comments
Closed

tutorial/example #3

mbehrisch opened this issue Sep 8, 2017 · 3 comments

Comments

@mbehrisch
Copy link

Hi,

would it be possible to get an example how to translate a valid caffe2 model into onnx?
Maybe this should go in the documentation README.md?!

Thanks

@jerryzh168
Copy link
Collaborator

For now, please take a look at https://github.com/onnx/onnx-caffe2/blob/master/tests/caffe2_ref_test.py for examples, we will write more tutorials/examples soon.

@bddppq
Copy link
Member

bddppq commented Sep 8, 2017

Just to add, the c2 frontend is at https://github.com/onnx/onnx-caffe2/blob/master/onnx_caffe2/frontend.py.

You can translate a caffe2 model to onnx with just couple lines of code (these are extracted from the caffe2_ref_test.py @jerryzh168 mentioned above):

import onnx_caffe2.frontend as c2_onnx
from caffe2.proto import caffe2_pb2

c2_net = caffe2_pb2.NetDef()
with open(c2_model_file, 'rb') as f:
    c2_net.ParseFromString(f.read())
onnx_graph = c2_onnx.caffe2_net_to_onnx_graph(c2_net)

@mbehrisch
Copy link
Author

Perfect. I just didn't think about looking into the unit tests. Maybe I should write more testing code myself :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants