ermig1979 / Synet

A small framework to infer neural network
MIT License
140 stars 26 forks source link

[Question] Getting started #38

Closed TonyCongqianWang closed 2 weeks ago

TonyCongqianWang commented 3 weeks ago

Hello, I would love to use your library to run onnx models without GPU. Unfortunatly I have no idea where to start. How do I go from a compiled onnx model to making predictions with a converted Synet model

TonyCongqianWang commented 3 weeks ago

What I have done so far is building the project and adding two models to data/onnx and added them to the test.sh script by copy pasting TEST onnx "" test_001 faces 30 0 1 1 1 004 2 I have no idea what the numbers behind "faces" mean and where to find the "faces" dataset. Also I have no idea what the "params.xml" files do besides naming the output folder. Both models I tried resulted in errors:

$ ./test.sh
Use increased accuracy threshold : 0.05 for BF16.
./test/onnx/test_slimdface/o_test_slimdface_t0_f1_b1_bf16_v004_p2.txt
Convert network from Onnx to Synet : [000] Error: Files './data/onnx/test_slimdface/other.onnx' and './data/onnx/test_slimdface/other.dat' are not exist!
$ ./test.sh
Use increased accuracy threshold : 0.05 for BF16.
./test/onnx/test_scrfd/o_test_scrfd_t0_f1_b1_bf16_v004_p2.txt
Convert network from Onnx to Synet : OK.
Start OnnxRuntime and Synet(fp32) single-thread comparison tests :
[000] Error: Input layer 'input' is not found!
[000] Error: Can't load Synet from './data/onnx/test_scrfd/synet.xml' and './data/onnx/test_scrfd/synet.bin' !
ermig1979 commented 3 weeks ago

onnx "" test_001 faces 30 0 1 1 1 004 2

1) onnx - tested framework 2) "" - test group subdir (it is absent). 3) test_001 - test name. 4) faces - directory with test images (relative to data/images). Can be 'local' - images must be placed locally in direcory 'image'. 5) 30 - number of test repeats. 6) 0 - number of test threads (to emulate multi-threaded load). 0 - is mean single thread debug mode. 7) 1 - model format (0 - NCHW, 1 - NHWC). 8) 1 - batch size. 9) 1 - internal data format (0 - FP32, 1 - BF16). 10) 004 - a tag to differ log files of different runs. 11) 2 - a performance statistic printing level (0, 1, 2).

TonyCongqianWang commented 2 weeks ago

Thank you so much for your help! So it turns out the first error was simply due to an typo. Actually I am also trying to convert ultraface but a compiled model. Now I receive the error.

[000] Error: MulLayer can't process inputs with this shape!
[000] Error: Can't reshape 116 layer with name: 381, type: Eltwise, src[0]: 32f { 1 17640 2 }, src[1]: 32f { 1 4420 2 } !
[000] Error: Can't load Synet from './data/onnx/test_slimface/synet.xml' and './data/onnx/test_slimface/synet.bin' !

I Think I also understand the params file now. It simply gives some metainformation about the models. And most importantly how the input layer is named and what the input dimensions are. I use non compiled models in the future!

Is there some kind of simple example program that shows how to load a model and perform inference with it on images?

ermig1979 commented 2 weeks ago

Hi! I can't see details but error is valid: I don't know how to multiply tensors with size { 1 17640 2 } and { 1 4420 2 }. Possible there is an error during model conversion.

There is an example in ./src/Use

TonyCongqianWang commented 2 weeks ago

Thank you!