Tencent / ncnn

ncnn is a high-performance neural network inference framework optimized for the mobile platform
Other
20.41k stars 4.16k forks source link

后续是否会支持将 tensorflow pb模型转为ncnn的模型呢? #5

Open dangbo opened 7 years ago

nihui commented 7 years ago

我也很想要这个转换器 qwq

nihui commented 7 years ago

TODO reopen

BiranLi commented 7 years ago

And Mxnet?

Wenstery commented 7 years ago

现在tools目录下的tensorflow,是否已经开始支持tensorflow pb转ncnn?

Daoctor commented 7 years ago

@nihui hi, 我编译安装了 tensorflow2ncnn, 但是我尝试解析一个 tf 的 pb 文件时, 提示了这个错误

[libprotobuf FATAL /usr/local/include/google/protobuf/stubs/hash.h:204] Should never be called.
terminate called after throwing an instance of 'google::protobuf::FatalException'
  what():  Should never be called.
Aborted (core dumped)

跟进去看了下, 是函数 read_proto_from_binary中的这一句报错了 message->ParseFromCodedStream(&codedstr). 不知道是我的环境问题 还是别的原因 ...

elva7073 commented 7 years ago

@Daoctor 我也是报这个问题 我用的是3.4.0的protobuf

nihui commented 7 years ago

以下repo里的 mnist 和 inception graph 可以正常转换使用了 https://github.com/miyosuda/TensorFlowAndroidMNIST https://github.com/miyosuda/TensorFlowAndroidDemo

mnist expert-graph.pb 输入 28x28 灰度图黑底白字 norm_vals[1] = { 1/255.f }

inception tensorflow_inception_graph.pb 输入 224x224 RGB图 mean_vals[3] = { 117.f }

kenttong commented 7 years ago

write_graph导出的pb文件用tensorflow2ncnn转换失败,格式解析不对,找不到node里面的input tensor,因为input tensor的类型不是const。是需要用freeze_graph进行固化吗?

tf.train.write_graph(tf.get_default_graph().as_graph_def, './checkpoints/', 'graph.pb', False)

Cv9527 commented 6 years ago

when compile tensorflow2nccc by qt with protobuf 3.3.0, I encounter the problems as follow:

op_def.pb.cc:(.text+0x3884):对‘google::protobuf::internal::WireFormatLite::VerifyUtf8String(char const, int, google::protobuf::internal::WireFormatLite::Operation, char const)’未定义的引用 CMakeFiles/tensorflow2ncnn.dir/op_def.pb.cc.o:在函数‘tensorflow::OpDef_ArgDef::OpDef_ArgDef()’中: op_def.pb.cc:(.text+0x3973):对‘google::protobuf::internal::fixed_address_empty_string[abi:cxx11]’未定义的引用 CMakeFiles/tensorflow2ncnn.dir/op_def.pb.cc.o:在函数‘tensorflow::OpDef_AttrDef::OpDef_AttrDef()’中: op_def.pb.cc:(.text+0x3a63):对‘google::protobuf::internal::fixed_address_empty_string[abi:cxx11]’未定义的引用 CMakeFiles/tensorflow2ncnn.dir/op_def.pb.cc.o:在函数‘tensorflow::OpDeprecation::OpDeprecation()’中: op_def.pb.cc:(.text+0x3b63):对‘google::protobuf::internal::fixed_address_empty_string[abi:cxx11]’未定义的引用 CMakeFiles/tensorflow2ncnn.dir/op_def.pb.cc.o:在函数‘tensorflow::OpDef_AttrDef::~OpDef_AttrDef()’中: op_def.pb.cc:(.text+0x3cff):对‘google::protobuf::internal::fixed_address_empty_string[abi:cxx11]’未定义的引用 CMakeFiles/tensorflow2ncnn.dir/op_def.pb.cc.o:在函数‘tensorflow::OpDef_AttrDef::~OpDef_AttrDef()’中: op_def.pb.cc:(.text+0x3e37):对‘google::protobuf::internal::fixed_address_empty_string[abi:cxx11]’未定义的引用 CMakeFiles/tensorflow2ncnn.dir/op_def.pb.cc.o:op_def.pb.cc:(.text+0x3fe3): 跟着更多未定义的参考到 google::protobuf::internal::fixed_address_empty_string[abi:cxx11]

how could I solve them?

wanghuijing commented 6 years ago

用源码编译出来的tensorflow2ncnn转化了tensorflow_inception_graph.pb,修改源码里带的android demo加载model和param,修改squeezencnn_jni.cpp中为ex.input(0, in);和ex.extract(329, out);测试结果是物体类别识别都是0。请问支持tensorflow转ncnn吗?支持的话,是out设置的不对吗?

mrlonely001 commented 6 years ago

你好, 我按照你这句 “mnist expert-graph.pb 输入 28x28 灰度图黑底白字 norm_vals[1] = { 1/255.f }”,修改了squeezenet.cpp 文件中的这几行,改为如下: squeezenet.load_param("/home/pi/ncnn-master/tools/tensorflow/build/ncnn.proto"); squeezenet.load_model("/home/pi/ncnn-master/tools/tensorflow/build/ncnn.bin"); ncnn::Mat in = ncnn::Mat::from_pixels_resize(bgr.data, ncnn::Mat::PIXEL_GRAY, bgr.cols, bgr.rows, 28, 28); const float mean_vals[1] = {1/255.f}; 重新编译之后,运行:squeezenet /home/pi/1.jpg 报错: find_blob_index_by_name data failed find_blob_index_by_name prob failed 段错误

WenguoLi commented 6 years ago

tensorflow2ncnn 这个工具应该该怎么编译出来? 我编译的时候出错了: versions.proto:1:10: Unrecognized syntax identifier "proto3". This parser only recognizes "proto2". make[2]: [tools/tensorflow/versions.pb.cc] Error 1 make[1]: [tools/tensorflow/CMakeFiles/tensorflow2ncnn.dir/all] Error 2 make: *** [all] Error 2

请问前面的几位大神是怎么编译出来的,能够指导一下,多谢!

我安装了下载了最新的protobuf, 编译可以通过,但是make check failed, 我还是安装了libprotoc 3.5.1,

重新编译上面的tensorflow2ncnn的工具,还是报和上面一样的错误。

求大神们指点迷津啊!

delongqilinksprite commented 6 years ago

Hi, 我使用tensorflow2ncnn来转我的模型,遇到了以下的错误: ./tensorflow2ncnn frozen_model.pb FusedBatchNorm not supported yet ! nepsilon #0 T #1 data_format #0 is_training #0 Elu not supported yet ! nT #1 FusedBatchNorm not supported yet ! nepsilon #0 T #1 data_format #0 is_training #0 Elu not supported yet ! nT #1 FusedBatchNorm not supported yet ! nepsilon #0 T #1 data_format #0 is_training #0 Elu not supported yet ! nT #1 FusedBatchNorm not supported yet ! nepsilon #0 T #1 data_format #0 is_training #0 Elu not supported yet ! nT #1 FusedBatchNorm not supported yet ! nepsilon #0 T #1 data_format #0 is_training #0 Elu not supported yet ! nT #1 FusedBatchNorm not supported yet ! nepsilon #0 T #1 data_format #0 is_training #0 Elu not supported yet ! nT #1 FusedBatchNorm not supported yet ! nepsilon #0 T #1 data_format #0 is_training #0 Elu not supported yet ! nT #1 FusedBatchNorm not supported yet ! nT #1 data_format #0 is_training #0 epsilon #0 Elu not supported yet ! nT #1 FusedBatchNorm not supported yet ! nT #1 data_format #0 is_training #0 epsilon #0 Elu not supported yet ! nT #1 FusedBatchNorm not supported yet ! nT #1 data_format #0 is_training #0 epsilon #0 Elu not supported yet ! nT #1 FusedBatchNorm not supported yet ! nT #1 data_format #0 is_training #0 epsilon #0 Elu not supported yet ! nT #1 FusedBatchNorm not supported yet ! nepsilon #0 T #1 data_format #0 is_training #0 Elu not supported yet ! nT #1 FusedBatchNorm not supported yet ! nT #1 data_format #0 is_training #0 epsilon #0 Elu not supported yet ! nT #1 FusedBatchNorm not supported yet ! nT #1 data_format #0 is_training #0 epsilon #0 FusedBatchNorm not supported yet ! nT #1 data_format #0 is_training #0 epsilon #0

