Skip to content

Instantly share code, notes, and snippets.

@Moelf
Created August 17, 2022 17:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Moelf/8aec81f8b5de0977794aa901ee7269b5 to your computer and use it in GitHub Desktop.
Save Moelf/8aec81f8b5de0977794aa901ee7269b5 to your computer and use it in GitHub Desktop.
ONNX Inference in Julia
julia> using ONNX, ONNX.Ghost
julia> dummy = rand(Float32, 78, 1);
julia> model = ONNX.load("./classifier_DF.onnx", dummy);
julia> x = range(0, Float32(0.5), length=78)
0.0f0:0.0064935065f0:0.5f0
julia> result = Ghost.play!(model, x)
1-element Vector{Float32}:
0.99929035
In [1]: import onnxruntime as onnx
In [2]: model = onnx.InferenceSession("./classifier_DF.onnx")
In [3]: input_name = model.get_inputs()[0].name
In [4]: input_name
Out[4]: 'dense_input'
In [5]: import numpy as np
In [26]: x = np.reshape(np.linspace(0, 0.5, 78, dtype=np.float32), (1, 78))
In [28]: result = model.run(None, {input_name: x})
In [29]: result
Out[29]: [array([[0.99929035]], dtype=float32)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment