xboot / libonnx

A lightweight, portable pure C99 onnx inference engine for embedded devices with hardware acceleration support.
MIT License
560 stars 101 forks source link

How to convert a `onnx_context` to a `unsigned char array` as in the hello world example? #17

Closed abhinandanudupa closed 2 years ago

abhinandanudupa commented 2 years ago

In the main.c file in the examples/hello folder, how did you convert the MNSIT model to a unsigned char array and use it?:

#include <onnx.h>

static const unsigned char mnist_onnx[] = {
    0x08, 0x03, 0x12, 0x04, 0x43, 0x4e, 0x54, 0x4b, 0x1a, 0x05, 0x32, 0x2e,
    0x35, 0x2e, 0x31, 0x22, 0x07, 0x61, 0x69, 0x2e, 0x63, 0x6e, 0x74, 0x6b,
    0x28, 0x01, 0x3a, 0xb2, 0xce, 0x01, 0x0a, 0x62, 0x0a, 0x0c, 0x50, 0x61,
    0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x31, 0x39, 0x33, 0x0a, 0x1b,
    0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x31, 0x39, 0x33,

If you have any code to do it can you share it?

abhinandanudupa commented 2 years ago

Is it the .onnx file but as a C unsigned char array?

jianjunjiang commented 2 years ago

You can using xxd -i command, for onnx file to c code.

xxd -i model.onnx
abhinandanudupa commented 2 years ago

You can using xxd -i command, for onnx file to c code.

xxd -i model.onnx

Thank you!