这是不是意味着我需要修改tensorflow的网络模型呢? @nihui 谢谢

WanchaoYao commented 6 years ago

补充一些不支持转换的op StridedSlice not supported yet ! nIndex #3 T #3 begin_mask #0 ellipsis_mask #0 end_mask #0 new_axis_mask #0 shrink_axis_mask #0 Print not supported yet ! nT #3 U #0 first_n #0 message #0 summarize #0 Cast not supported yet ! nDstT #1 SrcT #3 ResizeBilinear not supported yet ! nT #1 align_corners #0 SpaceToBatchND not supported yet ! nT #1 Tblock_shape #3 Tpaddings #3 BatchToSpaceND not supported yet ! nT #1 Tblock_shape #3 Tcrops #3 StridedSlice not supported yet ! nIndex #3 T #3 begin_mask #0 ellipsis_mask #0 end_mask #0 new_axis_mask #0 shrink_axis_mask #0 ResizeBilinear not supported yet ! nT #1 align_corners #0 StridedSlice not supported yet ! nIndex #3 T #3 begin_mask #0 ellipsis_mask #0 end_mask #0 new_axis_mask #0 shrink_axis_mask #0 ResizeBilinear not supported yet ! nT #1 align_corners #0 StridedSlice not supported yet ! nIndex #3 T #3 begin_mask #0 ellipsis_mask #0 end_mask #0 new_axis_mask #0 shrink_axis_mask #0 ResizeBilinear not supported yet ! nT #1 align_corners #0 StridedSlice not supported yet ! nIndex #3 T #3 begin_mask #0 ellipsis_mask #0 end_mask #0 new_axis_mask #0 shrink_axis_mask #0 ResizeBilinear not supported yet ! nT #1 align_corners #0 StridedSlice not supported yet ! nIndex #3 T #3 begin_mask #0 ellipsis_mask #0 end_mask #0 new_axis_mask #0 shrink_axis_mask #0 ResizeBilinear not supported yet ! nT #1 align_corners #0 StridedSlice not supported yet ! nIndex #3 T #3 begin_mask #0 ellipsis_mask #0 end_mask #0 new_axis_mask #0 shrink_axis_mask #0 ResizeBilinear not supported yet ! nT #1 align_corners #0 StridedSlice not supported yet ! nIndex #3 T #3 begin_mask #0 ellipsis_mask #0 end_mask #0 new_axis_mask #0 shrink_axis_mask #0 ResizeBilinear not supported yet ! nT #1 align_corners #0 StridedSlice not supported yet ! nIndex #3 T #3 begin_mask #0 ellipsis_mask #0 end_mask #0 new_axis_mask #0 shrink_axis_mask #0 ResizeBilinear not supported yet ! nT #1 align_corners #0 StridedSlice not supported yet ! nIndex #3 T #3 begin_mask #0 ellipsis_mask #0 end_mask #0 new_axis_mask #0 shrink_axis_mask #0 ResizeBilinear not supported yet ! nT #1 align_corners #0 StridedSlice not supported yet ! nIndex #3 T #3 begin_mask #0 ellipsis_mask #0 end_mask #0 new_axis_mask #0 shrink_axis_mask #0 ResizeBilinear not supported yet ! nT #1 align_corners #0 StridedSlice not supported yet ! nIndex #3 T #3 begin_mask #0 ellipsis_mask #0 end_mask #0 new_axis_mask #0 shrink_axis_mask #0 ResizeBilinear not supported yet ! nT #1 align_corners #0 StridedSlice not supported yet ! nIndex #3 T #3 begin_mask #0 ellipsis_mask #0 end_mask #0 new_axis_mask #0 shrink_axis_mask #0 ResizeBilinear not supported yet ! nT #1 align_corners #0 StridedSlice not supported yet ! nIndex #3 T #3 begin_mask #0 ellipsis_mask #0 end_mask #0 new_axis_mask #0 shrink_axis_mask #0 ResizeBilinear not supported yet ! nT #1 align_corners #0 StridedSlice not supported yet ! nIndex #3 T #3 begin_mask #0 ellipsis_mask #0 end_mask #0 new_axis_mask #0 shrink_axis_mask #0 ResizeBilinear not supported yet ! nT #1 align_corners #0 StridedSlice not supported yet ! nIndex #3 T #3 begin_mask #0 ellipsis_mask #0 end_mask #0 new_axis_mask #0 shrink_axis_mask #0 ResizeBilinear not supported yet ! nT #1 align_corners #0 StridedSlice not supported yet ! nIndex #3 T #3 begin_mask #0 ellipsis_mask #0 end_mask #0 new_axis_mask #0 shrink_axis_mask #0 ResizeBilinear not supported yet ! nT #1 align_corners #0 Pack not supported yet ! nN #0 T #3 axis #0 Slice not supported yet ! nIndex #3 T #3 finished

ujsyehao commented 6 years ago

期待resizebilinear operation支持!

HudsonHuang commented 6 years ago

I found an nice blog about this topic: https://blog.csdn.net/u012477435/article/details/80765005

lvchigo commented 6 years ago

@Daoctor @elva7073 这个问题解决了吗? 尝试解析一个 tf 的 pb 文件时, 提示了这个错误: [libprotobuf FATAL /usr/local/include/google/protobuf/stubs/hash.h:204] Should never be called. terminate called after throwing an instance of 'google::protobuf::FatalException' what(): Should never be called. Aborted (core dumped)

Liam-zzZ commented 5 years ago

ResizeNearestNeighbor not supported yet ! nT #1 align_corners #0 ResizeNearestNeighbor not supported yet ! nT #1 align_corners #0 ResizeNearestNeighbor not supported yet ! nT #1 align_corners #0 Less not supported yet ! nT #1 Switch not supported yet ! nT #10 Shape not supported yet ! nout_type #3 T #1 Switch not supported yet ! nT #1 _class #0 RandomUniform not supported yet ! nT #3 dtype #1 seed2 #0 seed #0 Switch not supported yet ! nT #1 _class #0 Switch not supported yet ! nT #1 _class #0 Merge not supported yet ! nT #1 N #0 Less not supported yet ! nT #1 Switch not supported yet ! nT #10 Shape not supported yet ! nout_type #3 T #1 Switch not supported yet ! nT #1 _class #0 RandomUniform not supported yet ! nT #3 dtype #1 seed2 #0 seed #0 Switch not supported yet ! nT #1 _class #0 Switch not supported yet ! nT #1 _class #0 Merge not supported yet ! nT #1 N #0 Greater not supported yet ! nT #1 Switch not supported yet ! nT #1 _class #0 Switch not supported yet ! nT #1 _class #0 Merge not supported yet ! nT #1 N #0 Less not supported yet ! nT #1 Switch not supported yet ! nT #10 Shape not supported yet ! nout_type #3 T #1 Switch not supported yet ! nT #1 _class #0 RandomUniform not supported yet ! nT #3 dtype #1 seed2 #0 seed #0 Switch not supported yet ! nT #1 _class #0 Switch not supported yet ! nT #1 _class #0 Merge not supported yet ! nT #1 N #0 Less not supported yet ! nT #1 Switch not supported yet ! nT #10 Shape not supported yet ! nout_type #3 T #1 Switch not supported yet ! nT #1 _class #0 RandomUniform not supported yet ! nT #3 dtype #1 seed2 #0 seed #0 Switch not supported yet ! nT #1 _class #0 Switch not supported yet ! nT #1 _class #0 Merge not supported yet ! nT #1 N #0 Greater not supported yet ! nT #1 Switch not supported yet ! nT #1 _class #0 Switch not supported yet ! nT #1 _class #0 Merge not supported yet ! nT #1 N #0 Less not supported yet ! nT #1 Switch not supported yet ! nT #10 Shape not supported yet ! nout_type #3 T #1 Switch not supported yet ! nT #1 _class #0 RandomUniform not supported yet ! nT #3 dtype #1 seed2 #0 seed #0 Switch not supported yet ! nT #1 _class #0 Switch not supported yet ! nT #1 _class #0 Merge not supported yet ! nT #1 N #0 Less not supported yet ! nT #1 Switch not supported yet ! nT #10 Shape not supported yet ! nout_type #3 T #1 Switch not supported yet ! nT #1 _class #0 RandomUniform not supported yet ! nT #3 dtype #1 seed2 #0 seed #0 Switch not supported yet ! nT #1 _class #0 Switch not supported yet ! nT #1 _class #0 Merge not supported yet ! nT #1 N #0 Greater not supported yet ! nT #1 Switch not supported yet ! nT #1 _class #0 Switch not supported yet ! nT #1 _class #0 Merge not supported yet ! nT #1 N #0

SAD...

Simplesss commented 5 years ago

I found an nice blog about this topic: https://blog.csdn.net/u012477435/article/details/80765005

Hello, I read this blog, converted to generate ncnn.bin and ncnn.proto ,but the format of ncnn.proto file is wrong, the first line is 7767517 The second line is 57 64, may you also encounter this problem?

Simplesss commented 5 years ago

In a different way, I converted tensorflow to ncnn. I will not be able to convert and drop the dropout of my model results, and finally convert to ncnn file, but unexpectedly, the converted .param file lacks weight. The variable (that is, the weight layer is missing), but there are all the parameters I use in the .bin file, I don't know what to do.The following is part of my .param file, missing weights such as Variable_2/read, Variable_4/read, Variable_6/read and so on. (I have a .pb file inside) 换了一种方法将tensorflow转ncnn,我将无法转换并且不会影响我模型结果的层(dropout)去掉,最终成功转换为ncnn文件,但是令人想不到的是,转换后的.param文件缺少权重变量(也就是缺少权重层),但是.bin文件内有我用的所有参数,我不清楚该怎么处理。(我的.pb文件内部是有的) 下面是我的.param文件的一部分,缺少Variable_2/read、Variable_4/read、Variable_6/read ... 等权重层。

7767517 42 46 Input Placeholder 0 1 Placeholder 0=0 1=0 2=0 MemoryData Variable_1/read 0 1 Variable_1/read 0=16 1=0 2=0 Reshape Reshape 1 1 Placeholder Reshape 0=40 1=40 2=3 3=0 Convolution Conv2D 1 1 Reshape Conv2D 0=16 1=5 11=5 2=1 12=1 3=1 13=1 4=0 5=0 6=1200 BinaryOp add 2 1 Conv2D Variable_1/read add 0=0 ReLU Relu 1 1 add Relu 0=0.000000 Pooling MaxPool 1 1 Relu MaxPool 0=0 1=2 11=2 2=2 12=2 3=0 4=0 5=1 MemoryData Variable_3/read 0 1 Variable_3/read 0=48 1=0 2=0 Convolution Conv2D_1 1 1 MaxPool Conv2D_1 0=48 1=3 11=3 2=1 12=1 3=1 13=1 4=0 5=0 6=6912 BinaryOp add_1 2 1 Conv2D_1 Variable_3/read add_1 0=0 ReLU Relu_1 1 1 add_1 Relu_1 0=0.000000 Pooling MaxPool_1 1 1 Relu_1 MaxPool_1 0=0 1=2 11=2 2=2 12=2 3=0 4=0 5=1 MemoryData Variable_5/read 0 1 Variable_5/read 0=64 1=0 2=0 Convolution Conv2D_2 1 1 MaxPool_1 Conv2D_2 0=64 1=3 11=3 2=1 12=1 3=1 13=1 4=0 5=0 6=27648 BinaryOp add_2 2 1 Conv2D_2 Variable_5/read add_2 0=0 ReLU Relu_2 1 1 add_2 Relu_2 0=0.000000 Pooling MaxPool_2 1 1 Relu_2 MaxPool_2 0=0 1=2 11=2 2=2 12=2 3=0 4=0 5=1 MemoryData Variable_7/read 0 1 Variable_7/read 0=64 1=0 2=0 Convolution Conv2D_3 1 1 MaxPool_2 Conv2D_3 0=64 1=2 11=2 2=1 12=1 3=1 13=1 4=0 5=0 6=16384 BinaryOp add_3 2 1 Conv2D_3 Variable_7/read add_3 0=0 ReLU Relu_3 1 1 add_3 Relu_3 0=0.000000 MemoryData Variable_9/read 0 1 Variable_9/read 0=100 1=0 2=0 Reshape Reshape_1 1 1 Relu_3 Reshape_1 0=256 1=-233 2=-233 3=1 InnerProduct MatMul 1 1 Reshape_1 MatMul 0=100 1=0 2=25600 BinaryOp add_4 2 1 MatMul Variable_9/read add_4 0=0 ReLU Relu_4 1 1 add_4 Relu_4 0=0.000000 Split splitncnn_0 1 5 Relu_4 Relu_4_splitncnn_0 Relu_4_splitncnn_1 Relu_4_splitncnn_2 Relu_4_splitncnn_3 Relu_4_splitncnn_4 MemoryData Variable_11/read 0 1 Variable_11/read 0=10 1=0 2=0 InnerProduct MatMul_1 1 1 Relu_4_splitncnn_4 MatMul_1 0=10 1=0 2=1000

