Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get custom network to perform in ncnn #11

Open
realElMartino opened this issue Sep 25, 2021 · 4 comments
Open

Can't get custom network to perform in ncnn #11

realElMartino opened this issue Sep 25, 2021 · 4 comments

Comments

@realElMartino
Copy link

Hi,

  1. I train a custom yolox-s network
  2. It works fine when testing with .\tools\demo.py
  3. I export the onnx model using simplify
  4. Convert to ncnn using onnx2ncnn
  5. I follow all instructions to replace the head of the .param file

original:
7767517
235 268
Input images 0 1 images
Split splitncnn_input0 1 4 images images_splitncnn_0 images_splitncnn_1 images_splitncnn_2 images_splitncnn_3
Crop Slice_4 1 1 images_splitncnn_3 467 -23309=1,0 -23310=1,2147483647 -23311=1,1
Crop Slice_9 1 1 467 472 -23309=1,0 -23310=1,2147483647 -23311=1,2
Crop Slice_14 1 1 images_splitncnn_2 477 -23309=1,0 -23310=1,2147483647 -23311=1,1
Crop Slice_19 1 1 477 482 -23309=1,1 -23310=1,2147483647 -23311=1,2
Crop Slice_24 1 1 images_splitncnn_1 487 -23309=1,1 -23310=1,2147483647 -23311=1,1
Crop Slice_29 1 1 487 492 -23309=1,0 -23310=1,2147483647 -23311=1,2
Crop Slice_34 1 1 images_splitncnn_0 497 -23309=1,1 -23310=1,2147483647 -23311=1,1
Crop Slice_39 1 1 497 502 -23309=1,1 -23310=1,2147483647 -23311=1,2
Concat Concat_40 4 1 472 492 482 502 503 0=0
Convolution Conv_41 1 1 503 877 0=32 1=3 11=3 2=1 12=1 3=1 13=1 4=1 14=1 15=1 16=1 5=1 6=3456

Modified:
7767517
226 268
Input images 0 1 images
Input focus 1 1 images 503
Convolution Conv_41 1 1 503 877 0=32 1=3 11=3 2=1 12=1 3=1 13=1 4=1 14=1 15=1 16=1 5=1 6=3456

  1. Then using ncnnoptimize with fp16 switch 65536
  2. Replace second dummy input with YoloV5Focus
    7767517
    220 250
    Input images 0 1 images
    YoloV5Focus focus 1 1 images 503
    Convolution Conv_41 1 1 503 877 0=32 1=3 4=1 5=1 6=3456
    ...

When doing this with yolox-tiny I end up with the exact same network as the provided demo one except the number of classes in the output which is 191 in my case.

Now everything looks fine but the network does not perform at all - like not working at all. For training of the final network I use 640x640 images and this is used in training and also set in the app. I also tested tiny networks with 416x416 but always the same result.

The environment I train and test is on Windows using onnx 1.10.1, onnxruntime 1.9.0, onnx-simplifier 0.3.6. Using yolox 0.1.0 and latest ncnn.
I have tested almost everything over weeks now and just can't find what the issue could be.
I also looked at other posts where they suggested to use onnx version 1.8.1, onnxruntime 1.8.0 and onnx-simplifier 0.3.5 - but also having this set in an environment it is the same result as well as doing the conversion on a linux box.
Followed instructions here https://zhuanlan.zhihu.com/p/391788686 and others but always end up with the same non-performing network in ncnn.

Please let me know what I'm missing. I'm aware that this is not an issue with this project.

@HyperScypion
Copy link

I've the same issue and I also think it's problem with compatibility or ncnn

@HyperScypion
Copy link

Hey I found some kind of the solution that worked for me. Use this version of the ncnn library https://github.com/Tencent/ncnn/releases/tag/20210525 and convert model base on it. The first issue that state this problem is from April 2021 so maybe there is a bug or some kind of problems with libraries which are from April or later.

@icyclv
Copy link

icyclv commented Feb 12, 2022

Hey,recently I tried it.I also found that my model didn't seem to work.
The way I deal with it is first change the Line 344 in yolox.cpp with

ncnn::Mat in = ncnn::Mat::from_pixels_resize(rgb.data, ncnn::Mat::PIXEL_RGB2BGR, img_w, img_h, w, h);

Note that is PIXEL_RGB2BGR

and second delete the Line 355 with in_pad.substract_mean_normalize(mean_vals, norm_vals); .

@danurrahmajati
Copy link

thankyou very much, I know there is something that I need to change in yolox.cpp, but I don't know which one to make the code work, my guest around line 350-400, but still don't understand what I suppose to do, btw you are awesome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants