-
-
Notifications
You must be signed in to change notification settings - Fork 82
Description
func getONNXInputSize(onnxFilePath string) {
backend:=simple.NewSimpleGraph()
//backend:=gorgonnx.NewGraph()
model := onnx.NewModel(backend)
// read the onnx model
b, err := utils.LoadFileBytes(onnxFilePath)
if err!=nil{
fmt.Println("read file error ",onnxFilePath,err)
panic(err)
}
if len(b)==0{
fmt.Println("onnf file error with lenght 0")
}
// Decode it into the model
err = model.UnmarshalBinary(b) // panic goes here!!!!!!!!!!!!!!!!!!!!!!!!
if err!=nil{
fmt.Println("parse onnx failure",err)
panic(err)
}
inputs := model.GetInputTensors()
if len(inputs) == 0 {
fmt.Println("No inputs found in the ONNX model")
}
input := inputs[0]
dims := input.Dims()
fmt.Println("Input image dimensions:", dims)
}
output:
panic: runtime error: index out of range [0] with length 0
goroutine 1 [running]:
gorgonia.org/tensor.StdEng.makeArray({{}}, 0xc00015adb8, {{0x831c20?, 0x721f60?}}, 0x0)
D:/golangdev/work/pkg/mod/gorgonia.org/tensor@v0.9.3/defaultengine.go:22 +0xec
gorgonia.org/tensor.(*Dense).makeArray(0xc00015ad80, 0x0)
D:/golangdev/work/pkg/mod/gorgonia.org/tensor@v0.9.3/dense.go:87 +0xe2
gorgonia.org/tensor.(*Dense).fix(0xc00015ad80)
D:/golangdev/work/pkg/mod/gorgonia.org/tensor@v0.9.3/dense.go:292 +0x1c5
gorgonia.org/tensor.New({0xc001cb4920, 0x3, 0x1?})
D:/golangdev/work/pkg/mod/gorgonia.org/tensor@v0.9.3/tensor.go:93 +0xb8
github.com/owulveryck/onnx-go/internal/onnx/ir.(*TensorProto).Tensor(0xc000141e60)
D:/golangdev/work/pkg/mod/github.com/owulveryck/onnx-go@v0.5.0/internal/onnx/ir/tensor.go:51 +0x5e5
github.com/owulveryck/onnx-go.toOperationAttribute(0xc0000c6100)
D:/golangdev/work/pkg/mod/github.com/owulveryck/onnx-go@v0.5.0/attributes.go:30 +0x109
github.com/owulveryck/onnx-go.toOperationAttributes({0xc00000a710, 0x1, 0xc0000afbf0?})
D:/golangdev/work/pkg/mod/github.com/owulveryck/onnx-go@v0.5.0/attributes.go:10 +0x6c
github.com/owulveryck/onnx-go.(*Model).applyModelProtoGraphNodeOperations(0xc00010bce0, 0xc000100500?)
D:/golangdev/work/pkg/mod/github.com/owulveryck/onnx-go@v0.5.0/decoder.go:235 +0x10d
github.com/owulveryck/onnx-go.(*Model).applyModelProtoGraph(0xc00010bce0, 0xc000132210)
D:/golangdev/work/pkg/mod/github.com/owulveryck/onnx-go@v0.5.0/decoder.go:149 +0x299
github.com/owulveryck/onnx-go.(*Model).decodeProto(0xc000198000?, 0x1b0853b?)
D:/golangdev/work/pkg/mod/github.com/owulveryck/onnx-go@v0.5.0/decoder.go:112 +0x105
github.com/owulveryck/onnx-go.(*Model).UnmarshalBinary(0x7a3222?, {0xc000198000, 0x1b0853b, 0x1b0853c})
D:/golangdev/work/pkg/mod/github.com/owulveryck/onnx-go@v0.5.0/decoder.go:38 +0x75
main.getONNXInputSize({0x7a3222, 0x24})
D:/GolangDev/learnings/testGoCV/yolov3.go:256 +0x277
main.testYolo()
D:/GolangDev/learnings/testGoCV/yolov3.go:27 +0x3a
main.main()
D:/GolangDev/learnings/testGoCV/main.go:27 +0x17
exit status 2