hunto commented 5 years ago

Provides a way to convert tensorflow model to ncnn.

My model(modified from MobileNetV2) works correctly.

  1. Use freeze_graph.py to generate tf .pb model file.

  2. Use tf-coreml to convert tf model to coreml model. Sample code:

    import tfcoreml as tf_converter 
    tf_converter.convert(tf_model_path = './pfld.pb', 
                         mlmodel_path = 'my_model.mlmodel', 
                         output_feature_names = ['PFLDnet/fc8_1/BiasAdd:0'])
  3. Use [WinMLTool] to convert coreml model to onnx model. Convert ML models to ONNX with WinMLTools Sample code:

    from coremltools.models.utils import load_spec
    # Load model file
    model_coreml = load_spec('my_model.mlmodel')
    from winmltools import convert_coreml
    # Convert it!
    # The automatic code generator (mlgen) uses the name parameter to generate class names.
    model_onnx = convert_coreml(model_coreml, 7, name='ExampleModel')  
    
    from winmltools.utils import save_model
    # Save the produced ONNX model in binary format
    save_model(model_onnx, 'example.onnx')
  4. Use ncnn/tools/onnx to convert onnx model to ncnn

NOTICE ncnn/onnx2ncnn not support onnx op Affine, tf op Relu6 will be converted to Relu & Affine, use tf op Relu instead.


提供一个tf转ncnn的方法 在基于MobileNetV2修改的模型上测试通过,模型输出正确

