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

pytorch->onnx->ncnn对mobileNetv3模型转换输出类别个数问题 #2517

Open
sumingzhe123 opened this issue Dec 29, 2020 · 9 comments
Open

Comments

@sumingzhe123
Copy link

我在pytorch->onnx->ncnn对mobileNetv3模型转换的过程中,遇到了:1、onnx2ncnn步骤有不支持问题,使用了onnxsim对onnx模型进行了处理后,再进行onnx2ncnn时转换OK,得到解决;2、我在构建应用,使用extractor.extract()时需要blob的name或index,当我使用ncnn2mem将文件转换成*.id.h打开查看最后的index并使用后,出现输出为28个,而我需要输出的是4个啊,奇了怪了,咋回事呢?我又使用netron可视化工具分别查看了*.param和*.param.bin两个文件,发现*.param正常最后输出4个,.param.bin不正常最后输出的是28个,整体长度对比,.param要比*.param.bin的图要长一些,貌似好像被截断了,但我使用的是*.param啊,这到底是咋回事呢?

@nihui
Copy link
Member

nihui commented Dec 29, 2020

模型中所有的 blob 都可以通过 name 和 index 拿出来,id.h 中的 28 个 BLOB_XXX 一定包含了 param 中的全部 blob 名字了,如果你只用 param,无需使用 ncnn2mem 工具,直接用 param 和 bin 文件即可

https://github.com/Tencent/ncnn/wiki/use-ncnn-with-alexnet.zh#%E5%8A%A0%E8%BD%BD%E6%A8%A1%E5%9E%8B

@sumingzhe123
Copy link
Author

