ONNX.jl
ONNX.jl copied to clipboard
Where does model.jl come from in the README?
I am trying to follow the steps in the readme. I have downloaded the model, and it seems to load the weights file correctly despite giving me the below error:
julia> ONNX.load_model("model.onnx")
ERROR: KeyError: key :Gather not found
Stacktrace:
[1] getindex(h::Dict{Symbol, Any}, key::Symbol)
@ Base ./dict.jl:482
[2] _graph(g::ONNX.Types.Graph)
@ ONNX ~/.julia/packages/ONNX/iz0dL/src/graph/graph.jl:0
[3] graph(g::ONNX.Types.Graph)
@ ONNX ~/.julia/packages/ONNX/iz0dL/src/graph/graph.jl:92
[4] code(g::ONNX.Types.Graph)
@ ONNX ~/.julia/packages/ONNX/iz0dL/src/graph/graph.jl:100
[5] write_julia_file(model_file::String)
@ ONNX ~/.julia/packages/ONNX/iz0dL/src/convert.jl:235
[6] load_model(model::String)
@ ONNX ~/.julia/packages/ONNX/iz0dL/src/convert.jl:250
[7] top-level scope
@ REPL[18]:1
shell> ls -l
total 3180640
-rw------- 1 logankilpatrick staff 1625394545 Oct 13 07:01 model.onnx
-rw-r--r-- 1 logankilpatrick staff 685933 Oct 13 07:02 weights.bson
julia> weights = ONNX.load_weights("weights.bson")
Dict{String, Any} with 521 entries:
"Constant_123" => fill(1.0)
"Constant_3300" => fill(2.0)
"Constant_2837" => fill(0)
"Constant_2150" => fill(1.0)
"Constant_3712" => fill(2.0)
"Constant_1246" => fill(0.5)
"Constant_2970" => fill(16)
"Constant_3817" => fill(0.125)
"Constant_1134" => fill(1.0)
"Constant_2064" => fill(1)
"Constant_3538" => fill(0.125)
"Constant_3896" => fill(1.0)
"Constant_397" => fill(2)
"Constant_148" => fill(1)
"Constant_3807" => fill(0)
"Constant_47" => fill(-1)
"Constant_3215" => fill(2.0)
"Constant_1378" => fill(2)
"Constant_2551" => fill(1.0f-5)
⋮ => ⋮
My question is what do I need to do now that I have the weights?
I'm surprised it works at all! AIUI the old version of ONNX (which you're running here) used to generate a julia source file describing the model. I'm not exactly sure how that process worked or what the failure modes were (seems from the error above that support for the gather
op wasn't implemented), but that's why the old README mentions a model.jl.