tf2ncnn有很多op不支持,因此找到了 tf->coreml->onnx->ncnn 这么一个方法。

  1. 使用 freeze_graph.py 生成 .pb 模型

  2. 使用 tf-coreml 将tf模型转换为coreml模型 Sample code:

    import tfcoreml as tf_converter 
    tf_converter.convert(tf_model_path = './pfld.pb', 
                         mlmodel_path = 'my_model.mlmodel', 
                         output_feature_names = ['PFLDnet/fc8_1/BiasAdd:0'])
  3. 使用 [WinMLTool] 将coreml转换为onnx模型 Convert ML models to ONNX with WinMLTools Sample code:

    from coremltools.models.utils import load_spec
    # Load model file
    model_coreml = load_spec('my_model.mlmodel')
    from winmltools import convert_coreml
    # Convert it!
    # The automatic code generator (mlgen) uses the name parameter to generate class names.
    model_onnx = convert_coreml(model_coreml, 7, name='ExampleModel')  
    
    from winmltools.utils import save_model
    # Save the produced ONNX model in binary format
    save_model(model_onnx, 'example.onnx')
  4. 编译 ncnn/tools/onnx ,使用 onnx2ncnn 将 onnx 模型转换为 ncnn

NOTICE ncnn/onnx2ncnn 不支持 onnx op Affine, 而 tf op Relu6 会被转换为 ReluAffine, 使用Relu替换Relu6即可(也许自己写一个relu6也可以,没有试过)。

SrealZ commented 5 years ago

@hunto That is what I want to say.

soham24 commented 5 years ago

@hunto Hello, I followed similar approach. but my param file is not loading in ncnn.

Here is starting of my param file generated by onnx2ncnn. `7767517 199 199 Input input1 0 1 Padding padding 1 1 input1 conv1_pad_output 0=0 1=0 2=0 3=0 4=0 5=0.000000 Convolution convolution 1 1 conv1_pad_output conv1_output 0=8 1=3 11=3 2=1 12=1 3=2 13=2 5=0 6=216

`

it is not loading in ncnn library (load params).

1> as seen below, in input layer, there is no shape/channel declared. is it a problem? well, I tried by adding this to first input layer: 0 1 input1 0=3 1=128 2=128 still params are not loading!

2> In normal param file I see layer has same name in parameter list , but here padding-> conv1_pad_output convolution -> conv1_output and on...

does this makes difference? Do I need to change 'padding' to 'conv1_pad_output' or 'conv1_pad_output' to 'padding'?

keyongyu commented 5 years ago

It totally depends on the tf models, right now the supported ops in tf 1.13 is super rich, even image op, loop, switch, if branch ops are supported. Maybe support subset like tflite is a good start ponit.

linkerzhang commented 5 years ago

It may be good to support ONNX, in order to support all different kinds of frameworks in industry, say, TF, MxNet, mentioned above, since there're converters or exporters for TF->ONNX, MxNet->ONNX with fair quality.

laobadao commented 5 years ago

Can you supported BasicLSTMCell op? please.

nihui commented 5 years ago

https://github.com/hanzy88/tensorflow2ncnn https://github.com/hanzy88/ckpt2ncnn note: this is a community developed tensorflow model converter

ArtyZe commented 4 years ago

@hunto Hello, I followed similar approach. but my param file is not loading in ncnn.

Here is starting of my param file generated by onnx2ncnn. `7767517 199 199 Input input1 0 1 Padding padding 1 1 input1 conv1_pad_output 0=0 1=0 2=0 3=0 4=0 5=0.000000 Convolution convolution 1 1 conv1_pad_output conv1_output 0=8 1=3 11=3 2=1 12=1 3=2 13=2 5=0 6=216

`

it is not loading in ncnn library (load params).

1> as seen below, in input layer, there is no shape/channel declared. is it a problem? well, I tried by adding this to first input layer: 0 1 input1 0=3 1=128 2=128 still params are not loading!

2> In normal param file I see layer has same name in parameter list , but here padding-> conv1_pad_output convolution -> conv1_output and on...

does this makes difference? Do I need to change 'padding' to 'conv1_pad_output' or 'conv1_pad_output' to 'padding'?

Hello, have you already solved this input shape problem? I have met the same problem

Zrufy commented 4 years ago

during the conversion i have this error

Unpack not supported yet !
naxis #0
T #3
num #0
Transpose not supported yet !
nT #1
Tperm #3

any solution???

nihui commented 2 months ago

针对onnx模型转换的各种问题,推荐使用最新的pnnx工具转换到ncnn

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

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