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

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

Open
dangbo opened this issue Jul 24, 2017 · 29 comments
Open

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

dangbo opened this issue Jul 24, 2017 · 29 comments

Comments

@dangbo
Copy link

dangbo commented Jul 24, 2017

No description provided.

@nihui
Copy link
Member

nihui commented Jul 24, 2017

我也很想要这个转换器 qwq

@nihui
Copy link
Member

nihui commented Jul 25, 2017

TODO
reopen

@nihui nihui reopened this Jul 25, 2017
@BiranLi
Copy link

BiranLi commented Jul 25, 2017

And Mxnet?

@Wenstery
Copy link

Wenstery commented Aug 9, 2017

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

@Daoctor
Copy link

Daoctor commented Aug 23, 2017

@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
Copy link

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

@nihui
Copy link
Member

nihui commented Sep 28, 2017

以下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
Copy link

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
Copy link

Cv9527 commented Dec 2, 2017

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
Copy link

用源码编译出来的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
Copy link

你好, 我按照你这句 “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
Copy link

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
Copy link

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
Copy link

补充一些不支持转换的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
Copy link
Contributor

期待resizebilinear operation支持!

@HudsonHuang
Copy link

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

@lvchigo
Copy link

lvchigo commented Aug 31, 2018

@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)

@linkerzhang
Copy link

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
Copy link

Can you supported BasicLSTMCell op? please.

@nihui
Copy link
Member

nihui commented Aug 26, 2019

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

@ArtyZe
Copy link

ArtyZe commented Jan 13, 2020

@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
Copy link

Zrufy commented Apr 30, 2020

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???

restyled-io bot pushed a commit that referenced this issue Jun 25, 2020
restyled-io bot pushed a commit that referenced this issue Jul 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests