tensorflow-yolov3
tensorflow-yolov3 copied to clipboard
怎么pb转tflite
调用函数:tf.contrib.lite.TFLiteConverter.from_frozen_graph 报错: 2019-07-10 03:18:33.807555: F tensorflow/lite/toco/graph_transformations/resolve_strided_slice_attributes.cc:95] Check failed: start_indices_size <= num_input_axes (2 vs. 1)StridedSlice op requires no more than 1 start indices
作者尝试过转换吗?
pb_file = "../my_yolov3_coco.pb"
input_arrays = ["input/input_data"]
output_arrays = ["pred_sbbox/concat_2", "pred_mbbox/concat_2", "pred_lbbox/concat_2"]
converter = tf.lite.TFLiteConverter.from_frozen_graph(pb_file, input_arrays, output_arrays, {"input/input_data" :[1, 416, 416, 3]})
tflite_model = converter.convert()
open("myModel.tflite", "wb").write(tflite_model)
遇到同样的问题
@dvlee1024 您好我也想转一下部署在安卓上,之前没有做过,请问你转好了吗
找到问题所在了,在模型里面作者扩展tensor维数通过tf.newaxis实现,转tflite会一直报上述的错误。通过tf.expand_dims来实现tensor扩维就可以转成功了。(这部分在def decode()函数里面) @dvlee1024 @airu924123
补充:虽然可以生成tflite,但在调用是会报._interpreter.allocate_tensors()的相关错误:StridedSlice op only supports 1D-4D input arrays.Node number 43 (STRIDED_SLICE) failed to prepare. 所以相关运算中需要把5维改成4维,应该就可以了,尝试中。。。
@panguxiaoshen 大佬您好,请问有什么update吗?感谢!
@panguxiaoshen 大佬您好,请问有什么update吗?感谢!
按照我上面说的改就行,我已经成功转换。tiny_tolov3可以在板子上跑50ms
@panguxiaoshen 大佬您好,请问有什么update吗?感谢!
我已经上传到 https://github.com/panguxiaoshen/tiny_yolov3
@panguxiaoshen 万分感谢!我回来试一下
Hi, I encounter the same error message than in the original issue. Have you found a solution or a workaround ?
Hi, I encounter the same error message than in the original issue. Have you found a solution or a workaround ?
There are two places to change in the code. When you are expanding the dimensions of tensor,you should use "tf.expand_dims" rather than "tf.newaxis". Another thing is , so far ,tflite op only supports 1D-4D input arrays, but in Yunyang1994's code, there exists 5D operations. If you want to solve the problem, you can refer to the link mentioned above.
Solution is here: https://github.com/peace195/tensorflow-lite-yolo-v3 The .pb file must be in right format of SavedModel. Please try it. I would appreciate if you give me a star for this project 👍
dear @peace195 :+1: how can I get the right format (.pb) from training the Yolo v3 model here, not from the original https://pjreddie.com/darknet/yolo/. thanks in advance.
@kerolos Please use this code: https://github.com/peace195/tensorflow-lite-yolo-v3/blob/master/convert_weights_pb.py
转成功了我在为这个问题烦恼,可以加下微信吗?15348365038
@panguxiaoshen 大佬您好,请问有什么update吗?感谢!
我已经上传到 https://github.com/panguxiaoshen/tiny_yolov3
参考了你的代码,绕过5D -> 4D的方法很棒。
@panguxiaoshen 大佬您好,请问有什么update吗?感谢!
我已经上传到 https://github.com/panguxiaoshen/tiny_yolov3
参考了你的代码,绕过5D -> 4D的方法很棒。
请问,哪个文件里有5D操作? train.py吗?
不是什么大佬,互相学习,可以加我微信15348365038互相探讨,都是慢慢测试出来的
------------------ 原始邮件 ------------------ 发件人: "netist123"<[email protected]>; 发送时间: 2020年3月6日(星期五) 晚上9:46 收件人: "YunYang1994/tensorflow-yolov3"<[email protected]>; 抄送: "烧火棍"<[email protected]>; "Comment"<[email protected]>; 主题: Re: [YunYang1994/tensorflow-yolov3] 怎么pb转tflite (#232)
@panguxiaoshen 大佬您好,请问有什么update吗?感谢!
我已经上传到 https://github.com/panguxiaoshen/tiny_yolov3
参考了你的代码,绕过5D -> 4D的方法很棒。
请问,哪个文件里有5D操作? train.py吗?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.
@panguxiaoshen 大佬您好,请问有什么update吗?感谢!
我已经上传到 https://github.com/panguxiaoshen/tiny_yolov3
参考了你的代码,绕过5D -> 4D的方法很棒。
请问,哪个文件里有5D操作? train.py吗?
yolov3.py里面,从下面这行开始:
conv_output = tf.reshape(conv_output, (batch_size, output_size, output_size, 2, 5 + NUM_CLASS))
就都是5D操作了。