Created
August 17, 2022 17:25
-
-
Save Moelf/8aec81f8b5de0977794aa901ee7269b5 to your computer and use it in GitHub Desktop.
ONNX Inference in Julia
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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