Toybrick

FusedBatchNormV3 support

kaishi

中级会员

积分
306
发表于 2020-3-24 11:59:52    查看: 2266|回复: 11 | [复制链接]    打印 | 显示全部楼层

My RKNN SDK versio is 1.3.0.
When I convert tensorflow lanenet.pb to rknn, I encounter the following error below which is due to FusedBatchNormV3 operator.
Does SDK support this?

f system memory.
E Unknow layer "fusedbatchnormv3"
E Try match FusedBatchNormV3 lanenet_model/vgg_backend/instance_seg/pix_bn/FusedBatchNormV3 failed, catch exception!
E Catch exception when loading tensorflow model: ./lanenet.pb!
E Traceback (most recent call last):
E   File "rknn/base/RKNNlib/converter/convert_tf.py", line 643, in rknn.base.RKNNlib.converter.convert_tf.convert_tf.match_paragraph_and_param
E   File "rknn/base/RKNNlib/RKNNnet.py", line 189, in rknn.base.RKNNlib.RKNNnet.RKNNNet.new_layer
E   File "/home/test/anaconda3/envs/directron2/lib/python3.6/site-packages/rknn/base/RKNNlib/RKNNlog.py", line 327, in e
E     raise ValueError(msg)
E ValueError: Unknow layer "fusedbatchnormv3"
E During handling of the above exception, another exception occurred:
E Traceback (most recent call last):
E   File "rknn/api/rknn_base.py", line 303, in rknn.api.rknn_base.RKNNBase.load_tensorflow
E   File "rknn/base/RKNNlib/converter/convert_tf.py", line 742, in rknn.base.RKNNlib.converter.convert_tf.convert_tf.match_paragraph_and_param
E   File "/home/test/anaconda3/envs/directron2/lib/python3.6/site-packages/rknn/base/RKNNlib/RKNNlog.py", line 327, in e
E     raise ValueError(msg)
E ValueError: Try match FusedBatchNormV3 lanenet_model/vgg_backend/instance_seg/pix_bn/FusedBatchNormV3 failed, catch exception!
done
--> Building model
Traceback (most recent call last):
  File "./lanenet.py", line 86, in <module>
    rknn.build(do_quantization=True, dataset='./dataset.txt')
  File "/home/test/anaconda3/envs/directron2/lib/python3.6/site-packages/rknn/api/rknn.py", line 220, in build
    inputs = self.rknn_base.net.get_input_layers()
AttributeError: 'NoneType' object has no attribute 'get_input_layers'


回复

使用道具 举报

jefferyzhang

超级版主

积分
7757
发表于 2020-3-24 12:09:00 | 显示全部楼层
1. tensorflow MUST is 1.13.x
2. keras.backend.set_learning_phase(0) before create tf session !
回复

使用道具 举报

jefferyzhang

超级版主

积分
7757
发表于 2020-3-24 12:11:40 | 显示全部楼层
本帖最后由 jefferyzhang 于 2020-3-24 12:22 编辑

BTW, you are so lucky, because I have tried lanenet last year...
https://github.com/rknn-demos/lanenet-lane-detection
回复

使用道具 举报

kaishi

中级会员

积分
306
 楼主| 发表于 2020-3-24 12:53:39 | 显示全部楼层
jefferyzhang 发表于 2020-3-24 12:11
BTW, you are so lucky, because I have tried lanenet last year...
https://github.com/rknn-demos/lanen ...

I use your script to do ckpt to pb:
python rknn/save_pb.py
and  then convert rknn using
python rknn/pb_to_rknn.py -i lanenet.pb  -o lanenet.rknn

But I got the same error
My tensorflow version is '1.15.0'. Could this be the sisue?


回复

使用道具 举报

kaishi

中级会员

积分
306
 楼主| 发表于 2020-3-24 13:39:28 | 显示全部楼层
I install tensorflow=1.13.0 and it works now.
However, it is quite slow on rk3399pro. The rknn_perf shows 0.24fps
Is there a reason why quantize is not on during pb_to_rknn conversion?
回复

使用道具 举报

jefferyzhang

超级版主

积分
7757
发表于 2020-3-24 16:04:58 | 显示全部楼层
kaishi 发表于 2020-3-24 13:39
I install tensorflow=1.13.0 and it works now.
However, it is quite slow on rk3399pro. The rknn_perf  ...

Yes, it is a perf without quantization.
You must set do_quantization=True, and run again.
回复

使用道具 举报

kaishi

中级会员

积分
306
 楼主| 发表于 2020-3-25 02:37:02 | 显示全部楼层
I enable quantization and speed is 3fps now. Is there a way to speed up to realtime?
回复

使用道具 举报

cfan

注册会员

积分
176
发表于 2020-12-23 11:49:24 | 显示全部楼层
jefferyzhang 发表于 2020-3-24 16:04
Yes, it is a perf without quantization.
You must set do_quantization=True, and run again.

我在你的代码中看到有这么一句话,
# Workaround RKNN 1.1.0 bug
想问问是遇到了什么样的bug。
我遇到了一个sortmax层相关的bug,
其输出的结果在rknn和在直接pycharm调用pb模型上输出的结果有较大差异
回复

使用道具 举报

jefferyzhang

超级版主

积分
7757
发表于 2020-12-23 11:57:19 | 显示全部楼层
cfan 发表于 2020-12-23 11:49
我在你的代码中看到有这么一句话,
# Workaround RKNN 1.1.0 bug
想问问是遇到了什么样的bug。

这个bug早在1.2.0就解决了。。。
回复

使用道具 举报

cfan

注册会员

积分
176
发表于 2020-12-24 13:53:56 | 显示全部楼层
jefferyzhang 发表于 2020-12-23 11:57
这个bug早在1.2.0就解决了。。。

再问一下,我把模型用一张图片进行量化之后速度达到7帧左右,还有什么办法能提高速度吗
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

产品中心 购买渠道 开源社区 Wiki教程 资料下载 关于Toybrick


快速回复 返回顶部 返回列表