.param文件如下:
7767517
112 187
Input input.1 0 1 input.1
Convolution Conv_0 1 1 input.1 785 0=16 1=3 11=3 2=1 12=1 3=2 13=2 4=1 14=1 15=1 16=1 5=1 6=432
HardSwish Div_5 1 1 785 408 0=1.666667e-01 1=5.000000e-01
Split splitncnn_0 1 2 408 408_splitncnn_0 408_splitncnn_1
Convolution Conv_6 1 1 408_splitncnn_1 788 0=16 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=256
ReLU Relu_7 1 1 788 411
ConvolutionDepthWise Conv_8 1 1 411 791 0=16 1=3 11=3 2=1 12=1 3=1 13=1 4=1 14=1 15=1 16=1 5=1 6=144 7=16
ReLU Relu_9 1 1 791 414
Convolution Conv_10 1 1 414 794 0=16 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=256
BinaryOp Add_11 2 1 794 408_splitncnn_0 417 0=0
Convolution Conv_12 1 1 417 797 0=64 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=1024
ReLU Relu_13 1 1 797 420
ConvolutionDepthWise Conv_14 1 1 420 800 0=64 1=3 11=3 2=1 12=1 3=2 13=2 4=1 14=1 15=1 16=1 5=1 6=576 7=64
ReLU Relu_15 1 1 800 423
Convolution Conv_16 1 1 423 803 0=24 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=1536
Split splitncnn_1 1 2 803 803_splitncnn_0 803_splitncnn_1
Convolution Conv_17 1 1 803_splitncnn_1 806 0=72 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=1728
ReLU Relu_18 1 1 806 428
ConvolutionDepthWise Conv_19 1 1 428 809 0=72 1=3 11=3 2=1 12=1 3=1 13=1 4=1 14=1 15=1 16=1 5=1 6=648 7=72
ReLU Relu_20 1 1 809 431
Convolution Conv_21 1 1 431 812 0=24 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=1728
BinaryOp Add_22 2 1 812 803_splitncnn_0 434 0=0
Convolution Conv_23 1 1 434 815 0=72 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=1728
ReLU Relu_24 1 1 815 437
ConvolutionDepthWise Conv_25 1 1 437 818 0=72 1=5 11=5 2=1 12=1 3=2 13=2 4=2 14=2 15=2 16=2 5=1 6=1800 7=72
ReLU Relu_26 1 1 818 440
Convolution Conv_27 1 1 440 821 0=40 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=2880
Split splitncnn_2 1 2 821 821_splitncnn_0 821_splitncnn_1
Pooling GlobalAveragePool_28 1 1 821_splitncnn_1 443 0=1 4=1
Convolution Conv_29 1 1 443 824 0=10 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=400
ReLU Relu_30 1 1 824 446
Convolution Conv_31 1 1 446 827 0=40 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=400
HardSigmoid Div_35 1 1 827 454 0=1.666667e-01 1=5.000000e-01
BinaryOp Mul_36 2 1 821_splitncnn_0 454 455 0=2
Split splitncnn_3 1 2 455 455_splitncnn_0 455_splitncnn_1
Convolution Conv_37 1 1 455_splitncnn_1 830 0=120 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=4800
ReLU Relu_38 1 1 830 458
ConvolutionDepthWise Conv_39 1 1 458 833 0=120 1=5 11=5 2=1 12=1 3=1 13=1 4=2 14=2 15=2 16=2 5=1 6=3000 7=120
ReLU Relu_40 1 1 833 461
Convolution Conv_41 1 1 461 836 0=40 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=4800
Split splitncnn_4 1 2 836 836_splitncnn_0 836_splitncnn_1
Pooling GlobalAveragePool_42 1 1 836_splitncnn_1 464 0=1 4=1
Convolution Conv_43 1 1 464 839 0=10 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=400
ReLU Relu_44 1 1 839 467
Convolution Conv_45 1 1 467 842 0=40 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=400
HardSigmoid Div_49 1 1 842 475 0=1.666667e-01 1=5.000000e-01
BinaryOp Mul_50 2 1 836_splitncnn_0 475 476 0=2
BinaryOp Add_51 2 1 476 455_splitncnn_0 477 0=0
Split splitncnn_5 1 2 477 477_splitncnn_0 477_splitncnn_1
Convolution Conv_52 1 1 477_splitncnn_1 845 0=120 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=4800
ReLU Relu_53 1 1 845 480
ConvolutionDepthWise Conv_54 1 1 480 848 0=120 1=5 11=5 2=1 12=1 3=1 13=1 4=2 14=2 15=2 16=2 5=1 6=3000 7=120
ReLU Relu_55 1 1 848 483
Convolution Conv_56 1 1 483 851 0=40 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=4800
Split splitncnn_6 1 2 851 851_splitncnn_0 851_splitncnn_1
Pooling GlobalAveragePool_57 1 1 851_splitncnn_1 486 0=1 4=1
Convolution Conv_58 1 1 486 854 0=10 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=400
ReLU Relu_59 1 1 854 489
Convolution Conv_60 1 1 489 857 0=40 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=400
HardSigmoid Div_64 1 1 857 497 0=1.666667e-01 1=5.000000e-01
BinaryOp Mul_65 2 1 851_splitncnn_0 497 498 0=2
BinaryOp Add_66 2 1 498 477_splitncnn_0 499 0=0
Convolution Conv_67 1 1 499 860 0=240 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=9600
HardSwish Div_72 1 1 860 508 0=1.666667e-01 1=5.000000e-01
ConvolutionDepthWise Conv_73 1 1 508 863 0=240 1=3 11=3 2=1 12=1 3=2 13=2 4=1 14=1 15=1 16=1 5=1 6=2160 7=240
HardSwish Div_78 1 1 863 517 0=1.666667e-01 1=5.000000e-01
Convolution Conv_79 1 1 517 866 0=80 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=19200
Split splitncnn_7 1 2 866 866_splitncnn_0 866_splitncnn_1
Convolution Conv_80 1 1 866_splitncnn_1 869 0=200 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=16000
HardSwish Div_85 1 1 869 528 0=1.666667e-01 1=5.000000e-01
ConvolutionDepthWise Conv_86 1 1 528 872 0=200 1=3 11=3 2=1 12=1 3=1 13=1 4=1 14=1 15=1 16=1 5=1 6=1800 7=200
HardSwish Div_91 1 1 872 537 0=1.666667e-01 1=5.000000e-01
Convolution Conv_92 1 1 537 875 0=80 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=16000
BinaryOp Add_93 2 1 875 866_splitncnn_0 540 0=0
Split splitncnn_8 1 2 540 540_splitncnn_0 540_splitncnn_1
Convolution Conv_94 1 1 540_splitncnn_1 878 0=184 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=14720
HardSwish Div_99 1 1 878 549 0=1.666667e-01 1=5.000000e-01
ConvolutionDepthWise Conv_100 1 1 549 881 0=184 1=3 11=3 2=1 12=1 3=1 13=1 4=1 14=1 15=1 16=1 5=1 6=1656 7=184
HardSwish Div_105 1 1 881 558 0=1.666667e-01 1=5.000000e-01
Convolution Conv_106 1 1 558 884 0=80 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=14720
BinaryOp Add_107 2 1 884 540_splitncnn_0 561 0=0
Split splitncnn_9 1 2 561 561_splitncnn_0 561_splitncnn_1
Convolution Conv_108 1 1 561_splitncnn_1 887 0=184 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=14720
HardSwish Div_113 1 1 887 570 0=1.666667e-01 1=5.000000e-01
ConvolutionDepthWise Conv_114 1 1 570 890 0=184 1=3 11=3 2=1 12=1 3=1 13=1 4=1 14=1 15=1 16=1 5=1 6=1656 7=184
HardSwish Div_119 1 1 890 579 0=1.666667e-01 1=5.000000e-01
Convolution Conv_120 1 1 579 893 0=80 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=14720
BinaryOp Add_121 2 1 893 561_splitncnn_0 582 0=0
Split splitncnn_10 1 2 582 582_splitncnn_0 582_splitncnn_1
Convolution Conv_122 1 1 582_splitncnn_1 896 0=480 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=38400
HardSwish Div_127 1 1 896 591 0=1.666667e-01 1=5.000000e-01
ConvolutionDepthWise Conv_128 1 1 591 899 0=480 1=3 11=3 2=1 12=1 3=1 13=1 4=1 14=1 15=1 16=1 5=1 6=4320 7=480
HardSwish Div_133 1 1 899 600 0=1.666667e-01 1=5.000000e-01
Convolution Conv_134 1 1 600 902 0=112 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=53760
Split splitncnn_11 1 2 902 902_splitncnn_0 902_splitncnn_1
Pooling GlobalAveragePool_135 1 1 902_splitncnn_1 603 0=1 4=1
Convolution Conv_136 1 1 603 905 0=28 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=3136
ReLU Relu_137 1 1 905 606
Convolution Conv_138 1 1 606 908 0=112 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=3136
HardSigmoid Div_142 1 1 908 614 0=1.666667e-01 1=5.000000e-01
BinaryOp Mul_143 2 1 902_splitncnn_0 614 615 0=2
Convolution Conv_144 1 1 582_splitncnn_0 911 0=112 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=8960
BinaryOp Add_145 2 1 615 911 618 0=0
Split splitncnn_12 1 2 618 618_splitncnn_0 618_splitncnn_1
Convolution Conv_146 1 1 618_splitncnn_1 914 0=672 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=75264
HardSwish Div_151 1 1 914 627 0=1.666667e-01 1=5.000000e-01
ConvolutionDepthWise Conv_152 1 1 627 917 0=672 1=3 11=3 2=1 12=1 3=1 13=1 4=1 14=1 15=1 16=1 5=1 6=6048 7=672
HardSwish Div_157 1 1 917 636 0=1.666667e-01 1=5.000000e-01
Convolution Conv_158 1 1 636 920 0=112 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=75264
Split splitncnn_13 1 2 920 920_splitncnn_0 920_splitncnn_1
Pooling GlobalAveragePool_159 1 1 920_splitncnn_1 639 0=1 4=1
Convolution Conv_160 1 1 639 923 0=28 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=3136
ReLU Relu_161 1 1 923 642
Convolution Conv_162 1 1 642 926 0=112 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=3136
HardSigmoid Div_166 1 1 926 650 0=1.666667e-01 1=5.000000e-01
BinaryOp Mul_167 2 1 920_splitncnn_0 650 651 0=2
BinaryOp Add_168 2 1 651 618_splitncnn_0 652 0=0
Split splitncnn_14 1 2 652 652_splitncnn_0 652_splitncnn_1
Convolution Conv_169 1 1 652_splitncnn_1 929 0=672 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=75264
HardSwish Div_174 1 1 929 661 0=1.666667e-01 1=5.000000e-01
ConvolutionDepthWise Conv_175 1 1 661 932 0=672 1=5 11=5 2=1 12=1 3=1 13=1 4=2 14=2 15=2 16=2 5=1 6=16800 7=672
HardSwish Div_180 1 1 932 670 0=1.666667e-01 1=5.000000e-01
Convolution Conv_181 1 1 670 935 0=160 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=107520
Split splitncnn_15 1 2 935 935_splitncnn_0 935_splitncnn_1
Pooling GlobalAveragePool_182 1 1 935_splitncnn_1 673 0=1 4=1
Convolution Conv_183 1 1 673 938 0=40 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=6400
ReLU Relu_184 1 1 938 676
Convolution Conv_185 1 1 676 941 0=160 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=6400
HardSigmoid Div_189 1 1 941 684 0=1.666667e-01 1=5.000000e-01
BinaryOp Mul_190 2 1 935_splitncnn_0 684 685 0=2
Convolution Conv_191 1 1 652_splitncnn_0 944 0=160 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=17920
BinaryOp Add_192 2 1 685 944 688 0=0
Convolution Conv_193 1 1 688 947 0=672 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=107520
HardSwish Div_198 1 1 947 697 0=1.666667e-01 1=5.000000e-01
ConvolutionDepthWise Conv_199 1 1 697 950 0=672 1=5 11=5 2=1 12=1 3=2 13=2 4=2 14=2 15=2 16=2 5=1 6=16800 7=672
HardSwish Div_204 1 1 950 706 0=1.666667e-01 1=5.000000e-01
Convolution Conv_205 1 1 706 953 0=160 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=107520
Split splitncnn_16 1 2 953 953_splitncnn_0 953_splitncnn_1
Pooling GlobalAveragePool_206 1 1 953_splitncnn_1 709 0=1 4=1
Convolution Conv_207 1 1 709 956 0=40 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=6400
ReLU Relu_208 1 1 956 712
Convolution Conv_209 1 1 712 959 0=160 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=6400
HardSigmoid Div_213 1 1 959 720 0=1.666667e-01 1=5.000000e-01
BinaryOp Mul_214 2 1 953_splitncnn_0 720 721 0=2
Split splitncnn_17 1 2 721 721_splitncnn_0 721_splitncnn_1
Convolution Conv_215 1 1 721_splitncnn_1 962 0=960 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=153600
HardSwish Div_220 1 1 962 730 0=1.666667e-01 1=5.000000e-01
ConvolutionDepthWise Conv_221 1 1 730 965 0=960 1=5 11=5 2=1 12=1 3=1 13=1 4=2 14=2 15=2 16=2 5=1 6=24000 7=960
HardSwish Div_226 1 1 965 739 0=1.666667e-01 1=5.000000e-01
Convolution Conv_227 1 1 739 968 0=160 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=153600
Split splitncnn_18 1 2 968 968_splitncnn_0 968_splitncnn_1
Pooling GlobalAveragePool_228 1 1 968_splitncnn_1 742 0=1 4=1
Convolution Conv_229 1 1 742 971 0=40 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=6400
ReLU Relu_230 1 1 971 745
Convolution Conv_231 1 1 745 974 0=160 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=6400
HardSigmoid Div_235 1 1 974 753 0=1.666667e-01 1=5.000000e-01
BinaryOp Mul_236 2 1 968_splitncnn_0 753 754 0=2
BinaryOp Add_237 2 1 754 721_splitncnn_0 755 0=0
Convolution Conv_238 1 1 755 977 0=960 1=1 11=1 2=1 12=1 3=1 13=1 4=0 14=0 15=0 16=0 5=1 6=153600
HardSwish Div_243 1 1 977 764 0=1.666667e-01 1=5.000000e-01
Pooling AveragePool_245 1 1 764 766 0=1 1=7 11=7 2=7 12=7 3=0 13=0 14=0 15=0 5=1 6=0
Reshape Reshape_251 1 1 766 774 0=-1
InnerProduct Gemm_252 1 1 774 775 0=1280 1=1 2=1228800
BatchNorm BatchNormalization_253 1 1 775 776 0=1280
HardSwish Div_258 1 1 776 783 0=1.666667e-01 1=5.000000e-01
InnerProduct Gemm_259 1 1 783 784 0=4 1=1 2=5120
经过ncnn2mem之后生成的
.id.h如下:
#ifndef NCNN_INCLUDE_GUARD_onnx_MobileNetV3_Large_weather_id_h
#define NCNN_INCLUDE_GUARD_onnx_MobileNetV3_Large_weather_id_h
namespace onnx_MobileNetV3_Large_weather_param_id {
const int LAYER_input_1 = 0;
const int BLOB_input_1 = 0;
const int LAYER_Conv_0 = 1;
const int BLOB_785 = 1;
const int LAYER_Div_5 = 2;
const int BLOB_408 = 2;
const int LAYER_splitncnn_0 = 3;
const int BLOB_408_splitncnn_0 = 3;
const int BLOB_408_splitncnn_1 = 4;
const int LAYER_Conv_6 = 4;
const int BLOB_788 = 5;
const int LAYER_Relu_7 = 5;
const int BLOB_411 = 6;
const int LAYER_Conv_8 = 6;
const int BLOB_791 = 7;
const int LAYER_Relu_9 = 7;
const int BLOB_414 = 8;
const int LAYER_Conv_10 = 8;
const int BLOB_794 = 9;
const int LAYER_Add_11 = 9;
const int BLOB_417 = 10;
const int LAYER_Conv_12 = 10;
const int BLOB_797 = 11;
const int LAYER_Relu_13 = 11;
const int BLOB_420 = 12;
const int LAYER_Conv_14 = 12;
const int BLOB_800 = 13;
const int LAYER_Relu_15 = 13;
const int BLOB_423 = 14;
const int LAYER_Conv_16 = 14;
const int BLOB_803 = 15;
const int LAYER_splitncnn_1 = 15;
const int BLOB_803_splitncnn_0 = 16;
const int BLOB_803_splitncnn_1 = 17;
const int LAYER_Conv_17 = 16;
const int BLOB_806 = 18;
const int LAYER_Relu_18 = 17;
const int BLOB_428 = 19;
const int LAYER_Conv_19 = 18;
const int BLOB_809 = 20;
const int LAYER_Relu_20 = 19;
const int BLOB_431 = 21;
const int LAYER_Conv_21 = 20;
const int BLOB_812 = 22;
const int LAYER_Add_22 = 21;
const int BLOB_434 = 23;
const int LAYER_Conv_23 = 22;
const int BLOB_815 = 24;
const int LAYER_Relu_24 = 23;
const int BLOB_437 = 25;
const int LAYER_Conv_25 = 24;
const int BLOB_818 = 26;
const int LAYER_Relu_26 = 25;
const int BLOB_440 = 27;
const int LAYER_Conv_27 = 26;
const int BLOB_821 = 28;
const int LAYER_splitncnn_2 = 27;
const int BLOB_821_splitncnn_0 = 29;
const int BLOB_821_splitncnn_1 = 30;
const int LAYER_GlobalAveragePool_28 = 28;
const int BLOB_443 = 31;
const int LAYER_Conv_29 = 29;
const int BLOB_824 = 32;
const int LAYER_Relu_30 = 30;
const int BLOB_446 = 33;
const int LAYER_Conv_31 = 31;
const int BLOB_827 = 34;
const int LAYER_Div_35 = 32;
const int BLOB_454 = 35;
const int LAYER_Mul_36 = 33;
const int BLOB_455 = 36;
const int LAYER_splitncnn_3 = 34;
const int BLOB_455_splitncnn_0 = 37;
const int BLOB_455_splitncnn_1 = 38;
const int LAYER_Conv_37 = 35;
const int BLOB_830 = 39;
const int LAYER_Relu_38 = 36;
const int BLOB_458 = 40;
const int LAYER_Conv_39 = 37;
const int BLOB_833 = 41;
const int LAYER_Relu_40 = 38;
const int BLOB_461 = 42;
const int LAYER_Conv_41 = 39;
const int BLOB_836 = 43;
const int LAYER_splitncnn_4 = 40;
const int BLOB_836_splitncnn_0 = 44;
const int BLOB_836_splitncnn_1 = 45;
const int LAYER_GlobalAveragePool_42 = 41;
const int BLOB_464 = 46;
const int LAYER_Conv_43 = 42;
const int BLOB_839 = 47;
const int LAYER_Relu_44 = 43;
const int BLOB_467 = 48;
const int LAYER_Conv_45 = 44;
const int BLOB_842 = 49;
const int LAYER_Div_49 = 45;
const int BLOB_475 = 50;
const int LAYER_Mul_50 = 46;
const int BLOB_476 = 51;
const int LAYER_Add_51 = 47;
const int BLOB_477 = 52;
const int LAYER_splitncnn_5 = 48;
const int BLOB_477_splitncnn_0 = 53;
const int BLOB_477_splitncnn_1 = 54;
const int LAYER_Conv_52 = 49;
const int BLOB_845 = 55;
const int LAYER_Relu_53 = 50;
const int BLOB_480 = 56;
const int LAYER_Conv_54 = 51;
const int BLOB_848 = 57;
const int LAYER_Relu_55 = 52;
const int BLOB_483 = 58;
const int LAYER_Conv_56 = 53;
const int BLOB_851 = 59;
const int LAYER_splitncnn_6 = 54;
const int BLOB_851_splitncnn_0 = 60;
const int BLOB_851_splitncnn_1 = 61;
const int LAYER_GlobalAveragePool_57 = 55;
const int BLOB_486 = 62;
const int LAYER_Conv_58 = 56;
const int BLOB_854 = 63;
const int LAYER_Relu_59 = 57;
const int BLOB_489 = 64;
const int LAYER_Conv_60 = 58;
const int BLOB_857 = 65;
const int LAYER_Div_64 = 59;
const int BLOB_497 = 66;
const int LAYER_Mul_65 = 60;
const int BLOB_498 = 67;
const int LAYER_Add_66 = 61;
const int BLOB_499 = 68;
const int LAYER_Conv_67 = 62;
const int BLOB_860 = 69;
const int LAYER_Div_72 = 63;
const int BLOB_508 = 70;
const int LAYER_Conv_73 = 64;
const int BLOB_863 = 71;
const int LAYER_Div_78 = 65;
const int BLOB_517 = 72;
const int LAYER_Conv_79 = 66;
const int BLOB_866 = 73;
const int LAYER_splitncnn_7 = 67;
const int BLOB_866_splitncnn_0 = 74;
const int BLOB_866_splitncnn_1 = 75;
const int LAYER_Conv_80 = 68;
const int BLOB_869 = 76;
const int LAYER_Div_85 = 69;
const int BLOB_528 = 77;
const int LAYER_Conv_86 = 70;
const int BLOB_872 = 78;
const int LAYER_Div_91 = 71;
const int BLOB_537 = 79;
const int LAYER_Conv_92 = 72;
const int BLOB_875 = 80;
const int LAYER_Add_93 = 73;
const int BLOB_540 = 81;
const int LAYER_splitncnn_8 = 74;
const int BLOB_540_splitncnn_0 = 82;
const int BLOB_540_splitncnn_1 = 83;
const int LAYER_Conv_94 = 75;
const int BLOB_878 = 84;
const int LAYER_Div_99 = 76;
const int BLOB_549 = 85;
const int LAYER_Conv_100 = 77;
const int BLOB_881 = 86;
const int LAYER_Div_105 = 78;
const int BLOB_558 = 87;
const int LAYER_Conv_106 = 79;
const int BLOB_884 = 88;
const int LAYER_Add_107 = 80;
const int BLOB_561 = 89;
const int LAYER_splitncnn_9 = 81;
const int BLOB_561_splitncnn_0 = 90;
const int BLOB_561_splitncnn_1 = 91;
const int LAYER_Conv_108 = 82;
const int BLOB_887 = 92;
const int LAYER_Div_113 = 83;
const int BLOB_570 = 93;
const int LAYER_Conv_114 = 84;
const int BLOB_890 = 94;
const int LAYER_Div_119 = 85;
const int BLOB_579 = 95;
const int LAYER_Conv_120 = 86;
const int BLOB_893 = 96;
const int LAYER_Add_121 = 87;
const int BLOB_582 = 97;
const int LAYER_splitncnn_10 = 88;
const int BLOB_582_splitncnn_0 = 98;
const int BLOB_582_splitncnn_1 = 99;
const int LAYER_Conv_122 = 89;
const int BLOB_896 = 100;
const int LAYER_Div_127 = 90;
const int BLOB_591 = 101;
const int LAYER_Conv_128 = 91;
const int BLOB_899 = 102;
const int LAYER_Div_133 = 92;
const int BLOB_600 = 103;
const int LAYER_Conv_134 = 93;
const int BLOB_902 = 104;
const int LAYER_splitncnn_11 = 94;
const int BLOB_902_splitncnn_0 = 105;
const int BLOB_902_splitncnn_1 = 106;
const int LAYER_GlobalAveragePool_135 = 95;
const int BLOB_603 = 107;
const int LAYER_Conv_136 = 96;
const int BLOB_905 = 108;
const int LAYER_Relu_137 = 97;
const int BLOB_606 = 109;
const int LAYER_Conv_138 = 98;
const int BLOB_908 = 110;
const int LAYER_Div_142 = 99;
const int BLOB_614 = 111;
const int LAYER_Mul_143 = 100;
const int BLOB_615 = 112;
const int LAYER_Conv_144 = 101;
const int BLOB_911 = 113;
const int LAYER_Add_145 = 102;
const int BLOB_618 = 114;
const int LAYER_splitncnn_12 = 103;
const int BLOB_618_splitncnn_0 = 115;
const int BLOB_618_splitncnn_1 = 116;
const int LAYER_Conv_146 = 104;
const int BLOB_914 = 117;
const int LAYER_Div_151 = 105;
const int BLOB_627 = 118;
const int LAYER_Conv_152 = 106;
const int BLOB_917 = 119;
const int LAYER_Div_157 = 107;
const int BLOB_636 = 120;
const int LAYER_Conv_158 = 108;
const int BLOB_920 = 121;
const int LAYER_splitncnn_13 = 109;
const int BLOB_920_splitncnn_0 = 122;
const int BLOB_920_splitncnn_1 = 123;
const int LAYER_GlobalAveragePool_159 = 110;
const int BLOB_639 = 124;
const int LAYER_Conv_160 = 111;
const int BLOB_923 = 125;
} // namespace onnx_MobileNetV3_Large_weather_param_id
#endif // NCNN_INCLUDE_GUARD_onnx_MobileNetV3_Large_weather_id_h
我需要拿最后的*.param中的Gemm_259,但是id.h中没有对应的;另外,我直接使用的是 param 和 bin 文件,但是在extract()中输入Gemm_259出现find_blob_index_by_name Gemm_259 failed的错误;(我是在windows中转换的)

