Read ONNX graphs in Julia
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Fixed batchnorm and leakyrelu interface Jan 5, 2019
test Final changes Nov 10, 2018
.codecov.yml ONNX.jl generated files. Jan 17, 2018
.travis.yml fixed a few ops for 1.0 Nov 9, 2018 ONNX.jl generated files. Jan 17, 2018 fixed a few ops for 1.0 Nov 9, 2018
REQUIRE Final changes Nov 10, 2018
appveyor.yml ONNX.jl generated files. Jan 17, 2018


Build Status

ONNX.jl : Read ONNX graphs and load these models in Julia. ONNX.jl provides an instance of transfer learning into Julia, by reading pretrained models from ONNX format to Flux.jl. This is done by generating the DataFlow graph from the model, and then reading it as Julia code.

Note: If you're using julia-0.6, checkout to the v0.6 branch.

Loading models

You need to have the model.onnx ( or in some cases model.pb ) file, which will be read. Several pretrained ONNX model files can also be downloaded from here. Now that we have the model.onnx file, we can read it into Flux as :

julia> using Flux, ONNX                             # Import the required packages.
julia> ONNX.load_model("model.onnx")                # If you are in some other directory, specify the entire path.
                                                    # This creates two files: model.jl and weights.bson.
julia> weights = ONNX.load_weights("weights.bson")  # Read the weights from the binary serialized file.
julia> model = include("model.jl")                  # Loads the model from the model.jl file.

And model is the corresponding model in Flux!

This package is currently under development, don't tell us we didn't warn you!

Running the tests

It's always better to run the tests before moving on to importing a model. The operator tests ensure that all ops are working. Follow the given steps to run these tests:

  • Change your working directory to the test directory (cd ~/.julia/v0.6/ONNX.jl/test from the terminal)

  • Inside the test repository, run the runtests.jl script. (julia runtests.jl).

  • Running these tests may take some time, as it may initially download the test files if you don't already have them.(You need to have git preinstalled in order to download the tests)

In order to read more about these tests and run model specific tests, go throught the docs in the test directory.

Contributing and Help

If you're looking to contribute to the development of this package, and don't know where to begin, this blog post can be a good starting point. It lists the approach taken towards developing this package, the current obstacles, and the work to be done in the future.

Since this package is currently under development, feel free to open an issue if you find any error/bug.

For more discussion, you can get in touch with us on Julia Slack. We're pretty active on the #machine-learning channel.