xboot / libonnx

A lightweight, portable pure C99 onnx inference engine for embedded devices with hardware acceleration support.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failed to load 'yolov5n.onnx'.

miaowrx opened this issue · comments

hi,
I try to load 'yolov5n.onnx' like this:

#include "onnx.h"

int main(void)
{
    struct onnx_context_t *sess = onnx_context_alloc_from_file("yolov5n.onnx", NULL, 0);
    onnx_context_dump(sess, 1);
    return 0;
}

but nothing was output, including warnings and errors.

commented

I'm having similar issue with different model (in my case, the model is yolov3-tiny.onnx) .

I added ONNX_LOG calls to the onnx_graph_alloc function for debugging.

		if(!n->operator)
		{
			resolver_solve_operator(&resolver_default, n);
			if(n->operator)
			{
				n->r = &resolver_default;
				n->rctx = NULL;
			}
			else
			{
				ONNX_LOG("Unresolved!\r\n");
				ONNX_LOG("n->proto->op_type : %s\r\n", n->proto->op_type);
				ONNX_LOG("n->proto->name : %s\r\n", n->proto->name);
				ONNX_LOG("n->opset : %d\r\n", n->opset);
				ONNX_LOG("n->inputs[0]->type : %d\r\n", n->inputs[0]->type);
			}
		}
		if(!n->reshape)
			n->reshape = reshape_dummy;
		if(!n->operator) {
			n->operator = operator_dummy;
		}
		if(n->init)
		{
			if(n->init(n) <= 0)
			{
				ONNX_LOG("n->init failed\r\n");
				ONNX_LOG("i : %d\r\n", i);
				ONNX_LOG("n->proto->op_type : %s\r\n", n->proto->op_type);
				ONNX_LOG("n->proto->name : %s\r\n", n->proto->name);
				if(g->nodes)
				{

There're a few things I have noticed.

  • Resize operator is still not implemented.
  • Many operators such as Concat, input data type must be defined when resolving operators. But it looks like it's undefined before running the model.

I have same issue with Segmentation fault (core dumped).
model in https://github.com/Linzaer/Ultra-Light-Fast-Generic-Face-Detector-1MB
xxd convert onnx model to .h file, load model err in onnx_graph_alloc()
in onnx.c line 1171, model g->nlen = 242, but run end 82, and Segmentation fault.