@nihui
Copy link
Member

nihui commented Dec 29, 2020

Gemm_259 是 layer name,不是 blob name,Gemm_259 的输出 blob name 是 784
推荐用netron打开,点击Gemm_259这个op,右边也会显示 blob name

@sumingzhe123
Copy link
Author

使用的是 param 和 bin 文件,extractor.extract("784", output); 依旧出现find_blob_index_by_name 784 failed的错误

@sumingzhe123
Copy link
Author

mobilenet_v3.zip附上文件

@nihui
Copy link
Member

nihui commented Dec 29, 2020

使用的是 param 和 bin 文件,extractor.extract("784", output); 依旧出现find_blob_index_by_name 784 failed的错误

确认 load_param load_model 文件是否正确

@sumingzhe123
Copy link
Author

ncnn::Net mobileNet_v3;
mobileNet_v3.load_param("MobileNetV3_Larger.param");
mobileNet_v3.load_model("MobileNetV3_Large.bin");
ncnn::Extractor extractor = mobileNet_v3.create_extractor();
extractor.input(0, in);
ncnn::Mat output;
extractor.extract("784", output);
加载方式确认无误,前面上传附件,您可以验证分析一下

@WangGeng0
Copy link

我也和你一样,遇到了同一个问题了,请问您解决了没???

@nihui
Copy link
Member

nihui commented Aug 5, 2024

针对onnx模型转换的各种问题,推荐使用最新的pnnx工具转换到ncnn
In view of various problems in onnx model conversion, it is recommended to use the latest pnnx tool to convert your model to ncnn

pip install pnnx
pnnx model.onnx inputshape=[1,3,224,224]

详细参考文档
Detailed reference documentation
https://github.com/pnnx/pnnx
https://github.com/Tencent/ncnn/wiki/use-ncnn-with-pytorch-or-onnx#how-to-use-pnnx

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

3 participants